csrw
Write control and status register
Writes t1 into the CSR and discards the value it held before.
Used in
- When an instruction cannot be carried outRISC-V assembly
Forms
Operands
t1- Any integer register,
x0tox31, or its named alias, such aszero,t0ort6. csr- A control and status register, written by name or number, such as
fcsr,fflags,frm,cycle,time,instret,ustatus,uepc,ucauseorutval. See the supported registers.
# Initialize fcsr to 0, apply csrw with mask 1, then read fcsr into t2 (1).
.text
li t3, 0
csrw t3, fcsr
li t1, 1
csrw t1, fcsr
csrr t2, fcsr