MIPS 异常 6 [Bad instruction address] for Newton's Method of finding Square Roots
MIPS Exception 6 [Bad instruction address] for Newton's Method of finding Square Roots
我正在尝试实施牛顿法来计算给定 k 的整数平方根(此处为 $a0)。我得到了正确的输出,但随后出现了无限系列的异常 6 错误,如下所示:
sqrt(32) = 5
sqrt(33) = 5
sqrt(34) = 5
sqrt(35) = 6
sqrt(36) = 6
sqrt(37) = 6
Exception occurred at PC=0x00000024
Bad address in text read: 0x00000025
Exception 6 [Bad instruction address] occurred and ignored
Exception occurred at PC=0x00000028
Bad address in text read: 0x00000028
Exception 6 [Bad instruction address] occurred and ignored
Exception occurred at PC=0x0000002c
Bad address in text read: 0x0000002c
Exception 6 [Bad instruction address] occurred and ignored
Exception occurred at PC=0x00000030
Bad address in text read: 0x00000030
Exception 6 [Bad instruction address] occurred and ignored
Exception occurred at PC=0x00000034
Bad address in text read: 0x00000034
Exception 6 [Bad instruction address] occurred and ignored
Exception occurred at PC=0x00000038
Bad address in text read: 0x00000038
Exception 6 [Bad instruction address] occurred and ignored
谁能看看我的代码并诊断问题?谢谢
您的 main
函数将 $ra
的值保存在 $s0
中并假定 $s0
将保持不变,但 sqrt
函数将修改 $s0
.
将 $ra
保存在不同的寄存器或堆栈中。
或者将 jr $s0
替换为:
li $v0,10
syscall
我正在尝试实施牛顿法来计算给定 k 的整数平方根(此处为 $a0)。我得到了正确的输出,但随后出现了无限系列的异常 6 错误,如下所示:
sqrt(32) = 5
sqrt(33) = 5
sqrt(34) = 5
sqrt(35) = 6
sqrt(36) = 6
sqrt(37) = 6
Exception occurred at PC=0x00000024
Bad address in text read: 0x00000025
Exception 6 [Bad instruction address] occurred and ignored
Exception occurred at PC=0x00000028
Bad address in text read: 0x00000028
Exception 6 [Bad instruction address] occurred and ignored
Exception occurred at PC=0x0000002c
Bad address in text read: 0x0000002c
Exception 6 [Bad instruction address] occurred and ignored
Exception occurred at PC=0x00000030
Bad address in text read: 0x00000030
Exception 6 [Bad instruction address] occurred and ignored
Exception occurred at PC=0x00000034
Bad address in text read: 0x00000034
Exception 6 [Bad instruction address] occurred and ignored
Exception occurred at PC=0x00000038
Bad address in text read: 0x00000038
Exception 6 [Bad instruction address] occurred and ignored
谁能看看我的代码并诊断问题?谢谢
您的 main
函数将 $ra
的值保存在 $s0
中并假定 $s0
将保持不变,但 sqrt
函数将修改 $s0
.
将 $ra
保存在不同的寄存器或堆栈中。
或者将 jr $s0
替换为:
li $v0,10
syscall