Write a SMAL Hawk program that is based on the program in problem 1 of Homework 4, except that it outputs, to the display screen, the value of t at the start of each iteration:
unsigned int t = 100; while (t > 1) { output(t); if (t & 1) { t = (t * 3) + 1; } else { t = t / 2; } } output('STOP');The value of t should be printed in decimal! Successive values of t should be printed 8 characters apart on the display screen, so that as the loop iterates, the screen fills with numbers.
Note, to convert binary to decimal, you will need to divide by 10! The fastest way to divide by 10 on the Hawk machine is to multiply by .1 (decimal). Note that
.1 (decimal) = .0001100110011001100110011 ... (binary) = .1999999 ... (hexadecimal)So, to divide by 10, do this:
; R3 = R2 / 10 ; reciprocal multiply ; 1/10 = .0001 1001 1001 1001 1001 1001 1001 1001 MOVE R3,R2 ADDSR R3,0,3 ; times .001 ADDSR R3,R2,1 ; times .1001 ADDSR R3,R2,3 ; times .0011001 ADDSR R3,R2,1 ; times .10011001 ADDSR R3,R2,3 ; times .00110011001 ADDSR R3,R2,1 ; times .100110011001 ADDSR R3,R2,3 ; times .001100110011001 ADDSR R3,R2,1 ; times .1001100110011001 ADDSR R3,R2,3 ; times .0011001100110011001 ADDSR R3,R2,1 ; times .10011001100110011001 ADDSR R3,R2,3 ; times .00110011001100110011001 ADDSR R3,R2,1 ; times .100110011001100110011001 ADDSR R3,R2,3 ; times .001100110011001100110011001 ADDSR R3,R2,1 ; times .1001100110011001100110011001 ADDSR R3,R2,4 ; times .00011001100110011001100110011001You are free to make rational assumptions about any details of this assignment that are not specified here!
Note that your solution must be clearly commented, and it must begin with a title and comment that includes your name, the course number, your section, the program title (MP1 is good enough)
As in most elementary programming courses, merely making the program function correctly will not (!!) give you full credit. Commentary and formatting should make the program easy to understand, and credit will be reduced for insufficient commenting, bad formatting or for excessive or distracting commenting!
To submit your solution, use the submit command; that is, if your solution is in a file named mp1.a, use the command "submit mp1.a" to submit it for grading.