Does SH store the whole register?
SH stores only the low 16 bits of rs2, not necessarily the full XLEN-wide register.
Store the low 16 bits of rs2 to memory
SH (S-type, opcode=0100011, funct3=001) stores the low 16 bits of rs2 to the effective address (rs1 + a sign-extended 12-bit offset). A naturally aligned halfword address is a multiple of 2; the EEI defines whether a misaligned access completes or raises an exception.
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.
SH forms the effective address as rs1 plus a signed 12-bit offset and stores the low 16 bits of rs2 to memory.
Understand this scenario with real code like «sh x6, 2(x10) # mem[x10+2][15:0] = x6[15:0]».
Understand this scenario with real code like «sh x6, 2(x10) # mem[x10+2][15:0] = x6[15:0]».
SH stores only the low 16 bits of rs2, not necessarily the full XLEN-wide register.
The effective address is the base register rs1 plus a sign-extended 12-bit byte offset.