c.sdsp
Store doubleword to stack
- Extension
- C, Zclsd
- XLEN
- RV32 and RV64
- Assembly (riscv-unified-db)
c.sdsp xs2, imm(sp)- Length
- 16-bit (compressed)
Encoding
RV64 form
| 1513 | 127 | 62 | 10 | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 111 | uimm[5:3|8:6] | rs2 | 10 | ||||||||||||
Match 0xe002, mask 0xe003. Source: c.sdsp c_rs2 c_uimm9sp_s 1..0=2 15..13=7 in riscv-opcodes/extensions/rv64_c.
| Field | Bits | riscv-opcodes name |
|---|---|---|
| uimm[5:3|8:6] | 12:7 | c_uimm9sp_s |
| rs2 | 6:2 | c_rs2 |
RV32 form; listed in riscv-opcodes as a pseudo-op of c.fswsp
| 1513 | 127 | 63 | 20 | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 111 | uimm[5:3|8:6] | rs2, even values only | 010 | ||||||||||||
Match 0xe002, mask 0xe007. Source: $pseudo_op rv32_c_f::c.fswsp c.sdsp c_rs2_e c_uimm9sp_s 2..0=2 15..13=7 in riscv-opcodes/extensions/rv32_zclsd.
| Field | Bits | riscv-opcodes name |
|---|---|---|
| uimm[5:3|8:6] | 12:7 | c_uimm9sp_s |
| rs2, even values only | 6:3 | c_rs2_e |
Description
Stores a 64-bit value in register xs2 to memory.
It computes an effective address by adding the zero-extended offset, scaled by 8,
to the stack pointer, x2.
It expands to sd xs2, offset(x2).
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;
if (xlen() == 32) {
if (implemented?(ExtensionName::Zclsd)) {
Bits<64> data = {X[xs2 + 1], X[xs2]};
write_memory(64, virtual_address, data, $encoding);
} else {
raise(ExceptionCode::IllegalInstruction, mode(), $encoding);
}
} else {
write_memory(64, virtual_address, X[xs2], $encoding);
}Pseudocode in riscv-unified-db’s IDL, quoted unchanged.