CS 2734
Computer Organization II
Laboratory 9
Laboratory 9 will meet in the Sun laboratory.
Prior to the laboratory you must write a program to implement
pass 1 of a MAC-1 assembler according to the following
specifications:
- Your assembler should use use
opcodes.c and symboltable.c
from laboratories 7 and 8 without
modification to these files.
If you did not complete lab 8, you can use the
symboltable.o
object file provided by John Gardner.
- You should not do Pass 1 in your main program, but should
call a function to do it.
- The outline for Pass 1 is as follows:
- Read in lines of MAC-1 source file one at a time.
The possible valid lines are:
- A blank line.
- A line containing a label (an identifier followed by a colon).
- A line containing the
.WORD directive followed by
a number indicating the number of words to allocate.
- A line containing an opcode followed by a numerical value
or an identifier.
Valid identifiers start with a letter and contain letters,
digits, underscore, or $. Identifiers can be of any length.
- Based on the type of line, take one or more of the
following actions as appropriate:
- Update the location counter
- Insert symbol and/or value in the symbol table.
-
At the end of Pass 1, output the symbol table to standard output.
Also output the final value of the location counter.
During laboratory checkoff you will be asked to demonstrate
Pass 1 is working correctly by running the program on some
given test files:
You must hand in copies of all source,
your makefile, and your lint output. There should be no lint
errors. (Use the -m and -u options on lint to get rid
of uninformative warnings.)