Exercise 6: Bits of Floats

This assignment has two parts that can be done in either order. It is open-book, open-note, and open-partner.

Part 1: Above half

Write a C++ program that reads a floating-point value (as an IEEE-754, 32-bit float; that is, using the data type float on a Windows machine) and prints either

        mantissa is a half or less
or
        mantissa is greater than a half
depending on whether the first bit of the mantissa is 1 (representing 1/2) and any other bit is 1. You will submit your solution to esubmit. Be sure to read through the notes below.

Part 2: Assembled Above Half

Rewrite the above solution in x86 with the input in register ecx and the result in register eax. That is, start main by setting ecx to the hexadecimal value of the number (as reported by BaseConvert), and have just one ret statement at the end of main, setting eax to 1 if the mantissa is above 1/2 and 0 otherwise. You must use bitwise operations and jumps in your solution. That is, you will implement an if statement to set eax appropriately.

Test your solution using the online GCC/GAS assembler. Show the program exits with the appropriate value for (at a minimum) 0.75 and 0.76. Submit a PDF to Canvas showing the two sample runs fo part 2, including your code.

You may work with other students on this assignment, but each must turn in screen shots of their own code.