FSGNJ.D is a double-precision sign-injection instruction in D. 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.D Decode And Execute Animation
Shows the D-extension double-precision OP-FP flow: decode fields, read FP operands, perform FSGNJ semantics, then write rd.
rd
rs1
rs2
fsgnj.d
,
,
Execution Context
FLEN>=64 / fmt=D (01)
funct3: copy rs2 sign
fflags: initial 0
31..27
26..25
24..20
19..15
14..12
11..7
6..0
00100
FSGNJ
01
fmt=D
01100
rs2
01011
rs1
000
funct3=000
01010
rd
1010011
OP-FP
Execution Data Path
instruction
0x22C58553
opcode
1010011 -> OP-FP
funct5/fmt
00100 + D(01) -> FSGNJ.D
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; double-precision OP-FP instructions use opcode 1010011.
encoding: 0x22C58553
syntax : fsgnj.d 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.
Double-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 D-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.D 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 D and enabled FP state; rd, rs1, rs2 select f0–f31, including writable f0.
32-bit OP-FP: funct5=00100, fmt=01, 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.
fmv.d rd, rs is the assembler pseudoinstruction for fsgnj.d rd, rs, rs; equal sources read one initial value.
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 is a bit-level sign operation, not floating add/subtract, compare, or numeric conversion.
The result exponent and significand fields come from rs1; do not treat rs2 as a full numeric source operand.
It does not set fflags and does not canonicalize NaNs or rewrite the payload.
NaN payload preservation assumes valid inputs in this format; malformed NaN-boxing first replaces the source value.
FAQ
Does FSGNJ.D change the 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.D set fflags?
No. It is a bit-level sign operation in FP registers and does not perform rounded arithmetic or exception-flag paths.
Related Instructions & Pseudo-instructions
Related instructions, pseudo-instructions, and context links for this instruction.