1 / 21

CS 230: Computer Organization and Assembly Language

CS 230: Computer Organization and Assembly Language. Aviral Shrivastava. Department of Computer Science and Engineering School of Computing and Informatics Arizona State University. Slides courtesy: Prof. Yann Hang Lee, ASU, Prof. Mary Jane Irwin, PSU, Ande Carle, UCB. Announcements. Quiz 2

moke
Download Presentation

CS 230: Computer Organization and Assembly Language

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CS 230: Computer Organization and Assembly Language Aviral Shrivastava Department of Computer Science and Engineering School of Computing and Informatics Arizona State University Slides courtesy: Prof. Yann Hang Lee, ASU, Prof. Mary Jane Irwin, PSU, Ande Carle, UCB

  2. Announcements • Quiz 2 • Project 2 • Quiz 3 • Thursday, Oct 06, 2009 • Complete Chapter 3 • Project 3 • Implement an assembler

  3. Floating Point (Real) Numbers • We need a way to represent • numbers with fractions, e.g., 3.1416 • very small numbers, e.g., .000000001 • very large numbers, e.g., 3.15576 ´ 109 • Representation: • sign, exponent, significand: (–1)sign ´ significand´ 2exponent • more bits for significand gives more accuracy • more bits for exponent increases range • IEEE 754 floating point standard: • single precision: 8 bit exponent, 23 bit significand

  4. IEEE 754 floating-point standard • IEEE Floating Point: (-1)S 1.M  2 E-127 • Mantissa (sign and magnitude -- S, M) • Exponent (excess 127 binary number -- E) S E M 1 bit 8 bits 23 bits • Example: • decimal: -.75 = - ( ½ + ¼ ) • binary: -.11 = -1.1 x 2-1 • floating point: exponent = 126 = 01111110 • IEEE single precision: • 1 01111110 10000000000000000000000

  5. Remember • For FP Number <SEM> • Value = (-1)S*1.M*2E-127 • 1st bit is the sign bit • Exponent = E-127 • Why? • Mantissa is after the decimal • 1.1100111  Mantissa is 1100111

  6. IEEE FP Numbers 0 .609375 x 2 1 .21875 x 2 0 .4375 x 2 0 .875 x 2 1 .75 x 2 1 .5 x 2 1 .0 • Example: 0 1000 0011 1101 0000 0000 0000 0000 000 • S = 0 (positive mantissa), E =131 - 127= 4, and M =.1101 • the number =1.1101 x 24=11101 =29 • Example: 1 0111 1011 1101 0000 0000 0000 0000 000 • S = 1 (negative mantissa), E =123 - 127=-4, and M =.1101 • the number =-1.1101 x 2-4=-0.00011101 =-(2-4+ 2-5+ 2-6+ 2-8) =-0.11328125 • Example: -10.609375 10.609375 = (1010.100111)2 = 1.010100111 x 23 • S =1, E =3+127=130 =1000 0010, and M =010100111 ... • FP:1 1000 0010 0101 0011 1000 0000 0000 000

  7. FP Addition Compute 9.999*101 + 1.610*10-1, assuming only 3 places in decimal • Make the exponents same • 9.999*101 + 0.01610*101 • Add the significands • 10.015*101 • Normalize • 1.0015*102 • Round-off • 1.002*102

  8. FP Addition • Example 1.1101 x 23 + 1.001 x 2-1 = 1.1101 x 23 + 0.0001001x23 =1.1110001 x 23 • Steps: X(m,e) + Y(m,e) • Shift the smaller operand --- align binary point • compute Ye-Xe, right shift XmXm’ if Ye > Xe • Add magnitudes (Xm’ + Ym) • Normalize and round-off if necessary

  9. FP Subtraction • 0.510 – 0.437510 • Step 1: Convert into FP Representation • 0.510 = 1.000 x 2-1 • -0.437510 = -1.110x2-2 • Step 2: Shift significand of smaller number • -1.110x2-2 = -0.111x2-1 • Step 3: Subtract the significands • 1.000 x 2-1 - 0.111x2-1 = 0.001x2-1 • Step 4: Normalize the sum, check for over/underflow • = 0.001x2-1 = 1.000x2-4 • Step 5: Round off • 1.000x2-4 • Step 6: Result • 1.000x2-4 = 0.0625

  10. FP Multiply Compute 1.110*1010 *9.200*10-5 assuming digit significands • Add the exponents • Exponent = 10-5 = 5 • Multiply the significands • 1.110*9.200 = 10.212000 • Normalize • 1.0212000*106 • Round-off • 1.021*106

  11. FP Multiply • Assume 4-bit mantissa • compute 0 0111 1110 0101 x 0 0111 1101 1110 • add exponent and adjust the bias: 0111 1110 + 0111 1101 - 0111 1111 = 0111 1100 • multiply 1.0101 and 1.1110 10.0111 0110 • normalize and detect underflow or overflow: exponent: 0111 1101, mantissa: 1.0011 1011 0 • round the product and the result is 0 0111 1101 0100 • compute (1.0101 x 2-1 ) x (1.1110 x 2-2) = .65625 x .46875 =0.3076171875 = 10.01110110 x 2-3 = 1.001110110 x 2-2 = .3076171875 = 0 0111 1101 0100 = .3125

  12. IEEE 754 Floating Point Numbers • Special Representation • When exponent is 1111 1111 or 0000 0000

  13. IEEE 754 FP Representation • There are two Zeroes • +0 (s is 0) and −0 (s is 1) • There are two Infinities • +∞ (s is 0) and −∞ (s is 1) • Numbers closest to zero • is a denormalized value • all 0s in the Exp field and the binary value 1 in the Fraction field • ±2−149 ≈ ±1.4012985×10−45 • Normalized numbers closest to zero • binary value 1 in the Exp field and 0 in the fraction field) • ±2−126 ≈ ±1.175494351×10−38 • Finite numbers furthest from zero • 254 in the Exp field and all 1s in the fraction field • ±(1-2-24)×2128[2] ≈ ±3.4028235×1038

  14. Inaccuracy in FPs • Double precision arithmetic • Double word – 64-bits • 11 bit exponent, 52 bit mantissa

  15. FP numbers • Limited precision: (- 1.5 x 1038 + 1.5 x 1038 ) + 1 = 0 + 1 = 1 -1.5 x 1038 + (1.5 x 1038 + 1) = -1.5 x 1038 + 1.5 x 1038 = 0 • A view of FP representation, (assume 4 bit precision) • There is a big gap between two large consecutive numbers: • gap = 2-23 x 2e-127 • Add de-normal numbers (exponent=0, mantissa >0) to fill the gap between 0 and 2-126 de-normal numbers 0 2-126 2-125 2-124

  16. The Patriot Missile Failure • On February 25, 1991, during the Gulf War, an American Patriot Missile battery in Dharan, Saudi Arabia, failed to track and intercept an incoming Iraqi Scud missile. The Scud struck an American Army barracks, killing 28 soldiers and injuring around 100 other people http://www.ima.umn.edu/~arnold/disasters/patriot.html

  17. The Patriot Missile Failure - I • Computed time on 1/10th of seconds • In 24-bit precision arithmetic • Truncation instead of round-off • 1/10 = 0.0001100110011001100110011001100 • Patriot Stored • 0.00011001100110011001100 • Error • 0.0000000000000000000000011001100 • = 0.000000095 decimal

  18. The Patriot Missile Failure • Patrioit battery was up for more than 100 hours • Accumulated Error: • 0.000000095×100×60×60×10=0.34 1/10ths of a second • Speed of scud is 1,676 meters per second, and so travels more than half a kilometer in this time • Completely out of range

  19. Explosion of the Ariane 5 On June 4, 1996 an unmanned Ariane 5 rocket launched by the European Space Agency exploded just forty seconds after its lift-off from Kourou, French Guiana. The rocket was on its first voyage, after a decade of development costing $7 billion. The destroyed rocket and its cargo were valued at $500 million. A board of inquiry investigated the causes of the explosion and in two weeks issued a report. It turned out that the cause of the failure was a software error in the inertial reference system. Specifically a 64 bit floating point number relating to the horizontal velocity of the rocket with respect to the platform was converted to a 16 bit signed integer. The number was larger than 32,767, the largest integer storeable in a 16 bit signed integer, and thus the conversion failed.

  20. The Number Agenda • Unsigned Numbers • Representation, • Addition, Subtraction • Multiplication, Division • Signed Numbers • Representation • Addition, Subtraction • Multiplication, Division • Floating Point Numbers (For large and fractions) • Representation • Addition, Subtraction • Multiplication (d31 d30 … d2 d1 d0)2 = d31*231 + d30*230 + … d2*22 + d1* 21 + d0*20 (d31 d30 … d2 d1 d0)2 = (-1)*231 + d30*230 + … d2*22 + d1* 21 + d0*20 (d31 d30 … d2 d1 d0)2 = (-1)*d31 * 1.d22… d0* 2(d30…d23 - 127)

  21. Yoda says… • Luke: I can’t believe it. • Yoda: That is why you fail

More Related