Skip to main content

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.
PointOne-passTwo-pass
Source scans12
Forward referencesNeeds back-patchingResolved by symbol table
SpeedFasterSlower
ComplexityMore complex handling of referencesSimpler and more reliable
UseSmall/simple assemblers, load-and-goMASM, 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)

All Microprocessor chapter 3 questions →