Intel 8087 is known to be a specially designed coprocessor used for performing mathematical calculations of data that contains integer and floating-point values. It is sometimes also called Math Processor or Numeric Data Processor (NDP).
The use of a coprocessor along with the microprocessor facilitates the speeding up of calculations thereby saving the overall time the CPU takes to perform the operation.
A coprocessor works parallelly with the microprocessor. The 80*87 series of coprocessors developed by Intel is used for the 80*86 family of microprocessors i.e., 16-bit processors. To work with Intel 8086/8088 microprocessor, Intel developed 8087 coprocessor that operates in maximum mode while 80287 coprocessor is designed for 80286 processor.
As the coprocessor works in conjunction with the microprocessor, therefore, the calculations part can be managed by the coprocessor and this permits the CPU to use the resources to perform various other activities. The coprocessor consists of 60 new instructions and the mnemonics of the coprocessor is differentiated from the standard 8086 instructions in a way that these instructions contain ‘F’ in the beginning.
For example, The 8086 instruction ADD is represented as FADD in 8087.
Some other names given to this processor are Numeric Processor Extension, Floating Point Unit, Numeric Data Processor, etc.
Architecture of Coprocessor 8087
We have mentioned at the beginning itself that the instructions of the microprocessor and coprocessor are executed individually at the same time. The normal instruction sets are executed by the microprocessor and the coprocessor instructions are executed by the coprocessor.
The figure below represents the internal architecture of Intel 8087:
Here the two major units consisting of the architecture are:
- Control Unit
- Numeric Execution Unit (NEU)
The various units that constitute the control unit are data buffer, shared operand queue, control, and status word register, addressing and bus tracking unit, and exception pointer. While the Numeric Execution Unit includes register stack, microcode control unit, programmable shifter, arithmetic module, temporary registers, shared operand queue, exponent module.
The control unit of the coprocessor controls the instruction execution for which NEU is responsible. Basically, the control unit of the NEU gets the numeric instructions from the control unit of the coprocessor. The 8087 has a total of eight registers of 80 bits each and these are used in the LIFO stack. The operands over which the coprocessor instructions will take place to reside within the register stack.
The current top of the stack is pointed by the 3-bit stack pointer which holds the binary values from 000 to 111 so as to show the eight registers of the stack. It operates in a circular stack manner in LIFO mode. However, when reset action takes place then the pointer is initialized with 000 of the binary value.
The three classifications of numeric data over which the coprocessor operates are binary integers, packed decimal numbers, and real numbers. The binary integers can be of three types namely word integer (16-bit), short integer (32-bit), and long integer (64-bit). BCD format of 80 bit represents the packed decimal numbers whereas real numbers are of three types namely short real (32-bit), long real (64-bit), temporary real (80-bit).
In order to transfer the numeric data within the coprocessor either a 64-bit mantissa bus or 16-bit exponent bus is used.
The math processor has a 16-bit control word and a 16-bit status word. The control word is to be written into the control register and this takes place in a way that the processor first writes the control word in the memory location and then the coprocessor reads the control word from the memory location and store it into the control register.
In a similar way, the status word is read in a way that the coprocessor sends the data within the status register to a memory location, and further the processor reads that status register from that particular memory location. This means the microprocessor and coprocessor communicate with each other through the main memory.
The figure below represents the format of the control word:
- IM/IE: Invalid Operation
- DM/DE: Denormalized Operand
- ZM/ZE: Zero Divide
- OM/OE: Overflow
- UM/UE: Underflow
- PM/PE: Precision
- Blank: Reserved
- IEM: Interrupt Enable Mask
- PC: Precision Control
- RC: Rounding Control
- IC: Infinity Control
Here we have shown the format of the status word:
- IR: Interrupt Request
- C0, C1, C2, C3: Condition Code
- ST: Stack Top Pointer
- B: Busy
How Coprocessor 8087 works with 8086?
We have mentioned at the beginning itself that there is a separate set of instructions of the 8087 coprocessor. When the microprocessor works in conjunction with the coprocessor then at the time of writing the program the instructions of both microprocessor and 8087 are included in it. In the assembly language program, the instructions that have F, in the beginning, represent the coprocessor instructions, and those without a prefix ‘F’ shows the microprocessor instructions.
First, the microprocessor fetches the instructions from the memory location and load sequentially them in the queue, simultaneously, 8087 also reads and stores the instructions in an internal queue. This means every single instruction is read by both processor and coprocessor but at the time of execution both microprocessor and coprocessor perform the execution of their respective instructions.
This means that instruction is read and decoded and after decoding if the microprocessor checks that there is coprocessor instruction then that instruction is treated as NOP i.e., No-operation. Likewise, if the coprocessor comes across any microprocessor instruction then it will be handled as no-operation.