lecture32 - 0306-250 Assembly Language Programming Lecture...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: 0306-250 Assembly Language Programming Lecture Thirty-Two • Floating-Point Multiplication Floating-Point Nomenclature Decimal Scientific Notation X = a ´ 10b – a: Significand or mantissa – b: Exponent • Binary Scientific Notation X = a ´ 2b – a: Binary significand or mantissa – b: Binary exponent Basis of binary floating-point representations 2 IEEE-754 Floating Point Format Normalized Value = (-1)S ´ 2E - Bias ´ 1.F • S: sign • E: biased exponent • F: fractional part of significand Special case: zero value—detection • Only normalized allowed E = 0 for normalized values • Denormalized allowed E = 0 and F = 0 3 Floating-Point Multiplication Two floating-point numbers • A = (-1)SA ´ 2EA - Bias ´ 1.FA • B = (-1)SB ´ 2EB - Bias ´ 1.FB Product • C =A ´ B = (-1)SC ´ 2EC - Bias ´ 1.FC ( )( A ´ B = [- 1]S A ´ 2 E A - Bias ´1.F A ´ [- 1]S B ´ 2 EB - Bias ´ 1.F B ) = (- 1)S A ´ (- 1)S B ´ 2 E A - Bias ´ 2 EB - Bias ´ 1.F A´1.F B = (- 1)S A + S B ´ 2 E A - Bias + EB - Bias ´ 1.F A´1.F B 4 Floating-Point Multiplication Algorithm: Special Case—Factor of Zero A ´ B = (- 1)S A + S B ´ 2 E A - Bias + EB - Bias ´1.F A´1.F B C = (- 1)SC ´ 2 EC - Bias ´1.F C • Look at exponents of factors (muliplicand and multiplier) – Either zero Þ Value of zero ® Zero result –A´0=0´B=0=C • Zero value encoding: – SC = 0 (or compute sign from factors) – EC = 0 – FC = 0 (or don’t care) 5 Floating-Point Multiplication Algorithm: Sign A ´ B = (- 1)S A + S B ´ 2 E A - Bias + EB - Bias ´1.F A´1.F B C = (- 1)SC ´ 2 EC - Bias ´1.F C • Look at signs of factors (muliplicand and multiplier) – Same signs ® Positive result – Different signs ® Negative result • S field outcome: (SA, SB) ® SC – Same signs ® Positive result (0,0) ® 0 or (1,1) ® 0 – Different signs ® Negative result (0,1) ® 1 or SC ß SA Å SB (1,0) ® 1 6 Floating-Point Multiplication Algorithm: Exponent (perhaps not final value) A ´ B = (- 1)S A + S B ´ 2 E A - Bias + EB - Bias ´1.F A´1.F B C = (- 1)SC ´ 2 EC - Bias ´1.F C Add exponents and adjust for bias • EC - Bias = EA - Bias + EB – Bias EC = EA + EB – 2Bias + Bias = EA + EB – Bias Exponent may need adjustment later. Why? 7 Floating-Point Multiplication Algorithm Significand A ´ B = (- 1)S A + S B ´ 2 E A - Bias + EB - Bias ´ 1.F A´1.F B C = (- 1)SC ´ 2 EC - Bias ´ 1.F C • Multiply significands (not just fractional parts) • Truncate fraction bits not available in format • Normalize significand result, if necessary – If most significant “1” digit is not in “one” position • Shift significand bits to get first significant “1” in “one” position • Adjust result exponent (EC) to account for shifting • FC is fractional part of normalized significand 8 Floating-Point Multiplication Algorithm: Check for Overflow and Underflow A ´ B = (- 1)S A + S B ´ 2 E A - Bias + EB - Bias ´1.F A´1.F B C = (- 1)SC ´ 2 EC - Bias ´1.F C • Overflow – Result exponent too large to encode – EC > 127 – Return infinity: E = 255; F = 0 • Underflow – Result exponent too small to encode – EC > -126 – Return zero: E = 0; F = 0 9 Floating-Point Multiplication Example IEEE-754 Single Precision Multiply 5.010 by 2.510 S 101.0 x 10.1 ---------------10.10 1010. ------------------1100.10 5.0 x 2.5 --------2.50 10.0 ----------12.50 E F 0 10000001 01000000000000000000000 0 10000000 01000000000000000000000 • Sign Negative: 0 Å 0 = 0 • Exponent 130 = 129 + 128 – 127 • Fraction 1.01000000000000000000000 x1.01000000000000000000000 -------------------------.0101000000000000000000000 +1.01000000000000000000000 -------------------------1.1001000000000000000000000000000000000000000000 S=0; E=10000010; F=10010000000000000000000 10 Floating-Point Multiplication Example IEEE-754 Single Precision Multiply 2048.12510 by -0.7510 S 100000000000.001 x -.11 ----------------1000000000.00001 -10000000000.0001 -------------------11000000000.00011 2048.125 x -.75 ---------102.40625 -1433.6875 -----------1536.09375 E F 0 10001010 00000000000001000000000 1 01111110 10000000000000000000000 • Sign Negative: 0 Å 1 = 1 • Exponent 137 = 138 + 126 – 127 • Fraction 1.00000000000001000000000 x1.10000000000000000000000 -------------------------.100000000000001000000000 +1.00000000000001000000000 -------------------------1.1000000000000110000000000000000000000000000000 S=1; E=10001001; F=10000000000001100000000 11 ...
View Full Document

This note was uploaded on 05/06/2010 for the course EECC 0306-250 taught by Professor Roymelton during the Fall '10 term at RIT.

Ask a homework question - tutors are online