Files
Sylpheed/tools/ppc-manual/fpu/faddx.md
sim 9bfe96e44d fix(ppc-manual): 543 dead links, from two generator bugs and wrong relative paths
- Category pages linked each family as `<slug>.md`, relative to categories/,
  where no family page lives. They now link `../<category>/<slug>.md`.
- Form pages linked a member into its *own* category directory, so every
  VMX128 sibling (`vsldoi128`) pointed at vmx128/ although its family page is
  under vmx/. They now link into the family's directory.
- Hand-written "Related" and sibling mentions linked other categories' pages
  as if they were in the same directory. 109 are retargeted through the page
  index; 29 that pointed a family page at itself (`vrefp128` on vrefp.md) and
  6 naming instructions the manual has no page for are plain text now.

Regenerated at the existing Canary pin (f21ebd49e): upstream has moved on, and
re-pinning belongs in its own change. The generator reports 0 family pages
changed and is idempotent; the only dead links left are TEMPLATE.md's
placeholders.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-16 22:37:12 +02:00

6.8 KiB
Raw Permalink Blame History

faddx — Floating Add

Category: Floating-Point · Form: A · Opcode: 0xfc00002a

Assembler Mnemonics

Mnemonic XML entry Flags Description
fadd faddx Floating Add
fadd. faddx Rc=1 Floating Add

Syntax

fadd[Rc] [FD], [FA], [FB]

Encoding

faddx — form A

  • Opcode word: 0xfc00002a
  • Primary opcode (bits 05): 63
  • Extended opcode: 21
  • Synchronising: no
Bits Field Meaning
05 OPCD primary opcode (59 or 63)
610 FRT destination FPR
1115 FRA source A FPR
1620 FRB source B FPR
2125 FRC source C FPR (multiplier for madd-style ops)
2630 XO extended opcode (5 bits)
31 Rc record-form flag (updates CR1)

Operands

Field Role Description
FA faddx: read Source A floating-point register (fr0fr31).
FB faddx: read Source B floating-point register.
FD faddx: write Destination floating-point register.
CR faddx: write (conditional) Condition-register update. When Rc=1, CR field 0 (or CR6 for vector compares, CR1 for FPU) is updated from the result.
FPSCR faddx: write Floating-Point Status and Control Register.

Register Effects

faddx

  • Reads (always): FA, FB
  • Reads (conditional): none
  • Writes (always): FD, FPSCR
  • Writes (conditional): CR

Status-Register Effects

  • faddx: CR1 ← FPSCR[FX, FEX, VX, OX] when Rc=1.; FPSCR updated per IEEE-754 flags (FX, FEX, FPRF, FR, FI, exceptions).

Operation (pseudocode)

FRT <- FRA + FRB                         ; double-precision

C Translation Example

/* fadd / fadd. — IEEE-754 double-precision add (A-form)            */
f[insn.FRT] = f[insn.FRA] + f[insn.FRB];
if (insn.Rc) update_cr1_from_fpscr();
/* FPSCR[FPRF, FR, FI, FX, exceptions] implicitly updated by the FPU. */

Implementation References

faddx

Canary emitter (frozen snapshot @ f21ebd49e9)
int InstrEmit_faddx(PPCHIRBuilder& f, const InstrData& i) {
  // frD <- (frA) + (frB)
  Value* v = f.Add(f.LoadFPR(i.A.FRA), f.LoadFPR(i.A.FRB));
  f.StoreFPR(i.A.FRT, v);
  f.UpdateFPSCR(v, i.A.Rc);
  return 0;
}

Extended Pseudocode

FRT <- round(FRA + FRB, FPSCR[RN])                 ; double precision, current rounding mode

; FPSCR side-effects (always)
    FPSCR[FPRF]  <- classify(FRT)                  ; sign / class bits
    FPSCR[FR,FI] <- round_info
    if overflow           then FPSCR[OX]   <- 1; FPSCR[FX] <- 1
    if underflow          then FPSCR[UX]   <- 1; FPSCR[FX] <- 1
    if inexact            then FPSCR[XX]   <- 1; FPSCR[FX] <- 1
    if NaN input or ±∞−±∞ then FPSCR[VXISI]<- 1; FPSCR[FX] <- 1
    FPSCR[FEX] <- any-enabled-exception

if Rc then
    CR1 <- FPSCR[FX, FEX, VX, OX]                  ; the four "summary" bits

Special Cases & Edge Conditions

  • Double precision. fadd always operates on IEEE-754 binary64 regardless of whether either source was produced by a single-precision instruction. Single-precision adds use faddsx and automatically round the result to binary32 precision.
  • No immediate / carry / OE. FPU arithmetic has no immediate forms, no carry, and no overflow-enable bit. Rc is the only modifier — it writes CR1 from the four top FPSCR bits.
  • FPSCR is always updated. Even the non-record form (fadd) updates FPSCR[FPRF, FR, FI, FX, …] on hardware. Canary does not compute them: its UpdateFPSCR is a stub that clears FEX and VX, leaves every other FPSCR bit unchanged and, with Rc=1, writes CR1 as all zeros, so translations that rely on observing FPSCR bits across a pair of FPU instructions will diverge from hardware. If your translator needs compatible FPSCR state, emit explicit updates — titles rarely read FPSCR except via mffs for exception sanity checks.
  • NaN propagation. Per IEEE-754, any NaN input produces a NaN output; PowerPC specifies that the result NaN is quiet (a signalling input is quietened). Canary emits a host f.Add — SSE addsd on x64, which also returns a quietened NaN.
  • ±∞ ±∞ is an invalid operation. Produces a quiet NaN and sets FPSCR[VXISI]. Canary returns the host's default NaN and sets no FPSCR bit; note x64's default NaN is 0xFFF8_0000_0000_0000 (sign set), whereas PowerPC's is 0x7FF8_0000_0000_0000.
  • Denormal flush. That Xenon boots with FPSCR[NI]=1 is unverified. Canary starts every guest thread in IEEE mode (MXCSR 0x1F80; its init comment flags the startup state as unchecked) and turns on the host's flush-to-zero (MXCSR.FZ) only when the guest sets NI through mtfsf/mtfsfi.
  • Rounding mode. FPSCR[RN] selects one of four rounding modes (nearest-even, toward 0, toward +∞, toward −∞). Games rarely change RN from the default nearest-even. If your translator needs faithful rounding-mode support emit fesetround around the operation.
  • Register encoding. A-form: FRT, FRA, FRB, FRC, Rc — but fadd ignores FRC (the "C" multiplier operand used by fmadd-style ops). The FRC field is architecturally don't-care but typically encoded as 0.

IBM Reference