Download presentation
Presentation is loading. Please wait.
1
Datorsystem 1 och Datorarkitektur 1 – föreläsning 8 fredag 9 november 2007
2
0x39383700 heltal 59985408 sträng “987” flyttal 0.0001756809651851654052734375 instruktion xor $24, $9, 0x3700 All interpretations are valid. You have to explicitly tell the machine which interpretation you want. Use an integer load (lw) to interpret them as an int Use a floating point load (l.s) to interpret them as a float Use a branch or a jump (bne or j) to interpret them as an instruction
3
Eight Conditions for Signed- Magnitude Addition/Subtraction Operation ADD Magnitudes SUBTRACT Magnitudes A > BA < BA = B (+A) + (+B)+ (A + B) (+A) + (-B)+ (A – B )- (B – A )+ (A – B ) (-A) + (+B)- (A – B )+ (B – A )+ (A – B ) (-A) + (-B)- ( A + B) (+A) - (+B)+ (A – B )- (B – A )+ (A – B ) (+A) - (-B)+ (A + B) (-A) - (+B)- ( A + B) (-A) - (-B)- (A – B )+ (B – A )+ (A – B )
4
Liten Demo
7
multiplicand multiplier partial product array double precision product n 2n n can be formed in parallel and added in parallel for faster multiplication
8
Multiplicand = 2 Multiplier = 5 partial product array Product = 10 4 2n 4 0010 0101 0010 0000 0010 0000 00001010 0101 00000010 0010 00000100 0001 00001000 8 bits 4 bits Add Multiplicand to product 0000000 Don’t Add Multiplicand to product 0000001000001010 Add Multiplicand to product 0000 00010000 Don’t Add Multiplicand to product 2*5 = 10
9
Optimera.... multiplicand multiplier partial product array double precision product 2n can be formed in parallel and added in parallel for faster multiplication n n 1378 * 32 kompilator Aha! Multiplicera med 32 = 2 5 1378 << 5 (shift left 5)
10
MIPS (IEEE 754) 1823 signexponentfraction (-1) sign x (1+fraction) x 2 (exponent - 127) exempel 0.75 10 = 0 + 0.5 + 0.25 = ½ + ¼ = 0.11 2 Normalisera 0.11 2 = 1.10 2 x (2 -1 ) 10 -0.75 10 (-1) 1 x (1 + 0.1000...0) x 2 (126 - 127) 10111111110000000000000000000000 -127 128
11
During the Gulf War in 1991, a U.S. Patriot missile failed to intercept an Iraqi Scud missile, and 28 Americans were killed. A later study determined that the problem was caused by the inaccuracy of the binary representation of 0.10. incremented –The Patriot incremented a counter once every 0.10 seconds. –It multiplied the counter value by 0.10 to compute the actual time. However, the (24-bit) binary representation of 0.10 actually corresponds to 0.099999904632568359375, which is off by 0.000000095367431640625. This doesn’t seem like much, but after 100 hours the time ends up being off by 0.34 seconds—enough time for a Scud to travel 500 meters! 0.10 10 = 1/128 + 1/256 + 1/1024 +.... = 000001111..... 2
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.