lhz

Load Halfword and Zero

lhz RT, D(RA)

Loads a halfword (16 bits) from memory and clears the upper 48 bits.

Details

The lhz instruction loads a halfword from the effective address (EA) formed by adding the contents of RA and the sign-extended displacement D. The loaded value is placed in RT, with the upper 16 bits set to zero.

Pseudocode Operation

EA ← (RA|0) + EXTS64(D)
RT ← EXTZ(MEM(EA, 2))

Programming Note

The lhz instruction is commonly used for loading halfword values from memory into a register while ensuring the upper 16 bits are zeroed. Ensure that the effective address (EA) is properly aligned to avoid unaligned access exceptions. This instruction operates at user privilege level and will raise an exception if the EA is invalid or if there's a protection fault.

Example

lhz r3, 0(r4)

Encoding

Binary Layout
40
0
RT
6
RA
11
D
16
 
Format D-form
Opcode 0xA0000000
Extension Base

Operands

  • RT
    Target Register
  • D
    Displacement
  • RA
    Base Register