# Assignment 10, due Apr 11

On every assignment, write your name legibly as it appears on your University ID card! Homework is due on paper at the start of class on the day indicated (usually Friday). Exceptions will be made only by advance arrangement (excepting "acts of God"). Late work must be turned in to the TA's mailbox (ask the CS receptionist in 14 MLH for help). Never push homework under someone's door!

1. Background: Consider this floating point format:
```  _______________
|_|_______|_____|
| | | | | | | | |
|s|   e   |  m  |
```
• s = the sign of the mantissa
• e = the biased exponent, where 1000 = 0
• m = magnitude of the mantissa, where 100 = 0.5

There are no hidden bits here, and no special cases for e = 0000 or e = 1111.

a) What is the exact decimal representation of the largest positive number in this floating point system? (0.3 points)

b) What is the exact decimal representation of the most extreme negative number in this floating point system? (0.1 points)

c) What is the exact decimal representation of the smallest nonzero positive number in this floating point system? (0.3 points)

2. Background: Now, consider what you gain by adding an IEEE-style hidden bit to this floating point number system:
• s = the sign of the mantissa
• e = the biased exponent, where 1000 = 0,
where 0000 and 0001 indicate the same exponent value,
but 0000 indicates a hidden bit value of zero,
and 1111 is reserved for NaN values like infinity.
• m = magnitude of the mantissa,
if the hidden bit is 1, 100 = 1.5
if the hidden bit is 0, 100 = 0.5
the hidden bit is 1 for all normalized mantissas.

Note that we did not move the point when we added the hidden bit, so the hidden bit is in the one's place of the mantissa.

a) What is the exact decimal representation of the largest non-infinite positive number in this floating point system? (0.3 points)

b) What is the exact decimal representation of the most extreme non-infinite negative number in this floating point system? (0.1 points)

c) What is the exact decimal representation of the smallest nonzero positive number in this floating point system? (0.3 points)

c) What is the binary representation of 1.0 in this floating point system. (0.3 points)

3. Background: Consider the problem of computing the distance between two points in the plane -- given that R3 points to one point and R4 points to another point, where each point is represented as 2 consecutive words in memory, where the words of each point represent the x and y coordinates of that point.

A problem: Write Hawk code to compute the distance, leaving the result in FPA0. Assume the floating point coprocessor is already turned on in single-precision mode. (1.0 point)

A small problem: Look at the code near the start of Chapter 12 for the GETCHAR routine. This uses the BITTST and BBR macros. What are the actual machine instructions this uses. You can solve this problem using the manual, but it might be faster to just assemble the code and look at how the Hawk emulator disassembles it. (0.3 points)