You are moving the sum from $v0
to $a1
after you store 1 in $v0
.
Also, You are storing the sum in $a1
, while $a0
is the register that gets printed..
add $a1,$v0,$zero #load return value into argument
^ HERE
This should fix it.
add $a0,$v0,$zero #load return value into argument
li $v0,1 # print integer
syscall