in Compiler Design edited by
1,784 views
0 votes
0 votes

Which activity is included in the first pass of two pass assemblers?

  1. Build the symbol table

  2. Construct the intermediate code

  3. Separate mnemonic opcode and operand fields

  4. None of these

in Compiler Design edited by
1.8k views

1 comment

(a) Building the symbol table happens in the first pass.
1
1

3 Answers

2 votes
2 votes

The assembler generates correct instructions by scanning the program code twice. The first time it count how long the machine instructions will be to find out address of all the LABELS.

This first scan leads to creation of a symbol table that has list of all addresses and where they will be in the program. This table is know as symbol table.

On the second scan, machine code is generated and the symbol table is used to generate the correct addresses.

Therefore a 2 pass assembler scans the program and creates the symbol table in first pass and in second pass it generates the machine code.

Hence, Only Option A is right.

0 votes
0 votes

All three activities are included in pass 1 of the assembler.

Check slide no. 18 and 24 of the following link.

https://www.slideshare.net/dattatraygandhmal/assemblers-33585130

0 votes
0 votes

The functions performed in pass 1 and pass 2 in 2 pass assembler are

Pass 1

  1. Assign addresses to all statements in the program.
  2. Save the values assigned to all labels for use in pass 2
  3. Perform some processing of assembler directives.
  4. Separate the symbol, mnemonic, opcode and operand.
  5. Perform LC processing.
  6. Construct the Intermediate representation.

Pass 2

  1. Assemble instructions.
  2. Generate data values defined by BYTE, WORD etc.
  3. Perform processing of assembler directives not done during pass 1.
  4. Write the program and the assembling listing.
  5. Process IR to synthesize the target program

A,B,C are correct.

Ref: https://gateoverflow.in/2721/gate1996-1-17

https://www.slideshare.net/dattatraygandhmal/assemblers-33585130 (slide 24)

edited by

2 Comments

Who does option C?
1
1

As per this reference its also done by pass 1 only.

https://www.slideshare.net/dattatraygandhmal/assemblers-33585130 (slide 24)

Have edited the answer sir.

0
0