3-183
INSTRUCTION SET REFERENCE
FCOMI/FCOMIP/
FUCOMI/FUCOMIPCompare Real and Set
EFLAGS
Description
These instructions compare the contents of register ST(0) and ST(i) and sets the status flags ZF,
PF, and CF in the EFLAGS register according to the results (refer to the table below). The sign
of zero is ignored for comparisons, so that 0.0 = +0.0.
NOTE:
*Flags are set regardless, whether there is an unmasked invalid-arithmetic-operand (#IA) exception gen-
erated or not.
The FCOMI/FCOMIP instructions perform the same operation as the FUCOMI/FUCOMIP
instructions. The only difference is how they handle qNaN operands. The FCOMI/FCOMIP
instructions set the status flags to unordered and generate an invalid-arithmetic-operand
exception (#IA) when either or both of the operands is a NaN value (sNaN or qNaN) or is in an
unsupported format.
The FUCOMI/FUCOMIP instructions perform the same operation as the FCOMI/FCOMIP
instructions, except that they do not generate an invalid-arithmetic-operand exception for
qNaNs. Refer to FXAMExamine in this chapter for additional information on unordered
comparisons.
If invalid operation exception is unmasked, the status flags are not set if the invalid-arithmetic-
operand exception is generated.
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 incre-
ments the stack pointer (TOP) by 1.
OpcodeInstruction
Description
DB F0+iFCOMI ST, ST(i)
Compare ST(0) with ST(i) and set status flags accordingly
DF F0+iFCOMIP ST, ST(i)
Compare ST(0) with ST(i), set status flags accordingly, and
pop register stack
DB E8+iFUCOMI ST, ST(i)
Compare ST(0) with ST(i), check for ordered values, and
set status flags accordingly
DF E8+iFUCOMIP ST, ST(i)Compare ST(0) with ST(i), check for ordered values, set
status flags accordingly, and pop register stack
Comparison Results
ZF
PF
CF
ST0 > ST(i)
0
0
0
ST0 < ST(i)
0
0
1
ST0 = ST(i)
1
0
0
Unordered*
1
1
1