#a = $a0 #b = $a1 #count = $a2 main: nop; addi $a0, $0, 1; add $a1, $0, $0; addi $a2, $0, 10; jal fib_iter; li $v0, 10 syscall fib_iter: beq $a2, $0, returnB; add $t0, $a0, $a1; #tmp0 = a+b addi $t1, $a2, -1; #tmp1 = count-1 sub $sp, $sp, 16 sw $ra 12($sp); sw $a0, 8($sp); sw $a1, 4($sp); sw $a2, 0($sp); #set parameters to a+b, a, count-1 add $a1, $a0, $0 add $a0, $t0, $0 add $a2, $t1, $0 #call it jal fib_iter lw $a2, 0($sp) lw $a1, 4($sp) lw $a0, 8($sp) lw $ra, 12($sp) addi $sp, $sp, 16 j $ra returnB: add $v1, $a1, $0 j $ra