FUCOM, FUCOMP, FUCOMPP

Unordered Compare Floating-Point Values

stableVMJITAOTinstruction

Encodings

OpcodeInstructionOp/En64-bitCompat/LegacyDescription
DD E0+iFUCOM ST(i)ValidValidCompare ST(0) with ST(i).
DD E1FUCOMValidValidCompare ST(0) with ST(1).
DD E8+iFUCOMP ST(i)ValidValidCompare ST(0) with ST(i) and pop register stack.
DD E9FUCOMPValidValidCompare ST(0) with ST(1) and pop register stack.
DA E9FUCOMPPValidValidCompare ST(0) with ST(1) and pop register stack twice.

Measured cost

Loading measurements from arch-data...

Description

Performs an unordered comparison of the contents of register ST(0) and ST(i) and sets condition code flags C0, C2, and C3 in the FPU status word according to the results (see the table below). If no operand is specified, the contents of registers ST(0) and ST(1) are compared. The sign of zero is ignored, so that 0.0 is equal to +0.0.

FUCOM/FUCOMP/FUCOMPP Results

Comparison Results*C3C2C0
ST0 > ST(i)000
ST0 < ST(i)001
ST0 = ST(i)100
Unordered111

Operation

CASE (relation of operands) OF

    ST > SRC:  C3, C2, C0 := 000;

    ST < SRC:  C3, C2, C0 := 001;

    ST = SRC:  C3, C2, C0 := 100;

ESAC;

IF ST(0) or SRC = QNaN, but not SNaN or unsupported format

    THEN
          C3, C2, C0 := 111;

    ELSE (* ST(0) or SRC is SNaN or unsupported format *)
           #IA;

        IF FPUControlWord.IM = 1

                THEN
                      C3, C2, C0 := 111;

          FI;
FI;

IF Instruction = FUCOMP

    THEN

          PopRegisterStack;

FI;

IF Instruction = FUCOMPP

    THEN

          PopRegisterStack;

FI;

FPU Flags Affected

C1                  Set to 0 if stack underflow occurred.

C0, C2, C3          See Table 3-43.

Floating-Point Exceptions

#IS                 Stack underflow occurred.
#IA                 One or both operands are SNaN values or have unsupported formats. Detection of a QNaN

value in and of itself does not raise an invalid-operand exception.

#D                  One or both operands are denormal values.

Exceptions

Protected mode
#NMCR0.EM[bit 2] or CR0.TS[bit 3] = 1.
#MFIf there is a pending x87 FPU exception.
#UDIf the LOCK prefix is used.
Real address mode
Same exceptions as in protected mode.
Virtual-8086 mode
Same exceptions as in protected mode.
Compatibility mode
Same exceptions as in protected mode.
64-bit mode
Same exceptions as in protected mode.

Sources