ld
Load doubleword
- Extension
- RV32I/RV64I base integer, Zilsd
- XLEN
- RV32 and RV64
- Assembly (riscv-unified-db)
ld xd, imm(xs1)- Length
- 32-bit
Encoding
RV64 form
| 3120 | 1915 | 1412 | 117 | 62 | 10 | ||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| imm[11:0] | rs1 | 011 | rd | 00000 | 11 | ||||||||||||||||||||||||||
Match 0x00003003, mask 0x0000707f. Source: ld rd rs1 imm12 14..12=3 6..2=0x00 1..0=3 in riscv-opcodes/extensions/rv64_i.
| Field | Bits | riscv-opcodes name |
|---|---|---|
| imm[11:0] | 31:20 | imm12 |
| rs1 | 19:15 | rs1 |
| rd | 11:7 | rd |
RV32 form; listed in riscv-opcodes as a pseudo-op of ld
| 3120 | 1915 | 1412 | 118 | 72 | 10 | ||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| imm[11:0] | rs1 | 011 | rd, even values only | 000000 | 11 | ||||||||||||||||||||||||||
Match 0x00003003, mask 0x000070ff. Source: $pseudo_op rv64_i::ld ld rd_e rs1 imm12 14..12=3 7..2=0x00 1..0=3 in riscv-opcodes/extensions/rv32_zilsd.
| Field | Bits | riscv-opcodes name |
|---|---|---|
| imm[11:0] | 31:20 | imm12 |
| rs1 | 19:15 | rs1 |
| rd, even values only | 11:8 | rd_e |
Description
For RV64, load 64 bits of data into register xd from an
address formed by adding xs1 to a signed offset.
When Zilsd is implemented:
For RV32, Loads a 64-bit value into registers xd and xd+1. The effective address is obtained by adding register xs1 to the sign-extended 12-bit offset.
Description from riscv-unified-db, reformatted.
Operation
XReg virtual_address = X[xs1] + $signed(imm);
if (xlen() == 64) {
X[xd] = read_memory(64, virtual_address, $encoding);
} else if (implemented?(ExtensionName::Zilsd)) {
if (endianness() == Endian::Big) {
X[xd+1] = read_memory(32, virtual_address, $encoding);
X[xd] = read_memory(32, virtual_address + 4, $encoding);
} else {
X[xd] = read_memory(32, virtual_address, $encoding);
X[xd+1] = read_memory(32, virtual_address + 4, $encoding);
}
} else {
raise(ExceptionCode::IllegalInstruction, mode(), $encoding);
}Pseudocode in riscv-unified-db’s IDL, quoted unchanged.