fsrm

RISC-V fsrm Pseudo-Instruction Details

Assembler pseudo-instruction

fsrm uses CSRRW to write the low three bits of rs to frm. It reads and returns the old value only when rd is not x0; rd=x0 and the one-operand form do not read frm.

What You Write
fsrm rd, rs fsrm rs
Expansion By Form
fsrm rd, rs
csrrw rd, frm, rs
fsrm rs
csrrw x0, frm, rs

What This Pseudo Instruction Is Saving You From Writing

fsrm rd, rs returns the old frm value when rd is not x0 and writes the low three bits of rs to frm. With rd=x0, including the one-operand form, frm is not read.

Availability And Extension Conditions

Base Conditions
  • Applies where the described fcsr and frm field are implemented.

How The Two Forms Differ

Form 1
fsrm rd, rs uses CSRRW to write the low three bits of rs1 to frm. When rd is not x0, the old frm is read and copied to rd; with rd=x0, frm is not read.
Form 2
fsrm rs uses CSRRW with rd=x0 to write frm and does not read that CSR.

Assembly Forms And Real Instructions

This page records the official expansion only; the RISC-V Assembly Programmer's Manual lists these spellings as pseudoinstructions.

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.

When To Think Of It First

Use the two-operand form with rd other than x0 to write frm and retain its old value.
Use the one-operand form to write frm.

Pitfalls / Common Confusions

FSRM writes frm from only the low three bits of rs1.
The two-operand form also permits rd=x0; CSRRW then does not read frm or cause CSR-read side effects.

FAQ

Is fsrm a separate hardware opcode?

No. the RISC-V Assembly Programmer's Manual lists fsrm as an assembler pseudoinstruction; behavior comes from the listed CSR expansion.

What is the official fsrm expansion?

the RISC-V Assembly Programmer's Manual lists: csrrw rd, frm, rs; csrrw x0, frm, rs.

Does fsrm rd, rs read the old value when rd=x0?

No. With rd=x0, its CSRRW expansion does not read frm or cause CSR-read side effects, but still writes the low three bits of rs to frm. Only rd other than x0 receives the old value.