Skip to content
Official PYQ · 1993

GATE CS 1993 Q7.6 — Lexical Analysis

Explain with AI

A simple two-pass assembler does the following in the first pass:

Select all correct options
View worked solution

Answer: A;B;C

A traditional two-pass assembler splits the translation process into two distinct phases to handle forward references of symbols effectively.

Pass 1: Analysis and Symbol Definition

The primary objective of the first pass is to scan the source code, determine the memory allocation for instructions and data, and build a dictionary of symbols. Specifically, it performs the following tasks:

  • Building the Symbol Table (Option C): It identifies labels (symbols) and associates them with their corresponding memory addresses (values) using a Location Counter (LC).
  • Allocating Space for Literals (Option A): Literals (constants specified directly in instructions) are gathered, and memory space is allocated for them (typically in a literal pool at the end of the program).
  • Computing Program Length (Option B): By tracking the Location Counter from the starting address to the end of the program, the assembler determines the total size/length of the program.

Pass 2: Code Generation

  • Generating Machine Code (Option D): Code generation for instructions (such as load, store, arithmetic, etc.) is performed in the second pass, once all symbol addresses have been resolved and are available in the symbol table.

Thus, statements A, B, and C are correct tasks performed during the first pass.

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

Published
Report a correction
Keep exploringMore Lexical Analysis questions