exception - 牛顿求平方根方法的 MIPS 异常 6 [错误指令地址]
问题描述
我正在尝试实现牛顿法来计算给定 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
in的值$s0
并假设该值$s0
将保持不变,但该sqrt
函数将修改$s0
.
要么保存$ra
在不同的寄存器中,要么保存在堆栈中。或替换为jr $s0
:
li $v0,10
syscall
推荐阅读
- android - Android Studio 3 布局编辑器奇怪的行为
- lua - Lua中的cjson解码返回空数组redis-cli
- sql-server - MSSQL死锁图只列出一个进程
- gstreamer - GStreamer-WARNING **:插件存在时无法加载插件
- docusignapi - 为什么 Connect/webhook 日期的时区不是 UTC?
- python - 从 shell 与 Django 视图运行外部 python 脚本
- git - 希望恢复/删除远程提交以解决合并冲突
- java - shared.loader 中的 Tomcat 环境变量触发警告
- makefile - make install 找不到 aclocal
- python-3.x - 分别在目录中的特定文件上运行代码(按文件名)