Assignment 2, due Jun 14
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" USE "ascii.h" A: ASCII "This", NUL B: ALIGN 4 C: H 'T' + ('h' << 8) H 'a' + ('t' << 8) B 0 . = . + 3 D: W A, B, C, D END
a) What are the values of the symbolic labels A, B, C, and D. (You can get these from the assembly listing file) (0.4 points)
Here are the relevant lines of the listing file, resulting from assembling line 10 of the original:
+00000010:+00000000 10 D: W A, B, C, D +00000014:+00000005 +00000018:+00000008 +0000001C:+00000010
From this, we conclude that
A = +00000000 = 0
B = +00000005 = 5
C = +00000008 = 8
D = +00000010 = 1610
b) What memory locations end up holding the values of the symbolic labels A, B, C, and D. (You can get these from the assembly listing too) (0.4 points)
The same lines of the listing file tell us this:
location +00000010 (1610) holds A
location +00000014 (2010) holds B
location +00000018 (2410) holds C
location +0000001C (2810) holds D
These are one-word (4 byte) locations, but I only gave the starting byte of each of them above.
c) If the data starting at label C is interpreted as a null-terminated character string on a bigendian computer, what is the string? (0.4 points)
If you just give a bigendian interpretation of the word in RAM, tahT.
But if the assembler and loader are bigendian too, you get hTta, which is the better answer.
d) If the data starting at label C is interpreted as a null-terminated character string on a littleendian computer, what is the string? (0.4 points)
e) What is the value of the location counter at the end of the file. (0.3 points)
The final line of the listing helps you get this:
The last address listed is +0000001C. The last value listed (+00000010) occupies 4 bytes, so the location counter will be incremented from +0000001C to +00000020 as that word is stored. Therefore, the final value is +00000020 or 3210
f) Try deleting the reference to the header file ascii.h to see what becomes undefined when you assemble your file. Based on the result of this experiment, which symbol or symbols used in the above code came from ascii.h. (0.3 points)
g) How many bytes in memory did the ALIGN directive skip over and leave uninitialized? (0.3 points)
h) One line of this file assigns to the location counter. Give an equivalent ALIGN directive. (0.3 points)
g) Which lines in the file did not assemble anything into memory. Give your answer as a list of line numbers from the source file. You can find these in the assembly listing. (0.2 points)
1, 2, 4, 5, 9, 11