FXCH
Usage: FXCH src Modifies flags: See below.
Exchanges the contents of registers ST(0) and ST(i). If no 'src' operand is specified, the contents of ST(0) and ST(1) are exchanged.
Floating-Point Exchange
FXCH ; D9 C9 [8086,FPU]
FXCH fpureg ; D9 C8+r [8086,FPU]
FXCH fpureg,ST0 ; D9 C8+r [8086,FPU]
FXCH ST0,fpureg ; D9 C8+r [8086,FPU]
FXCH exchanges ST0 with a given FPU register.
The no-operand form exchanges ST0 with ST1.
FPU Flags Affected C1 Set to 0 if stack underflow occurred; otherwise, set to 0.
C0, C2, C3 Undefined.
EXAMPLE:
fxch st6
FXAM
Usage: FXAM Modifies flags: See below.
Examines the contents of the ST(0) register and sets the condition code flags C0, C2, and C3 in the FPU status word to indicate the class of value or number in the register
Examine Class of Value in ST0
FXAM ; D9 E5 [8086,FPU]
FXAM sets the FPU flags C3, C2 and C0 depending on the type of value stored in ST0:
FXAM Results
Class C3 C2 C0
Unsupported format 0 0 0
NaN 0 0 1
Finite number 0 1 0
Infinity 0 1 1
Zero 1 0 0
Empty register 1 0 1
Denormal 1 1 0
Additionally, the C1 flag is set to the sign of the number.
.
EXAMPLE:
fxam
WAIT
Usage: WAIT Modifies flags: None
FWAIT
CPU enters wait state until the coprocessor signals it has finished its operation. This instruction is used to prevent the CPU from accessing memory that may be temporarily in use by the coprocessor. WAIT and FWAIT are identical.
Wait for Floating-Point Processor
WAIT ; 9B [8086]
FWAIT ; 9B [8086]
WAIT, on 8086 systems with a separate 8087 FPU, waits for the FPU to have finished any operation it is engaged in before continuing main processor operations, so that (for example) an FPU store to main memory can be guaranteed to have completed before the CPU tries to read the result back out.
On higher processors, WAIT is unnecessary for this purpose, and it has the alternative purpose of ensuring that any pending unmasked FPU exceptions have happened before execution continues.
All the FPU Instructions that would actually require a WAIT are directely encoded with a 09B Prefix. These Instructions are FSAVE, FINIT, FCLEX, FSTCW, FSTSW, FSTENV.
EXAMPLE:
wait
fwait
FUCOMxx
Usage: FUCOMxx dest,src Modifies flags: See below.
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. 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.
Floating-Point Unordered Compare
FUCOM fpureg ; DD E0+r [386,FPU]
FUCOM ST0,fpureg ; DD E0+r [386,FPU]
FUCOMP fpureg ; DD E8+r [386,FPU]
FUCOMP ST0,fpureg ; DD E8+r [386,FPU]
FUCOMPP ; DA E9 [386,FPU]
FUCOMI fpureg ; DB E8+r [P6,FPU]
FUCOMI ST0,fpureg ; DB E8+r [P6,FPU]
FUCOMIP fpureg ; DF E8+r [P6,FPU]
FUCOMIP ST0,fpureg ; DF E8+r [P6,FPU]
FUCOM compares ST0 with the given operand, and sets the FPU flags accordingly. ST0 is treated as the left-hand side of the comparison, so that the carry flag is set (for a `less-than' result) if ST0 is less than the given operand.
FUCOMP does the same as FUCOM, but pops the register stack afterwards. FUCOMPP compares ST0 with ST1 and then pops the register stack twice.
FUCOMI and FUCOMIP work like the corresponding forms of FUCOM and FUCOMP, but write their results directly to the CPU flags register rather than the FPU status word, so they can be immediately followed by conditional jump or conditional move instructions.
The FUCOM instructions differ from the FCOM instructions () only in the way they handle quiet NaNs: FUCOM will handle them silently and set the condition code flags to an 'unordered' result, whereas FCOM will generate an exception.
FUCOM/FUCOMP/FUCOMPP Results
Comparison Results C3 C2 C0
ST0 >ST(i) 0 0 0
ST0 <ST(i) 0 0 1
ST0 =ST(i) 1 0 0
Unordered 1 1 1
FUCOM Unordered compare floating-point
FUCOMI Unordered compare floating-point and set EFLAGS
FUCOMIP Unordered compare floating-point, set EFLAGS, and pop
FUCOMP Unordered compare floating-point and pop
FUCOMPP Unordered compare floating-point and pop twice
EXAMPLE:
[Reference: F$ 2.0 Variable: F$ 2.0]
fld F$Reference
fld F$Variable
; Compare ST0 (Variable) to ST1
fucomi ST1 | je S0> | ja S1>
; Variable < Reference
mov eax 0-1 | jmp S2>
; Variable = Reference
S0: mov eax 0 | jmp S2>
; Variable > Reference
S1: mov eax 1 | jmp S2>
; Clear the Stack
S2: fstp ST0 | fstp ST0
FTST
Usage: FTST Modifies flags: See below.
Compares the value in the ST(0) register with 0.0 and sets the condition code flags C0, C2, and C3 in the FPU status word according to the results.
Test ST0 Against Zero
FTST ; D9 E4 [8086,FPU]
FTST compares ST0 with zero and sets the FPU flags accordingly. ST0 is treated as the left-hand side of the comparison, so that a 'less-than' result is generated if ST0 is negative.
FTST Results
Condition C3 C2 C0
ST(0) >0.0 0 0 0
ST(0) <0.0 0 0 1
ST(0) =0.0 1 0 0
Unordered 1 1 1
EXAMPLE:
ftst
FSUBRP
Usage: FSUBRP dest,src Modifies flags: See below.
Subtracts the 'src' operand from the 'dest' operand and stores the difference in the 'dest' location. 'Src' operands in memory can be in single-precision or double-precision floating-point format or in word or doubleword integer.
Floating-Point Subtract
FSUB mem32 ; D8 /4 [8086,FPU]
FSUB mem64 ; DC /4 [8086,FPU]
FSUB fpureg ; D8 E0+r [8086,FPU]
FSUB ST0,fpureg ; D8 E0+r [8086,FPU]
FSUB TO fpureg ; DC E8+r [8086,FPU]
FSUB fpureg,ST0 ; DC E8+r [8086,FPU]
FSUBR mem32 ; D8 /5 [8086,FPU]
FSUBR mem64 ; DC /5 [8086,FPU]
FSUBR fpureg ; D8 E8+r [8086,FPU]
FSUBR ST0,fpureg ; D8 E8+r [8086,FPU]
FSUBR TO fpureg ; DC E0+r [8086,FPU]
FSUBR fpureg,ST0 ; DC E0+r [8086,FPU]
FSUBP fpureg ; DE E8+r [8086,FPU]
FSUBP fpureg,ST0 ; DE E8+r [8086,FPU]
FSUBRP fpureg ; DE E0+r [8086,FPU]
FSUBRP fpureg,ST0 ; DE E0+r [8086,FPU]
FSUB subtracts the given operand from ST0 and stores the result back in ST0.
FSUBR does the same thing, but does the subtraction the other way up: so, it subtracts ST0 from the given operand and stores the result in ST0.
FSUBP operates like FSUB, but pops the register stack once it has finished.
FSUBRP operates like FSUBR, but pops the register stack once it has finished.
The 'dest' operand is always an FPU data register; the 'src' operand can be a register or a memory location.
FPU Flags Affected C1 Set to 0 if stack underflow occurred.
Set if result was rounded up; cleared otherwise. C0, C2, C3 Undefined.
EXAMPLE:
fsubrp Label st3
FSUBR
Usage: FSUBR dest,src Modifies flags: See below.
Subtracts the 'src' operand from the 'dest' operand and stores the difference in the 'dest' location. 'Src' operands in memory can be in single-precision or double-precision floating-point format or in word or doubleword integer.
Floating-Point Subtract
FSUB mem32 ; D8 /4 [8086,FPU]
FSUB mem64 ; DC /4 [8086,FPU]
FSUB fpureg ; D8 E0+r [8086,FPU]
FSUB ST0,fpureg ; D8 E0+r [8086,FPU]
FSUB fpureg ; DC E8+r [8086,FPU]
FSUB fpureg,ST0 ; DC E8+r [8086,FPU]
FSUBR mem32 ; D8 /5 [8086,FPU]
FSUBR mem64 ; DC /5 [8086,FPU]
FSUBR fpureg ; D8 E8+r [8086,FPU]
FSUBR ST0,fpureg ; D8 E8+r [8086,FPU]
FSUBR fpureg ; DC E0+r [8086,FPU]
FSUBR fpureg,ST0 ; DC E0+r [8086,FPU]
FSUBP fpureg ; DE E8+r [8086,FPU]
FSUBP fpureg,ST0 ; DE E8+r [8086,FPU]
FSUBRP fpureg ; DE E0+r [8086,FPU]
FSUBRP fpureg,ST0 ; DE E0+r [8086,FPU]
FSUB subtracts the given operand from ST0 and stores the result back in ST0.
FSUBR does the same thing, but does the subtraction the other way up: so, it subtracts ST0 from the given operand and stores the result in ST0.
FSUBP operates like FSUB, but pops the register stack once it has finished.
FSUBRP operates like FSUBR, but pops the register stack once it has finished.
The 'dest' operand is always an FPU data register; the 'src' operand can be a register or a memory location.
FPU Flags Affected C1 Set to 0 if stack underflow occurred. Set if result was rounded up; cleared otherwise.
C0, C2, C3 Undefined.
EXAMPLE:
fsubr Label st3
FSUBP
Usage: FSUBP dest.src Modifies flags: See below.
Subtracts the 'src' from the 'dest' operand and stores the difference in the 'dest' location. 'Src' operands in memory can be in single-precision or double-precision floating-point format or in word or doubleword integer format.
Floating-Point Subtract
FSUB mem32 ; D8 /4 [8086,FPU]
FSUB mem64 ; DC /4 [8086,FPU]
FSUB fpureg ; D8 E0+r [8086,FPU]
FSUB ST0,fpureg ; D8 E0+r [8086,FPU]
FSUB fpureg ; DC E8+r [8086,FPU]
FSUB fpureg,ST0 ; DC E8+r [8086,FPU]
FSUBR mem32 ; D8 /5 [8086,FPU]
FSUBR mem64 ; DC /5 [8086,FPU]
FSUBR fpureg ; D8 E8+r [8086,FPU]
FSUBR ST0,fpureg ; D8 E8+r [8086,FPU]
FSUBR fpureg ; DC E0+r [8086,FPU]
FSUBR fpureg,ST0 ; DC E0+r [8086,FPU]
FSUBP fpureg ; DE E8+r [8086,FPU]
FSUBP fpureg,ST0 ; DE E8+r [8086,FPU]
FSUBRP fpureg ; DE E0+r [8086,FPU]
FSUBRP fpureg,ST0 ; DE E0+r [8086,FPU]
FSUB subtracts the given operand from ST0 and stores the result back in ST0.
FSUBR does the same thing, but does the subtraction the other way up: so, it subtracts ST0 from the given operand and stores the result in ST0.
FSUBP operates like FSUB, but pops the register stack once it has finished.
FSUBRP operates like FSUBR, but pops the register stack once it has finished.
FPU Flags Affected C1 Set to 0 if stack underflow occurred. Set if result was rounded up; cleared otherwise. C0, C2, C3 Undefined.
The 'dest' operand is always an FPU data register; the 'src' operand can be a register or a memory location.
EXAMPLE:
fsubp Label st3
FSUB
Usage: FSUB dest.src Modifies flags: See below.
Subtracts the 'src' from the 'dest' and stores the difference in the 'dest' location. 'Src' operands in memory can be in single-precision or double-precision floating-point format or in word or doubleword integer format.
Floating-Point Subtract
FSUB mem32 ; D8 /4 [8086,FPU]
FSUB mem64 ; DC /4 [8086,FPU]
FSUB fpureg ; D8 E0+r [8086,FPU]
FSUB ST0,fpureg ; D8 E0+r [8086,FPU]
FSUB fpureg ; DC E8+r [8086,FPU]
FSUB fpureg,ST0 ; DC E8+r [8086,FPU]
FSUBR mem32 ; D8 /5 [8086,FPU]
FSUBR mem64 ; DC /5 [8086,FPU]
FSUBR fpureg ; D8 E8+r [8086,FPU]
FSUBR ST0,fpureg ; D8 E8+r [8086,FPU]
FSUBR fpureg ; DC E0+r [8086,FPU]
FSUBR fpureg,ST0 ; DC E0+r [8086,FPU]
FSUBP fpureg ; DE E8+r [8086,FPU]
FSUBP fpureg,ST0 ; DE E8+r [8086,FPU]
FSUBRP fpureg ; DE E0+r [8086,FPU]
FSUBRP fpureg,ST0 ; DE E0+r [8086,FPU]
FSUB subtracts the given operand from ST0 and stores the result back in ST0.
FSUBR does the same thing, but does the subtraction the other way up: so, it subtracts ST0 from the given operand and stores the result in ST0,.
FSUBP operates like FSUB, but pops the register stack once it has finished.
FSUBRP operates like FSUBR, but pops the register stack once it has finished.
FPU Flags Affected C1 Set to 0 if stack underflow occurred. Set if result was rounded up; cleared otherwise. C0, C2, C3 Undefined.
The 'dest' operand is always an FPU data register; the 'src' operand can be a register or a memory location.
EXAMPLE:
fsub Label st3
FSTSW
Usage: FSTSW dest Modifies flags: See below
Stores the current value of the x87 FPU status word in the 'dest' location. The 'dest' can be either a two-byte memory location or the AX register. The FSTSW instruction checks for and handles pending unmasked floating - point exceptions before storing the status word; the FNSTSW instruction does not.
Store Floating-Point Status Word
FSTSW mem16 ; 9B DD /7 [8086,FPU]
FSTSW AX ; 9B DF E0 [286,FPU]
FNSTSW mem16 ; DD /7 [8086,FPU]
FNSTSW AX ; DF E0 [286,FPU]
FSTSW stores the FPU status word into AX or into a 2-byte memory area.
FNSTSW does the same thing as FSTSW, without first waiting for pending floating-point exceptions to clear.
FPU Flags Affected The C0, C1, C2, and C3 are undefined.
EXAMPLE:
fstsw Label