CSE 410 Programming Assignment 1

Spring 2007

Due: At the beginning of class, Wednesday 4/11/2007

Download the file fibonacci.s and open it up in SPIM. Use SPIM to analyze the program and answer the following questions.

  1. What instructions replace the pseudo-instructions move and li when the code is stored in memory? What happens to the load address instruction la $a0,newline, and why?
  2. Before the program reaches main, it executes several instructions that initialize the stack pointers and argument pointers. These are inserted automatically by SPIM. The program then jumps to the beginning of main with the jal instruction at location 0x00400014. What happens to R31 (ra) after this instruction is executed? What is the significance of this value?
  3. How many times does the program execute the section of code labeled loop?
  4. When the program terminates, what values are stored in the following registers (use hexadecimal)?
    1. R8 (t0)
    2. R19 (s3)
    3. R16 (s0)
    4. R17 (s1)
  5. Modify the program so that each iteration of the loop only executes one branch statement instead of two. Put a comment that begins with the note #CHANGED to the right of each line of code that you change to do this. Run your new code in SPIM to ensure that it produces the same results as the original version.

Turn in a printed copy of your modified program from question 5 along with written answers to the above questions at the beginning of class on the due date.