Computer Science, asked by prashashwitha7730, 1 year ago

What is forward refernce problem ? how it is resolve in 2 pass assembler?

Answers

Answered by shiva198
0
In forward referencing, variable or label is referenced before it is declared. Different problems can be solved using One Pass or Two Pass forward referencing.

In One Pass forward referencing source program is translated instruction by instruction. Assembler leave address space for label when it is referenced and when assembler found the declaration of label, it uses back patching.

Two Pass forward referencing consist of two passes.

During first pass symbol table, op-code table and label table are maintained.

In op-code table instruction size and address is stored.Label and label's address is stored in label table. When label is encountered, its name is stored in label table when label declaration is found then its location is also stored in label table.

During 2nd Pass, translation from source language to machine language takes place. Instruction addresses and label addresses are used from symbol table instead of their names.

Compiler does not know where program will be executed in the memory so compiler generated logical addresses instead of absolute address. Loader also uses the Relocation Constant to solve the problem of relocation. External Referencing problem is resolved by the linker during compilation. Linker connects the object program to the code for standard library functions.

Similar questions