li
Load Immediate
li RT, SIM
Loads a 16-bit signed immediate into a register. (Alias for 'addi RT, 0, SIM').
Details
Loads a 16-bit signed immediate value into the target register. This is an assembly-language alias for 'addi RT, 0, SIM' that simplifies loading small constants. No condition register flags are affected.
Pseudocode Operation
RT ← sign_extend(SIM, 16)
Programming Note
The `li` instruction is commonly used for initializing or resetting registers to specific values. Ensure the immediate value fits within the 32-bit signed integer range to avoid unexpected behavior. This instruction operates at user privilege level and does not generate exceptions unless there are issues with the instruction encoding.
Example
li r3, 4
Encoding
Binary Layout
14
0
RT
6
0
11
SIM
16
Operands
-
RT
Target -
SIM
Immediate