lhz
Load Halfword and Zero
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
Encoding
Operands
-
RT
Target Register -
D
Displacement -
RA
Base Register