Instruction Syntax
Mnemonic | Format | Flags |
fnmadds | frD,frA,frC,frB | Rc = 0 |
fnmadds. | frD,frA,frC,frB | Rc = 1 |
Instruction Encoding
Field | Bits | Description |
Primary Opcode | 0-5 | 111011 (0x3B) |
frD | 6-10 | Destination floating-point register |
frA | 11-15 | Source floating-point register A (multiplicand) |
frB | 16-20 | Source floating-point register B (addend) |
frC | 21-25 | Source floating-point register C (multiplier) |
XO | 26-30 | 11111 (31) |
Rc | 31 | Record Condition Register |
Operation
frD ← -SINGLE((frA × frC) + frB)
The contents of floating-point register frA are multiplied by the contents of floating-point register frC. The contents of floating-point register frB are then added to this intermediate product. The result is rounded to single-precision, then negated, and placed into floating-point register frD.
Note: This is a fused negative multiply-add operation optimized for single-precision. The intermediate product (frA × frC) is computed to infinite precision, added to frB, rounded to single-precision format, and then negated. This provides both the accuracy benefits of fused multiply-add and the performance advantages of single-precision arithmetic. The result is stored in double-precision format in the FPR.
Affected Registers
Condition Register (CR1 field)
(if Rc = 1)
- Reflects floating-point exception summary and status
Floating-Point Status and Control Register (FPSCR)
Affected fields:
- FPRF (Floating-Point Result Flags)
- FX (Floating-Point Exception Summary)
- OX (Overflow Exception)
- UX (Underflow Exception)
- XX (Inexact Exception)
- VXISI (Invalid Operation Exception for ∞ - ∞)
- VXIMZ (Invalid Operation Exception for 0 × ∞)
- FR (Fraction Rounded)
- FI (Fraction Inexact)
For more information on floating-point status see Section 2.1.4, "Floating-Point Status and Control Register (FPSCR)," in the PowerPC Microprocessor Family: The Programming Environments manual.
Examples
Basic Single-Precision Negative Multiply-Add
lfs f1, multiplicand(r0) # Load single-precision multiplicand lfs f2, addend(r0) # Load single-precision addend lfs f3, multiplier(r0) # Load single-precision multiplier fnmadds f4, f1, f3, f2 # f4 = -SINGLE((f1 × f3) + f2) stfs f4, result(r0) # Store single-precision result
3D Graphics: Inverted Single-Precision Lighting
# Calculate negative lighting: result = -(diffuse × intensity + ambient) lfs f1, diffuse_color(r0) # Load diffuse color component lfs f2, light_intensity(r0) # Load light intensity lfs f3, ambient_light(r0) # Load ambient light level fnmadds f4, f1, f2, f3 # f4 = -(diffuse × intensity + ambient) stfs f4, inverted_light(r0) # Store inverted lighting result
Audio Processing: Phase-Inverted Single-Precision FIR
# Phase-inverted FIR filter tap: output = -(coeff × sample + accumulator) lfs f1, filter_coeff(r0) # Load filter coefficient lfs f2, audio_sample(r0) # Load audio sample lfs f3, accumulator(r0) # Load current accumulator fnmadds f4, f1, f2, f3 # f4 = -(coeff × sample + accumulator) stfs f4, inverted_output(r0) # Store phase-inverted filter output
Game Physics: Negative Force Single-Precision
# Calculate opposing force: F = -(mass × acceleration + base_force) lfs f1, object_mass(r0) # Load object mass lfs f2, acceleration(r0) # Load acceleration lfs f3, base_force(r0) # Load base force fnmadds f4, f1, f2, f3 # f4 = -(mass × acceleration + base_force) stfs f4, opposing_force(r0) # Store opposing force
Computer Graphics: Inverted Alpha Blending
# Inverted alpha blend: result = -(src × alpha + dst) lfs f1, src_color(r0) # Load source color lfs f2, alpha_value(r0) # Load alpha value lfs f3, dst_color(r0) # Load destination color fnmadds f4, f1, f2, f3 # f4 = -(src × alpha + dst) stfs f4, inverted_blend(r0) # Store inverted blend result
Signal Processing: Inverted Single-Precision Modulation
# Inverted amplitude modulation: output = -(carrier × modulation + bias) lfs f1, carrier_signal(r0) # Load carrier signal lfs f2, modulation(r0) # Load modulation factor lfs f3, bias_level(r0) # Load bias level fnmadds f4, f1, f2, f3 # f4 = -(carrier × modulation + bias) stfs f4, inverted_am(r0) # Store inverted AM signal
Machine Learning: Negative Single-Precision Neuron
# Negative neuron output: result = -(weight × input + bias) lfs f1, neuron_weight(r0) # Load neuron weight lfs f2, input_value(r0) # Load input value lfs f3, bias_value(r0) # Load bias value fnmadds f4, f1, f2, f3 # f4 = -(weight × input + bias) stfs f4, neg_neuron_out(r0) # Store negative neuron output
Real-Time Audio: Inverted Single-Precision Reverb
# Inverted reverb mix: output = -(dry × dry_gain + wet) lfs f1, dry_signal(r0) # Load dry signal lfs f2, dry_gain(r0) # Load dry gain lfs f3, wet_signal(r0) # Load wet signal fnmadds f4, f1, f2, f3 # f4 = -(dry × dry_gain + wet) stfs f4, inverted_reverb(r0) # Store inverted reverb output
Financial Computing: Negative Single-Precision Interest
# Calculate debt: debt = -(principal × rate + fees) lfs f1, principal(r0) # Load principal amount lfs f2, interest_rate(r0) # Load interest rate lfs f3, fees(r0) # Load fees fnmadds f4, f1, f2, f3 # f4 = -(principal × rate + fees) stfs f4, total_debt(r0) # Store total debt (negative)
Game AI: Negative Single-Precision Utility
# Calculate negative utility: utility = -(base_value × multiplier + bonus) lfs f1, base_value(r0) # Load base utility value lfs f2, utility_mult(r0) # Load utility multiplier lfs f3, bonus_points(r0) # Load bonus points fnmadds f4, f1, f2, f3 # f4 = -(base_value × multiplier + bonus) stfs f4, negative_utility(r0) # Store negative utility score
Physics Simulation: Negative Single-Precision Energy
# Calculate energy loss: loss = -(kinetic × friction_coeff + heat_loss) lfs f1, kinetic_energy(r0) # Load kinetic energy lfs f2, friction_coeff(r0) # Load friction coefficient lfs f3, heat_loss(r0) # Load heat loss fnmadds f4, f1, f2, f3 # f4 = -(kinetic × friction_coeff + heat_loss) stfs f4, energy_loss(r0) # Store energy loss