8087 Co-Processor Configuration
8087 Co-Processor Configuration
Coprocessor
Why we need a math coprocessor?
• Each gets a copy of the instructions as they are fetched from memory.
• Since all the instructions of the 8087 have 9BH in the most significant
byte of the opcode, the 8088/86 ignores these instructions.
• In reality, 9BH is the opcode for the 8088/86 ESCAPE instruction.
• Likewise, the 8087 ignores any opcode that lacks 9BH.
• It must be made clear that although both receive a copy of each
fetched opcode, only the 8088/86 can fetch opcodes since it is the
only device that has the instruction pointer.
• Now one might ask how the 8088/86 makes sure it is not flooding the
8087 by fetching instructions for the coprocessor faster than the 8087
can process them.
• The first rule of working together is that the 8088/86 cannot fetch
another 8087 instruction until the 8087 has finished execution of the
present instruction.
How the 8088 and 8087 work together in the IBM PC/XT
Can interrupt
the 8086
WAIT instructions
can be used to halt the
8086 to ensure that the
8087 has finished a crucial
step,
e.g. storing a result in
memory.
Comparison of 8087 and 8086 Clock Times
In some cases the differences of run times is hours between
PCs with and without math-coprocessor.
8087 Program
Other data formats of the 8087
• In addition to short real (single precision) and long real
(double precision) representations for real numbers, the
8087 also supports 16 , 32 , and 64 bit integers.
• They are referred to as
– word integers,
– short integers, and
– long integers,
• respectively, and are shown in Figure 20-1.
• These forms are sometimes referred to as signed integer
numbers.
• No decimal points are allowed in integers, in contrast to real
numbers, in which decimal points are allowed.
Different Data Representation of 8087
different data directives
• There are different directives to define the different
data types of the coprocessor.
They are as follows:
• DW (Define word) for word integer
• DD (Define double word) for short real (single
precision)
& for short integer
• DQ (Define quad word) for long real (double
precision)
& for long integer
• DT (Define ten bytes) for packed decimal
& for temporary real
80x87 registers
• There are only 8 general-purpose registers in the 80x87.
• Rather than having different-size registers for different-size operands, all the
registers of the 8087 are 80 bits wide.
• Every time the 8087 loads an operand, it automatically converts it to this 80-bit
format.
• This gives uniformity to the registers and makes programming, as well as 8087
hardware design, much easier.
• Although these 8 registers have been numbered from 0 to 7, they are accessed like a
stack, meaning that a last-in-first-out policy is used.
• At any given time, the top of the stack is referred to as ST(0), or simply ST, and all
other registers, regardless of their number, are referred to according to their
positions compared to the top of the stack, ST.
• The programming examples below will demonstrate the use of registers in the 8087.
• Example 20-5 will show a complete Assembly language program using the 8087
coprocessor.
80x87 Assembly code and registers
1. All 80x87 mnemonics start with the letter “ f ” to distinguish them
from 80x86 instructions.
2. . Whenever a register is not identified specifically, ST [which is ST(0)]
is assumed automatically.
3. ST(0) is the top of the stack, ST(1) is one register below that, and
ST(2) is two registers below ST(0), and so on. In other words, for
register ST(m), the number in parentheses, m, has nothing to do with
the register number. There is a way to find out which register number,
0 - 7, is ST(0), the top of the stack. .
How 8087 uses its registers
Reading an operand by the coprocessor
• Assume that the 8087 needs to read an operand. When the
8088/86 initiates the operand read cycle, the 8087 grabs the
20-bit address and saves it internally.
• If the operand is a single word (like a word integer), the
read cycle has been initiated and the word will come into
both processors.
• Only the 8087 will use the data; the 8088/86 will ignore it.
However, if the operand is 32 bits or longer, the 8087 will
take over the buses by sending a low pulse on its RQ/GTO
to the RQ/GT1 of the 8088/86
Reading an operand by the coprocessor
• The 8088/86 in turn will send back a low pulse through the
same pin, thereby allowing the 8087 to take over the buses.
• Remember, RQ/GT is a bidirectional bus.
• When the 8087 takes over the buses, it will use them until it
brings in the last byte of the operand.
• It is only then that by activating RQ/GT (making it low),
control of the buses is given back to the 8088/86.
• For example, in the case of a DT operand, the 8087 has
control over the buses for the time needed to fetch all 10
bytes and then it gives back the buses.
Writing an operand by the coprocessor
• In the case of writing an operand by the coprocessor (e.g., FST data),
the 8088/86 initiates the write cycle, but the 8087 ignores it since the
8086 does not have the operand.
• This is called a dummy cycle.
• All the 8087 does during the dummy cycle is grab the address of the
first memory location where the operand is to be stored and keep it
until the data is ready, and then it requests the use of the buses by
activating the RQ/GT pin.
• From then on, the process is the same as the read cycle, meaning that
it will use the buses until it writes the last byte of the operand.
• All the cases discussed so far have been taken care of by either the
assembler or the hardware and there was no need for the programmer
to be worried.
8087 status words
8087 control words
Pentium
• There are few changes as far as instructions and
registers are concerned from the 8087 to the math
processor inside the Pentium, except for a few new
instructions and much lower clock counts for
instruction execution.
• The new instructions introduced in the 80387 are
FSIN(sine), FCOS (cosine), FSINCOS (sine and
cosine), FPREMl (partial remainder), and FUCOM
and its variations.