Home/Instructions/Store Doubleword
SD

RISC-V SD Instruction Details

Instruction ManualS-type

RV64I: store the 64-bit value in rs2; RV32 Zilsd: store a 64-bit value from an even/odd register pair.

Instruction Syntax

sd rs2, offset(rs1)
Operand Breakdown
Source rs2: register holding data to write to memory.
Base rs1: register holding the base address.
Immediate offset: 12-bit signed value added to rs1 for the final address.
RV64IZilsdMemory Store

Instruction Behavior

In RV64I, SD is an S-type instruction (opcode=0100011, funct3=011) that stores the low 64 bits of rs2 to rs1 plus a sign-extended 12-bit offset. In the RV32 Zilsd extension, the same mnemonic/encoding means store doubleword from a register pair: the 64-bit value comes from rs2 and rs2+1, and rs2 must be even. An 8-byte-aligned Zilsd access cannot raise an address-misaligned exception but need not be atomic; when the effective address is a multiple of 4, each word access must be atomic and a misaligned trap remains possible.

SD Decode And Execute Animation

Starts with machine-code field decoding, then shows operand reads, instruction-specific execution, and ISA-visible state update.

rs2
imm
rs1
sd
,
(
)
Execution Context
a0(x10)
0x0000000000001000

This EEI branch applies only when the effective address is not divisible by 8; a naturally aligned access must not raise an address-misaligned exception.

31..25
24..20
19..15
14..12
11..7
6..0
0000000
imm[11:5]
00101
rs2
01010
rs1
011
funct3
00000
imm[4:0]
0100011
opcode
Execution Data Path
instruction
0x00553023
opcode
0100011 -> STORE
funct3
011 -> SD
rs2 / base
t0(x5)=0x0000000000003001 / a0(x10)=0x0000000000001000
S-imm
imm[11:5]|imm[4:0] -> 0; ea=0x0000000000001000 (naturally aligned (8-byte))
store data
select low 64 bits -> 0x0000000000003001
memory
mem[0x0000000000001000] = 0x0000000000003001
Current Step

Concept Step: receive the 32-bit instruction encoding

The machine code is split by the current instruction format; the animation starts from encoding/decode.

encoding: 0x00553023
syntax : sd t0(x5), 0(a0(x10))
result : mem[0x0000000000001000] = 0x0000000000003001
Architectural Result
mem[0x0000000000001000] = 0x0000000000003001

This SD animation models only the RV64I single-register 64-bit store. RV32 Zilsd uses the same mnemonic and encoding but operates on an even/odd register pair; its distinct conditions are covered in the static page content.

Common Usage Scenarios

Address & Pointer

Understand this scenario with real code like «sd x10, 24(x2) # store 64-bit value to stack at offset 24».

Data Storing

Understand this scenario with real code like «sd x10, 24(x2) # store 64-bit value to stack at offset 24».

Pre-Use Checklist

Syntax Check
  • Verify store source rs2 and base address rs1 registers.
  • Confirm immediate offset (imm[11:5] | imm[4:0]) is split correctly.
Semantic Check
  • Check the target memory address alignment requirement.
  • Ensure the write does not corrupt caller-saved registers.

Pitfalls / Common Confusions

RV64I semantics store one 64-bit register; RV32 Zilsd semantics store an even/odd register pair.
Under Zilsd, rs2 must be even; odd rs2 encodings are reserved.
The offset is a sign-extended 12-bit immediate; 8-byte natural alignment is the most portable case.