Introduction
8087 was the first math coprocessor for 16bit
www.eazynotes.com
processors designed by Intel.
It was built to pair with 8086 and 8088.
The purpose of 8087 was to speed up the
computations involving floating point calculations.
Addition, subtraction, multiplication and division
of simple numbers is not the coprocessor’s job.
It does all the calculations involving floating point
numbers like scientific calculations and algebraic
functions. 1
20Nov10
Introduction
By having a coprocessor, which performs all the
calculations, it can free up a lot of CPU’s time.
www.eazynotes.com
This would allow the CPU to focus all of its resources on the
other functions it has to perform.
This increases the overall speed and performance of the
entire system.
This coprocessor introduced about 60 new instructions
available to the programmer.
All the mnemonics begin with “F” to differentiate them from
the standard 8086 instructions.
For e.g.: in contrast to ADD/MUL, 8087 provide 2
FADD/FMUL.
20Nov10
Introduction
Math coprocessor is also called as:
www.eazynotes.com
Numeric Processor Extension (NPX)
Numeric Data Processor (NDP)
Floating Point Unit (FPU)
3
The 8087 is divided into 2 sections CU and NEU. That’s is
control unit and numeric execution unit.
The numeric execution unit executes all numeric processor
instructions while control unit receives, decodes
instructions, read and writes memory operands and
executes 8087 control instructions.
These 2 units works asynchronously with each other.
The control unit is majorly responsible for establishing
communication between CPU and memory and also for
coordinating internal coprocessor execution.
The NEU has 8 registers 80 bit wide stack that holds
operands for arithmetic instructions and their result.
The FSTSW AX; is the instructions used for
communication between coprocessor and micro processor.
The control unit is used to synchronize operation between
coprocessor and microprocessor.
The unit has a control word a status word and a data
buffer. If the instruction is an ESCape (coprocessor)
instruction the coprocessor executes it otherwise the
microprocessor executes it.
The status register reflects the overall operation of the
coprocessor.
The 8087 is a numeric data processor. It is basically
made to work along with the 8086 and 8088
processors.
It is incapable of fetching the instructions on its own,
so it is simply connected to respective buses of the
processor.
Its instructions are recognized by word ‘F’ as each and
every instructions starts with F. for example FADD,
FSUB etc.
The BUSY pin of the coprocessor is connected to the
main processor's TEST pin. This TEST pin is active
20Nov10
Architecture of 8087
8087 coprocessor is designed to operate with
8086 microprocessor.
www.eazynotes.com
The microprocessor and coprocessor can execute
their respective instructions simultaneously.
Microprocessor interprets and executes the
normal instruction set and the coprocessor
interprets and executes only the coprocessor
instructions.
All the coprocessor instructions are ESC
instructions, i.e. they start with “F”.
6
20Nov10 www.eazynotes.com
7
Architecture of 8087
20Nov10
Architecture of 8087
The internal structure of 8087 coprocessor is
divided into two major sections:
www.eazynotes.com
Control Unit (CU)
Numerical Execution Unit (NEU)
8
20Nov10
Control Unit (CU)
It interfaces coprocessor to the microprocessor
system bus.
www.eazynotes.com
It also synchronize the operation of the
coprocessor and the microprocessor.
This unit has a Control Word, Status Word and
Data Buffer.
If an instruction is ESC instruction, then
coprocessor executes it.
If not, then microprocessor executes.
9
20Nov10
Numeric Execution Unit (NEU)
This unit is responsible for executing all
coprocessor instructions.
www.eazynotes.com
It has an 8 register stack that holds the operands
for instructions and result of instructions.
The stack contains 8 registers that are 80bits
wide.
Numeric data is transferred inside the
coprocessor in two parts:
64bit mantissa bus
16bit exponent bus
10
20Nov10 www.eazynotes.com
11
Status Register
20Nov10
Status Register
www.eazynotes.com
Status Register tells the overall status of 8087
coprocessor.
It is a 16bit register.
It is accessed by executing the FSTSW
instruction.
This instruction stores the contents of status
register into memory.
Once the status is stored in memory, the bit
12
positions of the status register can be examined.
20Nov10
Status Register
www.eazynotes.com
Busy: It indicates that the coprocessor is busy
executing the task.
Condition Codes (C0C3): They indicate various conditions about
the coprocessor.
Top of Stack: It indicates a register as top of stack register, out of the eight stack
registers.
Exception Flag: It is set if any of the exception flag bits (SF, PR, UF, OF, ZD, DN,
IO) are set. 13
20Nov10
Status Register
www.eazynotes.com
Stack Fault: It is not available in 8087. It is
active only in 80387 and above.
Precision: It indicates that the result has
exceeded the selected precision.
Underflow: It tells if the result is too small to
fit in a register.
Overflow: It tells if the result is too large to fit
in a register.
14
20Nov10
Status Register
www.eazynotes.com
Zero Divide: It indicates that you try to divide a
nonzero value by zero.
Denormalized: It indicates that at least one of
the operand is denormalized.
Invalid Operation: It indicates an invalid
operation. For e.g.: pushing more than eight
items onto the stack, attempting to pop an item
off an empty stack or taking the square root of a
negative number. 15
20Nov10 www.eazynotes.com
16
Control Register
20Nov10
Control Register
www.eazynotes.com
Control Register controls the operating modes of
8087.
It is also a 16bit register.
It performs rounding control and precision control.
It is also used to do masking and unmasking of the
exception bits that correspond to the rightmost six
bits of the status register.
FLDCW instruction is used to load the value into
control register. 17
20Nov10
Control Register
www.eazynotes.com
Rounding Control: It determines the type of
rounding or truncating to be done.
Precision Control: It sets the precision of the
result.
Exception Masks: It determines that whether an
error effects the exception bits in the status register.
If it is one, then the corresponding error is ignored.
If it is zero and the corresponding error occurs, then it
generates an interrupt, and the corresponding bit in
status register is set. 18
20Nov10
Tag Register
www.eazynotes.com
TAG 7 TAG 6 TAG 5 TAG 4 TAG 3 TAG 2 TAG 1 TAG 0
Tag Values:
00 = Valid
01 = Zero
10 = Invalid
11 = Empty
19
TAG 7 TAG 6 TAG 5 TAG 4 TAG 3 TAG 2 TAG 1 TAG 0
20Nov10
Tag Values:
Tag Register 00 = Valid
01 = Zero
10 = Invalid
11 = Empty
www.eazynotes.com
Tag Register is used to indicate the contents of
each register in the stack.
There are total 8 tags (Tag 0 to Tag 7) in this
register and each tag uses 2 bits to represent a
value.
Therefore, it is a 16bit register.
20
20Nov10
Pin Diagram of 8087
GND VCC
AD14 AD15
AD13 A16/S3
AD12 A17/S4
www.eazynotes.com
AD11 A18/S5
AD10 A19/S6
AD9 BHE/S7
AD8
8087 RQ/GT1
AD7 INT
AD6 RQ/GT0
AD5 NC
AD4 NC
AD3 S2
AD2 S1
AD1 S0
AD0 QS0
NC QS1
NC BUSY 21
CLK READY
GND RESET
20Nov10
Interfacing of 8086 and 8087
Multiplexed addressdata bus lines are
connected directly from 8086 to 8087.
www.eazynotes.com
The status lines and the queue status lines are
connected directly from 8086 to 8087.
The Request/Grant (RQ/GT0 and RQ/GT1) signals of 8087 are
connected to RQ/GT0 and RQ/GT1 of 8086.
BUSY signal of 8087 is connected to TEST pin of 8086.
22
Thank You
Have a Nice Day
23