MIPS“la”伪指令
在 MIPS 中,la
指令转换为 lui
和 ori
。然而,MARS Simulator 似乎根本没有这样做。当我转储以下机器代码时:
.text
la $a0, array
la $a1, array_size
lw $a1, 0($a1)
.data
array: .word 0:10
array_size: .word 10
message: .asciiz "The sum of numbers in array is: "
我得到:
00100000000001000010000000000000
00100000000001010010000000101000
10001100101001010000000000000000
这显然是。它将 la
转储为一条指令。火星有什么作用?如何让它将 la
解释为 lui
和 ori
?
谢谢你,
In MIPS, the la
instruction translates into lui
and ori
. However, MARS Simulator does not seem to do that at all. When I dump the following machine code:
.text
la $a0, array
la $a1, array_size
lw $a1, 0($a1)
.data
array: .word 0:10
array_size: .word 10
message: .asciiz "The sum of numbers in array is: "
I get:
00100000000001000010000000000000
00100000000001010010000000101000
10001100101001010000000000000000
Which is obviously. It is dumping la
as one instruction. What does MARS do? How can I make it interpret la
as lui
and ori
?
Thank you,
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这里发生的情况是,您的汇编器正在将这些
la
编译为addi $, $0,
。仅当无法用 16 位立即数表示的值时才需要两指令序列;您在此处使用的值类似于0x2000
和0x2028
,因此它们适合单个指令。加载更大的常数。
:)
您的汇编程序还可能有一个选项来强制使用完整序列,即使这是不必要的。What's happening here is that your assembler is compiling these
la
s asaddi $<dest>, $0, <value>
. The two-instruction sequence is only required for values which can't be represented in a 16-bit immediate; the values you're using here look like0x2000
and0x2028
, so they fit in a single instruction.Load bigger constants.
:)
Your assembler might also have an option to force the use of the full sequence even when it's unnecessary.