I have the following mips code:
.text
c:
li $8, 0
addu $sp, $sp, -4
sw $8, 0($sp)
jr $ra
a:
li $8, 0
addu $sp, $sp, -4
sw $8, 0($sp)
addu $sp, $sp, -4
sw $8, 0($sp)
addu $sp, $sp, -8
sw $fp, 0($sp)
sw $ra, 4($sp)
jal c
lw $fp, 0($sp)
lw $ra, 4($sp)
addu $sp, $sp, 8
lw $8, 0($sp)
addu $sp, $sp, 4
jr $ra
main:
addu $sp, $sp, 0
addu $sp, $sp, -8
sw $fp, 0($sp)
sw $ra, 4($sp)
jal a
lw $fp, 0($sp)
lw $ra, 4($sp)
addu $sp, $sp, 8
addu $sp, $sp, 0
j exit
I get " Exception 6 [Bad instruction address]", but I can't see anything wrong with the code.
How can I know where is it happening? I run the code using spim command. I suspect the return adress or the stack pointer is not being restored' but it looks right to me, what am I doing wrong?
j mainat the beginning after .text and before c:). – Erik Eidt 3 hours ago