帮助从 MIPS 指令中查找十六进制地址
您好,我被困在我的作业中,这需要我编写一个ac程序,该程序读取一个输入文件,如下所示:
Registers
r1 = 0c100009
Instructions
0c100009
3c071001
8ce20011
84e33080
80e48000
ace2ffff
a4e39001
a0e48088
03e00008
并查明该指令是保存还是加载,该指令访问了多少字节,以及该指令的地址内存中这些字节的第一个。
我需要帮助了解这些说明的工作原理。我确实知道我必须将指令转换为二进制,例如
8ce20011
转换为
100011 00111 00010 0000000000010001
二进制
lw $t3 17($s7)
,但我不知道如何计算地址和访问的字节数。我应该忽略所有未保存或加载的指令。
另外,符号扩展是什么意思?
感谢您的帮助。
Hi I am stuck on my assignment, which requires me to write a c program which reads in an input file such as this:
Registers
r1 = 0c100009
Instructions
0c100009
3c071001
8ce20011
84e33080
80e48000
ace2ffff
a4e39001
a0e48088
03e00008
and find out whether the instruction is a save or load, how many bytes accessed by the instruction, and the address of the first of these bytes in memory.
I need help understanding how the instructions work. I do know that I have to translate the instruction to binary, for example
8ce20011
to
100011 00111 00010 0000000000010001
which is
lw $t3 17($s7)
but i don't know how to calculate the address and the number of bytes accessed. I am suppose to ignore all the instructions that are not save or load.
And also, what does it mean by sign extend?
Thank you for your help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你走在正确的轨道上。
操作码 8ce20011 反汇编为“lw v0, 17(a3)”或等效的“lw $2,17($7)”
在“lw $t3, 17($7)”示例中,您需要知道 $7 的当前值(即$a3) 之前您可以计算它加载的地址。提示:查看前面的说明。 “lw”指令加载一个字,即 4 个字节。
顺便说一句,具有像 17 这样的偏移量且未在字边界上对齐的“lw”是非法的,并且会在 MIPS 中导致陷阱。
签名扩展
You are on the right track.
The opcode 8ce20011 disassembles to "lw v0, 17(a3)" or equivalently "lw $2,17($7)"
In your "lw $t3, 17($7)" example, you need to know the current value of $7 (i.e. $a3) before you can calculate the address that it is loading from. Hint: look at the previous instruction. A "lw" instruction loads a word, or 4 bytes.
Incidentally, "lw" with an offset like 17 which is not aligned on a word boundary is illegal and causes a Trap in MIPS.
Sign extension