fmsub or fms (Floating Multiply-Subtract) instruction

Purpose

Subtracts one floating-point operand from the result of multiplying two floating-point operands without an intermediate rounding operation.

Syntax

Bits Value
0-5 63
6-10 FRT
11-15 FRA
16-20 FRB
21-25 FRC
26-30 28
31 Rc
PowerPC® 
fmsub FRT, FRA, FRC, FRB
fmsub. FRT, FRA, FRC, FRB
POWER® family 
fms FRT, FRA, FRC, FRB
fms. FRT, FRA, FRC, FRB
Bits Value
0-5 59
6-10 FRT
11-15 FRA
16-20 FRB
21-25 FRC
26-30 28
31 Rc
PowerPC® 
fmsubs FRT, FRA, FRC, FRB
fmsubs. FRT, FRA, FRC, FRB

Description

The fmsub and fms instructions multiply the 64-bit, double-precision floating-point operand in floating-point register (FPR) FRA by the 64-bit, double-precision floating-point operand in FPR FRC and subtract the 64-bit, double-precision floating-point operand in FPR FRB from the result of the multiplication.

The fmsubs instruction multiplies the 32-bit, single-precision floating-point operand in FPR FRA by the 32-bit, single-precision floating-point operand in FPR FRC and subtracts the 32-bit, single-precision floating-point operand in FPR FRB from the result of the multiplication.

The result is rounded under control of the Floating-Point Rounding Control Field RN of the Floating-Point Status and Control Register and is placed in the target FPR FRT.

Note: If an operand is a denormalized number, then it is prenormalized before the operation is begun.

The Floating-Point Result Flags Field of the Floating-Point Status and Control Register is set to the class and sign of the result, except for Invalid Operation Exceptions, when the Floating-Point Invalid Operation Exception Enable bit is 1.

The fmsub, fmsubs, and fms instructions each have two syntax forms. Each syntax form has a different effect on Condition Register Field 1.

Item Description
Syntax Form Floating-Point Status and Control Register Record Bit (Rc) Condition Register Field 1
fmsub C,FL,FG,FE,FU,FR,FI,OX,UX, XX,VXSNAN,VXSI,VXIMZ 0 None
fmsub. C,FL,FG,FE,FU,FR,FI,OX,UX, XX,VXSNAN,VXSI,VXIMZ 1 FX,FEX,VX,OX
fmsubs C,FL,FG,FE,FU,FR,FI,OX,UX, XX,VXSNAN,VXSI,VXIMZ 0 None
fmsubs. C,FL,FG,FE,FU,FR,FI,OX,UX, XX,VXSNAN,VXSI,VXIMZ 1 FX,FEX,VX,OX
fms C,FL,FG,FE,FU,FR,FI,OX,UX, XX,VXSNAN,VXSI,VXIMZ 0 None
fms. C,FL,FG,FE,FU,FR,FI,OX,UX, XX,VXSNAN,VXSI,VXIMZ 1 FX,FEX,VX,OX

All syntax forms of the fmsub, fmsubs, and fms instructions always affect the Floating-Point Status and Control Register. If the syntax form sets the Record (Rc) bit to 1, the instruction affects the Floating-Point Exception (FX), Floating-Point Enabled Exception (FEX), Floating-Point Invalid Operation Exception (VX), and Floating-Point Overflow Exception (OX) bits in Condition Register Field 1.

Parameters

Item Description
FRT Specifies target floating-point register for operation.
FRA Specifies source floating-point register containing a multiplier.
FRB Specifies source floating-point register containing the quantity to be subtracted.
FRC Specifies source floating-point register containing a multiplier.

Examples

  1. The following code multiplies the contents of FPR 4 and FPR 5, subtracts the contents of FPR 7 from the product of the multiplication, places the result in FPR 6, and sets the Floating-Point Status and Control Register to reflect the result of the operation:
    
    # Assume FPR 4 contains 0xC053 4000 0000 0000.
    # Assume FPR 5 contains 0x400C 0000 0000 0000.
    # Assume FPR 7 contains 0x3DE2 6AB4 B33c 110A.
    # Assume FPSCR = 0.
    fmsub 6,4,5,7
    # FPR 6 now contains 0xC070 D800 0000 0935.
    # FPSCR now contains 0x8202 8000.
    
  2. The following code multiplies the contents of FPR 4 and FPR 5, subtracts the contents of FPR 7 from the product of the multiplication, places the result in FPR 6, and sets the Floating-Point Status and Control Register and Condition Register Field 1 to reflect the result of the operation:
    
    # Assume FPR 4 contains 0xC053 4000 0000 0000.
    # Assume FPR 5 contains 0x400C 0000 0000 0000.
    # Assume FPR 7 contains 0x3DE2 6AB4 B33c 110A.
    # Assume FPSCR = 0 and CR = 0.
    fmsub. 6,4,5,7
    # FPR 6 now contains 0xC070 D800 0000 0935.
    # FPSCR now contains 0x8202 8000.
    # CR now contains 0x0800 0000.