fsrmi

RISC-V fsrmi Pseudo-Instruction Details

Assembler pseudoinstruction

RISC-V fsrmi is an assembler pseudoinstruction for frm: fsrmi rd, imm expands to csrrwi rd, frm, imm, while fsrmi imm uses x0; the CSR immediate field is five bits.

What You Write
fsrmi rd, imm fsrmi imm
Expansion By Form
fsrmi rd, imm
csrrwi rd, frm, imm
fsrmi imm
csrrwi x0, frm, imm

What This Pseudo Instruction Is Saving You From Writing

The assembly manual defines these two spellings for CSRRWI access to frm.

How The Two Forms Differ

Form 1
fsrmi rd, imm expands to csrrwi rd, frm, imm; it reads and returns the old frm value only when rd is not x0.
Form 2
fsrmi imm expands to csrrwi x0, frm, imm; it does not read frm or cause CSR-read side effects.

Assembly Forms And Real Instructions

Read this spelling through the CSRRWI expansions shown on this page.

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 fsrmi rd, imm with rd other than x0 when the old frm value is needed.
Use fsrmi imm for the write form, whose expansion uses rd=x0.

Pitfalls / Common Confusions

The CSR immediate field is a zero-extended five-bit value.
frm is fcsr bits 7 through 5; dynamic rounding-mode values 101 through 111 are reserved.
The two-operand form can also specify rd=x0; CSRRWI then does not read frm or cause CSR-read side effects.

FAQ

Which standard fsrmi forms exist?

fsrmi rd, imm and fsrmi imm expand to CSRRWI with rd and x0 as the destination register, respectively. The two-operand form reads and returns the old frm value only when rd is not x0; rd=x0 suppresses the CSR read.