lha

Load Halfword Algebraic

lha RT, D(RA)

Loads a halfword (16 bits) from memory and sign-extends it to 64 bits.

Details

The lha instruction loads a halfword from memory into the target register, sign-extending it to fill the entire 64-bit register. The effective address is calculated by adding the displacement D to the contents of the base register RA.

Pseudocode Operation

RT <- EXTS(MEM(EA, 2))

Programming Note

The lha instruction is commonly used for loading signed halfword values from memory into a register, ensuring proper sign extension. Ensure that the effective address (EA) is properly aligned to avoid alignment faults. This instruction operates at user privilege level and will raise an exception if the EA is invalid or if there are insufficient privileges.

Example

lha r3, 0(r4)

Encoding

Binary Layout
42
0
RT
6
RA
11
D
16
 
Format D-form
Opcode 0xA8000000
Extension Base

Operands

  • RT
    Target Register
  • D
    Displacement
  • RA
    Base Register