Reputation: 307
Does li (load immediate) Pseudo-Instruction in MIPS loads the constant into the register differently based on the sign and size of the constant? Is li translated into different instructions when for example the constant is a 16-bit number in two's complement (-2^15 <= k < 2^15) in contrast to a positive number(0 <= k < 2^16)? what about 32-bit numbers?
The links that I found did not address it specifically. That would kind, if you explain it with examples (I use MARS simulator).
Upvotes: 1
Views: 10190
Reputation: 6266
LI
gets translated into a single instruction by the assembler when the immediate constant can be represented as a 16 bit two's complement number. (Typically addiu $dst, 0, imm
).
LI
is translated by the assembler into LUI
(load upper immediate) followed by ORI
when the immediate constant is too large to be represented as a 16 bit two's complement number.
Upvotes: 4