MIPS “la” pseudo instruciton

岁酱吖の 提交于 2019-12-23 08:54:35

问题


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,


回答1:


What's happening here is that your assembler is compiling these las as addi $<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 like 0x2000 and 0x2028, so they fit in a single instruction.

How can I make it interpret la as lui and ori?

Load bigger constants. :) Your assembler might also have an option to force the use of the full sequence even when it's unnecessary.



来源:https://stackoverflow.com/questions/8290861/mips-la-pseudo-instruciton

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!