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 uses a 32-bit S-type encoding (opcode=0100011, funct3=001) to store rs2's low 16 bits. The effective byte address is rs1 plus a sign-extended 12-bit offset, wrapping to XLEN bits; the offset ranges from -2048 through 2047. imm[11:5] occupies inst[31:25], and imm[4:0] occupies inst[11:7]. Addresses divisible by 2 are naturally aligned; the EEI defines whether a misaligned access completes or raises address-misaligned/access-fault.
Starts with machine-code field decoding, then shows operand reads, instruction-specific execution, and ISA-visible state update.
This example uses fixed initial register values and PC=0x2000; instruction fetch succeeds, with no asynchronous interrupt or extra extension checks. Exception branches stop ordinary commit; post-trap PC and handler state are EEI-dependent.
Assumes writable ordinary little-endian memory. Success stores the low 16 bits and advances PC by 4; general permissions, partial writes and device side effects are not modeled. Misaligned exceptions do not guarantee unchanged memory.
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.
SH stores the source at this page's data width; check the address, region permissions, and applicable RV32I/RV64I conditions.
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.