Beruflich Dokumente
Kultur Dokumente
8087 Features
1. Can handle integer,decimal and real data types with lengths ranging from 2 to 10 bytes. 2. Its instruction set not only includes various forms of addition and substraction but also useful functions such as square root , exponential , tangent and so on. 3. It can multiply two 64 bit real numbers in about 27s and calculate square root in about 36 s.
8087 Features
4. It follows IEEE floating point standard. 5. It is multi-bus compatible.
RQ/GT1
This request/grant signal is usually connected to the request/grant pin of the independent processor such as 8089.
INT
The interrupt pin is connected to the interrupt management logic. The 8087 interrupts the 8086 through this at the time error condition exits.
0
1 1 1 1
X
0 0 1 1
X
0 1 0 1
-unused
-unused -Read memory -Write memory -passive
QS1 O 0
QS0 1 1
1 1
0 1
Instruction queue
Maintains a 6 byte instruction queue and tracks the execution sequence of the host. If the current host instruction is an ESC instruction , the 8087 decodes the external op-code to perform the specified operation and captures the operand address. Other instructions are ignored by 8087.
Data registers
It has 8 data registers each is 80-bits wide and is accessed as a stack. An operand may be pushed or popped from top of stack. A PUSH operation decrements TOP of stack by 1 a loads the a value into the new TOP of stack register. A POP operation stores the a value from the current TOP of stack register and then increments TOP of stack by 1. The top of stack register is pointed by ST bits.(bits 13,12 and 11 of the status register).
Status register
It is a 16-bit register. It reflects the overall state of the 8087. It ;
1. indicates various errors, 2. indicates condition codes for certain instructions, 3. specifies which register is at the top of stack and 4. indicates BUSY status.
Status register
Fig 10.5 shows bit definitions of the Status Register. Error Flags;
IE : Indicates invalid operation such as stack overflow , stack underflow , invalid operand , square root of ve number etc. DE : The operand is not normalized. ZE : A divide by zero error. JE : An exponent overflow error(biased exponent is too small)
Status register
PE : A precision error , the result cannot be represented in the designated format and hence is rounded off.
Interrupt Flag IR : Indicates the existence of the interrupt request. Condition code
C0-C3 indicate the condition code,its set by the compare and examine instructions(discussed later).
Status register
Stack bits
ST:S0-S1 indicate the top of stack register.
Busy status
B:Indicates current operation is not completed.
NOTE THAT:
After the 8087 is reset or initialized , all status bits except the condition code are cleared.
Control register
It is also 16 bit. Gives the opportunity to select several processing options provided by 8087 by loading a word from memory into a control register. Through this register one can mask each error type individually from causing an interrupt.
Control register
Furthermore it can be used to set precision levels , rounding type and infinity representation. Fig. 10.6 shows the bit definition of control register.
Control register
Lower order byte configures 8087 interrupts and exception masking. Bits 5-0 contain individual masks for each of the six exceptions recognized by 8087. Bit 7 is general mask bit for all 8087 interrupts. High order byte configures the 8087 operating mode including precision , rounding and infinity.
Control register
After reset or initialization of 8087 ,PC=11,RC=00,IC=0,IEM=0 and all error mask bits are 1.
Tag register
TAG register holds the status of the contents of data register. This includes;
00-Data Valid 01-Zero 10-A special value i.e NAN(Not A Number),infinity or denormal. 11-Empty
IMPORTANT NOTICE
1. An exponent with all 1s is reserved to represent infinity or not a number (NAN). 2. An exponent with all 0s plus a sign bit of 0 is reserved to represent +0. 3. An exponent with all 0s plus a sign bit of 1 is reserved to represent -0(a denormal). 4. The 8087 works internally with all numbers in the 80-bit temporary real format(1 bit for sign,15 bits for exponent and 64 bits for the mantissa). 5. Temporary real format reduce chances for overflows and underflows during series of calculations which produce final range within desired range.
Stack in 8087
The 8087 has a 3-bit stack pointer which holds the number of the register which is the current top-of-stack. During initialization the stack pointer is loaded with 000 implying that register 0 is top-of-stack. As shown in fig.10.8,the stack of 8087 is circular.
Stack in 8087
So , decrementing 000 changes the top-ofstack register to 111. When the 8087 reads the first number,stack is decremented to 111 and the number is stored in register number 111 making register 111 the top-of-stack. In the 8087 instructions the register that is currently top-of-stack is referred as ST(0),or simply ST.
Stack in 8087
The next to ST(0) is referred as ST(1). We can all agree that : If we pop one number from the stack the stack pointer will point to ST(1).
Examples;
FLD ST(2) ;Copies ST(2) to ST FLD [BX] ;Number from memory pointed ;by BX copied to ST
Examples;
FST ST(3) ;Copies ST to ST(3) FST [BX] ;Number from ST is copied to memory location pointed by BX
Examples;
FSTP ST(3) ;Copies ST to ST(3) FSTP [BX] ;Number from ST is copied to memory location pointed by BX
Examples;
FXCH ST(4) ;Swap ST and ST(4)
Examples;
FILD DWORD PTR [BX] ;Short integer from ;memory location ;pointed by [BX]
Examples;
FIST INT_NUM ;ST to memory locations ;named INT_NUM
Examples;
FISTP INT_NUM ;ST to memory locations ;named INT_NUM
Examples;
FBLD AMOUNT ;Ten byte BCD number form ;memory location ;AMOUNT to ST
Examples;
FBSTP MONEY ;Contents from top stack are ;converted to BCD and stored ;in memory
Arithmetic instructions
Can be divided to;
1. 2. 3. 4. 5. 6. Addition Subtraction Reversed subtraction Multiplication Division Other arithmetic operations
Examples;
FADD ST(2),ST ; Add ST to ST(2),result in ST(2) FADD ST,ST(5) ; Add ST(5) to ST , result in ST FADD SUM ; Real number from memory + ST FADD ;ST+ST(1),pop stack-result at ST
Examples;
FADD ST(2) ; Add ST(2) to ST ;Increment stack pointer so ST(2) ;becomes ST
Subtraction instructions
The FSUB Instruction Subtracts the real number from destination to real number at the source. Source can be stack element or memory location. If no source or destination is specified,then STis subtracted from ST(1) and the stack pointer is incremented so that the result is at ST.
Subtraction instructions
Exceptions : I,D,O,U,P Format
FSUB destination , source ;
Examples;
FSUB ST(3),ST ; ST(3)=ST(3)-ST FSUB DIFFERENCE ;ST=ST- Real number ;from memory FSUB ;ST=ST(1)-ST
Subtraction instructions
The FSUBP Instruction Subtracts ST from specified stack element and puts the result in the specified stack element,then it increments stack pointer by one.
Exceptions : I,D,O,U,P
Subtraction instructions
Format
FSUBP destination , source ;
Examples;
FSUB ST(2) ; ST(2)=ST(2)-ST ;Increment stack pointer so ST(1) ;becomes new ST
Subtraction instructions
The FISUB Instruction Subtracts integer stored in memory from ST and stores the result in ST.
Exceptions : I,D,O,P Format
FISUB source ;
Subtraction instructions
Examples;
FISUB DIFFERENCE ; ST=ST-Integer number ;from memory
Reversed subtraction
FSUBR destination,source FSUBRP destination,source FISUBR source These instructions operate same as the FSUB instructions described above except that these instructions subtract the contents of the destination from the contents of the source and put the result in the destination. NOTE : Normal FSUB subtracts source from destination.
Examples;
FMUL ST(2),ST ; ST(2)=ST x ST(2) FMUL ST,ST(5) ; ST= ST x ST(5)
Examples;
FMULP ST(2) ; Multiplies ST(2) by ST ;Increment stack pointer so ST(1) ;becomes ST
Examples;
FDIV ST(2),ST ; ST(2)=ST(2)/ST
Examples;
FDIVP ST(2),ST ; ST(2)=ST(2)/ ST ;Increment stack pointer so ST(1) ;becomes ST
Reversed division
FDIVR destination,source FDIVRP destination,source FIDIVR source These instructions operate same as the FDIV,FDIVP and FIDIV instructions described above except that these instructions divide the source operand by the destination and put the result in the destination. NOTE : Normal division instructions divides destination to source
Example
FSQRT;ST=Square root of ST
Format
FSCALE;
Example
FSCALE ; Exponent in ST=Exponent in ;ST + Integer value in ST(1)
Example
FPREM ; ST=ST-ST(1) until when ST<ST(1)
Example
FRNDINT ; Make ST an integer
Example
FXTRACT ; ST=Significant number of ;temporary-real and ST(1)=exponent ;of temporary-real
Example
FABS ; ST=absolute of ST
Example
FCHS ; ST sign=complement of the sign in ST
Compare instructions
Compares the contents of ST with contents of a specified or default source. The source may be another stack element or real number in memory. They set condition code bits C3,C2,C1 and C0 of the status word shown in Table 10.1. You can transfer the status word to memory with 8087 FSTSW instruction and then use 8086 instructions to determine the results of the comparison.
Compare instructions
Table 10.1 gives complete listing of each combination of condition code bits and their functions. Note that these bits have different meanings for different instructions, as indicated in table 10.1. The top of the stack is denoted as ST in this table.