Homework 3

Remember, homeworks are graded, so you must do your own work. If you do not follow this policy, you will be given a failing grade in the course, and risk college disciplinary action.

Assignment: Exercises 3.1 through 3.6

Write your answers out on paper, and hand it in on the due date.

Recommended: Fix Exercise 3.6 and run the code on the MIPS simulator. You will need to add a label, main, to the beginning and to terminate the program with a syscall. Here is a sample program that illustrates comments, directives for data, and using syscall. For more details, see Appendix A of the book.


      #  Program to add two numbers

            .data       # Begin Data Segment
      num1: .word 123
      num2: .word 321

            .text       # Begin Code Segment
      main:
            lw  $t0, num1
            lw  $t1, num2
            add $s1, $t0, $t1

            li  $v0, 10 # "Exit" code for syscall
            syscall
            .end