The 80x87 Math Coprocessor. Why we need a math coprocessor?. Using a general-purpose microprocessor such as the 8088/86 to perform mathematical functions such as log, sine, and others is very time consuming, not only for the CPU but also for programmers writing such programs.
Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.
In some cases the differences of run times is hours between PCs with and without math-coprocessor.
31 1-bit Sign bit: 0 for positive (+) and 1 for negative (-)
23 - 30 8-bit Biased exponent
22 - 0 23-bit The fraction, also called significand
1. The real number is converted to its binary form.
2. The binary number is represented in scientific form: 0l.xxxx E yyyy
3. Bit 31 is either 0 for positive or 1 for negative.
4. The exponent portion, yyyy, is added to 7F to get the biased exponent, which is placed in bits 23 to 30.
5. The significand, xxxx, is placed in bits 22 to 0.
Examples 20-1, 20-2, and 20-3 demonstrate this process.
=1x23+ 0x22+ 0x21+ 1x20 . 1x2-1+ 1x2-2
= 1.00111 E 3
Sign bit, 31st bit = 0
Exponent bits, bits 30 to 23 = 3+7F = 82 = 1000 0010
Significant bits, bits 22 to 0 = 0011 1 rest fill with 0s
0 1000 0010 0011 1000 00…00
0100 0001 0001 1100 0000 0000 0000 0000
4 1 1 C 0 0 0 0
They are as follows:
& for temporary real
1. All 80x87 mnemonics start with the letter “ f ” to distinguish them from 80x86 instructions.
2. The 80x87 must be initialized to make sure that the top of the stack will be register number 7.
3. Whenever a register is not identified specifically, ST [which is ST(0)] is assumed automatically.
4. 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.
5. In the following programming examples, all values of X, Y, and Z have been defined in the data segment and allocated memory locations. The same is true for variables such as SUM, for storing the result.
MOV AX,16EB ; 16EB is the DS value (DATASEG)
1. The 8088 and 8087 receive the same signals, CLK, READY, and RESET, from the 8284. This ensures that they are synchronized.
2. S0, S1, and S2 are going from the 8088 or 8087 to the 8288, which allows either of these two processors to provide the status signal to the 8288.
3. The Queue Status, QS1 and QS2, from the 8088 go to the 8087, allowing it to know the status of the queue of the 8088 at any given time.
4. The TEST signal to the 8088 comes from BUSY of the 8087. By deactivating (going low) the BUSY signal, the 8087 informs the 8088 that it finished execution of the instruction which it has been WAITing for.
5. RQ/GT1 (request/grant) of the 8088 is connected to RQ/GTO of the 8087, allowing them to arbitrate mastery over the buses. There are two sets of RQ/GT: RQ/GT1 and RQ/GTO . RQ/GT1 of the 8087 is not used and is connected to Vcc permanently. This extra RQ/GT is provided in case there is a third microprocessor connected to the local bus.
6. Both the 8088 and 8087 share buses ADO -AD7 and A8 -A19, allowing either one to access memory. Since the 8087 is designed for both the 8088 and 8086, signal BHE is provided for the 8086 processor. It is connected to Vcc if the 8087 is used with the 8088. If the microprocessor used was an 8086, BHE from the 8086 is connected to BHE of the 8087.
7. INT of the 8087 is an output signal indicating error conditions, also called exceptions, such as divide by zero. Error conditions are given in the status word. Assuming the bit for that error is not masked and an interrupt is enabled, whenever any of these errors occurs, the 8087 automatically activates the INT pin by putting high on it. In the IBM PC and compatibles, this signal is connected to the NMI circuitry as discussed in Chapter 14. Since there is only one INT for all error conditions (exceptions) of the 8087, it is up to the programmer to write a program to check the status word to see which has caused the error.
8. The 8088, often called the host processor, must be connected in maximum mode to be able to accommodate a coprocessor such as the 8087.
FLD X FLD y
FADD ST(O),ST(1 )
FLD src ;pushes source operand onto ST(0) ;source may be ST(i) or memory
;Tip: FLD ST(0) duplicates stack top
FST dest ;copies ST(0) to destination
;dest may be ST(i) or short or long real ;variable
FADD dest,src ;adds src to dest, storing result in dest