lwa
Load Word Algebraic
Loads a word (32 bits) from memory and sign-extends it to 64 bits.
Details
Loads a 32-bit word from memory at address (RA + (DS || 0b00)), where DS is a 14-bit signed displacement (making the effective address 4-byte aligned), and places it into RT with sign extension to 64 bits. This is a 64-bit instruction available only in 64-bit implementations. No condition or status registers are affected.
Pseudocode Operation
if RA = 0 then
EA ← (DS || 0b00)
else
EA ← (RA) + (DS || 0b00)
RT ← sign_extend([EA+3:EA])
// Load word at aligned EA and sign-extend to 64 bits
Programming Note
The lwa instruction is commonly used for loading a 32-bit word from memory into a target register while zeroing out the upper 32 bits. Ensure that the base address in RA and displacement D are correctly aligned to avoid alignment faults. This instruction operates at user privilege level and will raise an exception if the effective address is invalid or if there is a protection fault.
Example
// Load signed 32-bit int.
Encoding
Operands
-
RT
Target Register -
DS
Displacement (Aligned) -
RA
Base Register