MIPS "la" pseudo-instruction

In MIPS, the la command translates to lui and ori . However, MARS Simulator does not seem to do this at all. When I unload 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 

It is obvious. This is dumping la as one instruction. What does MARS do? How to make la interpret as lui and ori ?

Thanks,

+7
source share
1 answer

What happens here is that your assembler compiles these la as addi $<dest>, $0, <value> . A sequence of two commands is required only for values โ€‹โ€‹that cannot be represented in 16-bit immediate; the values โ€‹โ€‹you use here look like 0x2000 and 0x2028 , so they fit into one command.

How can I interpret la as lui and ori ?

Loading large constants. :) Your assembler may also be able to force use the full sequence, even if it is not needed.

+8
source

All Articles