What offset range does LHU use?
Base load instructions use a sign-extended 12-bit byte offset, typically -2048 through 2047.
Load a 16-bit halfword from memory, zero-extend it to XLEN, and write rd
LHU (I-type, opcode=0000011, funct3=101) reads a 16-bit halfword from the effective byte address rs1 plus a sign-extended 12-bit offset, zero-extends it to XLEN, and writes rd. A naturally aligned halfword address is a multiple of 2; the EEI defines completion or an exception for a misaligned access. Unlike LH, LHU zero-extends.
Starts with machine-code field decoding, then shows operand reads, instruction-specific execution, and ISA-visible state update.
This EEI branch applies only when the effective address is not divisible by 2; a naturally aligned access must not raise an address-misaligned exception.
The machine code is split by the current instruction format; the animation starts from encoding/decode.
This animation shows ISA-visible decode and state changes, not any specific CPU pipeline, cache, prediction, or timing implementation.
LHU reads a 16-bit halfword from the effective address formed by rs1 plus a signed 12-bit offset, then zero-extends the value into rd.
Understand this scenario with real code like «lhu x8, 2(x10) # x8 = zero_ext(mem[x10+2][15:0])».
Understand this scenario with real code like «lhu x8, 2(x10) # x8 = zero_ext(mem[x10+2][15:0])».
Base load instructions use a sign-extended 12-bit byte offset, typically -2048 through 2047.
LB/LH/LW sign-extend the loaded value to XLEN; LBU/LHU zero-extend. On RV64, use LWU when a 32-bit word should be zero-extended.