







Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!








Data types Interfacing Instructions and programming
which it is compatible. ¾Math Coprocessor is known as NPX,NDP, FUP. Numeric processor extension (NPX), Numeric data processor (NDP), Floating point unit (FUP).
Processors
Vcc
Execution Unit
GND 40
GND 20
19
18 CLK
NC
NC (^17)
16
AD (^14) AD (^13) AD (^12) AD (^11) AD (^10) AD (^9) AD (^8) AD (^7) AD (^6) AD (^5) AD (^4)
AD (^3) AD (^2) AD AD (^0)
15
14
13
12
11
1 2 3 4 5 6 7 8 9
10
RESET
READY
BUSY
QS (^1)
AD (^15) A 16 /S 3 A 17 /S 4 A 18 /S 5
BHE/S (^7)
A 19 /S 6
RQ/GT (^1) INT
RQ/GT (^0) NC
NC (^) _ __^ S^2 S (^1)
QS (^0)
(A 14 ) (^39) (A 13 ) 38 (A 12 ) 37 (A 11 ) 36 (A 10 ) 35 (A 9 ) 34
32
31 30
29 28
21
22
23
24
25
26
(^27) __ S (^0)
¾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.
•IC Infinity control •RC Rounding control •PC Precision control •PM Precision control •UM Underflow mask •OM Overflow mask •ZM Division by zero mask •DM Denormalized operand mask •IM Invalid operand mask ¾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 ¾RC –Rounding control determines the type of rounding. 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 ¾PC- Precision control sets the precision of he result as define in table PRECISION CONTROL 00=Single precision (short) 01=Reserved 10=Double precision (long) 11=Extended precision (temporary) ¾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 in the coprocessor’s registers. ¾Numeric registers in NUE are 80 bits wide. ¾NUE is able to perform arithmetic, logical and transcendental operations as well as supply a small number of mathematical constants from its on-chip ROM. ¾Numeric data is routed into two parts ways a 64 bit mantissa bus and a 16 bit sign/exponent bus. Circuit Connection for 8086 - 8087
RQ/GT 0 pin. The 8086 responds to this by sending another low
goin pulse ack to and outputs
d by
es for its data transfer, it
e host
e the 8086 needs the data produced by the
the FSTSW
t until the 8087 completes the FSTSW
olve this problem by connecting the 8087 BUSY output to the TEST pin of the
pin high. When it is finished
nstruction in your program after the 8087 FSTSW here it
STATUS ;copy 8087 status word to memory US
In this set of instructions we ing WAIT instruction. Due to this the flow of
; doing next 8086 instruction
g b the RQ/GT 0 pin of 8087 and by floating its buses. ¾The 8087 then increments the address it grabbed during the first transfer 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 require the instruction to/from memory. ¾When the 8087 is using the bus
sends another low-going pulse out on its RQ/ GT 0 pin to 8086 to know it can have the buses back again. The next type of the synchronization between th processor and the coprocessor is that required to make sure the 8086 hast does not attempt to execute the next instruction before the 8087 has completed an instruction. ¾Taking one situation, in the case wher execution of an 8087 instruction to carry out its next instruction. ¾In the instruction sequence for example the 8087 must complete 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 wai instruction, the 8086 will go on and execute the MOV AX , STATUS with erroneous data. ¾We s 8086 and putting on the WAIT instruction in the program. ¾While 8087 is executing an instruction it asserts its BUSY 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 i instruction .When 8086 executes the WAIT instruction it enters an internal loop w 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.
MOV AX, STAT ;copy status word to AX to check ; bits ( a ) ¾ are not us 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. FSTSW STATUS ;copy 8087 status word to memory FWAIT ;wait for 8087 to finish before-
MOV A A ;copy status word to AX to check ; bits
instruction so that it will stop the execution of finishes it’s work .so that you are not loosing
the next 8087
ding,
y insert the 8-bit code for the WAIT instruction ,10011011 binary (9BH), as
ected directly from the 8086 to 8087. d the queue status lines connected directly from 8086 to 8087.
BUSY ed to TEST pin of 8086. Interr ut of 86. This intimates an error _ Low to
e NUE has not completed the execution of the previous instruction.
sure
ese will cause an interrupt if unmasked and interrupts are
( b ) ¾In this code we are adding up of FWAIT the command until the above instruction is 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 instruction from memory. (^) ________ ¾Here again you use the BUSY-TEST connection and the FWAIT instruction to solve the problem. If you are hand co 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 automaticall the first byte of the code for 8087 instruction.
¾Multiplexed address-data bus lines are conn ¾The status lines an
¾The Request/Grant signal RQ/GT0 of 8087 is connected to
RQ/GT1 of 8086.
¾ signal 8087 is connect ¾ upt output INT of the 8087 to NMI inp 80 condition. (^) _____ ¾A WAIT instruction is passed to keep looking at its TEST pin, until it finds pin indicates that the 8087 has completed the computation. ¾SYNCHRONIZATION must be established between the processor and coprocessor in two situations. a) The execution of an ESC instruction that require the participation of the NUE must not be initiated if th b) When a processor instruction accesses a memory location that is an operand of a previous coprocessor instruction .In this case CPU must synchronize with NPX to en that it has completed its instruction. Processor WAIT instruction is provided.
¾The 8087 detects six different types of exception conditions that occur during instruction execution. Th enabled. 1)INVALID OPERATION 2)OVERF 3)ZERO DIVISOR
FSTP Store real and pop egisters
and pop NSFER(BCD)
ck pointer by one and copies a real number from a nt or memory location to the new ST.
ry
;increment stack pointer.
t nts of a specified
re. Convert number from ST to integer and copy to
estination -Integer store and pop. Identical to FIST except that stack pointer is y
.
plication, and
Add real Add real and pop d integer tion
Subtract real and pop t integer
FXCH Exchange r ¾ INTEGER TRANSFER FILD Load integer FIST Store integer FISTP Store integer ¾ PACKED DECIMAL TRA FBLD Load BCD FBSTP Store BCD and pop
¾ FLD Source - Decrements the sta stack eleme •FLD ST(3) ;Copies ST(3) to ST. •FLD LONG_REAL[BX] ;Number from memo ;copied to ST. ¾ FLD Destination- Copies ST to a specified stack position or to a specified memory location. •FST ST(2) ;Copies ST to ST(2),and
•FST SHORT_REAL[BX] ;Copy ST to a memory at a ;SHORT_REAL[BX] ¾ FXCH Destination – Exchange the contents of ST with the con e stack element. •FXCH ST(5) ;Swap ST and ST(5) ¾ FILD Source format and push on 8087 stack. •FILD DWORD PTR[BX] ;Short integer from memory at [BX]. ¾ FIST Destination- Integer sto memory. •FIST LONG_INT ;ST to memory locations named LONG_INT. ¾ FISTP D incremented after cop. ¾ FBLD Source- Convert BCD number from memory to temporary- real format and push on top of 8087 stack
Arithmetic Instructions .Four basic arithmetic functions: Addition, Subtraction, Multi Division. ¾ Addition FADD FADDP FIADD Ad ¾ Subtrac FSUB Subtract real FSUBP FISUB Subtrac FSUBR Subtract real reversed
FSUBRP Subtract real and pop FISUBR Subtract integer reversed cation ultipl tiply real and pop ger
lue Change sign
onent and mantissa.
destination Source can be a stack location. Destination must be a stack element. If no source or destination is
ST(4) ;Add ST(4) to ST, result in ST.
ck
d Subtract the ified destination and
m memory.
d put result in specified stack .Then crem e.
rom ST, result in ST. ld ory
l and pop P nd pop twice
mi
tangent
¾ Multipli FMUL M y real FMULP Mul FIMUL Multiply inte ¾ Advanced FABS Absolute va FCHS FPREM Partial remainder FPRNDINT Round to integer FSCALE Scale FSQRT Square root FXTRACT Extract exp
¾ FADD – Add real from specified source to specified or memory specified, then ST is added to ST(1) and stack pointer is incremented so that the result of addition is at ST. •FADD ST(3), ST ;Add ST to ST(3), result in ST(3) •FADD ST, •FADD ;ST + ST(1), pop stack result at ST •FADDP ST(1) ;Add ST(1) to ST. Increment sta ;pointer so ST(1) become ST. •FIADD Car_Sol ;Integer number from memory + ST¾ FSUB - real number at the specified source from the real number at the spec put the result in the specified destination. •FSUB ST(2), ST ;ST(2)=ST(2) – ST. •FSUB Rate ;ST=ST – real no fro •FSUB ;ST=( ST(1) – ST) ¾ FSUBP - Subtract ST from specified stack element an element in ent the pointer by on •FSUBP ST(1) ;ST(1)-ST. ST(1) becomes new ST ¾ FISUB – Integer from memory subtracted f •FISUB Cars_So ;ST becomes ST – integer from mem
Compare Instructions. ¾ Comparison FCOM Compare real FCOMP Compare rea FCOMP Compare real a FICOM Compare integer FICOMP Compare integer and pop FTST Test ST against +0. FXAM Exa ne ST
Transcendental Instruction. ¾ Transcendental FPTAN Partial FPATAN Partial arctangent
load: fld y ;load the power fld x ;load the base
nc: nc_c d dint
;save integer after truncation
opw xm1 the power fraction temp ult
the result
h
cale: cale
temp he final result in real and integer ver:
comput: fyl2x ;compute (y * log 2 (x)) fst temp ;save the temp result tru fldcw tru w ;set truncation comman frn fld temp ;load real number of fyl2x fist tempint fld temp ;load the real number getfrac: fisub tempint ;subtract the integer fst diff ;store the fraction fracby2: fidiv two ;divide the fraction by tw rx: f2 ;calculate the 2 to fst 1 ;minus 1 and save the res fld1 ;load fadd ;add 1 to the previous result fst temp1 ;save the result sqfrac: fmul st(0),st(0) ;square the result as fraction fst temp1 ;was halved and save fild tempint ;save the integer portion fxc ;interchange the integer ;and power of fraction. s fs ;scale the result in real and ;integer fst 2 ;in st(1) and store fist tempint1 ;save t o mov ax,4c00h ;exit to dos int 21h end start