Functions return their value in $v0
; the print integer
syscall expects its argument in $a0
.
You need to move $a0
to $v0
before you do the print, otherwise you’ll be printing whatever happened to be in $a0
(which in the case is the last value that you recursively added; i.e. 10).
solved the answer is always wrong in this MIPS recursion . got 10, supposed to be 55