Home/Instructions/FCVTMOD-W-D
FCVTMOD.W.D

RISC-V FCVTMOD.W.D Instruction Details

Instruction ManualR-type

Modular convert double-precision float to signed word (mod 2^32)

Instruction Syntax

fcvtmod.w.d rd, rs1, rtz
Operand Breakdown
Destination rd: register receiving the operation result.
Source rs1: register holding the first operand.
Source rs2: register holding the second operand.
ZfaDFloating-Point Convert

Instruction Behavior

fcvtmod.w.d is a Zfa instruction. It converts a double-precision value toward zero to an unbounded two's-complement integer, takes the low 32 bits, sign-extends to XLEN, and converts NaN and infinities to zero.

Quick Understanding & Search Notes

fcvtmod.w.d is a Zfa instruction. It converts a double-precision value toward zero to an unbounded two's-complement integer, takes the low 32 bits, sign-extends to XLEN, and converts NaN and infinities to zero.

It is encoded like FCVT.W.D but with rs2=8 and rm=RTZ.
Assembly syntax must explicitly write rtz; other rm encodings are reserved.
It is a modulo 2^32 conversion, not the saturating/clipping conversion of FCVT.W.D.
NaN and positive or negative infinity produce zero, a special rule for this Zfa instruction.

Common Usage Scenarios

JavaScript Engines

Understand this scenario with real code like «fcvtmod.w.d x10, f0, rtz # x10 = (int32_t)(f0) mod 2^32, always RTZ».

WebAssembly

Understand this scenario with real code like «fcvtmod.w.d x10, f0, rtz # x10 = (int32_t)(f0) mod 2^32, always RTZ».

Modular Arithmetic

Understand this scenario with real code like «fcvtmod.w.d x10, f0, rtz # x10 = (int32_t)(f0) mod 2^32, always RTZ».

Pre-Use Checklist

Syntax Check
  • Confirm the current instruction format is R-type.
  • Confirm the operand order matches the example.
Semantic Check
  • Ensure the destination register usage is compatible with the calling convention.
  • Confirm this is not the lower-level form of a pseudo-instruction expansion.

Pitfalls / Common Confusions

Assembly syntax must explicitly write rtz; other rm encodings are reserved.
It is a modulo 2^32 conversion, not the saturating/clipping conversion of FCVT.W.D.
NaN and positive or negative infinity produce zero, a special rule for this Zfa instruction.

FAQ

How is fcvtmod.w.d different from fcvt.w.d?

fcvtmod.w.d takes the low 32 bits of the unbounded RTZ conversion result modulo 2^32; fcvt.w.d uses the official invalid-conversion result for out-of-range integer conversion.

Why does fcvtmod.w.d require rtz?

Zfa requires assembly syntax to explicitly specify RTZ; other rm encodings are reserved.