MC48 Homework 2 (Fall 1998)

Due: September 23, 1998

  1. Do exercise 3.1 from page 197. Also, write an alternate version of the program that only uses one branch or jump instruction each time through the loop, rather than both a branch and a jump each time. For full credit, your version should produce the same result as the given one for all integer values of n, rather than only when n is positive.
  2. Do exercise 3.14 from page 200.
  3. Do exercise 3.17 from page 201.
  4. Write (in MIPS assembly language) a procedure named whence, such that after calling the procedure with the instruction
    jal whence
    the procedure will return (to the next instruction) with the $v0 register containing the address in memory where that jal whence instruction occurs.

Instructor: Max Hailperin