FSGNJ.Q is a quad-precision sign-injection instruction in Q. With valid inputs in this format, non-sign bits come from rs1 and the sign is copied from rs2; it uses no rm, does not round, sets no FP exception flags, and does not canonicalize NaNs. Sources narrower than FLEN first undergo NaN-boxing checks: malformed upper bits make the source a canonical NaN in this format; narrower results get upper ones.
FSGNJ.Q Decode And Execute Animation
Shows the Q-extension quad-precision OP-FP flow: decode fields, read FP operands, perform FSGNJ semantics, then write rd.
rd
rs1
rs2
fsgnj.q
,
,
Execution Context
FLEN=128 / fmt=Q (11)
funct3: copy rs2 sign
fflags: initial 0
31..27
26..25
24..20
19..15
14..12
11..7
6..0
00100
FSGNJ
11
fmt=Q
01100
rs2
01011
rs1
000
funct3=000
01010
rd
1010011
OP-FP
Execution Data Path
instruction
0x26C58553
opcode
1010011 -> OP-FP
funct5/fmt
00100 + Q(11) -> FSGNJ.Q
funct3
000 -> copy rs2 sign
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: 0x26C58553
syntax : fsgnj.q fa0(f10), fa1(f11), fa2(f12)
result : Not written yet; initial fflags=0
Sign injection only recombines the floating-point sign bit: exponent and significand fields come from rs1, while the sign bit follows the current instruction rule from rs2 or the rs1/rs2 sign relation; it does not round or canonicalize NaNs.
Quad-precision Calculation
rs1
fa1(f11) = 3.5
rs2
fa2(f12) = -2.0
result
Awaiting Execute
rs1 sign
0
rs2 sign
1
result sign
Awaiting Execute
other bits
exponent/significand from rs1
Sign injection only recombines the floating-point sign bit: exponent and significand fields come from rs1, while the sign bit follows the current instruction rule from rs2 or the rs1/rs2 sign relation; it does not round or canonicalize NaNs.
Assumes required extensions and FS enabled, valid NaN-boxing for narrower sources, and initial fflags=0. Finite inputs use the exact whitelist; signed zeros and infinities are supported. NaN payload bit patterns are covered in static text; textual NaN animation inputs are not supported. Equal sources require one initial value; rd may overlap a source and f0 is writable. 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
FSGNJ.Q copies only the rs2 sign; rs1 supplies the exponent and significand. With valid inputs in this format, 3.5 and -2 give -3.5, with existing fflags unchanged.
RV32/RV64 requires Q and enabled FP state; rd, rs1, rs2 select f0–f31, including writable f0.
32-bit OP-FP: funct5=00100, fmt=11, funct3=000, opcode=1010011; no rm or immediate.
Sources narrower than FLEN first undergo NaN-boxing checks: malformed upper bits make the source canonical NaN; narrower results get upper ones.
For a valid NaN input, rs1 supplies non-sign bits and payload; sNaN is not quieted and does not set NV. Existing fflags are preserved.
Assume required extensions and FP state enabled, f11=3.5 and f12=-2 in this format (validly NaN-boxed when narrower than FLEN), and initial fflags=0: the example writes f10=-3.5, keeping f11 non-sign bits and copying f12 sign; fflags remains 0.
Floating-Point Bit Manipulation
Assume required extensions and FP state enabled, f11=3.5 and f12=-2 in this format (validly NaN-boxed when narrower than FLEN), and initial fflags=0: the example writes f10=-3.5, keeping f11 non-sign bits and copying f12 sign; fflags remains 0.
Pre-Use Checklist
Syntax Check
rd, rs1, rs2: FP registers f0–f31 or ABI names; f0 is writable, rd may overlap a source, and equal sources use one initial value.
No rm, immediate, or rs3; funct3=000 selects FSGNJ, keeping rs1 non-sign bits and copying the rs2 sign.
Semantic Check
Confirm required extensions and enabled FP state. Narrower-than-FLEN sources undergo NaN-boxing checks; malformed boxing is treated as canonical NaN.
For valid sources, non-sign bits come from rs1 and the sign from rs2; no rounding, sNaN quieting, or fflags updates. Narrower results get upper ones.
Pitfalls / Common Confusions
This recombines the sign bit of a floating-point encoding; it is not FP arithmetic, comparison, or integer/FP conversion.
The result exponent and significand fields come from rs1; rs2 only contributes sign-bit information.
FSGNJ-family instructions do not use rm, do not set fflags, and do not canonicalize NaN payloads.
NaN payload preservation assumes valid inputs in this format; malformed NaN-boxing first replaces the source value.
FAQ
Does FSGNJ.Q change a NaN payload?
For valid inputs in this format, rs1 non-sign bits and NaN payload are preserved, and sNaN is not quieted; only the sign comes from rs2. Narrower-than-FLEN sources still undergo NaN-boxing checks, with malformed boxing treated as canonical NaN.
Does FSGNJ.Q set fflags?
No. The FSGNJ family performs sign injection, does not use rm, does not round, and does not set floating-point exception flags.
Related Instructions & Pseudo-instructions
Related instructions, pseudo-instructions, and context links for this instruction.