FCOM Compare real Exceptions: I D FCOMP Compare real and pop C3 C2 C1 C0: * * * * FCOMPP Compare real and pop twice
FCOM [source] FCOMP [source] FCOMPP
Logic ; FCOM ; FCOMP ; FCOMPP if source operand if source operand CMP ST, ST(1) CMP ST, source CMP ST, source set condition codes else else pop ST CMP ST, ST(1) CMP ST, ST(1) pop ST endif endif set condition codes set condition codes pop ST
C3 C1 C0 0 0 0 ST > source 0 0 1 ST < source 1 0 0 ST = source 1 1 1 ST not comparable to source
FCOM compares a real number to ST and leaves the result encoded in the status word as shown above. If no source operand is specified, ST(1) is compared to ST. Otherwise, source is compared to ST.
FCOMP operates like FCOM, except that it also pops the stack.
FCOMPP compares ST to ST(1), sets the condition codes as shown above, and pops the stack twice. It takes no operands.
Note If ST contains a NaN or has an undefined format, or a stack fault occurs, the invalid-operand exception is raised and the condition bits are set to 'unordered'. The sign of zero is ignored, so that -0.0 = +0.0.
The FCOM instructions perform the same operation as the FUCOM instructions. The only difference is how they handle QNaN operands. The FCOM instructions raise an invalid-arithmetic-operand exception (#IA) when either or both of the operands is a NaN value or is in an unsupported format. The FUCOM instructions perform the same operation as the FCOM instructions, except that they do not generate an invalid-arithmetic-operand exception for QNaNs.
Opcode Format D8 /2 FCOM m32 DC /2 FCOM m64 D8 D0 + i FCOM ST(i) D8 D1 FCOM D8 /3 FCOMP m32 DC /3 FCOMP m64 D8 D8 + i FCOMP ST(i) D8 D9 FCOMP DE D9 FCOMPP
Timing Variations/ operand 8087 287 387 486 Pentium fcom reg 40-50 40-50 24 4 4/1 FX fcom m32 (60-70)+EA 60-70 26 4 4/1 FX fcom m64 (65-75)+EA 65-75 31 4 4/1 FX fcomp 42-52 42-52 26 4 4/1 FX fcompp 45-55 45-55 26 5 4/1 FX