sd
Store doubleword
- Extension
- RV32I/RV64I base integer, Zilsd
- XLEN
- RV32 and RV64
- Assembly (riscv-unified-db)
sd xs2, imm(xs1)- Length
- 32-bit
Encoding
RV64 form
| 3125 | 2420 | 1915 | 1412 | 117 | 62 | 10 | |||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| imm[11:5] | rs2 | rs1 | 011 | imm[4:0] | 01000 | 11 | |||||||||||||||||||||||||
Match 0x00003023, mask 0x0000707f. Source: sd imm12hi rs1 rs2 imm12lo 14..12=3 6..2=0x08 1..0=3 in riscv-opcodes/extensions/rv64_i.
| Field | Bits | riscv-opcodes name |
|---|---|---|
| imm[11:5] | 31:25 | imm12hi |
| rs2 | 24:20 | rs2 |
| rs1 | 19:15 | rs1 |
| imm[4:0] | 11:7 | imm12lo |
RV32 form; listed in riscv-opcodes as a pseudo-op of ld
| 3125 | 2421 | 20 | 1915 | 1412 | 117 | 62 | 10 | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| imm[11:5] | rs2, even values only | 0 | rs1 | 011 | imm[4:0] | 01000 | 11 | ||||||||||||||||||||||||
Note: riscv-opcodes lists this line under the name ld (as a pseudo-op of ld), but its major opcode is STORE (0100011) with an rs2 source pair; the Zilsd chapter of the ISA manual (src/unpriv/zilsd.adoc) defines this encoding as the RV32 sd, store doubleword from an even/odd register pair, so it is shown here.
Match 0x00003023, mask 0x0010707f. Source: $pseudo_op rv64_i::ld ld imm12hi rs1 rs2_e imm12lo 20=0 14..12=3 6..2=0x08 1..0=3 in riscv-opcodes/extensions/rv32_zilsd.
| Field | Bits | riscv-opcodes name |
|---|---|---|
| imm[11:5] | 31:25 | imm12hi |
| rs2, even values only | 24:21 | rs2_e |
| rs1 | 19:15 | rs1 |
| imm[4:0] | 11:7 | imm12lo |
Description
For RV64, store 64 bits of data from register xs2 to an
address formed by adding xs1 to a signed offset.
When Zilsd is implemented:
For RV32, store doubleword from even/odd register pair.
Description from riscv-unified-db, reformatted.
Operation
XReg virtual_address = X[xs1] + $signed(imm);
if (xlen() == 64) {
write_memory(64, virtual_address, X[xs2], $encoding);
} else if (implemented?(ExtensionName::Zilsd)) {
if (endianness() == Endian::Big) {
write_memory(32, virtual_address, X[xs2 + 1], $encoding);
write_memory(32, virtual_address + 4, X[xs2], $encoding);
} else {
write_memory(32, virtual_address, X[xs2], $encoding);
write_memory(32, virtual_address + 4, X[xs2 + 1], $encoding);
}
} else {
raise(ExceptionCode::IllegalInstruction, mode(), $encoding);
}Pseudocode in riscv-unified-db’s IDL, quoted unchanged.