Webcentive RISC-V Reference

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

31252420191514121176210
imm[11:5]rs2rs1011imm[4:0]0100011

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.

FieldBitsriscv-opcodes name
imm[11:5]31:25imm12hi
rs224:20rs2
rs119:15rs1
imm[4:0]11:7imm12lo

RV32 form; listed in riscv-opcodes as a pseudo-op of ld

3125242120191514121176210
imm[11:5]rs2, even values only0rs1011imm[4:0]0100011

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.

FieldBitsriscv-opcodes name
imm[11:5]31:25imm12hi
rs2, even values only24:21rs2_e
rs119:15rs1
imm[4:0]11:7imm12lo

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.

Specification and related pages