csrrw

Atomic read/write CSR

Reads the CSR into t0 and writes t1 into it, as one atomic step.

Forms

  • csrrw , ,

Operands

t0
Any integer register, x0 to x31, or its named alias, such as zero, t0 or t6.
csr
A control and status register, written by name or number, such as fcsr, fflags, frm, cycle, time, instret, ustatus, uepc, ucause or utval. See the supported registers.
t1
An integer register. It may be the same register as t0.
# Initialize fcsr=0; csrrw returns old fcsr in t0 and leaves fcsr=1.
.text
li t3, 0
csrw t3, fcsr
li t1, 1
csrrw t0, fcsr, t1