Homework 4: Encoding IEEE 754 numbers and MIPS instructions
TA: Alan Christopher
Due Sunday, February 19, 2012 @ 23:59:59
Submission instructions: Submit your solution by creating a directory named "hw4". In this directory, create a file named "hw4.txt" and put your answers inside. Then run “submit hw4”.
1. What floating point numbers are represented by the following bit patterns? Give answer in decimal system, no scientific notation.
a) 0x00000000
b) 0xBF800000
c) 0x7F800000
d) 0x44802000
2. Write a function in C that converts unsigned integers into a single precision floating point representation using only integer operations. Don’t worry about imprecision in rounding the mantissa.
float unsignedToFloat( unsigned int x ) {
unsigned int result = 0;
/* Your code here. Don’t use “float” and “double” types! */
/* read the result as float and return */
return *(float*)&result;
}
For example, if x = 357, it should return 357.0 and result = 0x43B28000.
3. What MIPS instructions are represented by the following bit patterns?
a) 0x000B6FC2
b) 0x01285020
c) 0x8D09FFFC
d) 0x3322FFFC
e) 0x2008FFFC
f) 0x24EFFFFC
g) 0x3C10FFFC
4. Encode the following instructions into MIPS machine code:
Address Machine code Instruction
0x400000 (fill in) jal mul
0x401000 mul: addu $a0, $a0, $a1
0x401004 addiu $a2, $a2, -1
0x401008 bne $a2, $0, mul
0x40100c add $v0, $a0, $0
0x401010 jr $ra