34. Explain how an assembler works, including how it generates the symbol table, what it does with source and object code, and how it handles labels.
The Assembler is a Software that converts an assembly language code to machine code.
Types of Assembler
Assemblers generate instruction. On the basis of a number of phases used to convert to machine code, assemblers have two types:
1. One-Pass Assembler
These assemblers perform the whole conversion of assembly code to machine code in one go.
2. Multi-Pass/Two-Pass Assembler
These assemblers first process the assembly code and store values in the opcode table and symbol table. And then in the second step, they generate the machine code using these tables.
Object code is nothing but ,machine code.
a) Pass 1
b) Pass 2
The asssembler records the reference to the label name in a table and emits a jump with a dummy address. Later, when the label definition is encountered and the instruction pointer is therefore known, the assembler goes through the table of references to this label and patches in the - now known - address.