Webcentive RISC-V Reference

sw

Store word

Extension
RV32I/RV64I base integer
XLEN
RV32 and RV64
Assembly (riscv-unified-db)
sw xs2, imm(xs1)
Length
32-bit

Encoding

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

Match 0x00002023, mask 0x0000707f. Source: sw imm12hi rs1 rs2 imm12lo 14..12=2 6..2=0x08 1..0=3 in riscv-opcodes/extensions/rv_i.

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

Description

Store 32 bits of data from register xs2 to an address formed by adding xs1 to a signed offset.

Description from riscv-unified-db, reformatted.

Operation

XReg virtual_address = X[xs1] + $signed(imm);

write_memory(32, virtual_address, X[xs2][31:0], $encoding);

Pseudocode in riscv-unified-db’s IDL, quoted unchanged.

Specification and related pages