MIPS 加载字语法
如果我想从基地址位于 $a0 且偏移量 $t2 的内存中加载一个值,为什么我不能执行以下操作:
lw $s2, $a1($t2)
那么上面的表达式的等价物是什么?
If I want to load a value from a memory which base address is at $a0 and off set $t2, why can't I do the following:
lw $s2, $a1($t2)
so what is the equivalent of the expression above?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你不能这样做,因为没有 MIPS 指令编码支持这样的事情。您需要自己进行加法:
lw
指令编码如下:其中
sssss
是源寄存器编号,ttttt
是目标寄存器数字,iiiiiiiiiiiiiiii
是立即数。该编码(并且没有替代指令编码)中没有空间使用两个寄存器来生成内存地址。从上面的示例中编码的特定机器指令是:由于立即数是
0
,因此$s2
是寄存器18
和$a2
是寄存器6
。You can't do that because there's no MIPS instruction encoding that supports such a thing. You need to do the addition yourself:
The
lw
instruction encoding looks like this:Where
sssss
is the source register number,ttttt
is the destination register number, andiiiiiiiiiiiiiiii
is the immediate. There's no room in that encoding (and no alternate instruction encodings) that use two registers to generate the memory address. The specific machine instruction that would get encoded from the example above is:Since the immediate is
0
,$s2
is register18
and$a2
is register6
.