# Assignment 10, due April 10

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: 50 years ago, the best selling computer in the world was the PDP-8, a very small computer (even by the standards of 1965) with a 12-bit word. A binary common floating-point format on this machine uses 3 words for each floating point number: The first holds the exponent, as a 2's complement binary number from -2048 to +2047. The second and third words are the mantissa, most significant bits first, a two's complement fixed point binary fraction with the point just to the right of the sign, normalized (if possible) so the value is greater than 0.5. There is no hidden bit. Here are some examples:
```  1 = 000000000001 010000000000 000000000000 (exp = 1, mantissa = 1/2)
10 = 000000000100 010100000000 000000000000 (exp = 4, mantissa = 5/8)
0.1 = 111111111101 011001100110 011001100110 (exp = -3, mantissa = 8/10)
```

a) Given a floating point number in IEEE format in R3, write code to extract the exponent from that number and convert it to PDP-8 format in the least significant 12 bits of R4, leaving R3 unchanged. You may use R5 as a scratch register. Assume that the number is neither unnormalized nor a NaN. (0.5 points)

b) Given a floating point number in IEEE format in R3, write code to extract the mantissa from that number and convert it to PDP-8 format in the least significant 24 bits of R3 (the most significant 8 bits of R3 must be set to zero). You may use R5 and R6 as scratch registers, if necessary.

2. Background: For small x, sin xx (where x is given in radians). For somewhat larger x, we can use the first few terms of the Taylor series, so:
sin xxx3/6 + x5/120

A Problem: Given that the Hawk floating point coprocessor is already turned on, and given the value of x in R3, write Hawk code (not a subroutine, just straight line code) that computes the above approximation for sin x, leaving the result in R3. (1 point).

Note: You may need some place to store intermediate results. You can use R4 and up if necessary.

3. Background: Hardware hackers used to love the IBM PC parallel port because, if you wanted to build a new device, perhaps a robotic machine of some sort, interfacing to the parallel port was the easiest way to go. If we wanted to add a parallel port to the Hawk, we might do it like this:

A Hawk Parallel Interface
FF100010
 07 06 05 04 03 02 01 00 data
Parallel-port data register

FF100004
 07 06 05 04 03 02 01 00 IE ER DR RD
Parallel-port status and control register
IE = interrupt enable (control)
ER = error (status)
DR = direction (control, in = 0)