fsflags

RISC-V fsflags Pseudo-Instruction Details

Assembler pseudo-instruction

Write-fflags pseudo-instruction. The common read/write form expands to csrrw rd, fflags, rs; an x0 form does not return old exception flags.

What You Write
fsflags rd, rs / fsflags rs
Typical Real Expansion
csrrw rd, fflags, rs # or write-only form: csrrw x0, fflags, rs

What This Pseudo Instruction Is Saving You From Writing

Floating-point state is accessed through CSR instructions; these pseudo-instructions name common fcsr/frm/fflags read and write forms for more readable floating-point environment code.

fsflags primarily means "Write floating-point exception flags". It is assembler-level shorthand; when debugging, auditing, or reading machine code, reason from the real expansion and relocation semantics listed on this page.

Official Semantics Checklist

The official assembly manual treats fsflags as an assembler-level pseudo-instruction or alias; hardware executes the expanded real instruction sequence.
The real semantics come from the ISA definitions of CSRRW and the other expanded instructions, not from a separate fsflags hardware opcode.
CSR read, write, set, clear, and immediate behavior follows the Zicsr CSRRW/CSRRS/CSRRC instructions and their immediate variants.

Availability And Extension Conditions

Base Conditions
  • Requires the related floating-point state CSRs
  • Accesses fflags/frm/fcsr through Zicsr instructions
Single-Instruction Or Standard Form
  • The target ISA/ABI environment supports the relevant floating-point extension and CSR access
Fallback / Boundary
Without the corresponding floating-point state or CSR access permission, do not assume these pseudo-instructions are available.
Notes
  • Writing frm, fflags, or fcsr can affect later floating-point results or exception flags.

How To Read The Expansion

Step 1
The rd form expands to csrrw rd, fflags, rs, writing new fflags and returning the old value.
Step 2
The form without rd expands to csrrw x0, fflags, rs, writing new fflags and not returning the old value.

What You May See In objdump / Disassembly

Tools may show frcsr/fscsr/frrm/fsrm/frflags/fsflags pseudo names or the underlying CSRRS/CSRRW/CSRRWI instructions.

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

Save or restore the floating-point environment
Read floating-point exception flags for diagnostics
Switch dynamic rounding mode
Write runtime-library, math-library, or low-level test code

Pitfalls / Common Confusions

These pseudo-instructions require the implementation to support the related floating-point state; do not assume availability without the relevant extension
Writing frm/fflags/fcsr can affect later floating-point results or exception flags
Immediate forms are still limited by the 5-bit CSR immediate field

FAQ

Is fsflags a real RISC-V instruction?

fsflags is an assembler pseudo-instruction or alias, not a separate hardware opcode. The “Typical Real Expansion” section lists the official expansion, and behavior is defined by the expanded ISA instructions.

What is the main trap when using fsflags?

These pseudo-instructions require the implementation to support the related floating-point state; do not assume availability without the relevant extension