The hand-written parts of the manual still described how the retired xenia-rs interpreter behaved: its snapshots, Rust casts and helpers. Each of those 490 statements is now either restated as what Canary's emitters and x64 backend actually do (at the pinned canary_experimental commit), or dropped where it only made sense for xenia-rs. Checking them turned up claims that were wrong, not just outdated: - VSCR[SAT] is never modelled in Canary (DID_SATURATE is a stub and mfvscr cannot see it); the pages said saturating ops set it stickily. - Canary does not implement lswi/lswx/stswi/stswx, dcbi, mtfsb0/mtfsb1, vmsum*, vmhaddshs, vupkhpx/vupklpx, and most SPRs; pages described them as working. - Traps evaluate TO in Canary; stvebx/stvehx/stvewx store one element, not 16 bytes; mtmsrd writes only EE; fres/frsqrte/vrsqrtefp precision claims and the stfs "rounds under RN / sets FPSCR" claim contradicted the spec. - Reservations are a 64 KiB block bitmap plus a value compare, not per-address tracking. Claims that neither Canary's source nor a public spec settles are marked unverified (NI at boot, vmaddcfp128 operand order, estimate bit-exactness). Generated regions are untouched; re-running the generator changes nothing. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
5.2 KiB
5.2 KiB
fnegx — Floating Negate
Category: Floating-Point · Form: X · Opcode:
0xfc000050
Assembler Mnemonics
| Mnemonic | XML entry | Flags | Description |
|---|---|---|---|
fneg |
fnegx |
— | Floating Negate |
fneg. |
fnegx |
Rc=1 | Floating Negate |
Syntax
fneg[Rc] [FD], [FB]
Encoding
fnegx — form X
- Opcode word:
0xfc000050 - Primary opcode (bits 0–5):
63 - Extended opcode:
40 - Synchronising: no
| Bits | Field | Meaning |
|---|---|---|
| 0–5 | OPCD |
primary opcode |
| 6–10 | RT/FRT/VRT |
destination |
| 11–15 | RA/FRA/VRA |
source A |
| 16–20 | RB/FRB/VRB |
source B |
| 21–30 | XO |
extended opcode (10 bits) |
| 31 | Rc |
record-form flag |
Operands
| Field | Role | Description |
|---|---|---|
FB |
fnegx: read | Source B floating-point register. |
FD |
fnegx: write | Destination floating-point register. |
CR |
fnegx: write (conditional) | Condition-register update. When Rc=1, CR field 0 (or CR6 for vector compares, CR1 for FPU) is updated from the result. |
Register Effects
fnegx
- Reads (always):
FB - Reads (conditional): none
- Writes (always):
FD - Writes (conditional):
CR
Status-Register Effects
fnegx: CR0 ← signed-compare(result, 0) withSO ← XER[SO], whenRc=1.
Operation (pseudocode)
FRT <- flip_sign(FRB)
C Translation Example
/* No hand-written C yet. Translate the Canary emitter snapshot */
/* under Implementation References; its HIR maps directly: */
/* f.LoadGPR(n) / f.StoreGPR(n, v) -> r[n] / r[n] = v */
/* f.LoadFPR / StoreFPR, f.LoadVR / StoreVR -> f[n], v[n] */
/* f.Load(ea, T), f.Store(ea, v) -> raw read / write; emitters */
/* wrap them in f.ByteSwap for the big-endian guest value */
/* f.UpdateCR(n, v) -> CR field n from v's LOW 32 BITS vs 0 */
/* f.LoadCA / f.StoreCA -> xer.CA; f.StoreSAT -> vscr.SAT */
/* i.XO.RA, i.D.DS, ... -> the bit-fields listed under Operands */
/* The Register Effects and Status-Register Effects tables above */
/* enumerate every side effect a faithful translation must emit. */
Implementation References
fnegx
- Canary XML:
tools/ppc-instructions.xml— search formnem="fnegx" - Canary emitter:
src/xenia/cpu/ppc/ppc_emit_fpu.cc:515 - Sylpheed opcode:
crates/sylpheed-ppc/src/opcode.rs:84 - Sylpheed decoder:
crates/sylpheed-ppc/src/decoder.rs:1018
Canary emitter (frozen snapshot @ f21ebd49e9)
int InstrEmit_fnegx(PPCHIRBuilder& f, const InstrData& i) {
// frD <- ¬ frB[0] || frB[1-63]
Value* v = f.Neg(f.LoadFPR(i.X.RB));
f.StoreFPR(i.X.RT, v);
// f.UpdateFPSCR(v, i.X.Rc);
if (i.X.Rc) {
// todo
}
return 0;
}
Special Cases & Edge Conditions
- Bit-pattern operation, no rounding.
fnegtoggles the sign bit (bit 0) of the source binary64 value and writes the 64-bit pattern to the destination. No precision change, no exception bits. - NaN handling. PowerISA specifies that
fnegtoggles the NaN sign bit (unlikefnmaddwhich does not). Canary'sNegisvxorpdwith the sign mask, which toggles NaN signs too — a match. ⚠️ ItsRc=1branch is empty, sofneg.does not update CR1 in Canary. - Special values.
fneg(+0) = -0;fneg(-0) = +0;fneg(±∞) = ∓∞. NoFPSCR[VXSNAN]raised even on signalling NaN inputs (sign-bit ops are not arithmetic). - FPSCR. Hardware does not update
FPRFand does not raise any exception bit. The "FPSCR write" in the header refers only toRc=1updating CR1 from existing FPSCR contents. Rc=1(fneg.) copiesFPSCR[FX, FEX, VX, OX]into CR1.- No
FRA. X-form, primary 63, XO 40. ReadsFRBonly. - Use as a free negate. Common in compiled PPC code for
-xor as part of negate-and-fma sequences when no fused negative variant exists.
Related Instructions
fabsx— clear sign bit (positive).fnabsx— set sign bit (negative).fmrx— plain register copy.fnmaddx,fnmsubx,fnmaddsx,fnmsubsx— fused negate-multiply-add forms; eliminate the need for an explicitfnegafter an FMA.fselx— combined withfnegfor branch-freecopysign/clamp patterns.
IBM Reference
- AIX 7.3 —
fneg(Floating Negate) - PowerISA v2.07B, Book I, Chapter 4 — Floating-Point Processor (PPC's
fnegtoggles NaN sign — distinct from thefnmaddfamily).