8087 Numeric Data Co Processor
8087 Numeric Data Co Processor
8087 Numeric Data Co Processor
Contents
Architecture of 8087
Data types
Interfacing
Overview
Each processor in the 80x86 family has a corresponding coprocessor with which it is
compatible.
Processors
Coprocessors
1. 8087
2. 80287,80287XL
3. 80287,80387DX
4. 80387SX
5. It is Inbuilt
6. 80487SX
Pin Diagram of 8087
Architecture of 8087
Control Unit
Execution Unit
Control Unit
Control unit: To synchronize the operation of the coprocessor and the processor.
This unit has a Control word and Status word and Data Buffer
Status Register
B-Busy bit indicates that coprocessor is busy executing a task. Busy can be tested by
examining the status or by using the FWAIT instruction. Newer coprocessor
automatically synchronize with the microprocessor, so busy flag need not be tested
before performing additional coprocessor tasks.
TOP- Top of the stack (ST) bit indicates the current register address as the top of the
stack.
ES-Error summary bit is set if any unmasked error bit (PE, UE, OE, ZE, DE, or IE) is
set. In the 8087 the error summary is also caused a coprocessor interrupt.
PE- Precision error indicates that the result or operand executes selected precision.
UE-Under flow error indicates the result is too large to be represent with the current
precision selected by the control word.
OE-Over flow error indicates a result that is too large to be represented. If this error is
masked, the coprocessor generates infinity for an overflow error.
ZE-A Zero error indicates the divisor was zero while the dividend is a non-infinity or
non-zero number.
CONTROL REGISTER
It also masks an unmasks the exception bits that correspond to the rightmost Six bits of
status register.
Instruction FLDCW is used to load the value into the control register.
Control Register
IC –Infinity control selects either affine or projective infinity. Affine allows positive
and negative infinity, while projective assumes infinity is unsigned.
INFINITY CONTROL
0 = Projective
1 = Affine
ROUNDING CONTROL
00=Round to nearest or even
01=Round down towards minus infinity
10=Round up towards plus infinity
11=Chop or truncate towards zero
PRECISION CONTROL
Exception Masks – It Determines whether the error indicated by the exception affects
the error bit in the status register. If a logic1 is placed in one of the exception control bits,
corresponding status register bit is masked off.
Numeric data is routed into two parts ways a 64 bit mantissa bus and
a 16 bit sign/exponent bus.
Interrupt output INT of the 8087 to NMI input of 8086. This intimates an error
condition.
The main purpose of the circuitry between the INT output of 8087 and the NMI input is
to make sure that an NMI signal is not present upon reset, to make it possible to mask
NMI input and to make it possible for other devices to cause an NMI interrupt.
BHE pin is connected to the system BHE line to enable the upper bank of memory.
The RQ/GT1 input is available so that another coprocessor such as 8089 I/O processor
can be connected and function in parallel with the 8087.
One type of Cooperation between the two processors that you need
to know about it is how the 8087 transfers data between memory and its internal registers.
When 8086 reads an 8087 instruction that needs data from memory or wants to send
data to memory, the 8086 sends out the memory address code in the instruction and sends
out the appropriate memory read or memory write signal to transfer a word of data.
In the case of memory read, the addressed word will be kept on the data bus by the
memory. The 8087 then simply reads the word of data bus. The 8086 ignores this word
.If the 8087 only needs this one word of data, it can then go on and executes its
instruction.
Some 8087 instructions need to read in or write out up to 80-bit word. For these cases
8086 outputs the address of the first data word on the address bus and outputs the
appropriate control signal.
The 8087 reads the data word on the data bus by memory or writes a data word to
memory on the data bus. The 8087 grabs the 20-bit physical address that was output by
the 8086.To transfer additional words it needs to/from memory, the 8087 then takes over
the buses from 8086.
To take over the bus, the 8087 sends out a low-going pulse on
___ ____
RQ/GT0 pin. The 8086 responds to this by sending another low
___ ____
going pulse back to the RQ/GT0 pin of 8087 and by floating its buses.
The 8087 then increments the address it grabbed during the first transfer and outputs
the incremented address on the address bus. When the 8087 output a memory read or
memory write signal, another data word will be transferred to or from the 8087.
The 8087 continues the process until it has transferred all the data words required by
the instruction to/from memory.
When the 8087 is using the buses for its data transfer, it
____ ___
sends another low-going pulse out on its RQ/ GT0 pin to
8086 to know it can have the buses back again.
Taking one situation, in the case where the 8086 needs the data produced by the
execution of an 8087 instruction to carry out its next instruction.
In the instruction sequence for example the 8087 must complete the FSTSW
STATUS instruction before the 8086 will have the data it needs to execute the
MOV AX , STATUS instruction.
Without some mechanism to make the 8086 wait until the 8087 completes the FSTSW
instruction, the 8086 will go on and execute the MOV AX , STATUS with erroneous
data .
We solve this problem by connecting the 8087 BUSY output to the TEST pin of the
8086 and putting on the WAIT instruction in the program.
While 8087 is executing an instruction it asserts its BUSY pin high. When it is finished
with an instruction, the 8087 will drop its BUSY pin low. Since the BUSY pin from 8087
is connected to the TEST pin 8086 the processor can check its pin of 8087 whether it
finished it instruction or not.
You place the 8086 WAIT instruction in your program after the 8087 FSTSW
instruction .When 8086 executes the WAIT instruction it enters an internal loop where it
repeatedly checks the logic level on the TEST input. The 8086 will stay in this loop until
it finds the TEST input asserted low, indicating the 8087 has completed its instruction.
The 8086 will then exit the internal loop, fetch and execute the next instruction.
Example
(a)
In this set of instructions we are not using WAIT instruction. Due to this the flow of
execution of command will takes place continuously even though the previous
instruction had not finished it’s completion of its work .so we may lost data .
(b)
In this code we are adding up of FWAIT instruction so that it will stop the execution of
the command until the above instruction is finishes it’s work .so that you are not loosing
data and after that you will allow to continue the execution of instructions.
Another case where you need synchronization of the processor and the coprocessor is
the case where a program has several 8087 instructions in sequence.
The 8087 are executed only one instruction at a time so you have to make sure that
8087 has completed one instruction before you allow the 8086 to fetch the next 8087
instruction from memory. ________
Here again you use the BUSY-TEST connection and the FWAIT instruction to solve
the problem. If you are hand coding, you can just put the 8086 WAIT(FWAIT)
instruction after each instruction to make sure that instruction is completed before going
on to next.
If you are using the assembler which accepts 8087 mnemonics, the assembler will
automatically insert the 8-bit code for the WAIT instruction ,10011011 binary (9BH), as
the first byte of the code for 8087 instruction.
INTERFACING
Multiplexed address-data bus lines are connected directly from the 8086 to 8087.
The status lines and the queue status lines connected directly from 8086 to 8087.
__ ___
The Request/Grant signal RQ/GT0 of 8087 is connected to
___ __
RQ/GT1 of 8086.
______
BUSY signal 8087 is connected to TEST pin of 8086.
Interrupt output INT of the 8087 to NMI input of 8086. This intimates an error
condition. ______
A WAIT instruction is passed to keep looking at its TEST pin, until it finds pin Low to
indicates that the 8087 has completed the computation.
a) The execution of an ESC instruction that require the participation of the NUE
must not be initiated if the NUE has not completed the execution of the previous
instruction.
The 8087 detects six different types of exception conditions that occur during
instruction execution. These will cause an interrupt if unmasked and interrupts are
enabled.
1)INVALID OPERATION
2)OVERFLOW
3)ZERO DIVISOR
4)UNDERFLOW
5)DENORMALIZED OPERAND
6)INEXACT RESULT
Data Types
Internally, all data operands are converted to the 80-bit temporary real format.
We have 3 types.
Packed BCD
Example
Converting a decimal number into a Floating-point number.
1) 100.25
2) 1100100.01 = 1.10010001 * 26
3) 110+01111111=10000101
4) Sign = 0
Exponent =10000101
Significand = 10010001000000000000000
•In step 3 the biased exponent is the exponent a 26 or 110,plus a bias of 01111111(7FH)
,single precision no use 7F and double precision no use 3FFFH.
•IN step 4 the information found in prior step is combined to form the floating point no.
INSTRUCTION SET
The 8087 instruction mnemonics begins with the letter F which stands for Floating
point and distinguishes from 8086.
The 8087 detects an error condition usually called an exception when it executing an
instruction it will set the bit in its Status register.
Types
I. DATA TRANSFER INSTRUCTIONS.
INTEGER TRANSFER
Example
FLD Source- Decrements the stack pointer by one and copies a real number from a
stack element or memory location to the new ST.
FIST Destination- Integer store. Convert number from ST to integer and copy to
memory.
FISTP Destination-Integer store and pop. Identical to FIST except that stack pointer is
incremented after copy.
FBLD Source- Convert BCD number from memory to temporary- real format and
push on top of 8087 stack.
Arithmetic Instructions.
Addition
Subtraction
Advanced
Example
FADD – Add real from specified source to specified destination Source can be a stack
or memory location. Destination must be a stack element. If no source or destination is
specified, then ST is added to ST(1) and stack pointer is incremented so that the result of
addition is at ST.
FSUB - Subtract the real number at the specified source from the real number at the
specified destination and put the result in the specified destination.
FSUBP - Subtract ST from specified stack element and put result in specified stack
element .Then increment the pointer by one.
Compare Instructions.
Comparison
Transcendental Instruction.
Transcendental
Example
FPTAN – Compute the values for a ratio of Y/X for an angle in ST. The angle must be
in radians, and the angle must be in the range of 0 < angle < π/4. F2XM1 – Compute
Y=2x-1 for an X value in ST. The result Y replaces X in ST. X must be in the range
0≤X≤0.5.
ALGORITHM
.MODEL SMALL
.DATA
x Dq 4.567 ;Base
y Dq 2.759 ;Power
temp DD
temp1 DD
temp2 DD ;final real result
tempint DD
tempint1 DD ;final integer result
two DW
diff DD
trunc_cw DW 0fffh
.STACK 100h
.CODE
start: mov ax, @DATA ;init data segment
mov ds, ax
4. ___ Connection and the _______ instruction will solve the problem of
synchronization between processor and coprocessor.
a) INT & NMI, WAIT b) RQ/GT0 & RQ/GT1, FWAIT
c) BUSY & TEST, FWAIT d) S0 & QS0, WAIT
6. In 8087, _______ many register stack are there? And of _____ registers. These
registers are used as _________ stack.
a) 7, 40 bit, FIFO. b) 8, 60 bit, LILO. c) 8, 80 bit, LIFO d) 7, 80 bit, FILO.
7. If ______ and ________ connections are made so that an error condition in 8087
can interrupt to the processor.
a) BHE, RQ/GT1 b) BUSY, TEST c) INT, NMI d) RQ/GT0, RQ/GT1
a. FSIN
b. FPTAN
c. FIDIV
d. FSQRT
a. HOLD
b. BUSY
c. TEST
d. NMI
Key: