The pass number for each of the following activities Object code generation…

1996

The pass number 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

  1. A.

    1, 2, 1, 2

  2. B.

    2, 1, 2, 1

  3. C.

    2, 1, 1, 2

  4. D.

    1, 2, 2, 2

Attempted by 38 students.

Show answer & explanation

Correct answer: B

Let's break down when each of the four activities occurs:

  1. Literals added to literal table (Pass 1):

    • During the first pass, the assembler scans the entire program line-by-line to build the framework. When it encounters a literal (like =5 or ='X'), it assigns a memory slot for it and adds it to the Literal Table (LITTAB).

    • Occurs in: Pass 1

  2. Address resolution of local symbols (Pass 1):

    • Pass 1 is primarily dedicated to defining symbols and labels. The assembler maintains a Location Counter (LC) to track addresses. When it sees a symbol definition (e.g., LOOP: MOV AX, BX), it resolves the address of that local symbol and stores it in the Symbol Table (SYMTAB).

    • Occurs in: Pass 1

  3. Object code generation (Pass 2):

    • Once the symbol and literal tables are fully populated with exact memory addresses after Pass 1, the assembler goes through the code a second time. It translates the mnemonics (like MOV, ADD) into their respective binary opcodes and fills in the resolved operand addresses from the tables to generate the final Object Code.

    • Occurs in: Pass 2

  4. Listing printed (Pass 2):

    • The assembly listing file contains the original source code side-by-side with its generated object code and addresses. Since the object code isn't ready until Pass 2, the listing can only be printed during Pass 2.

    • Occurs in: Pass 2

Matching the Sequence:

  • Object code generation ⟶ 2

  • Literals added to literal table ⟶ 1

  • Listing printed ⟶ 2

  • Address resolution of local symbols ⟶ 1

The resulting sequence is 2, 1, 2, 1.

Explore the full course: Gate Guidance By Sanchit Sir