In: Computer Science
3.21 [10] <§3.5> If the bit pattern 0×0C000000 is placed into the Instruction Register, what MIPS instruction will be executed?
3.22 [10] <§3.5> What decimal number does the bit pattern 0×0C000000 represent if it is a floating point number? Use the IEEE 754 standard.
Given the following 32-bit binary sequences representing single precision IEEE
754 floating point numbers:
a = 0100 0000 1101 1000 0000 0000 0000 0000
b = 1011 1110 1110 0000 0000 0000 0000 0000
Perform the following arithmetic and show the final addition and multiplication results in both normalized binary format and IEEE 754 single-precision format. Show your steps (Do not convert a and b to decimal base, compute the addition and multiplication, then convert the results back to normalized binary and single precision).
a) a + b
b) a × b
3.21) 0x0C000000 Converting 0C000000 to binary 0 => 0000 C => 1100 0 => 0000 0 => 0000 0 => 0000 0 => 0000 0 => 0000 0 => 0000 So, in binary 0C000000 is 00001100000000000000000000000000 => 00001100000000000000000000000000 => 000011 00000000000000000000000000 => I-type instruction 000011 is jal => jal 0 Answer: jal 0 3.22) in binary 0C000000 is 00001100000000000000000000000000 0 00011000 00000000000000000000000 sign bit is 0(+ve) exp bits are 00011000 Converting 00011000 to decimal 00011000 => 0x2^7+0x2^6+0x2^5+1x2^4+1x2^3+0x2^2+0x2^1+0x2^0 => 0x128+0x64+0x32+1x16+1x8+0x4+0x2+0x1 => 0+0+0+16+8+0+0+0 => 24 in decimal it is 24 so, exponent/bias is 24-127 = -103 frac bits are IEEE-754 Decimal value is 1.frac * 2^exponent IEEE-754 Decimal value is 1.0 * 2^-103 Answer: 2^-103 1 * 2^-103 in decimal is 9.860761315262648e-32 so, 00001100000000000000000000000000 in IEEE-754 single precision format is 9.860761315262648e-32 Answer: 2^-103 or 9.860761315262648e-32 3.23) a = 0 10000001 10110000000000000000000 sign bit is 0(+ve) exp bits are 10000001 Converting 10000001 to decimal 10000001 => 1x2^7+0x2^6+0x2^5+0x2^4+0x2^3+0x2^2+0x2^1+1x2^0 => 1x128+0x64+0x32+0x16+0x8+0x4+0x2+1x1 => 128+0+0+0+0+0+0+1 => 129 in decimal it is 129 so, exponent/bias is 129-127 = 2 frac bits are 1011 IEEE-754 Decimal value is 1.frac * 2^exponent IEEE-754 Decimal value is 1.1011 * 2^2 b = 1 01111101 11000000000000000000000 sign bit is 1(-ve) exp bits are 01111101 Converting 01111101 to decimal 01111101 => 0x2^7+1x2^6+1x2^5+1x2^4+1x2^3+1x2^2+0x2^1+1x2^0 => 0x128+1x64+1x32+1x16+1x8+1x4+0x2+1x1 => 0+64+32+16+8+4+0+1 => 125 in decimal it is 125 so, exponent/bias is 125-127 = -2 frac bits are 11 IEEE-754 Decimal value is 1.frac * 2^exponent IEEE-754 Decimal value is 1.11 * 2^-2 a) a + b = 1.1011 * 2^2 - 1.11 * 2^-2 = 1.1011 * 2^2 - 0.000111 * 2^2 = 1.100101 * 2^2 single precision: -------------------- sign bit is 0(+ve) exponent bits are (127+2=129) => 10000001 Divide 129 successively by 2 until the quotient is 0 > 129/2 = 64, remainder is 1 > 64/2 = 32, remainder is 0 > 32/2 = 16, remainder is 0 > 16/2 = 8, remainder is 0 > 8/2 = 4, remainder is 0 > 4/2 = 2, remainder is 0 > 2/2 = 1, remainder is 0 > 1/2 = 0, remainder is 1 Read remainders from the bottom to top as 10000001 So, 129 of decimal is 10000001 in binary frac/significant bits are 10010100000000000000000 so, a+b in single-precision format is 0 10000001 10010100000000000000000 Answer: ---------- normalized binary format: 1.100101 * 2^2 IEEE 754 single-precision format: 0 10000001 10010100000000000000000 b) a x b = 1.1011 * 2^2 x -1.11 * 2^-2 = 1.1011 x -1.11 = -10.111101 = -1.0111101 * 2^1 single precision: -------------------- sign bit is 1(-ve) exponent bits are (127+1=128) => 10000000 Divide 128 successively by 2 until the quotient is 0 > 128/2 = 64, remainder is 0 > 64/2 = 32, remainder is 0 > 32/2 = 16, remainder is 0 > 16/2 = 8, remainder is 0 > 8/2 = 4, remainder is 0 > 4/2 = 2, remainder is 0 > 2/2 = 1, remainder is 0 > 1/2 = 0, remainder is 1 Read remainders from the bottom to top as 10000000 So, 128 of decimal is 10000000 in binary frac/significant bits are 01111010000000000000000 so, a x b in single-precision format is 1 10000000 01111010000000000000000 normalized binary format: -1.0111101 * 2^1 IEEE 754 single-precision format: 1 10000000 01111010000000000000000