- Asked 2/14
- 2075 Baisakh · 4 marks
- 2072 Magh · 4 marks
Short note: one pass and two pass assembler
Short answer
A two-pass assembler scans the source twice: first builds a symbol table, second generates machine code, easily resolving forward references. A one-pass assembler scans only once, leaving blanks for forward references to be back-patched later; it is faster and uses less memory but more complex, suited for simple assemblers.
Write a short note on one pass and two pass assembler.
An assembler translates assembly source into machine code. The translation is done in one or two scans of the source.
Two-pass assembler
- Pass 1: reads the source, maintains a location counter, builds the symbol table (labels and their addresses) and processes directives. No code is generated.
- Pass 2: reads the source again, uses the symbol table to replace labels by addresses, generates the machine code, and produces the object file and listing.
- Handles forward references (a label used before it is defined) easily, because all labels are known after pass 1.
One-pass assembler
- Scans the source only once, generating code as it reads.
- A forward reference cannot be resolved immediately; the assembler leaves the address blank, records it in a table, and back-patches it when the label is defined (or the loader fixes it later).
- Faster, needs less memory, and is suitable for small, simple assemblers.
| Point | One-pass | Two-pass |
|---|---|---|
| Source scans | 1 | 2 |
| Forward references | Needs back-patching | Resolved by symbol table |
| Speed | Faster | Slower |
| Complexity | More complex handling of references | Simpler and more reliable |
| Use | Small/simple assemblers, load-and-go | MASM, TASM, most assemblers |
MASM is a (multi-)pass assembler; two-pass is the most common textbook design.
✓ Answer checked by Claude Opus 5.5 (high effort)
Related questions
- Interface 4 KB EPROM and two 2 KB RAM · Microprocessor, chapter 4
- Cryptarithmetic ONE+ONE+TWO=FOUR · Artificial Intelligence, chapter 2 · asked 2×
- Two copper, one steel rod: 3000 kg · Strength of Materials, chapter 3 · asked 2×
- Two copper, one steel rod: 5000 kg · Strength of Materials, chapter 3 · asked 2×
- Converting two-way slope to one-way slope · Transportation Engineering I, chapter 3 · asked 2×