I'm trying to execute this MIPS assembly code for fibonacci sequence (trying to find 10th fibonacci number, fib(10) in main. in QtSpim and it keeps throwing errors such as: "Exception occured at PC=0x7ffff774" and "Bad Address in text read..."
I'm not sure what I'm doing wrong, I think the error might be in the main statement.
.data
num: .word 10
ans: .word -1
.text
.globl main
main:
lw $a3, num
jal fib
sw $v1, ans
li $v0, 1
move $a0, $v1
syscall
fib: addi $sp, $sp, -12
sw $a0, 8($sp)
sw $ra, 4($sp)
sw $s0, 0($sp)
slti $t0, $a0, 2
beq $t0, $0, else
addi $v0, $a0, 0
j exit
else: addi $a0, $a0, -1
jal fib
add $s0, $v0, $0
addi $a0, $a0, -1
jal fib
add $v0, $v0, $s0
exit: lw $a0, 8($sp)
lw $ra, 4($sp)
lw $s0, 0($sp)
addi $sp, $sp, 12
jr $ra