Chapter 5
|
Coprocessor |
Topical Cross-reference for Coprocessor Instructions................ 146
Interpreting Coprocessor Instructions............................ 148
Syntax............................................... 148
Examples............................................. 148
Clock Speeds.......................................... 148
Instruction Size......................................... 148
Architecture.............................................. 149
|
|
|
FABS |
FADD/FIADD |
FADDP |
|
FCHS |
FDIV/FIDIV |
FDIVP |
|
FDIVR/FIDIVR |
FDIVRP |
FMUL/FIMUL |
|
FMULP |
FPREM |
FPREM1§ |
|
FRNDINT |
FSCALE |
FSQRT |
|
FSUB/FISUB |
FSUBP |
FSUBR/FISUBR |
|
FSUBRP |
FXTRACT |
|
FCOM/FICOM |
FCOMP/FICOMP |
FCOMPP |
|
FSTSW/FNSTSW |
FTST |
FUCOM§ |
|
FUCOMP§ |
FUCOMPP§ |
FXAM |
|
FLD/FILD/FBLD |
FLDCW |
FLDENV |
|
FRSTOR |
FXCH |
|
FLD1 |
FLDL2E |
FLDL2T |
|
FLDLG2 |
FLDLN2 |
FLDPI |
|
FLDZ |
|
FCLEX/FNCLEX |
FDECSTP |
FDISI/FNDISI* |
|
FENI/FNENI* |
FFREE |
FINCSTP |
|
FINIT/FNINIT |
FLDCW |
FNOP |
|
FRSTOR |
FSAVE/FNSAVE |
FSETPM_ |
|
FSTCW/FNSTCW |
FSTENV/FNSTENV |
FSTSW/FNSTSW |
|
FWAIT |
|
FSAVE/FNSAVE |
FST/FIST |
FSTCW/FNSTCW |
|
FSTENV/FNSTENV |
FSTP/FISTP/FBSTP |
FSTSW/FNSTSW |
|
F2XM1 |
FCOS§ |
FPATAN |
|
FPREM |
FPREM1§ |
FPTAN |
|
FSIN§ |
FSINCOS§ |
FYL2P1 |
|
FYL2X |
* 8087 only 80287 only. § 8038780486 only.
|
|
This section provides an alphabetical reference to instructions of the 8087, 80287, and 80387 coprocessors. The format is the same as the processor instructions except that encodings are not provided. Differences are noted in the following.
The 80486 has the coprocessor built in. This one chip executes all the instructions listed in the previous section and this section.
Syntaxes in Column 1 use the following abbreviations for operand types:
|
Syntax |
Operand |
|
|
|
|
reg |
A coprocessor stack register |
|
memreal |
A direct or indirect memory operand storing a real number |
|
memint |
A direct or indirect memory operand storing a binary integer |
|
membcd |
A direct or indirect memory operand storing a BCD number |
The position of the examples in Column 2 is not related to the clock speeds in Column 3.
Column 3 shows the clock speeds for each processor. Sometimes an instruction may have more than one possible clock speed. The following abbreviations are used to specify variations:
|
Abbreviation |
Description |
|
|
|
|
EA |
Effective address. This applies only to the 8087. See the Processor Section, Timings on the 8088 and 8086 Processors, for an explanation of effective address timings. |
|
s,l,t |
Short real, long real, and 10-byte temporary real. |
|
w,d,q |
Word, doubleword, and quadword binary integer. |
|
to, fr |
To or from stack top. On the 80387 and 80486, the to clocks represent timings when ST is the destination. The fr clocks represent timings when ST is the source. |
The instruction size is always 2 bytes for instructions that do not access memory. For instructions that do access memory, the size is 4 bytes on the 8087 and 80287. On the 80387 and 80486, the size for instructions that access memory is 4 bytes in 16-bit mode, or 6 bytes in 32-bit mode.
On the 8087, each instruction must be preceded by the WAIT (also called FWAIT) instruction, thereby increasing the instructions size by 1 byte. The assembler inserts WAIT automatically by default, or with the .8087 directive.
The 8087, 80287, and 80387 coprocessors, along with the 80486, have several common elements of architecture. All have a register stack made up of eight 80-bit data registers. These can contain floating-point numbers in the temporary real format. The coprocessors also have 14 bytes of control registers. Figure 5.1 shows the format of registers.
Fig. 5 . 1 Coprocessor Registers
The most important control registers are the control word and the status word. Figure 5.2 shows the format of these registers.
Fig. 5 . 2 Control Word and Status Word
F2XM1 2X1
Calculates Y = 2X 1. X is taken from ST. The result, Y, is returned in ST. X must be in the range 0 X 0.5 on the 8087/287, or in the range 1.0 X +1.0 on the 8038780486.
|
Syntax |
Examples |
CPU |
Clock Cycles |
|
|
|||
|
F2XM1 |
f2xm1 |
87 |
310630 |
FABS Absolute Value
Converts the element in ST to its absolute value.
|
Syntax |
Examples |
CPU |
Clock Cycles |
|
|
|||
|
FABS |
fabs |
87 |
1017 |
FADD/FADDP/FIADD Add
Adds the source to the destination and returns the sum in the destination. If two register operands are specified, one must be ST. If a memory operand is specified, the sum replaces the value in ST. Memory operands can be 32- or 64-bit real numbers or 16- or 32-bit integers. If no operand is specified, ST is added to ST(1) and the stack is popped, returning the sum in ST. For FADDP, the source must be ST; the sum is returned in the destination and ST is popped.
|
Syntax |
Examples |
CPU |
Clock Cycles |
|
|
|||
|
FADD [[reg,reg]] |
fadd st,st(2) |
87 |
70100 |
|
FADDP reg,ST |
faddp st(6),st |
87 |
75105 |
|
FADD memreal |
fadd QWORD PTR [bx] |
87 |
(s=90120,s=95125)+EA |
|
FIADD memint |
fiadd int16 |
87 |
(w=102137,d=108 |
FBLD Load BCD
See FLD.
FBSTP Store BCD and Pop
See FST.
FCHS Change Sign
Reverses the sign of the value in ST.
|
Syntax |
Examples |
CPU |
Clock Cycles |
|
|
|||
|
FCHS |
fchs |
87 |
1017 |
FCLEX/FNCLEX Clear Exceptions
Clears all exception flags, the busy flag, and bit 7 in the status word. Bit 7 is the interrupt-request flag on the 8087, and the error-status flag on the 80287, 80387, and 80486. The instruction has wait and no-wait versions.
|
Syntax |
Examples |
CPU |
Clock Cycles* |
|
|
|||
|
FCLEX |
fclex |
87 |
28 |
* These timings reflect the no-wait version of the instruction. The wait version may take additional clock cycles.
FCOM/FCOMP/FCOMPP/FICOM/FICOMP Compare
Compares the specified source operand to ST and sets the condition codes of the status word according to the result. The instruction subtracts the source operand from ST without changing either operand. Memory operands can be 32- or 64-bit real numbers or 16- or 32-bit integers. If no operand is specified or if two pops are specified, ST is compared to ST(1) and the stack is popped. If one pop is specified with an operand, the operand is compared to ST. If one of the operands is a NAN, an invalid-operation exception occurs (see FUCOM for an alternative method of comparing on the 8038780486).
|
Syntax |
Examples |
CPU |
Clock Cycles |
|
|
|
|
|||
|
FCOM [[reg]] |
fcom st(2) |
87 |
4050 |
|
|
FCOMP [[reg]] |
fcomp st(7) |
87 |
4252 |
|
|
FCOMPP |
fcompp |
87 |
4555 |
|
|
FCOM memreal |
fcom shortreals[di] |
87 |
(s=6070,l=6575)+EA |
|
|
FCOMP memreal |
fcomp longreal |
87 |
(s=6373,l=6777)+EA |
|
|
FICOM memint |
ficom double |
87 |
(w=7286,d=7891)+EA |
|
|
FICOMP memint |
ficomp WORD PTR [bp+6] |
87 |
(w=7488,d=8093)+EA |
|
Condition Codes for FCOM
|
C3 |
C2 |
C1 |
C0 |
Meaning |
|
|
||||
|
0 |
0 |
? |
0 |
ST > source < |