Skip to content
Official PYQ · 1996

GATE CS 1996 Q1.17 — Lexical Analysis

Explain with AI

The pass numbers for each of the following activities

  1. object code generation

  2. literals added to literal table

  3. listing printed

  4. address resolution of local symbols that occur in a two pass assembler

respectively are

Choose one option
View worked solution

Answer: B

In a standard two-pass assembler, the translation of assembly language to machine code is divided into two distinct phases (passes) to handle forward references and generate the final output efficiently:

Pass 1 Activities:

  • Address Resolution of Local Symbols (iv): The assembler scans the source code, maintains a Location Counter (LC), and defines the addresses of all symbols (labels) in the Symbol Table. Thus, address resolution happens in Pass 1.
  • Literals Added to Literal Table (ii): Any literal values encountered in the source code are collected and placed into a Literal Table during this initial scan. Thus, this happens in Pass 1.

Pass 2 Activities:

  • Object Code Generation (i): Using the completed Symbol Table and Literal Table from Pass 1, the assembler translates the instruction mnemonics and operands into binary machine instructions (object code). Thus, this happens in Pass 2.
  • Listing Printed (iii): The assembly listing (which displays the source code side-by-side with its generated object code and memory addresses) can only be printed once the object code is fully generated. Thus, this happens in Pass 2.

Mapping the activities to their respective pass numbers:

  1. Object code generation → 2
  2. Literals added to literal table → 1
  3. Listing printed → 2
  4. Address resolution of local symbols → 1

The resulting sequence of pass numbers is 2,1,2,12, 1, 2, 1, which corresponds to Option B.

Free practice · Your answers on this page are not saved.

Published
Report a correction
Keep exploringMore Lexical Analysis questions