1. Introduction There are two main classes of programming languages: high level (e.g., C, Pascal) and low level. Assembly Language is a low level programming language. Programmers code symbolic instructions, each of which generates machine instructions.
An assembler is a program that accepts as input an assembly language program (source) and produces its machine language equivalent (object code) along with the information for the loader.
Assembly language program
Assembler Linker EXE
Figure 1. Executable program generation from an assembly source code
Advantages of coding in assembly language are:
Provides more control over handling particular hardware components
Figure 4. Flowchart of a translator routine
- Fills addresses and data that was unknown during Pass 1.
More lines in N
Forward References Done
Get the next line
Retrieve the name of the symbol from SSB
Get the value of the symbol from ST
Compute the location in memory
where this value will be placed
(starting address + offset)
Place the symbol value at this location
Figure 5. Second pass of a two-pass assembler.
Producing an object code, which can be placed to any specific area in memory.
Direct Address Table (DAT): contains offset locations of all direct addresses in the program (e.g., 8080 instructions that specify direct addresses are LDA, STA, all conditional jumps...). To relocate the program, the loader adds the loading point to all these locations.
assembly language program Assembler machine language program
Figure 6. Assembler output for a relocatable code.
Example 3: Following relocatable object code and DAT are generated for Example 1.
assembly language memory object code
program address in memory
LDA #0 0000 01
LDX #0 0003 05
LOOP: ADD LIST, X 0006 18
TIX COUNT 0009 2C
JLT LOOP 000C 38
RSUB 000F 4C
LIST: WORD 200 0012 00
COUNT: WORD 6 0015 00
Forward and backward references in the machine code are generated relative to address 0000. To relocate the code, the loader adds the new load-point to the references in the machine code which are pointed by the DAT.
Either all labels used in forward references are defined in the source program before they are referenced, or forward references to data items are prohibited.
- Generating the object code in memory
No object program is written out and no loader is needed. The program needs to be re-assembled every time.
Multi-Pass Assemblers Make as many passes as needed to process the definitions of symbols.
A EQU B
B EQU C
C DS 1
3 passes are required to find the address for A.
Such references can also be solved in two passes: entering symbol definitions that involve forward references in the symbol table. Symbol table also indicates which symbols are dependent on the values of others.