Datorsystem 1 och Datorarkitektur 1 – föreläsning 8 fredag 9 november 2007
0x heltal sträng “987” flyttal 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
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 )
Liten Demo
multiplicand multiplier partial product array double precision product n 2n n can be formed in parallel and added in parallel for faster multiplication
Multiplicand = 2 Multiplier = 5 partial product array Product = n bits 4 bits Add Multiplicand to product Don’t Add Multiplicand to product Add Multiplicand to product Don’t Add Multiplicand to product 2*5 = 10
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 = << 5 (shift left 5)
MIPS (IEEE 754) 1823 signexponentfraction (-1) sign x (1+fraction) x 2 (exponent - 127) exempel = = ½ + ¼ = Normalisera = x (2 -1 ) (-1) 1 x ( ) x 2 ( ) 128
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 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 , which is off by 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! = 1/ / / =