c.ldsp
Load doubleword from stack pointer
- Extension
- C, Zclsd
- XLEN
- RV32 and RV64
- Assembly (riscv-unified-db)
c.ldsp xd, imm(sp)- Length
- 16-bit (compressed)
Encoding
RV64 form
| 1513 | 12 | 117 | 62 | 10 | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 011 | uimm[5] | rd≠0 | uimm[4:3|8:6] | 10 | |||||||||||
Match 0x6002, mask 0xe003. Source: c.ldsp rd_n0 c_uimm9sphi c_uimm9splo 1..0=2 15..13=3 in riscv-opcodes/extensions/rv64_c.
| Field | Bits | riscv-opcodes name |
|---|---|---|
| uimm[5] | 12 | c_uimm9sphi |
| rd≠0 | 11:7 | rd_n0 |
| uimm[4:3|8:6] | 6:2 | c_uimm9splo |
RV32 form; listed in riscv-opcodes as a pseudo-op of c.flwsp
| 1513 | 12 | 118 | 7 | 62 | 10 | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 011 | uimm[5] | rd≠0, even values only | 0 | uimm[4:3|8:6] | 10 | ||||||||||
Match 0x6002, mask 0xe083. Source: $pseudo_op rv32_c_f::c.flwsp c.ldsp rd_n0_e c_uimm9sphi c_uimm9splo 1..0=2 15..13=3 7=0 in riscv-opcodes/extensions/rv32_zclsd.
| Field | Bits | riscv-opcodes name |
|---|---|---|
| uimm[5] | 12 | c_uimm9sphi |
| rd≠0, even values only | 11:8 | rd_n0_e |
| uimm[4:3|8:6] | 6:2 | c_uimm9splo |
Description
C.LDSP is an RV64C/RV128C-only instruction that loads a 64-bit value from memory
into register xd.
It computes its effective address by adding the zero-extended offset, scaled by 8,
to the stack pointer, x2.
It expands to ld xd, offset(x2).
C.LDSP is only valid when xd ≠ x0; code points with xd=x0 are reserved.
Description from riscv-unified-db, reformatted.
Operation
if (implemented?(ExtensionName::C) && MISA_CSR_IMPLEMENTED && (CSR[misa].C == 1'b0)) {
reserved_instruction($encoding);
}
XReg virtual_address = X[2] + imm;
Bits<64> value = read_memory(64, virtual_address, $encoding);
if (xlen()== 64) {
X[xd] = value;
} else if (xlen() == 32) {
X[xd] = value[31:0];
X[xd + 1] = value[63:32];
}Pseudocode in riscv-unified-db’s IDL, quoted unchanged.