In: Computer Science
MIPS assembly language.
Why do "la label" instructions always need to be translated into 2 lines of pseudo code? What about "lw label" instructions? Explain the similarities and differences in how they are implemented in MARS.
lui $rs, upper( big )
ori $rs, $rs, lower( big )
Address will be of 32 bit in size. Upper address will be defaulted like 0x0040 is default for MARS.
So if
If you had done la $s0,main,
the lui would be lui $at,0x0040 because the default start address for .text is 0x00400000.
The lui loads the upper 16 bits of the address, and the ori loads the lower 16 bits of the address. The address can be any 32 bit value
hence to access exact address la translates in two instructions.
2) LW
Load word also required address to access the address hence it will translates into following instructions.
LUI load upper immediate
LW load word
lw d,exp # Load register $d with the value at # address exp. exp can be any # of several expression types # that evaluate to an address # (pseudoinstruction)
Here is a possible translation the pseudo instruction lw. Say that the symbol data stands for the address 0x10000004
lw $t0,data == lui $1,0x1000 lw $8,4($1)