Assignment 5, due Feb 17
Part of
the homework for 22C:60 (CS:2630), Spring 2012
|
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!
a) What Hawk monitor routines are relevant to this assignment? (0.5 points)
b) What parameters must you pass to each of these routines? (For the purpose of this question, the integer you want to output is the variable i.) (0.5 points)
while (i > 1) do { if (i is even) { i = i / 2; } else { i = (3 * i) + 1; } }
Note: To solve this, assuming that the variable i is in R3, you will need to use the BITTST R3,0 instruction to test the least significant bit of R3 and either BBR or BBS to do a conditional branch on the result of the test. You can divide R3 by two using SR R3,1 and you can multiply by three by repeated addition.
A problem: Give an equivalent fragment of SMAL Hawk code. The total number of instructions required is approximately ten, with about 5 labels. (1.0 points)
A problem: Write the application code of a main program for the Hawk that uses PUTAT and PUTCHAR to display an X in the center of the screen. (1.0 points)
You are welcome to substitute your code into the skeleton of a main program in order to try it, but please do not turn in the boilerplate code for the working program. Just turn in the 6 or so lines of code that do the work.