Home/Instructions/Load Doubleword
LD

RISC-V LD Instruction Details

Instruction ManualI-type

RV64I: load a 64-bit doubleword into rd; RV32 Zilsd: load a 64-bit value into an even/odd register pair.

Instruction Syntax

ld rd, offset(rs1)
Operand Breakdown
Destination rd: general-purpose register receiving the result.
Source rs1: register holding the first operand.
Immediate imm: 12-bit signed value, sign-extended before operation with rs1.
RV64IZilsdMemory Load

Instruction Encoding

31..20
imm[11:0]
19..15
rs1
14..12
funct3
11..7
rd
6..0
opcode

LD uses opcode 0000011 (0x03), funct3 011. The rs1 field selects the source register, the 12-bit immediate provides the second operand, and rd selects the destination.

Format: I-type
opcode: 0000011 (0x03)
funct3: 011 (0x3)

Instruction Behavior

In RV64I, LD is an I-type instruction (opcode=0000011, funct3=011) that loads a 64-bit value from rs1 plus a sign-extended 12-bit offset into rd. In the RV32 Zilsd extension, the same mnemonic/encoding means load doubleword to a register pair: the 64-bit value is written to rd and rd+1, and rd 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 «ld x10, 16(x2) # load 64-bit value from stack at offset 16».

Data Loading

Understand this scenario with real code like «ld x10, 16(x2) # load 64-bit value from stack at offset 16».

Pre-Use Checklist

Syntax Check
  • Confirm the current instruction format is I-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 load one 64-bit register; RV32 Zilsd semantics load an even/odd register pair.
Under Zilsd, rd must be even; odd rd encodings are reserved.
The offset is a sign-extended 12-bit immediate; 8-byte natural alignment is the most portable case.