Assignment 3, Solutions
Part of
the homework for 22C:60 (CS:2630), Spring 2013
|
B 239 B -66 H 57005
A Problem: If you assemble this and load it into memory, these two bytes plus a halfword can be viewed as a single word in memory. What is the value of that word in hexadecimal? (1.2 points)
DEADBEEFThis value was chosen because it is one the best known hexadecimal values that reads as an English phrase. Other popular alternatives include FEED and DEAF. If you allow zero and one to stand for similar looking letters, a few more words become possible.
Suggestion: Do it by hand first, converting the three parts to binary and then shuffling them into the correct fields of a 32 bit word before converting the results to hex. Then check your work by assembling this code using the SMAL assembler and then loading the resulting object file into the Hawk emulator to see what actually loads in memory. If you do this, you prove that you understand what the assembler did and you check your work.
NULL = 0 VALUE = 1 BIG = 2 HEAD: W CO, VALUE+BIG AX: W DE, VALUE BE: W NULL,(BE-HEAD)+1 CO: W EE, BIG >> VALUE DE: W BE, (DE-CO)+1 EE: W AX, BIG+BIG
a) What values does this place in memory? As above, you will learn more from this question if you do it by hand and then check your work using SMAL. (0.6 points)
Here is the answer, in hex:
000000: 00000018 000004: 00000003 000008: 00000020 00000C: 00000001 000010: 00000000 000014: 00000011 000018: 00000028 00001C: 00000001 000020: 00000010 000024: 00000009 000028: 00000008 00002C: 00000004
b) If you traverse this list, starting at the head and continuing until you reach a null pointer, what integer values are found in each list element (list them from left to right and you should almost recognize a pattern -- unfortunately, the problem statement above got scrambled, and the last two list elements break the intended pattern). (0.6 points)
Here are the list elements, lifted from the above answer, and placed in order using the pointer fields of each list element:
000000: 00000018 000004: 00000003 000018: 00000028 00001C: 00000001 000028: 00000008 00002C: 00000004 000008: 00000020 00000C: 00000001 000020: 00000010 000024: 00000009 000010: 00000000 000014: 00000011Writing down the values from left to right in decimal, we get this:
3 1 4 1 9 17It was supposed to be successive digits of Pi, but for the error in the problem statement.
Here is a screen-shot from the Hawk emulator showing the result:
HAWK EMULATOR /------------------CPU------------------\ /----MEMORY----\ PC: 00001000 R8: 00000000 000FFC: NOP PSW: 00000000 R1: 0000000E R9: 00000000 000FFE: NOP NZVC: 0 0 0 0 R2: 0001003C RA: 00000000 -*001000: STORES R1,R2 R3: 00000050 RB: 00000000 001002: LEACC R2,R2,#0004 R4: 00000009 RC: 00000000 001006: LEA R8,#001034 R5: 00000000 RD: 00000000 00100A: MOVECC R0,R8 R6: 00000000 RE: 00000000 00100C: BEQ #00102C R7: 00000000 RF: 00000000 00100E: LOAD R3,R8,#0000 **HALTED** r(run) s(step) q(quit) ?(help)As it turns out, the contents of R1 and R2 are deterministic, while the contents of R3 and R4 depend on your window size. This caused the TA some difficulty in grading; those who lost credit for unexpected values of R3 and R4 may get it back by seeing the TA.