FSUB.Q

RISC-V FSUB.Q Instruction Details

Instruction ManualR-type

Quad-precision floating-point subtraction, OP-FP fmt=Q(11).

Instruction Syntax

fsub.q rd, rs1, rs2[, rm]
Operand Breakdown
rd, rs1 and rs2 select FP f0–f31 or ABI names; f0 is writable and rd may overlap a source. Equal source registers require one initial value.
32-bit OP-FP: funct5=00001, fmt=11 (Q), opcode=1010011. Optional rm defaults to dyn; explicit rm mnemonics must be lowercase.
Requires enabled FP state and Q 2.2 (dependent on D), with FLEN=128 but no XLEN=128 requirement. Round rs1-rs2 by rm/frm and write rd.
rm=101/110 and dynamic frm=101–111 have reserved behavior. Applicable NV, OF and NX accrue in fflags; setting a flag does not itself trap. The animation covers finite exact inputs only.
QFloating-Point Arithmetic

Instruction Behavior

FSUB.Q performs quad-precision floating-point subtraction on two FP source operands, rounds according to the rm field or dynamic frm, writes the result to FP register rd, and records fflags according to RISC-V floating-point rules.

FSUB.Q Decode And Execute Animation

Shows the Q-extension quad-precision OP-FP flow: decode fields, read FP operands, perform FSUB semantics, then write rd.

rd
rs1
rs2
rm
fsub.q
,
,
,

Leave rm empty to use the assembly default dyn encoding and fcsr.frm below.

Execution Context
FLEN=128 / fmt=Q (11)
rounding: RNE nearest-even
fflags: initial 0
31..27
26..25
24..20
19..15
14..12
11..7
6..0
00001
FSUB
11
fmt=Q
01100
rs2
01011
rs1
000
rm
01010
rd
1010011
OP-FP
Execution Data Path
instruction
0x0EC58553
opcode
1010011 -> OP-FP
funct5/fmt
00001 + Q(11) -> FSUB.Q
rm
000 -> RNE nearest-even
rd/rs
fa0(f10) / fa1(f11) / fa2(f12)
read
Source registers not read yet
FP op
Awaiting Execute
write
Not written yet; initial fflags=0
Current Step

Fetch: show the 32-bit OP-FP encoding

The word is split as an R-type OP-FP instruction; quad-precision OP-FP instructions use opcode 1010011.

encoding: 0x0EC58553
syntax : fsub.q fa0(f10), fa1(f11), fa2(f12), rne
result : Not written yet; initial fflags=0

The whitelisted inputs and nonzero result are exactly representable. With initial fflags=0, no flags are added under any legal rounding mode. Zero, special values, and rounding boundaries are outside this animation.

Quad-precision Calculation
rs1
fa1(f11) = 3.5
rs2
fa2(f12) = 1.5
result
Awaiting Execute

The whitelisted inputs and nonzero result are exactly representable. With initial fflags=0, no flags are added under any legal rounding mode. Zero, special values, and rounding boundaries are outside this animation.

Assumes the extension is available, FS enabled, correctly NaN-boxed inputs, and initial fflags=0. Only nonzero finite exact whitelisted inputs and nonzero whitelisted results are accepted; zero and rounding/exception boundaries are outside this animation. One source register must have one initial value; rd may overlap a source, and f0 accepts writeback. Steps are teaching views.

This animation shows only Q-extension ISA-visible OP-FP encoding, example numeric results, and fflags relationship; it does not model FPU pipelines, latency, every IEEE 754 corner case, or microarchitecture.

Quick Understanding & Search Notes

FSUB.Q is a Q-extension quad-precision OP-FP arithmetic instruction. It decodes funct5=00001 with fmt=Q(11), reads f[rs1] and f[rs2], performs subtraction, rounds by rm/frm, and writes f[rd].

fmt=Q(11) selects the quad-precision floating-point format; the opcode remains OP-FP 1010011.
The rm field selects a static rounding mode, while rm=111 uses dynamic frm; exact examples keep the same numeric value but the field is still encoded.
FSUB's applicable FP exception flags are NV, OF, and NX, accrued in fflags; this is not integer arithmetic or condition-code update.
The Q extension provides the quad-precision format; this page animation shows only ISA-visible reads and writes of Q-format operands and results in FP registers, not narrower-format conversion.
Requires Q 2.2 (dependent on D) and enabled FP state. Q extends FP registers to FLEN=128; XLEN=128 is not required.
The animation accepts nonzero finite exact whitelisted inputs and a nonzero whitelisted result. Equal source registers must have one initial value; rd may overlap a source and f0 is writable. Zero, special values, and rounding boundaries are outside the animation.

Common Usage Scenarios

Floating-point arithmetic

Understand this scenario with real code like «fsub.q f0, f1, f2, rne # f0 = f1 - f2».

Pre-Use Checklist

Syntax Check
  • rd, rs1 and rs2 select FP f0–f31 or ABI names; f0 is writable and rd may overlap a source. Equal source registers require one initial value.
  • 32-bit OP-FP: funct5=00001, fmt=11 (Q), opcode=1010011. Optional rm defaults to dyn; explicit rm mnemonics must be lowercase.
Semantic Check
  • Requires enabled FP state and Q 2.2 (dependent on D), with FLEN=128 but no XLEN=128 requirement. Round rs1-rs2 by rm/frm and write rd.
  • rm=101/110 and dynamic frm=101–111 have reserved behavior. Applicable NV, OF and NX accrue in fflags; setting a flag does not itself trap. The animation covers finite exact inputs only.

Pitfalls / Common Confusions

Optional lowercase rm defaults to dyn; rm=111 uses frm. Static 101/110 and dynamic frm=101–111 have reserved behavior.
Floating-point exceptions accrue in fflags; setting these flags does not itself generate a trap.
FSUB's listed exception flags are NV, OF, and NX; they do not include UF.

FAQ

What does rm do for FSUB.Q?

rm selects the floating-point rounding mode; rm=111 uses dynamic frm. If the result is exactly representable, rounding does not change the example value, but the encoded field still matters.

Does FSUB.Q write integer registers or condition codes?

FSUB.Q writes FP register f[rd]. RISC-V floating-point exceptions are accrued in fflags, not reported through integer condition codes.