In the second pass, the assembler performs the actual translation of the program. It converts mnemonics into their corresponding binary opcodes using an instruction set lookup table.
The assembler also looks up any symbolic labels in the previously created Symbol Table and replaces them with their actual numeric memory addresses. This results in the final machine code where every instruction and operand is represented in binary.
The following table summarizes the functional differences between the two stages of the assembly process:
| Feature | Pass 1 | Pass 2 |
|---|---|---|
| Primary Goal | Build the Symbol Table | Generate Machine Code |
| Label Handling | Identifies and stores addresses | Replaces labels with addresses |
| Instruction Handling | Increments location counter | Translates mnemonics to opcodes |
| Output | Symbol Table | Object Program |
Identify the Stage: If a question asks when labels are resolved, the answer is Pass 1. If it asks when binary code is produced, the answer is Pass 2.
The Role of the Loader: Remember that the assembler does NOT run the program; it only creates the file. The loader is the utility that actually places the code into memory for execution.
Forward References: Be prepared to explain why one pass is insufficient. Without Pass 1, the assembler would encounter a 'jump' to a label it hasn't defined yet, causing a translation error.
Symbol Table Contents: Always check that the symbol table contains two specific columns: the Label Name and the Memory Address (often in Hex or Denary).