ISRO Scientist/Engineer CSE 2020Compiler Design › Not yet assigned to a topic
ISRO Scientist/Engineer CSE 2020 PYQ: In a two-pass assembler, resolution of subroutine calls and inclusion of labels in the symbol table is done…
In a two-pass assembler, resolution of subroutine calls and inclusion of labels in the symbol table is done during
- Asecond pass
- Bfirst pass and second pass respectively
- Csecond pass and first pass respectivelyCorrect answer
- Dfirst pass
Answer
(C) second pass and first pass respectively
Approach
A two-pass assembler splits its work so that forward references can be resolved. During the FIRST pass it scans the source line by line, advances the location counter, processes each label in the label field, and enters that label together with its assigned address into the symbol table. Thus the inclusion of labels in the symbol table is a first-pass activity. The problem with a single pass is that a forward reference (a symbol used before it is defined, e.g. a subroutine called by name before its definition appears) cannot be resolved until the symbol table is complete. Therefore all such references -- including subroutine CALL statements -- are held over and resolved in the SECOND pass, when the finished symbol table supplies the correct address and the final object code is emitted. Hence the correct pairing is: subroutine-call resolution -> second pass; label inclusion in the symbol table -> first pass, i.e. 'second pass and first pass respectively'. Among the options, A ('second pass') wrongly puts symbol-table construction in pass 2; D ('first pass') wrongly claims subroutine calls can be resolved in pass 1 without a complete symbol table; B reverses both roles; only C matches the standard two-pass model.
Reviewed by ISRO IQ Editorial Team.