NOTE:The last day to turn this assignment in late is Saturday February 21, 2015 by 11:59pm PST so the solutions can be posted to study before Midterm 2.
Loop: beq $t5, $a1, Exit # if t5 == a1, exit loop
lw $t0, 0($a0) # Load fib(n-2)
lw $t1, 4($a0) # Load fib(n-1)
add $t2, $t0, $t1 # Calculate fib(n)
sw $t2, 8($a0) # Store fib(n)
add $a0, $a0, $s1 # s1 contains 4
add $t5, $t5, $s2 # s2 contains 1
j Loop
Exit:
lw $t4, 100($t2)
sub $t6, $t4, $t3
add $t2, $t3, $t5
Do NOT reorder the code to answer this question.
Loop: lw $t1, 0($s0)
add $v0, $v0, $t1
add $s0, $s0, $s2
slt $t0, $s0, $s1
beq $t0, $s3, Loop