lha
Load Halfword Algebraic
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
Encoding
Operands
-
RT
Target Register -
D
Displacement -
RA
Base Register