Floating Point Unit
description
Transcript of Floating Point Unit
![Page 1: Floating Point Unit](https://reader038.fdocuments.us/reader038/viewer/2022102604/56815957550346895dc6931b/html5/thumbnails/1.jpg)
Floating Point Unit
8087 Coprocesor
![Page 2: Floating Point Unit](https://reader038.fdocuments.us/reader038/viewer/2022102604/56815957550346895dc6931b/html5/thumbnails/2.jpg)
8087: a 40-pin Coprocessor
![Page 3: Floating Point Unit](https://reader038.fdocuments.us/reader038/viewer/2022102604/56815957550346895dc6931b/html5/thumbnails/3.jpg)
Connection to Processor
![Page 4: Floating Point Unit](https://reader038.fdocuments.us/reader038/viewer/2022102604/56815957550346895dc6931b/html5/thumbnails/4.jpg)
FPU: Floating Point Unit• Helps the Processor for floating point calculations• Part of a cpu. (Inside Pentium and 486)• Direct support for:
– floating-point– Extended integer– BCD data types
• Supports Standard IEEE 754 & 854 • Compatible with object code for
– 8087 for 8086– Intel287 for 80286– Intel387 DX & SX – Intel487 DX – Intel486 DX: when in 66MHz = 1/3 Performance of Pentium (66
MHz)
![Page 5: Floating Point Unit](https://reader038.fdocuments.us/reader038/viewer/2022102604/56815957550346895dc6931b/html5/thumbnails/5.jpg)
Comparison of 8087 and 8086 Clock Times
In some cases the differences of run times is hours between
PCs with and without math-coprocessor.
![Page 6: Floating Point Unit](https://reader038.fdocuments.us/reader038/viewer/2022102604/56815957550346895dc6931b/html5/thumbnails/6.jpg)
Real Number Representationb b bb b b
b
b
![Page 7: Floating Point Unit](https://reader038.fdocuments.us/reader038/viewer/2022102604/56815957550346895dc6931b/html5/thumbnails/7.jpg)
Numeric Data Types
![Page 8: Floating Point Unit](https://reader038.fdocuments.us/reader038/viewer/2022102604/56815957550346895dc6931b/html5/thumbnails/8.jpg)
Floating-Point Manipulation
• IEEE Floating Point Format• FPU Registers• DATA TRANSFER• BASIC ARITHMETIC• COMPARISON• TRANSCENDENTAL• LOAD CONSTANTS• FPU CONTROL
![Page 9: Floating Point Unit](https://reader038.fdocuments.us/reader038/viewer/2022102604/56815957550346895dc6931b/html5/thumbnails/9.jpg)
FPU CONTROL• FINCSTP Increment FPU register stack pointer• FDECSTP Decrement FPU register stack pointer• FFREE Free floating-point register• FINIT Initialize FPU after checking error conditions• FNINIT Initialize FPU without checking error conditions• FCLEX Clear floating-point exception flags after checking for error• conditions• FNCLEX Clear floating-point exception flags without checking for error• conditions• FSTCW Store FPU control word after checking error conditions• FNSTCW Store FPU control word without checking error conditions• FLDCW Load FPU control word• FSTENV Store FPU environment after checking error conditions• FNSTENV Store FPU environment without checking error conditions• FLDENV Load FPU environment• FSAVE Save FPU state after checking error conditions• FNSAVE Save FPU state without checking error conditions• FRSTOR Restore FPU state• FSTSW Store FPU status word after checking error conditions• FNSTSW Store FPU status word without checking error conditions• WAIT/FWAIT Wait for FPU• FNOP FPU no operation
![Page 10: Floating Point Unit](https://reader038.fdocuments.us/reader038/viewer/2022102604/56815957550346895dc6931b/html5/thumbnails/10.jpg)
Branch Preparation
FCOMI, FCOMIP, FUCOMI, and FUCOMIP) compare two floating-point values and set the ZF, PF, and CF flags in the EFLAGS register directly.(Pentium Pro Only)
![Page 11: Floating Point Unit](https://reader038.fdocuments.us/reader038/viewer/2022102604/56815957550346895dc6931b/html5/thumbnails/11.jpg)
LOAD CONSTANTS
• FLD1 Load +1.0• FLDZ Load +0.0• FLDPI Load • FLDL2E Load log2e• FLDLN2 Load loge2• FLDL2T Load log210• FLDLG2 Load log102
![Page 12: Floating Point Unit](https://reader038.fdocuments.us/reader038/viewer/2022102604/56815957550346895dc6931b/html5/thumbnails/12.jpg)
TRANSCENDENTAL• FSIN Sine• FCOS Cosine• FSINCOS Sine and cosine• FPTAN Partial tangent st(0)=tan(st(0)); 1push register stack• FPATAN Partial arctangent• F2XM1 st(0)=2^st(0) 1• FYL2X ylog2x• FYL2XP1 ylog2(x+1)
![Page 13: Floating Point Unit](https://reader038.fdocuments.us/reader038/viewer/2022102604/56815957550346895dc6931b/html5/thumbnails/13.jpg)
COMPARISON• FCOM m32/m64/st(I)/none st(0):src flags:c0,c1,c2• FCOMP Compare real and pop• FCOMPP Compare real and pop twice• FUCOM Unordered compare real Does not generate an invalid-
arithmetic-operand exception• FUCOMP Unordered compare real and pop• FUCOMPP Unordered compare real and pop twice• FICOM m16/m32 Compare with integer• FICOMP Compare integer and pop• FCOMI Compare real and set EFLAGS(Z,P,C)• FUCOMI Unordered compare real and set EFLAGS• FCOMIP Compare real, set EFLAGS, and pop• FUCOMIP Unordered compare real, set EFLAGS, and pop• FTST Test real Compare St(0):0.0• FXAM Examine real
![Page 14: Floating Point Unit](https://reader038.fdocuments.us/reader038/viewer/2022102604/56815957550346895dc6931b/html5/thumbnails/14.jpg)
FXAM
C1 sign bit of ST; (* 0 for positive, 1 for negative *)
![Page 15: Floating Point Unit](https://reader038.fdocuments.us/reader038/viewer/2022102604/56815957550346895dc6931b/html5/thumbnails/15.jpg)
BASIC ARITHMETICFloatng point Addition/subtractionFSUBR, FSUBRP, FISUBR Reverse SubtractionFMUL Multiply realFMULP Multiply real and popFIMUL Multiply integerFDIV Divide realFDIVP Divide real and popFIDIV Divide integerFDIVR, FDIVRP, FIDIVR Reverse DivisionFPREM Partial remainder FPREMI IEEE Partial remainder st(0)%=st(1)FABS Absolute valueFCHS Change signFRNDINT Round to integerFSCALE Scale by power of two st(0)=st(0)*2^st(1)FSQRT Square rootFXTRACT st(0)=exponent(st(0)) significandregister stack
![Page 16: Floating Point Unit](https://reader038.fdocuments.us/reader038/viewer/2022102604/56815957550346895dc6931b/html5/thumbnails/16.jpg)
Floating Point Addition/Subtraction
![Page 17: Floating Point Unit](https://reader038.fdocuments.us/reader038/viewer/2022102604/56815957550346895dc6931b/html5/thumbnails/17.jpg)
DATA TRANSFERFLD m32real/m64real/m80real/st(I) push onto FPU register stackFST m32real/m64real/st(I) store st(0) on m32…. FSTP m32real/m64real/m80real/st(I) FST & pop stackFILD m16/m32/m64 Load integer. push onto FPU register
stackFIST Store integerFISTP Store integer and popFBLD Load BCDFBSTP Store BCD and popFXCH st(I)/none Exchange registers st(0) and st(I)/st(1)FCMOVE Floating-point conditional move if equalFCMOVNE Floating-point conditional move if not equalFCMOVB Floating-point conditional move if belowFCMOVBE Floating-point conditional move if below or equalFCMOVNB Floating-point conditional move if not belowFCMOVNBE Floating-point conditional move if not below or equalFCMOVU Floating-point conditional move if unorderedFCMOVNU Floating-point
![Page 18: Floating Point Unit](https://reader038.fdocuments.us/reader038/viewer/2022102604/56815957550346895dc6931b/html5/thumbnails/18.jpg)
Binary Floating Point Format
J-Bit is implied
Normalized Representation: 1<= Significand < 2
Exponent is Biased, So always it is positive
![Page 19: Floating Point Unit](https://reader038.fdocuments.us/reader038/viewer/2022102604/56815957550346895dc6931b/html5/thumbnails/19.jpg)
Convert 9.75 to single-precision floating point
![Page 20: Floating Point Unit](https://reader038.fdocuments.us/reader038/viewer/2022102604/56815957550346895dc6931b/html5/thumbnails/20.jpg)
Convert 0.078125 to short real FP
![Page 21: Floating Point Unit](https://reader038.fdocuments.us/reader038/viewer/2022102604/56815957550346895dc6931b/html5/thumbnails/21.jpg)
Convert -96.27 to short real FP
![Page 22: Floating Point Unit](https://reader038.fdocuments.us/reader038/viewer/2022102604/56815957550346895dc6931b/html5/thumbnails/22.jpg)
Convert 152.1875 to double-precision
![Page 23: Floating Point Unit](https://reader038.fdocuments.us/reader038/viewer/2022102604/56815957550346895dc6931b/html5/thumbnails/23.jpg)
Encoding Special Values• Signed zeros : 0+ or 0-
• Denormalized finite numbers.
• Normalized finite numbers.
• Signed infinities.
• NaNs : Not a Number
Quiet NaNs
No exception
Signaling Nans
• Indefinite numbers.
![Page 24: Floating Point Unit](https://reader038.fdocuments.us/reader038/viewer/2022102604/56815957550346895dc6931b/html5/thumbnails/24.jpg)
FPU Registers
Error Pointers: Instruction & Operand
16bit Selector + 32 bit address
Opcode of the last non-control FPU instruction.
![Page 25: Floating Point Unit](https://reader038.fdocuments.us/reader038/viewer/2022102604/56815957550346895dc6931b/html5/thumbnails/25.jpg)
Example
![Page 26: Floating Point Unit](https://reader038.fdocuments.us/reader038/viewer/2022102604/56815957550346895dc6931b/html5/thumbnails/26.jpg)
FPU Control Word
![Page 27: Floating Point Unit](https://reader038.fdocuments.us/reader038/viewer/2022102604/56815957550346895dc6931b/html5/thumbnails/27.jpg)
FPU Status & TAG Register
Save Reg: FSTSW/FNSTSW, FSTENV/FNSTENV, FSAVE/FNSAVE
![Page 28: Floating Point Unit](https://reader038.fdocuments.us/reader038/viewer/2022102604/56815957550346895dc6931b/html5/thumbnails/28.jpg)
Condition Codes
![Page 29: Floating Point Unit](https://reader038.fdocuments.us/reader038/viewer/2022102604/56815957550346895dc6931b/html5/thumbnails/29.jpg)
Correspondence Between FPU and CPU Flag Bits
![Page 30: Floating Point Unit](https://reader038.fdocuments.us/reader038/viewer/2022102604/56815957550346895dc6931b/html5/thumbnails/30.jpg)
Opcode Field
![Page 31: Floating Point Unit](https://reader038.fdocuments.us/reader038/viewer/2022102604/56815957550346895dc6931b/html5/thumbnails/31.jpg)
FCOM, FCOMP, FCOMPP
C1 Set to 1 if stack underflow occurred; otherwise, cleared to 0.
Floating-Point Exceptions
#IS Stack underflow occurred.
#IA One or both operands are NaN values or have unsupported formats. Register is marked empty.
#D One or both operands are denormal values.