CZ1101, Lab 1, Week 5, 11-16 August. Due Tuesday, 19 August, 1997

Submitting your answers by the due date 19 August. Follow the requirements of header format.

Our TA's (Shing Gene) remarks and last year's comments. And further remarks.

  1. What does this program do? First do it on paper, and then step it through xspim. Record the sequence of events that has happened (i.e., after each instruction, what happened to registers or memory)? Write the results (changes to registers or memory) as comments to the code. You can get this program from CZ1101 web page by click HERE.
    main:
       li  $2, 0x10000000    #  (1)
       li  $4, 1             #  (2)
       sw  $4, 0($2)         #  (3)
       li  $4, 3             #  (4)
       sw  $4, 4($2)         #  (5)
       li  $4, 5             #  (6)
       sw  $4, 8($2)         #  (7)
       lw  $3, 0($2)         #  (8)
       lw  $4, 4($2)         #  (9)
       add $3, $3, $4        # (10)
       lw  $4, 8($2)         # (11)
       add $3, $3, $4        # (12)
       sw  $3, 12($2)        # (13)
       lw  $3, 0($2)         # (14)
       lw  $4, 4($2)         # (15)
       mul $3, $3, $4        # (16)
       lw  $4, 8($2)         # (17)
       mul $3, $3, $4        # (18)
       sw  $3, 16($2)        # (19)
       j $31
    
  2. Write a MIPS assembly program to verify the formula for the sum of fourth power of natural numbers:
    1^4 + 2^4 + 3^4 + 4^4 + ... + n^4 = 
                          ( (1 + n)n(1 + 2n)(-1 + 3n + 3n^2) )/30,
    
    for the case of n=3. More precisely, you should compute
     a = 1^4 + 2^4 + 3^4,
     b = ((1+3)*3*(1+2*3)(-1+3*3+3*3*3))/30
    
    and show that a-b = 0. You may use any registers from $8 to $25, but code should be carefully commented. What is the sum? Submit your assembly program and report your findings.