Assignment 10, due Jul 17Solutions
Part of
the homework for CS:2630, Summer 2018

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 (Tuesday or Thursday). 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!
sin x =  16 x ( π – x ) 
5 π ^{2} – 4 x ( π – x ) 
In the following, you can assume that the floating point unit is already turned on and that it is running in singleprecision mode. Assume that the following floating point constants needed to evaluate the above are available and assembled into memory near your code:
ALIGN 4 F4: W 4.00 in IEEE floating point format F16: W 16.00 in IEEE floating point format FPI: W PI in IEEE floating point format F5PI2: W 5.00 * PI * PI in IEEE floating point format
A problem: Write a SMAL Hawk subroutine using the HAWK floating point unit that implements Bhaskara I's approximation of the sine function. This should take the parameter x in R3 and return the approximate sine of x in R3. Your code can use both floating point accumulators and it should conform to the standard Hawk calling sequence and the standard assumptions about subroutine register usage. (1.5 points)
SIN: ; given: R3 = x ; returns: R3 = sin(x) approximated by Bhskara I's formula LOAD R4,FPI COSET R4,FPA0 COSET R3,FPA0+FPSUB ;  pi  x COSET R3,FPA0+FPMUL ;  x(pi  x) COGET R3,FPA0 ; t = x(pi  x)  get a copy; need it twice LOAD R4,F16 COSET R4,FPA0+FPMUL ; a0 = 16x(pi  x) COSET R3,FPA1 LOAD R4,F4 COSET R4,FPA1+FPMUL ;  4x(pi  x) COGET R3,FPA1 ; t = 4x(pi  x) LOAD R4,F5PI2 COSET R4,FPA1 COSET R3,FPA1+FPSUB ;  5pi**2  4x(pi  x) COGET R3,FPA1 ; t = 5pi**2  4x(pi  x) COSET R3,FPA0+FPDIV ;  16x(pi  x) / (5pi**2  4x(pi  x)) COGET R3,FPA0 ;  put result in place JUMPS R1
The above code is written for clarity. You could probably make the code run faster by moving the LOAD instructions forward to a point before the immediately preceeding COGET so that the coprocessor can work while the CPU is doing the load.
a) 40800000 (0.3 points)
sign = +
exp = 10000001 = 2
mantissa = (1).00000000000000000000000 (parens surround the hidden bit)
value = 1.0 × 2^{2} = 4
b) 40A00000 (0.3 points)
sign = +
exp = 10000001 = 2
mantissa = (1).01000000000000000000000
value = 1.25 × 2^{2} = 5
c) 41800000 (0.3 points)
sign = +
exp = 100 00011 = 4
mantissa = (1).00000000000000000000000
value = 1.0 × 2^{4} = 16
d) 40490FDB (0.3 points)
sign = +
exp = 10000000 = 1
mantissa = (1).10010010000111111011011
value = 1.57 × 2^{1} = 3.14 = ~π
e) 42456460 (0.3 points)
sign = +
exp = 10000100 = 5
mantissa = (1).10001010110010001100000
value = 1.54 × 2^{5} = 49.28 = ~5π^{2}
Note that there are online IEEE calculators that can help you check your results, but note also that on the next midterm, you will be given a greatly simplified floating point format and asked to solve a related problem without use of any tools more powerful than pencil and paper.