Lab 4: Introduction to MIPS Assembly with QtSpim


Due Wednesday, August 10 at 11:59 PM

Goals for This Lab

By the time you have completed this work, you should be able to:

Provided files:

Step-by-Step Instructions

Step 1: Familiarize Yourself with a QtSpim Tutorial

Read and familiarize yourslf with a short QtSpim tutorial. This tutorial discusses how to open and run MIPS assembly code from within QtSpim, which you will be doing frequently over the next few weeks. Additionally, the following resources will be useful:

Step 2: Download all Required Files

Download all the files listed under Provided files above.

Step 3: Edit print_hardcoded_strings.asm

Open the print_hardcoded_strings.asm file, and open it up in a text editor of your choice. Note that word processors (e.g., Microsoft Word, Pages, Google Docs) will probably not work for this purpose, as you must save your file as plain text. You must write MIPS assembly code which, when run under QtSpim, will print the following:

first
second

print_hardcoded_strings.asm contains comments which further describe exactly how you can go about this. As a hint, your code will look similar to hello_world.asm.

Step 4: Edit print_not.asm

Open the print_not.asm file, and open it up in a text editor of your choice. Note that word processors (e.g., Microsoft Word, Pages, Google Docs) will probably not work for this purpose, as you must save your file as plain text. You must write MIPS assembly code which will read an integer from the user, and will then print (in order):

  1. The integer
  2. A newline character
  3. The negation of the integer (with the help of the nor instruction)
  4. A newline character
Example output of this code is shown below, where 63 was the input integer:

63
-64

print_not.asm contains comments which further describe exactly how you can go about this. As a hint, your code will look similar to read_and_print_int.asm.

Step 5: Edit binops.asm

Open the binops.asm file, and open it up in a text editor of your choice. Note that word processors (e.g., Microsoft Word, Pages, Google Docs) will probably not work for this purpose, as you must save your file as plain text. You must write MIPS assembly code which will read two integers from the user (hereafter referred to as A and B, respectively), and will then print (in order):

  1. A + B on its own line
  2. A - B on its own line
  3. A & B (bitwise AND) on its own line
  4. A | B (bitwise OR) on its own line
  5. A ^ B (bitwise XOR) on its own line

Example output of this code is shown below, which results from reading in 4 and 5 as the provided integers:

9
-1
4
5
1

binops.asm contains comments which further describe exactly how you can go about this. As a hint, your code will look similar to the basic examples under the week 3 materials..

Step 6: Turn in Your Code Using Canvas

Log into Canvas, and go to the COMP 122 class. Click “Assignments” on the left pane, then click “Lab 4”. From here, you can upload your .asm files. Specifically, you must turn in the following three files:

In addition, if you collaborated with anyone else, be sure to download collaborators.txt and write the names of the people you collaborated with in the file, one per line. Please submit this file along with the other three files.

You can turn in the assignment multiple times, but only the last version you submitted will be graded.

IMPORTANT: Your Code Must Run Under QtSpim

The code you submit must run under QtSpim without modification.
Code with syntax errors gets an automatic 0.
If you can't get your code to do the right thing, it's better to submit code that runs but does the wrong thing.