Section 14.4
Translation
14.4 Assemblers
The assembler program converts assembly language into machine code.
14.4.1 Assembler Directives
These are instructions to the assembly program that do not have a machine code
equivalent.
Action is taken is taken at translation time.
E.g. .START
- Start storing object code in memory location 200
The most common use of directives is with symbolic addresses
These are an alternative to using physical addresses.
E.g. LDA 200
can be replaced with
RADIUS: .RB 1
- Reserve one byte for radius
- - -
- - -
- - -
LDA RADIUS
14.4.3 Macro Instructions
A macro is a single instruction that represents a group of instructions.
E.g. A macro to add two numbers
.MACRO ADDUP NUM1, NUM2, NUM3, RES
     LDA NUM1
     ADD NUM2
     STA RES
.END MACRO
The above would be used thus:
- - -
- - -
- - -
ADDUP 300, 301, 302
- - -
- - -
14.4.4 Two-Pass Assemblers
Such assemblers go through the assembly language twice when producing machine
code.
The First Pass
- Comments are removed
- Entries are made in the symbol table - these are symbol names and
memory addresses
- Directives are carried out
- Macro instructions are replaced by their full set of instructions
- Errors found and reported
The Second Pass
- Mnemonics are replaced by their machine code equivalents
- Memory addresses (listed in the symbol table) are replaced by actual
machine code addresses
- Decimal, hexadecimal and character items are replaced by machine code
equivalents
- Further errors are reported