ECE291 Computer Engineering II Lecture 11 Dr. Zbigniew Kalbarczyk University of Illinois at Urbana- Champaign.

Slides:



Advertisements
Similar presentations
CH10 Instruction Sets: Characteristics and Functions
Advertisements

Set 16 FLOATING POINT ARITHMETIC. TOPICS Binary representation of floating point Numbers Computer representation of floating point numbers Floating point.
Gursharan Singh Tatla Math Co-Processor Nov-10 Gursharan Singh Tatla
UQ: Explain in brief integer instruction pipeline stages of Pentium
1/1/ / faculty of Electrical Engineering eindhoven university of technology Introduction Part 2: Data types and addressing modes dr.ir. A.C. Verschueren.
ECE291 Computer Engineering II Lecture 11 Josh Potts University of Illinois at Urbana- Champaign.
Spring 2013 Advising Starts this week! CS2710 Computer Organization1.
There are two types of addressing schemes:
Fixed Point Numbers The binary integer arithmetic you are used to is known by the more general term of Fixed Point arithmetic. Fixed Point means that we.
ECE291 Computer Engineering II Lecture 24 Josh Potts University of Illinois at Urbana- Champaign.
Comp Sci Floating Point Arithmetic 1 Ch. 10 Floating Point Unit.
Computer Engineering FloatingPoint page 1 Floating Point Number system corresponding to the decimal notation 1,837 * 10 significand exponent A great number.
Instruction Set Architecture
Topics covered: Floating point arithmetic CSE243: Introduction to Computer Architecture and Hardware/Software Interface.
Instruction Set Architecture & Design
6/9/2015TUC-N dr. Emil CEBUC Math Coprocessor Also called Floating Point Unit FPU.
Microprocessors The MIPS Architecture (Floating Point Instruction Set) Mar 26th, 2002.
Floating Point Numbers
Outline Floating point arithmetic 80x87 Floating Point Unit.
The 80x87 Math Coprocessor.
Assembly Language for x86 Processors 6th Edition
Lecture 15 Floating point math Dr. Dimitrios S. Nikolopoulos CSL/UIUC.
Computer Arithmetic. Instruction Formats Layout of bits in an instruction Includes opcode Includes (implicit or explicit) operand(s) Usually more than.
Machine Instruction Characteristics
ECE232: Hardware Organization and Design
Dr Mohamed Menacer College of Computer Science and Engineering Taibah University CS-334: Computer.
Computer Architecture and Operating Systems CS 3230 :Assembly Section Lecture 10 Department of Computer Science and Software Engineering University of.
Floating Point Arithmetic
CSC 221 Computer Organization and Assembly Language
ECE 456 Computer Architecture
COMP201 Computer Systems Floating Point Numbers. Floating Point Numbers  Representations considered so far have a limited range dependent on the number.
FLOATING POINT ARITHMETIC. TOPICS Binary representation of floating point Numbers Computer representation of floating point numbers Floating point instructions.
The x87 FPU Lecture 19 Fri, Mar 26, 2004.
Computer Architecture and Organization
The 80x87 Math Coprocessor. Why we need a math coprocessor? Using a general-purpose microprocessor such as the 8088/86 to perform mathematical functions.
Computer Architecture EKT 422
Computer Architecture Lecture 22 Fasih ur Rehman.
Floating Point Numbers Representation, Operations, and Accuracy CS223 Digital Design.
EEL5708/Bölöni Lec 8.1 9/19/03 September, 2003 Lotzi Bölöni Fall 2003 EEL 5708 High Performance Computer Architecture Lecture 5 Intel 80x86.
Assembly Language for x86 Processors 7th Edition
ECE291 Computer Engineering II Lecture 3 Dr. Zbigniew Kalbarczyk University of Illinois at Urbana- Champaign.
Microprocessors used in Personal Computers. The Memory Map of a Personal Computers Transient Program Area (TPA): Holds the operating system (interrupt.
Real Numbers SignExponentMantissa.
Real Arithmetic Computer Organization and Assembly Languages Yung-Yu Chuang 2006/12/11.
Instruction Sets. Instruction set It is a list of all instructions that a processor can execute. It is a list of all instructions that a processor can.
Instruction Sets: Characteristics and Functions  Software and Hardware interface Machine Instruction Characteristics Types of Operands Types of Operations.
ECE291 Lecture 13 Advanced Mathematics. ECE 291 Lecture 13Page 2 of 40 Lecture outline Floating point arithmetic 80x87 Floating Point Unit MMX Instructions.
Chapter 14: The Arithmetic Coprocessor, MMX, and SIMID Technologies.
Floating Points & IEEE 754.
Floating Point Representations
Presented by, C.Balasubramaniam, Lect / CSE ESEC
Integer Division.
Chapter 6 Floating Point
Arithmetic for Computers
Topic 3d Representation of Real Numbers
Assembly Language for Intel-Based Computers, 5th Edition
Using the 80x87 Math Chip in Assembly
ECE 498AL Spring 2010 Lecture 11: Floating-Point Considerations
The x87 FPU Lecture 18 Wed, Mar 23, 2005.
Computer Organization and Assembly Languages Yung-Yu Chuang 2005/12/22
© David Kirk/NVIDIA and Wen-mei W. Hwu,
Review In last lecture, done with unsigned and signed number representation. Introduced how to represent real numbers in float format.
Computer Architecture and System Programming Laboratory
Computer Organization and Assembly Language
Computer Organization
Computer Architecture and System Programming Laboratory
Part I Data Representation and 8086 Microprocessors
Chapter 10 Instruction Sets: Characteristics and Functions
Presentation transcript:

ECE291 Computer Engineering II Lecture 11 Dr. Zbigniew Kalbarczyk University of Illinois at Urbana- Champaign

Z. KalbarczykECE291 Outline Floating point arithmetic 80x87 Floating Point Unit

Z. KalbarczykECE291 Floating-Point Numbers Components of a floating point number Sign: 0=pos(+); 1=neg(-) Exponent: (with Constant bias added) Mantissa: 1 <= M < 2 Number = (1.Mantissa) * 2 (exponent-bias) Example: (decimal) = (binary) = * 2 3 (normalized)

Z. KalbarczykECE291 Floating-point Format Precision Size Exp. Bias Mant. Mant. (bits) (bits) (bits) 1st Digit Single (7Fh) 23 Implied Double (3FFh) 52 Implied Extended (3FFFh) 63 Explicit

Z. KalbarczykECE291 Converting to Floating-Point Form Convert the decimal number into binary Normalize the binary number Calculate the biased exponent Store the number in floating point-point format Example: = = x (7Fh) = (85h) 4. Sign = 0 Exponent = Mantissa = Note mantissa of a number 1.XXXX is the XXXX The 1. is an implied one-bit that is only stored in the extended precision form of the floating-point number as an explicit-one bit

Z. KalbarczykECE291 Converting to Floating-Point Form Format Sign Exponent Mantissa Single (+) 7F+6 = 85h (8 bits) Implied 1. (23 bit) , ,1000,1000,0000,0000,0000 Double (+) 3FFh + 6 = 405h (11 bits) Implied 1. (52 bit) 0 100,0000, ,1000,1000,0000,…,0000 Extended (+) 3FFFh+6 = 4005h (15 bits) Explicit 1. (63 bit) 0 100,0000,0000, ,1000,1000,0000,…,

Z. KalbarczykECE291 Examples

Z. KalbarczykECE291 Special Representations Zero: –Exp = All Zero, Mant = All Zero NAN (not a number) an invalid floating-point result –Exp = All Ones, Mant non-zero + Infinity: –Sign = 0, Exp = All Ones, Mant = 0 - Infinity: –Sign = 1, Exp = All Ones, Mant = 0

Z. KalbarczykECE291 Converting from Floating-Point Form (example) Sign = 1 Exponent = 1000,0011 Mantissa = 100,1001,0000,0000, = 1000, ,1111 (convert the biased exponent) x 2 4 (a normalized binary number) (a de-normalized binary number) ( a decimal number)

Z. KalbarczykECE291 The 80x87 Floating Point Unit On-chip hardware for fast computation on floating point numbers FPU operations run in parallel with integer operations Historically implemented as separate chip – Coprocessor 80486DX-Pentium III contain their own internal and fully compatible versions of the CPU/FPU Exchange data through memory –Converts Single and Double to Extended-precision

Z. KalbarczykECE291 Arithmetic Coprocessor Architecture Control unit –interfaces the coprocessor to the microprocessor-system data bus Numeric execution unit (NEU) –executes all coprocessor instructions NEU has eight-register stack –each register is 80-bit wide (extended-precision numbers) –data appear as any other form when they reside in the memory system –holds operands for arithmetic instructions and the results of arithmetic instructions –FSTSW AX ;the only instruction (not available for 8087) that allows direct communications between CPU and FPU through the AX register Other registers - status, control, tag, exception

Z. KalbarczykECE291 Arithmetic Coprocessor FPU Registers The eight 80-bit data registers are organized as a stack As data items are pushed into the top register, previous data items move into higher-numbered registers, which are lower on the stack All coprocessor data are stored in registers in the 10-byte real format Internally, all calculations are done on the greatest precision numbers Instructions that transfer numbers between memory and coprocessor automatically convert numbers to and from the 10-byte real format

Z. KalbarczykECE291 Sample 80x87 FPU Opcodes FADD: Addition FMUL: Multiplication FDIV: Division (divides the destination by the source) FDIVR: Division (divides the source by the destination) FSIN: Sine (uses radians) FCOS: Cosine (uses radians) FSQRT: Square Root FSUB: Subtraction FABS: Absolute Value FYL2X: Calculates Y * log 2 X(X) (Really) FYL2XP1: Calculates Y * log 2 X(X)+1 (Really)

Z. KalbarczykECE291 Programming the FPU FPU Registers = ST(0).. ST(7) Format: OPCODE destination, source Restrictions: One register must be ST(0) ST=ST(0)=top of stack Use of ST(0) is implicit when not specified FINIT - Execute before starting to initialize FPU registers!

Z. KalbarczykECE291 Programming the FPU (cont.) FLD MemVar –Load ST(0) with MemVar & –Push all other ST(i) to ST(i+1) for i=0..6 FSTP MemVar –Move top of stack to memory & –Push all other ST(i) to ST(i-1) for I = 1..7 FST MemVar –Move top of stack to memory –Leave result in ST(0) FSTP –Store Result and Pop FPU stack

Z. KalbarczykECE291 FPU Programming Classical-Stack Format Instructions treat the coprocessor registers like items on the stack ST (the top of the stack) is the source operand ST(1), the second register, is the destination ST ST(1) fld1fldpifadd Instructions Stack Contents

Z. KalbarczykECE291 FPU Programming Memory Format The stack top (ST) is always the implied destination ST ST(1) fld m1 fld m2fadd m1 1.0 fstp m1 fst m2 m1 m DATA m1 REAL4 1.0 m2 REAL4 2.0.CODE …. fld m1 fld m2 fadd m1 fstp m1 fst m2

Z. KalbarczykECE291 FPU Programming Register Format Instructions treat coprocessor registers as registers rather than stack elements –require two register operands; one of them must be the stack top (ST) ST ST(1) fadd st(1), st fadd st, st(2) fxch st(1) ST(2)

Z. KalbarczykECE291 FPU Programming Register-Pop Format Coprocessor registers are treated as a modified stack –the source register must always be a stack top ST ST(1) faddp st(2), st 2.0 ST(2)

Z. KalbarczykECE291 FPU Programming Timing Issues A coprocessor instruction following a processor instruction –coordinated by assembler for 8086 and 8088 –coordinated by processor on Pentium A processor instruction that accesses memory following a coprocessor instruction that accesses the same memory –for 8087 need include WAIT or FWAIT to ensure that coprocessor finishes before the processor begins –assembler is doing this automatically

Z. KalbarczykECE291 Calculating the Area of a Circle MODEL SMALL.DATA RAD DD 2.34, 5.66, 9.33, 234.5, 23.4 AREA DD5 dup (?).CODE.STARTUP movsi, 0;source element 0 movdi, 0;destination element 0 mov cx, 5;count of 5 Main1: fld rad[si];radius to ST fmulst, st(0); square radius fldpi ; pi to ST fmul ; multiply ST = ST x ST(1) fstp AREA[di] inc si inc di loop Main1 mov ax, 4C00h int21h end

Z. KalbarczykECE291 Floating Point Operations Calculating Sqrt(x 2 + y 2 ) cseg segment public 'CODE' assume cs:cseg, ds:cseg StoreFloat db 94 dup(?) X real4 4.0 Y real4 3.0 Z real4 ? ShowFP MACRO fsave StoreFloat frstor StoreFloat ENDM main proc far movax, cseg ; Initialize DS=CS movds, ax finit ShowFP fldX ShowFP fld st(0) ShowFP fmul ShowFP fldY ShowFP fldst(0) ShowFP fmul ShowFP fadd ShowFP fsqrt ShowFP fstZ ShowFP movax, 4C00h ;Exit to DOS int21h mainendp csegends end main