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 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.

LD Decode And Execute Animation

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

rd
imm
rs1
ld
,
(
)
Execution Context
a0(x10)
0x0000000000001000
mem[0x0000000000001000]
0x12345678

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..20
19..15
14..12
11..7
6..0
000000000000
imm[11:0]
01010
rs1
011
funct3
00101
rd
0000011
opcode
Execution Data Path
instruction
0x00053283
opcode
0000011 -> LOAD
funct3
011 -> LD
rd / base
t0(x5) / a0(x10)=0x0000000000001000
offset
000000000000 -> 0; ea=0x0000000000001000 (naturally aligned (8-byte))
load
64-bit 0x0000000012345678 -> sign extend
x5
t0(x5) = 0x0000000012345000
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: 0x00053283
syntax : ld t0(x5), 0(a0(x10))
result : t0(x5) = 0x0000000012345000
Architectural Result
t0(x5) = 0x0000000012345000

This LD animation models only the RV64I single-register 64-bit load. 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 «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
  • Verify the immediate field is within the valid range.
  • Confirm source register rs1 points to the correct operand.
Semantic Check
  • Check if the immediate sign-extension matches expectations.
  • Ensure the result register rd has a clear purpose.

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.