我的子程序代码有问题。这是我的代码。它正在给出一个
0x00400074处的运行时异常:地址超出范围0x000000c8错误。
该行是:sb $t2, 0($t4)
- 这是第二个存储字节。
intToa: addi $sp, $sp, -12
sw $ra ,8($sp)
sw $a0, 4($sp)
sw $a1, 0($sp)
move $t0, $a0
move $t4, $a1
bne $t0, $zero, while
li $t2, 48
sb $t2, 0($t4)
addi $t4, $t4, 1
b end
while: beq $t0, $zero, end
li $t6, 10
div $t0, $t6 # divide $t0 by 10
mfhi $t1 # $t3 = $t0%10 (last digit of $t0)
mflo $t0 # $t0 = $t0/10 (first digit of $t0)
addi $t2, $t1, 48 # store character '0' to $t1 in
sb $t2, 0($t4) # out destinationg string
addi $t4, $t4, 1 # increment our string pointer
j while # continue looping
end:
sb $zero, 0($t4) # null terminate our string
move $a1, $a0
jal reverse
lw $ra, 12($sp)
addiu $sp, $sp, 12 # put stack back in place
jr $ra