Today we continue work on our assembler. In short, this is our development checklist:
strip out the cruft (unnecessary whitespace, comments)
identify addresses for all code labels
resolve all symbols to addresses
convert text instructions to binary
We accomplished steps 1 and 2 last time, but didn’t test it. Let’s write a quick infinite loop to see if it worked.
Resolving all symbols will look a bit like this:
for each instruction
if instruction is @
if symbol table does not have identifier
"declare" a new symbol and resolve a slot in RAM
look up identifier in symbol table
replace it with address
Once all addresses have been resolved, we have only a mathematical facade over the machine code. We can convert each instruction to its machine code cousin directly via this algorithm:
for each instruction
if instruction is @
'@' + 15-bit address
else
figure out assignment destination bits
figure out computation bits
figure out jump bits
'111' + computation bits + assignment destination bits + jump bits
If we have any extra time today, I can’t think of a better way to spend it than collectively playing Human Resource Machine.
Here’s your TODO list:
The next homework is posted. You will need to git pull template master to get the PDF and updated grader. Due before November 9. No later week submission on this one! It’s just three parts.