assembler module is responsible for taking lines
of assembly code and processing it to generate equivalent machine code.
It is passed a list of strings which are the lines of the assembly file. Each
line is then processed and the information about the line stored in
During processing each line is checked to see if it’s a constant definition, if
not, it’s treated as an assembly line and
parsed into machine code bytes.
The line is passed to
each operation to attempt to
generate the machine code bytes. The operations can expect certain tokens on the
line to be constants and are identified as such and returned to the assembler.
The constants are then
validated and identified and the machine code bytes added to the
dictionary of information about the line of assembly.
With all the lines processed, machine code bytes generated and constants
identified, the assembler
checks for overall validity and structure The assembler then performs global operations that
need to take the entire assembly code into account:
Assigning indexes to the machine code bytes
Assigning labels to machine code bytes
Resolving labels to indexes in program memory
Resolving number constants to bytes
Resolving variable constants to indexes in data memory
With these checks, assignments and resolutions complete, the final assembly line dictionaries are returned.