csrrci

csrrci

RISC-V Assembly Reference

lyszt.net covers csrrci and other RISC-V instructions in more detail.

Description

Clears the bits named by a 5-bit constant in a CSR. In csrrci rd, csr, uimm, bits that are 1 in the value 0 to 31 are cleared in csr, and the previous content goes to rd. A span wider than five bits goes through a register with csrc.

Official definition

RISC-V Instruction Set Manual

All CSR instructions atomically read-modify-write a single CSR, whose CSR specifier is encoded in the 12-bit csr field of the instruction held in bits 31-20. The immediate forms use a 5-bit zero-extended immediate encoded in the rs1 field.

The CSRRWI, CSRRSI, and CSRRCI variants are similar to CSRRW, CSRRS, and CSRRC respectively, except they update the CSR using an XLEN-bit value obtained by zero-extending a 5-bit unsigned immediate (uimm[4:0]) field encoded in the rs1 field instead of a value from an integer register. For CSRRSI and CSRRCI, if the uimm[4:0] field is zero, then these instructions will not write to the CSR, and shall not cause any of the side effects that might otherwise occur on a CSR write, nor raise illegal-instruction exceptions on accesses to read-only CSRs. For CSRRWI, if rd=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. Both CSRRSI and CSRRCI will always read the CSR and cause any read side effects regardless of rd and rs1 fields.

Instructionrd is x0uimm=0Reads CSRWrites CSR
CSRRWIYes-NoYes
CSRRWINo-YesYes
CSRRSI/CSRRCI-YesYesNo
CSRRSI/CSRRCI-NoYesYes