Assignment 3, due Jun 19Solutions
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!
USE "hawk.h" . = 0 LIS R3,'a' ADDSI R3,#2 ADDI R4,R3,-99 ADD R3,R3,R4 END
a) What registers does this (small and useless) Hawk program change, and what values does it put in them? Give the values in binary. (0.6 points)
R3 ends up 000000000000000000000000011000112 which is 'a'+2+0 which is 9910
R4 ends up 000000000000000000000000000000002 which is 'a'+2–99. Since this is its original value, it would be correct to say that there was no change.
b) Assemble the above instructions, by hand or by machine, and show how the program is represented in the Hawk memory. Show the result as a sequence of 32 bit words, expressed in hexadecimal. Note that it is entirely fair to ask a question like this on an exam, so you should learn to convert assembly language to binary or hex by hand. For a homework like this, you can check your work by using SMAL. (1.0 points)
000000: C21361D3 000004: FF9D63F4 000008: 00003433
The assignment called for words, but you should get partial credit if you stopped halfway to the final answer with something like this:
000000: 61D3 -- LIS R3,'a' 000002: C213 -- ADDSI R3,#2 000004: 63F4 -- ADDI R4,R3,... 000006: FF9D -- ...,-99 000008: 3433 -- ADD R3,R3,R4
00E3 0100 00D4 A3F4
a) If the Hawk CPU's program counter points to the first halfword in this sequence, what instructions does it see? Note: You can do this by hand using the appendix at the back of the Hawk manual that gives a list of Hawk instructions listed in numeric order, and you can also check your work by putting this sequence of halfwords into the Hawk emulator's memory and letting it show you the instructions it recognizes. (1.0 points)
LIL R3,#010000 LIS R4,#00 STORES R4,R3
b) What does this program fragment do? That is, what registers or memory locations does it change and what values does it put in them? (0.5 points)
It sets R3 to 1000016 and R4 to zero, and then it stores zero in memory location 1000016