csrs

RISC-V csrs Pseudo-Instruction Details

Assembler pseudo-instruction

csrs expands to csrrs x0, csr, rs. CSRRS sets writable CSR bits selected by rs and writes the old value to x0.

What You Write
csrs csr, rs
Typical Real Expansion
csrrs x0, csr, rs

What This Pseudo Instruction Is Saving You From Writing

A CSRRS spelling with rd fixed to x0.

How To Read The Expansion

Step 1
csrrs x0, csr, rs
Step 2
CSRRS uses rs as the set-bit mask for writable CSR bits.

Assembly Forms And Real Instructions

The expansion above identifies the CSRRS ISA semantics that apply.

Official References And Reading Order

This page treats pseudo-instructions as assembler-level aliases or macros: first read what real instructions they expand to, then use the official ISA manual for the behavior of those real instructions. ABI, relocation, and linker-relaxation details follow the psABI document.

Pitfalls / Common Confusions

rd=x0 discards the old value, but CSRRS still reads the selected CSR.
With rs=x0, CSRRS does not write the CSR; a non-x0 register holding zero is not the same condition.

FAQ

What is the official csrs expansion?

csrrs x0, csr, rs