lwa

Load Word Algebraic

lwa RT, DS(RA)

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

lwa r3, 8(r4)

// Load signed 32-bit int.

Encoding

Binary Layout
58
0
RT
6
RA
11
DS
16
2
30
 
Format DS-form
Opcode 0xE8000002
Extension Base

Operands

  • RT
    Target Register
  • DS
    Displacement (Aligned)
  • RA
    Base Register