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 Encoding

31..25
imm[11:5]
24..20
rs2
19..15
rs1
14..12
funct3
11..7
imm[4:0]
6..0
opcode

SD uses opcode 0100011 (0x23), funct3 011. The rs1 field holds the base address, rs2 holds the store data, and the 12-bit immediate split across imm[11:5] and imm[4:0] provides the offset.

Format: S-type
opcode: 0100011 (0x23)
funct3: 011 (0x3)

Instruction Behavior

In RV64I, SD is an S-type instruction (opcode=0100011, funct3=011) that stores the 64-bit value in 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. Natural alignment is an 8-byte address; under Zilsd, a 4-byte-aligned but not 8-byte-aligned access may be decomposed into two atomic word accesses and may still raise a misaligned trap.

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
  • Confirm the current instruction format is S-type.
  • Confirm the operand order matches the example.
Semantic Check
  • Ensure the destination register usage is compatible with the calling convention.
  • Confirm this is not the lower-level form of a pseudo-instruction expansion.

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.