csrrw

Atomically swap values in the CSRs and integer registers. Read the old value of the CSR, zero-extends the value to `XLEN` bits, and then write it to integer register xd. The initial value in xs1 is written to the CSR. If `xd=x0`, then the instruction shall not read the CSR and shall not cause any of the side effects that might occur on a CSR read.

Synopsis

csrrw xd, csr, xs1

Encoding

Type:

067111214151920311110011xd001xs1csr
funct3: 001
opcode: 1110011

RISC-V Instruction Encoder/Decoder

open csrrw in rvcodecjs

Availability