Repeat:
Read the next Assembly language command
Load R1,18
Break it into the different fields it is composed of
Load R1 18
Lookup the binary code for each field
11001 01 000010010
Combine these codes into a single machine language command
1100101000010010
Output this machine language command
Until end-of-file
- very simple
- Used for
- Labels
JMP loop
- Variables
Load R1, weight
- Labels
- Assembler must replace names with address
- use a symbol table < symbol name , memory address >
- variables: if in symbol table, use it; otherwise, alloc a new memory , and put the address in symbol table
- lable : remember the address of the instruction next to the label declaration.
- but what if the label is used before declaration ?
@value
- binary: 0xxxxxxxxxxxxxxx
- where value is either
- a non-negative decimal constant , or
- a symbol referring to such a constant
- Translation to binary
- if value is a decimal constant , generate the 15-bit binary constant
- if value is a symbol, later.
- Symbol
- Variables
- Labels
- pre-defined symbols
- Use symbol table
- init symbol table with pre-dfined symbols
- first pass , add Lable symbols to symbol table
- 2nd pass , translate code
- Proposed software architecture
- Parse: unpacks each instruction into its underlying fields
- Code: translates each field into its corresponding binary value
- SymbolTable: managers the symbol table
- Main: initializes the I/O files and drives the process