Assignment 3, due Jun 20
Part of
the homework for 22C:60, Summer 2005
|
Always, on every assignment, please write your name legibly as it appears on your University ID and on the class list! All assignments will be due at the start of class on the day indicated, and unless there is what insurance companies call "an act of God" - something outside your control; the only exceptions to this rule will be by advance arrangement.
Remember, summer session goes very quickly! You will fall behind very quickly if you do not keep up with the work.
a) What is the minimum storage required by each component of each array element, assuming that each is allotted the minimum possible number of bits. Also give the sum total number of bits per array element. (1/2 point)
b) Show how the fields of one array entry can be arranged in the memory of a Hawk computer, paying attention to all alignment constraints, and from this, suggest how many bytes per array entry would be consumed if this array was part of a Hawk program. (1/2 point)
c) Given your answer to part b, if the array A begins at address a, what is the address of array element A[i]? Give a general formula that will work for any value of i. (1/2 point)
d) Consider the unlikely possibility that the array is a constant, and that you are writing SMAL code to assemble this constant value into memory. Assume that the location counter has already been set to the address of A[i], and give a fragment of code to initialize this element (in terms of your answer to part b) so that it describes the label for the town of Ffestiniog (with blanks added to pad it to 12 letters), at coordinates 12766, 27832, where the name is to be printed in size 3 (it is a small town), and at an angle of 25. (1/2 point)
Problem: Give a SMAL macro definition for a macro that assembles a critter description record into memory. (1 point)
Example: Here is some text that calls this macro:
CRITTER "horse",4,0 CRITTER "bird",2,2 CRITTER "beetle",6,2
Note: Notice that nothing in the macro call deals with the issue of null termination, and nothing explicitly conveys the character count. There are several clever ways of dealing with the latter problem. If you ignore the problem of sensing errors (critter names with too many letters), the easy solution is a macro that expands to something like this:
X = . ASCII "horse",0 ; critter name . = X + 16 ; allow for maximum name size (including null) B 4 ; critter leg count B 0 ; critter wing count
Write a SMAL program for the Hawk computer that sets all of the locations in the HAWK RAM to the hexadecimal value ABADABBA. Your program should begin in location zero of memory. If we had a C compiler for the Hawk, the equivalent C code might look something like this fragment:
int p = 0x10000; while (p < 0x20000) do { * (int *) p = 0xABADABBA; p = p + 4; }
Hints: Your program can fake up a halt with a jump to location 0. Don't bother with the elaborate Hawk macros, this program is small and simple enough that you can write it in hex (lots of Halfword directives). You'll learn more this way.
Format Constraints: Your result should be in a file called mp1.a; this must begin with the following (edited with your name where indicated):
TITLE "MP1 by YOUR NAME HERE"
Comments must be added where needed to make the program readable. Given that it is in hexadecimal, it will take a good number of comments to do this.
Submitting your result: Use the submit command on the department linux cluster to submit your solution. Your complete submit dialogue will look like this:
[you@serv16 ~/assem]$ submit mp1.a Course (22C:016 would be c016): c060 Possible submit directories for /group/submit/c060 are: mp1 Choice: mp1 mp1.a * File/directory mp1.a has been * copied to /group/submit/c060/mp1/mp1.a.you. [you@serv16 ~/assem]$
Grading: This is a trivial program, most students should have something that works! Out of 5 points, you will receive penalties of: