Chapter 4 System Mode and Coprocessor of i8086
Chapter 4 System Mode and Coprocessor of i8086
The is as follows:
• AD0-AD15 (Address Data Bus): Bidirectional
address/data lines. These are low order address
bus. They are multiplexed with data. When these
lines are used to transmit memory address, the
symbol A is used instead of AD, for example, A0-
A15.
• A16 - A19 (Output): High order address lines.
These are multiplexed with status signals.
• A16/S3, A17/S4: A16 and A17 are multiplexed
with segment identifier signals S3 and S4.
• A18/S5: A18 is multiplexed with interrupt status
S5.
• A19/S6: A19 is multiplexed with status signal S6.
• In that architecture, the coprocessor speeds up floating-point arithmetic on the order of fiftyfold.
Users that only used the PC for word processing, for example, saved the high cost of the coprocessor,
which would not have accelerated performance of text manipulation operations.
• The 8087 was tightly integrated with the 8086/8088 and responded to floating-point machine code
operation codes inserted in the 8088 instruction stream.
• An 8088 processor without an 8087 could not interpret these instructions, requiring separate versions
of programs for FPU and non-FPU systems, or at least a test at run time to detect the FPU and select
appropriate mathematical library functions.
• Intel 80386DX CPU with 80387DX math coprocessor
• Another coprocessor for the 8086/8088 central processor was the 8089 input/output coprocessor. It
used the same programming technique as 8087 for input/output operations, such as transfer of data
from memory to a peripheral device, and so reducing the load on the CPU. But IBM didn't use it in
IBM PC design and Intel stopped development of this type of coprocessor.
• The Intel 80386 microprocessor used an optional "math" coprocessor (the 80387) to perform floating
point operations directly in hardware.
• RG/GT6:-Request/Grant pin used to gain control of bus from host 8086/8088 for
operand transfer.
• An active low pulse of one clock duration generated for the host to inform it that it
wants to gain control of the local bus either for itself or for other Co processor
connected to RQ/GT Pin.
• RQ/GT1:- Bidirectional pin used by other bus masters to convey their need of local
bus access to 8087.
15 0
TAG (7) TAG(6) TAG (5) TAG (4) TAG (3) TAG (2) TAG (1) TAG (0)
TAG VALUES
00=VALID 01ZERO
10=SPECIAL 11=EMPTY
0 0 X 0 ST>Source or 0(FTST)
Remainder 1 0 X 1 Complete reduction with three low bits of
quotient
Q1 0 Q0 Q2
incomplete reduction
U 1 U U Valid, positive un normalized
0 0 0 0 Invalid,positive, exponent=0
0 0 0 1 Valid, negative, un normalized
0 0 1 0 Valid, negative , exponent=0
0 0 1 1 Invalid, positive, normalized
0 1 0 0 Valid, positive, normalized
0 1 0 1 Infinity, positive
0 1 1 0 Valid, negative, normalized
Examine 0 1 1 1 Infinity, negative
1 0 0 0 Zero, positive
1 0 0 1 Empty
1 0 1 0 Zero, negative
1 0 1 1 Empty
1 1 0 0 Invalid, positive, exponent=0
1 1 0 1 Empty
1 1 1 0 Invalid, Negative, exponent=0
1 1 1 1
3/31/2025 by eng A4k 18
Instruction & Data pointer: - Used to enable the programmers to write their own
exception handling subroutines. Before executing a mathematical instruction, the
8087 forms a table in memory containing the instruction address in the field of
instruction, operand address in the field of data pointer TAG word Status word
Control word in their respective fields table
80x87 coprocessor
• The operations performed by 80x87 generally execute faster than equivalent
operations written with the programs that use microprocessor’s normal
instruction set.
• With the improved Pentium coprocessors, operations are at about 5 times faster
than those performed by the 80486 microprocessor.
• The 80x87 executes 68 different instructions.
• The host microprocessor executes all normal instructions and 80x87 executes
arithmetic coprocessor instructions only.
• Both the host microprocessor and coprocessor can execute their respective
instruction concurrently.
1. Intel 8087 is a processor with architecture and instruction set optimized for performing complicated
arithmetic operations.
2. An 8087 is along with the host microprocessor 8086 rather than serving as the main processor itself.
Therefore, it is referred to as the coprocessor.
3. An 8087 instruction may perform a given mathematical computation 100 times faster than the
equivalent sequence of 8086 instructions.
4. 8087 is an actual processor with its own specialized instruction set. Instructions for 8087 are written
in the program as needed, interspersed with 8086 instructions.
5. As the 8086 fetches instruction bytes from the memory and puts them in its queue, the 8087 also
reads these instruction bytes and puts them in its queue. The 8087 decodes each instruction that
comes into its queue.
6. When 8087 decodes an instruction from its queue and finds that it is an 8086 instruction, the 8087
simply treats the instruction as NOP.
7. Likewise, when the 8086 decodes an instruction from its queue and finds that it is an 8087
instruction, the 8086 simply treats the instruction as NOP or in some cases reads a data word from
the memory for the 8087.
8. Each processor decodes all instructions in the fetched instruction byte stream but executes only its
own instructions.
I8087 instruction sets
The Intel 8087 is a floating-point coprocessor designed to work with the 8086/8088 CPUs. It accelerates
complex mathematical operations, including trigonometry, logarithms, and arithmetic. Below is a
breakdown of its instruction set and a coding example.
Key Instruction Categories:
Data Transfer instruction:
FLD: Push a floating-point value onto the register stack.
FST: Store the top of the stack (ST(0)) into memory (without popping).
FSTP: Store and pop the stack.
FILD: Load an integer from memory into the stack.
Arithmetic instruction:
FADD/FADDP: Add values. Control instructions:
FSUB/FSUBP: Subtract values. FINIT: Initialize the 8087.
FMUL/FMULP: Multiply values. FSTSW: Store the status word (e.g., for conditional
FDIV/FDIVP: Divide values. jumps
FSQRT: Compute square root of ST(0).
Comparison instructions:
FCOM: Compare ST(0) with a value (sets status flags).
FTST: Compare ST(0) with 0.0.
Transcendental Functions
FSIN/FCOS: Compute sine/cosine of ST(0) (in radians).
FPTAN: Compute tangent of ST(0).
).
Key Components of the 8087 Instruction Sets
1. Data Transfer Instruction format
FLD src: Push a floating-point value (from memory or register) onto the stack.
FST dest: Store the top of the stack (ST(0)) into memory.
FSTP dest: Store ST(0) into memory and pop the stack.
FILD src: Load an integer from memory into ST(0).
FIST dest: Store ST(0) as an integer to memory (without popping).
FISTP dest: Store ST(0) as an integer and pop the stack.
2. Arithmetic Instructions format since it is operation on stack(zero address instruction), the operation is
done the top elements whether the operator is unary or binary
FADD: Add two values (e.g., FADD ST(0), ST(1) or FADD [mem]).
FSUB: Subtract (e.g., FSUB ST(0), ST(1) subtracts ST(1) from ST(0)).
FMUL: Multiply.
FDIV: Divide.
FSUBR: Reverse subtract (computes src - ST(0)).
FDIVR: Reverse divide (computes src / ST(0)).
FSQRT: Compute square root of ST(0).
3. Comparison Instructions and operational description
FCOM src: Compare ST(0) with src (memory or register).
FCOMP: Compare and pop the stack.
FCOMPP: Compare ST(0) with ST(1) and pop twice.
FTST: Compare ST(0) with 0.0.
4. Transcendental Functions and computational description
FPTAN: Compute partial tangent of ST(0) (result in ST(0) and ST(1)).
FPATAN: Compute arctangent of ST(1)/ST(0) and pop twice.
F2XM1: Compute 2𝑆𝑇(0) −1.
(𝑆𝑇 0 )
FYL2X: Compute ST(1)⋅𝑙𝑜𝑔2
5. Instructions work with Constants
FLD1: Push 1.0 onto the stack.
(𝑒)
FLDL2E: Push 𝑙𝑜𝑔2 natural logarithm
FLDPI: Push π. The constant pi
FLDZ: Push 0.0.
6. Control Instructions
FINIT: Initialize the coprocessor (reset registers and control word).
FSTSW dest: Store the status word (e.g., to check comparison results).
FLDCW src: Load the control word (set rounding modes, precision).
Coding Example: Calculate the Area of a Circle
Formula:
Area=π×r2
Usage Notes
• The 8087 uses an 80bit-register stack (ST(0) to ST(7)).
• Floating-point values are stored in IEEE 754 format (real4 = 32-bit, real8 = 64-bit).
• Use FSTSW + SAHF to transfer 8087 status flags to the CPU for conditional branching.
• This example demonstrates basic 8087 usage for floating-point computation. For advanced operations
(e.g., trigonometry), use instructions like FSIN or FPTAN.
Emu8086 is primarily an emulator for the Intel 8086/8088 CPU and does not natively support the i8087
math coprocessor instructions. Here's a breakdown:
Assembler Support:
While Emu8086’s assembler may parse some i8087 instructions (depending on syntax), they cannot
execute properly. The emulator lacks the necessary logic to simulate floating-point operations or the
i8087’s internal stack/registers.
Workarounds:
Software-Based Floating-Point: Use software libraries (e.g., integer-based or custom routines) to handle
floating-point calculations.
Alternative Emulators: Tools like DOSBox, Bochs, or NASM with QEMU (configured to emulate an FPU)
support i8087 instructions.
Modern x86 Environments: Modern CPUs and emulators (e.g., VirtualBox, VMware) typically include FPU
emulation, but these are outside Emu8086’s scope.
Conclusion: Emu8086 cannot execute i8087 instructions. For FPU functionality, use alternative methods
or emulators that explicitly support the i8087.
Thank you