image/svg+xmlFCOMI/FCOMIP/ FUCOMI/FUCOMIP—Compare Floating Point Values and Set EFLAGSDescriptionPerforms an unordered comparison of the contents of registers ST(0) and ST(i) and sets the status flags ZF, PF, and CF in the EFLAGS register according to the results (see the table below). The sign of zero is ignored for compari-sons, so that –0.0 is equal to +0.0. An unordered comparison checks the class of the numbers being compared (see “FXAM—Examine Floating-Point” in this chapter). The FUCOMI/FUCOMIP instructions perform the same operations as the FCOMI/FCOMIP instruc-tions. The only difference is that the FUCOMI/FUCOMIP instructions raise the invalid-arithmetic-operand exception (#IA) only when either or both operands are an SNaN or are in an unsupported format; QNaNs cause the condition code flags to be set to unordered, but do not cause an exception to be generated. The FCOMI/FCOMIP instructions raise an invalid-operation exception when either or both of the operands are a NaN value of any kind or are in an unsupported format.If the operation results in an invalid-arithmetic-operand exception being raised, the status flags in the EFLAGS register are set only if the exception is masked. The FCOMI/FCOMIP and FUCOMI/FUCOMIP instructions set the OF, SF and AF flags to zero in the EFLAGS register (regardless of whether an invalid-operation exception is detected).The FCOMIP and FUCOMIP instructions also pop the register stack following the comparison operation. To pop the register stack, the processor marks the ST(0) register as empty and increments the stack pointer (TOP) by 1.This instruction’s operation is the same in non-64-bit modes and 64-bit mode.IA-32 Architecture CompatibilityThe FCOMI/FCOMIP/FUCOMI/FUCOMIP instructions were introduced to the IA-32 Architecture in the P6 family processors and are not available in earlier IA-32 processors. OpcodeInstruction64-Bit ModeCompat/Leg ModeDescriptionDB F0+iFCOMI ST, ST(i)ValidValidCompare ST(0) with ST(i) and set status flags accordingly.DF F0+iFCOMIP ST, ST(i)ValidValidCompare ST(0) with ST(i), set status flags accordingly, and pop register stack.DB E8+iFUCOMI ST, ST(i)ValidValidCompare ST(0) with ST(i), check for ordered values, and set status flags accordingly.DF E8+iFUCOMIP ST, ST(i)ValidValidCompare ST(0) with ST(i), check for ordered values, set status flags accordingly, and pop register stack.Table 3-22. FCOMI/FCOMIP/ FUCOMI/FUCOMIP ResultsComparison Results*ZFPFCFST0 > ST(i)000ST0 < ST(i)001ST0 = ST(i)100Unordered**111NOTES:*See the IA-32 Architecture Compatibility section below.**Flags not set if unmasked invalid-arithmetic-operand (#IA) exception is generated.

image/svg+xmlOperationCASE (relation of operands) OFST(0) > ST(i):ZF, PF, CF := 000;ST(0) < ST(i):ZF, PF, CF := 001;ST(0) = ST(i):ZF, PF, CF := 100;ESAC;IF Instruction is FCOMI or FCOMIPTHENIF ST(0) or ST(i) = NaN or unsupported formatTHEN #IAIF FPUControlWord.IM = 1THEN ZF, PF, CF := 111;FI;FI;FI;IF Instruction is FUCOMI or FUCOMIPTHENIF ST(0) or ST(i) = QNaN, but not SNaN or unsupported formatTHEN ZF, PF, CF := 111;ELSE (* ST(0) or ST(i) is SNaN or unsupported format *) #IA;IF FPUControlWord.IM = 1THEN ZF, PF, CF := 111;FI;FI;FI;IF Instruction is FCOMIP or FUCOMIP THEN PopRegisterStack;FI;FPU Flags AffectedC1Set to 0.C0, C2, C3 Not affected.Floating-Point Exceptions#ISStack underflow occurred.#IA(FCOMI or FCOMIP instruction) One or both operands are NaN values or have unsupported formats.(FUCOMI or FUCOMIP instruction) One or both operands are SNaN values (but not QNaNs) or have undefined formats. Detection of a QNaN value does not raise an invalid-operand excep-tion.

image/svg+xmlProtected Mode Exceptions#NMCR0.EM[bit 2] or CR0.TS[bit 3] = 1.#MF If there is a pending x87 FPU exception.#UD If the LOCK prefix is used.Real-Address Mode ExceptionsSame exceptions as in protected mode.Virtual-8086 Mode ExceptionsSame exceptions as in protected mode.Compatibility Mode ExceptionsSame exceptions as in protected mode.64-Bit Mode ExceptionsSame exceptions as in protected mode.

This UNOFFICIAL reference was generated from the official Intel® 64 and IA-32 Architectures Software Developer’s Manual by a dumb script. There is no guarantee that some parts aren't mangled or broken and is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.