GATE / CS ARCHIVE

SUBJECT COLLECTION

Compiler Design · Compiler Phases, Linking & Loading

31 questions, newest first

GATE CSE has asked 31 questions on Compiler Phases, Linking & Loading (Compiler Design) from 1991 to 2024, in 19 of the 46 papers; the most recent is in GATE CSE 2024 Set 2. In the last five years it carried 0.2 marks per 100-mark paper on average, against 0.3 since 2003. Since 2014 the questions have been 8 MCQ. 1 group of questions here are solved the same way; “One per method” keeps the newest of each.

Browse topics
1 mark · MCQ
Report issue

Match compiler phases to their products

Compiler Phases, Linking & Loading

Question 21, GATE 2024: Match P lexical analyzer, Q syntax analyzer, R intermediate code generator, S code optimizer to 1 abstract syntax tree, 2 token, 3 parse tree, 4 constant folding. A 4,1,3,2; B 2,3,1,4; C 2,1,3,4; D 4,3,2,1 (listed in P,Q,R,S order).
Tap to enlarge
Your answer
Answer & solution

Official answer: B

Approach: Follow the conventional progression from source characters to structure to intermediate form to optimization.

1. Derivation. Lexical analysis produces tokens(P–2). Syntax analysis constructs a parse tree(Q–3). An abstract syntax tree is a common intermediate representation associated with intermediate-code generation(R–1). Constant folding is a code optimization(S–4). This gives B. Practical compilers can construct ASTs during parsing too; these are the conventional matches among the listed choices, not exclusive ownership of representations.

2. Explanation and checks. A lexer recognizes lexemes such as identifiers and produces tokens; a parser groups tokens according to grammar productions and yields a parse tree. An AST removes grammar-only detail to represent the essential operators and operands, so among these choices it is the intermediate representation. Constant folding replaces an expression such as 3×4 with 12. Real implementations may combine phase boundaries, but B is the intended one-to-one conceptual match.

Original paper, page 15 · Answer key

1 mark · MCQ
Report issue

Compiler Phases, Linking & Loading

Question 11, GATE 2023: Assess compiler statements S1: front-end phases are target-hardware independent; S2: back-end phases are target-hardware specific; S3: back-end phases are specific to the source programming language. A S1 only; B S1,S2; C all; D S1,S3.
Tap to enlarge
Your answer
Answer & solution

Official answer: B

The front end analyzes the source language and produces a target-independent representation, making S1 true. The back end maps that representation to the target instruction set and hardware, making S2 true. Source-language-specific analysis is normally a front-end responsibility rather than a back-end phase, so S3 is false. Thus B.

Teaching detail. Lexical analysis, parsing, and semantic/type analysis must understand source-language rules, but need not know the final processor's register set. Conversely, instruction selection, register allocation, and machine-code generation depend on the target. An intermediate representation is the interface separating these responsibilities. Particular compilers may mix optimizations across this boundary, but the question concerns the standard conceptual division; source-language semantics do not become a back-end-specific phase merely because the back end receives their translated representation.

Original paper, page 8 · Answer key

1 mark · MCQ
Report issue

Compiler Phases, Linking & Loading

Question 9, GATE 2020: Test I: symbol tables are accessed only in lexical and syntax analysis. II: supporting recursion necessarily requires heap allocation. III: declaration-before-use errors are detected during syntax analysis. Options: A I only; B I and III; C II only; D none.
Tap to enlarge
Your answer
Answer & solution

Official answer: D

Worked explanation

A symbol table records information such as declarations, types and locations. Type checking needs that information in semantic analysis, and code generation may need offsets and storage locations, so “only” makes I false. Recursive calls need distinct activation records, but their last-in-first-out lifetimes are exactly what a runtime stack handles; a heap is not logically necessary. Finally, syntax checks whether token sequences fit grammatical productions, whereas whether a particular name has already been declared depends on the binding environment. That contextual condition belongs to semantic analysis in the conventional compiler-phase distinction used here.

Derivation and answer

Semantic analysis and code generation also consult symbol-table information, refuting I. Ordinary nested recursion can be supported with stack activation records and does not inherently need a heap, refuting II. Declaration-before-use is a contextual semantic condition, not ordinary context-free syntax checking, refuting III. Thus none, D.

Original paper, page 5 · Answer key

1 mark · MCQ
Report issue

Compiler phase ordering

Compiler Phases, Linking & Loading

Question 8, GATE 2018: Choose the false claim: A CFGs can specify lexical and syntactic rules; B type checking precedes parsing; C high-level code can translate to different intermediate representations; D function arguments can be passed on the program stack.
Tap to enlarge
Your answer
Answer & solution

Official answer: B

Method

Parsing identifies constructs such as expressions, declarations and function calls. Type checking applies rules to those constructs and their symbol-table information, so the conventional dependency is syntax before semantic type checking. A compiler may interleave actions during parsing, but that does not establish the blanket claim in B. Regular token languages are also context-free, which is why A is expressively valid even though practical lexers usually use regular expressions.

Solution

Parsing supplies the syntactic structure on which conventional type checking operates, so saying type checking is performed before parsing is false, B. CFGs can express regular lexical rules as well as syntax, multiple intermediate representations are possible, and stack argument passing is standard.

Original paper, page 5 · Answer key

1 mark · MCQ
Report issue

Compiler Phases, Linking & Loading

Question 5, GATE 2017: Match compiler inputs P:syntax tree, Q:character stream, R:intermediate representation, S:token stream with phases i:code generator, ii:syntax analyzer, iii:semantic analyzer, iv:lexical analyzer. Options (P,Q,R,S): A:(ii,iii,iv,i), B:(ii,i,iii,iv), C:(iii,iv,i,ii), D:(i,iv,ii,iii).
Tap to enlarge
Your answer
Answer & solution

Official answer: C

1. Follow the compiler pipeline from source text. The lexical analyzer reads characters and groups them into tokens, so Q→iv. The syntax analyzer reads those tokens and recognizes grammatical structure, so S→ii.

2. Semantic analysis then uses the syntax tree to check matters such as declarations, types, and compatible operations; hence P→iii.

3. After front-end processing and intermediate-code construction, the code generator translates the intermediate representation into target code, giving R→i. In the requested P,Q,R,S order the mapping is (iii,iv,i,ii), option C. Do not confuse a phase's output with its input.

Original paper, page 3 · Answer key

1 mark · MCQ
Report issue

Compiler Phases, Linking & Loading

Question 19, GATE 2016: Match P lexical analysis, Q top-down parsing, R semantic analysis, S runtime environments with i leftmost derivation, ii type checking, iii regular expressions, iv activation records. A P-i,Q-ii,R-iv,S-iii; B P-iii,Q-i,R-ii,S-iv; C P-ii,Q-iii,R-i,S-iv; D P-iv,Q-i,R-ii,S-iii.
Tap to enlarge
Your answer
Answer & solution

Official answer: B

Lexical analysis uses regular expressions; top-down parsing constructs a leftmost derivation; semantic analysis checks types; runtime environments organize activation records. Hence P-iii, Q-i, R-ii, S-iv, B.

A lexer recognizes tokens such as identifiers and numbers from character patterns. A top-down parser expands the leftmost pending nonterminal toward the input. Semantic analysis rejects type-incompatible expressions even when their syntax parses. Activation records store each call’s parameters, locals and return information at runtime; this separates all four roles.

Original paper, page 30 · Answer key

1 mark · MCQ
Report issue

Compiler Phases, Linking & Loading

Question 27, GATE 2015: Match P lexical analysis, Q parsing, R register allocation, S expression evaluation with 1 graph colouring, 2 DFA minimization, 3 postorder traversal, 4 production tree. A P2Q3R1S4; B P2Q1R4S3; C P2Q4R1S3; D P2Q3R4S1.
Tap to enlarge
Your answer
Answer & solution

Official answer: C

Lexical analysis uses minimized DFAs; parsing constructs production/parse trees; register allocation uses interference-graph coloring; expression evaluation visits operands before operators in postorder. Therefore P-2, Q-4, R-1, S-3, C.

Lexical patterns are recognized by finite automata, which can be minimized without changing recognized tokens. Parsing uses grammar productions organized into a parse tree. Register-allocation interference graphs put simultaneously live variables at adjacent vertices, so colouring assigns nonconflicting registers. To evaluate an expression tree, children must be evaluated before their operator parent, which is postorder. Combining all four gives the single complete matching C.

Original paper, page 35 · Answer key

1 mark · MCQ
Report issue

Compiler Phases, Linking & Loading

Question 18, GATE 2014: Which is not performed during compilation of a program? A dynamic memory allocation; B type checking; C symbol-table management; D inline expansion.
Tap to enlarge
Your answer
Answer & solution

Official answer: A

1. Set up the reasoning. Distinguish work done on the source representation by a compiler from operations performed by the compiled program when it runs. A dynamic allocation creates runtime objects whose sizes or lifetimes may depend on execution.

2. Derive the result. Allocation of the running program’s dynamic objects occurs at runtime. Type checking, symbol-table construction and inline expansion are compiler tasks. Thus A. A compiler may itself allocate memory while running, but that is not the intended meaning of program dynamic allocation.

3. Check the interpretation. The compiler may emit allocation calls and itself allocate memory while compiling; those facts do not make allocation of the target program's runtime objects a compilation phase. Type checks, names, and inlining are standard compile-time concerns.

Original paper, page 33 · Answer key

1 mark · MCQ
Report issue

Compiler activity matching

Compiler Phases, Linking & Loading

Question 17, GATE 2009: Match P regular expressions, Q pushdown automata, R dataflow analysis, S register allocation to 1 syntax analysis, 2 code generation, 3 lexical analysis, 4 code optimization. A P4Q1R2S3; B P3Q1R4S2; C P3Q4R1S2; D P2Q1R4S3.
Tap to enlarge
Your answer
Answer & solution

Answer: B (no official key was published)

Regular expressions specify tokens for lexical analysis(P→3). Pushdown automata model syntax analysis(Q→1). Dataflow facts support code optimization(R→4), while register allocation is part of code generation(S→2). Hence B.

Regular expressions specify lexical tokens, giving P3. A pushdown store models nested grammatical structure in syntax analysis, giving Q1. Dataflow facts support optimizations such as dead-code elimination and constant propagation, giving R4. Register allocation assigns machine storage during code generation, giving S2. All four pairings are needed: option B is the unique complete match.

Original paper, page 3

1 mark · MCQ
Not in GATE 2027 syllabusReport issue

Resolving an external function reference

Compiler Phases, Linking & Loading

Question 9, GATE 2004: A program has separately stored source modules M1 and M2. M1 refers to a function defined in M2. At what stage is this reference resolved in the conventional separate-compilation model?
Options:
(A) Edit time
(B) Compile time
(C) Link time
(D) Load time
Tap to enlarge
Your answer
Answer & solution

Answer: C (no official key was published)

1. With conventional separate compilation and static linking, each module produces an object file with symbol definitions/references. The linker matches the external reference in M1 to the definition in M2, so link time, C.

2. Dynamic loading can defer binding, but is not the default compilation model stated here.

3. Teaching check: Compilation can emit an unresolved external symbol into M1’s object file. Linking has access to both objects and supplies the address from M2. Editing only changes text; loading places an already linked image into memory under the assumed static-binding model.

Original paper, page 2

1 mark · MCQ
Not in GATE 2027 syllabusReport issue

Assigning load addresses and adjusting references

Compiler Phases, Linking & Loading

Question 1.17, GATE 2001: What is the process of assigning actual load addresses and adjusting program address references: assembly, parsing, relocation, or symbol resolution?
Tap to enlarge
Your answer
Answer & solution

Answer: C (no official key was published)

Step 1: Object code can contain address-dependent references expressed relative to an initially assumed location. Loading the program elsewhere requires assigning its actual locations.

Step 2: Address fields or relocation entries are adjusted to match those locations; this operation is relocation, C. Assembly translates symbolic instructions, parsing recognizes syntactic structure, and symbol resolution identifies which definition a name denotes. These can accompany linking/loading but are distinct tasks.

Original paper, page 3

1 mark · MCQ
Not in GATE 2027 syllabusReport issue

Relocation constants for concatenated modules

Compiler Phases, Linking & Loading

Question 1.28, GATE 1998: Modules of lengths 200, 800, 600, 500 words are loaded consecutively in that order from zero. Find their relocation constants.
Tap to enlarge
Your answer
Answer & solution

Answer: B: 0, 200, 1000, 1600 (no official key was published)

The first module starts at 0. The next starts after its 200 words, at 200. The third begins after 200+800=1000 words, and the fourth after 200+800+600=1600. These starting addresses are the relocation constants for modules assembled relative to zero. Thus B. The final 500-word length determines the image’s end, not an additional start. A nonzero loading base would add the same base to all four constants.

Original paper, page 3

1 mark · MCQ
Not in GATE 2027 syllabusReport issue

Conditional macro expansion

Compiler Phases, Linking & Loading

Question 1.9, GATE 1997: What does conditional expansion in a macro processor do: runtime tests, conditional runtime expansion, recursion, or choosing statements during macro expansion?
Question 1.9, GATE 1997: What does conditional expansion in a macro processor do: runtime tests, conditional runtime expansion, recursion, or choosing statements during macro expansion?
Tap to enlarge
Your answer
Answer & solution

Answer: D (no official key was published)

The macro processor evaluates an expansion-time condition, often based on macro arguments or expansion variables, and includes or omits corresponding model statements in the generated text. This occurs while expanding the macro, before the resulting program runs. Therefore D is the matching description. Runtime conditionals instead remain as executable control flow in the expanded program; they do not decide what source text the macro processor generates.

Original paper, page 1

1 mark · MCQ
Not in GATE 2027 syllabusReport issue

Tasks of a two-pass assembler

Compiler Phases, Linking & Loading

Question 1.17, GATE 1996: Assign object-code generation, adding literals to the literal table, assembly listing generation, and establishing local-symbol addresses to pass 1 or 2.
Tap to enlarge
Your answer
Answer & solution

Answer: B: 2,1,2,1 (no official key was published)

Pass 1 scans source statements, advances the location counter, records labels and collects literals. It therefore establishes local-symbol addresses and enters literals before final machine-code emission. Pass 2 uses those tables to encode instructions, resolve forward uses and produce object code; the final listing can include that generated code. Hence the listed order is 2,1,2,1. If the word resolution refers specifically to substituting a symbol address at its use, that substitution occurs in pass 2; the conventional matching here means establishing the symbol-table address in pass 1.

Original paper, page 3

2 marks · MCQ
Not in GATE 2027 syllabusReport issue

Termination of recursive macro expansion

Compiler Phases, Linking & Loading

Question 2.16, GATE 1996: Macro M1 recursively invokes M1(X+1) when X=0, otherwise emits WORD X. M2 instead recursively invokes M2(X) when X=0. Which can recurse indefinitely?
Question 2.16, GATE 1996: Macro M1 recursively invokes M1(X+1) when X=0, otherwise emits WORD X. M2 instead recursively invokes M2(X) when X=0. Which can recurse indefinitely?
Tap to enlarge
Your answer
Answer & solution

Answer: A: (ii) only (no official key was published)

For M1 invoked with X=0, the recursive call receives 1. Its condition is then false, so it emits WORD 1 and stops. For any nonzero initial value it stops immediately. M2 invoked with X=0 calls itself with the same argument, so the condition never changes and expansion repeats indefinitely. Thus only the second definition has the nontermination problem, option A. This reasoning uses expansion-time integer parameter evaluation; the recursion is in the macro processor, not a runtime subroutine.

Original paper, page 5

2 marks · MCQ
Not in GATE 2027 syllabusReport issue

Matching translation mechanisms

Compiler Phases, Linking & Loading

Question 2.17, GATE 1996: Match activation record, location counter, reference counts and address relocation with subroutine call, assembler, garbage collection and linking loader.
Tap to enlarge
Your answer
Answer & solution

Answer: D: A–3,B–4,C–2,D–1 (no official key was published)

An activation record stores the state of a subroutine invocation, such as saved control information and local variables. An assembler’s location counter tracks the address assigned to successive statements. Reference counts can support garbage collection by tracking how many references target an object. Address relocation adjusts addresses when a linking loader places program units in memory. These associations give 3,4,2,1 in the listed order. Reference counting has cycle limitations, but it is still the relevant collection mechanism in this matching question.

Original paper, page 6

1 mark · MCQ
Not in GATE 2027 syllabusReport issue

Macro definition parameters

Compiler Phases, Linking & Loading

Question 1.11, GATE 1995: In macro Add x,y with body Load y; Mul x; Store y, are x,y variables, identifiers, actual parameters or formal parameters?
Tap to enlarge
Your answer
Answer & solution

Answer: D: formal parameters (no official key was published)

The names x and y appear in the macro definition and stand for values or text supplied by each invocation. They are therefore formal parameters. An invocation such as Add A,B supplies actual parameters A and B, which replace the corresponding formals during expansion. Although formal names are also identifiers in a broad lexical sense, “formal parameters” is the specific role asked here. They need not denote runtime storage variables of the expanded program.

Original paper, page 2

1 mark · MCQ
Not in GATE 2027 syllabusReport issue

Information not required in a relocatable object

Compiler Phases, Linking & Loading

Question 1.14, GATE 1995: GFG asks what need NOT be included: object code, relocation bits, exported-symbol names and locations, or absolute addresses of internal symbols. GateForum omits NOT.
Tap to enlarge
Your answer
Answer & solution

Answer: D (no official key was published)

A relocatable object contains machine code plus information allowing its addresses to be adjusted and its external definitions and references resolved. Internal symbol locations can be encoded relative to the module; their final absolute addresses are not known until placement. Therefore absolute addresses of all internal symbols need not be included, D. Object code and relocation/symbol information are the conventional inputs to linking.

Original paper, page 2

Report issue

Matching compiler formalisms

Compiler Phases, Linking & Loading

Question 3.5, GATE 1994: Match BNF, lexical analysis, YACC and recursive-descent parsing with general CFGs, regular expressions, LALR(1), LL(1).
Question 3.5, GATE 1994: Match BNF, lexical analysis, YACC and recursive-descent parsing with general CFGs, regular expressions, LALR(1), LL(1).
Tap to enlarge
Answer & solution

Answer: i–d,ii–a,iii–b,iv–c (no official key was published)

Backus–Naur form is a notation for context-free grammar productions. Lexical token patterns are commonly specified by regular expressions and recognized by finite automata. Traditional YACC constructs an LALR(1) parser. A predictive recursive-descent parser uses LL(1) choices, with one-token lookahead selecting a production. Thus the requested mapping is d,a,b,c. General recursive descent can also use backtracking or more lookahead, so the LL(1) match refers to its standard nonbacktracking predictive form.

Original paper, page 4

Descriptive
Report issue

Two-pass assembler tables

Compiler Phases, Linking & Loading

Question 17(b), GATE 1994: State true or false with reason: A two-pass assembler uses its machine opcode table in the first pass of assembly.
Question 17(b), GATE 1994: State true or false with reason: A two-pass assembler uses its machine opcode table in the first pass of assembly.
Tap to enlarge
Answer & solution

Answer: True for the conventional two-pass assembler. (no official key was published)

1. Pass one assigns addresses and builds the symbol table. To advance the location counter correctly, it must recognize instructions and determine their lengths.

2. The machine opcode table supplies instruction classification and length information, so it is consulted before final code generation in pass two.

3. Using the table does not mean final object code or unresolved operand addresses must already be emitted during pass one.

Original paper, page 6

Descriptive
Report issue

Macros versus callable subroutines

Compiler Phases, Linking & Loading

Question 18(a), GATE 1994: State true or false with reason: A subroutine cannot always be used to replace a macro in an assembly-language program.
Question 18(a), GATE 1994: State true or false with reason: A subroutine cannot always be used to replace a macro in an assembly-language program.
Tap to enlarge
Answer & solution

Answer: True. (no official key was published)

1. A macro performs assembly-time text expansion. Its parameters may select register names, opcodes, labels, data declarations or conditional assembly. Such choices can alter the generated instruction sequence itself.

2. A subroutine is runtime code reached by a call; it has call/return and argument conventions rather than general assembly-time substitution. A macro that declares a label or storage at each expansion point cannot be replaced simply by calling one fixed subroutine.

3. Some computational macros can be rewritten as subroutines, but that limited case does not justify the universal replacement claim.

Original paper, page 6

Descriptive
Report issue

External symbol resolution

Compiler Phases, Linking & Loading

Question 18(b), GATE 1994: State true or false with reason: A symbol declared external in assembly language is assigned an address outside the program by the assembler itself.
Question 18(b), GATE 1994: State true or false with reason: A symbol declared external in assembly language is assigned an address outside the program by the assembler itself.
Tap to enlarge
Answer & solution

Answer: False. (no official key was published)

1. External means the definition is supplied by another object module or library, not defined in this assembly unit.

2. The assembler records an unresolved external reference and the necessary relocation/linkage information.

3. The linker, or a loader performing dynamic resolution, combines definitions and assigns/resolves the final address. The assembler alone generally lacks the required placement and definition information.

Original paper, page 6

2 marks · MSQ
Not in GATE 2027 syllabusReport issue

First pass of a two-pass assembler

Compiler Phases, Linking & Loading

Question 7.6, GATE 1993: Which first-pass tasks apply: allocate literal space,compute program length,build symbol table,generate load/store machine code?
Tap to enlarge
Select all that apply
Answer & solution

Answer: A,B,C in the standard assembler model (no official key was published)

Pass one tracks the location counter and instruction/data sizes. It assigns addresses to labels, records symbol values, and determines the total layout and length. Literal-pool placement also reserves space and assigns literal addresses when the pool is processed. Final instruction encoding is normally deferred to pass two, when forward symbol references can be resolved, so generating all load/store code is not a standard first-pass task. The answer assumes the ordinary two-pass design, not a hybrid implementation that opportunistically emits some instructions early.

Original paper, page 7

Report issue

Why macro expansion precedes final assembly

Compiler Phases, Linking & Loading

Question 1(vii), GATE 1992: Why expand macros in pass one rather than pass two?
Question 1(vii), GATE 1992: Why expand macros in pass one rather than pass two?
Tap to enlarge
Answer & solution

Answer: Expansion changes code size and the addresses needed for the symbol table (no official key was published)

A macro invocation can expand into several instructions, data definitions and labels. Pass one must account for their sizes to advance the location counter correctly and assign addresses to all later symbols. Deferring expansion until after that layout would invalidate those addresses or require another layout pass. Thus the standard macro assembler expands before or during its first layout pass. A separately implemented macro preprocessor can perform the same work before the nominal assembler passes; the essential requirement is expansion before final address assignment.

Original paper, page 1

Report issue

Instruction location counter

Compiler Phases, Linking & Loading

Question 1(viii), GATE 1992: What is the purpose of an assembler’s instruction location counter?
Question 1(viii), GATE 1992: What is the purpose of an assembler’s instruction location counter?
Tap to enlarge
Answer & solution

Answer: Track the address assigned to the next instruction or data item (no official key was published)

The location counter starts from the selected origin and advances by each assembled instruction or reserved data size. A label encountered at a statement is assigned the current location, enabling the symbol table to record its address. Directives such as ORG can change the counter explicitly. This is a compile/assembly-time layout variable, not the processor’s runtime program counter. Its final difference from the origin can also help determine section length, subject to separate sections and origin changes.

Original paper, page 1

Descriptive
Report issue

A recursive macro that fails to progress

Compiler Phases, Linking & Loading

Question 3(i), GATE 1992: M1 calls M1(X+1) when X=0 and otherwise emits WORD X; M2 calls M2(X) when X=0 and otherwise emits WORD X+1. Which loops forever, and give a call.
Question 3(i), GATE 1992: M1 calls M1(X+1) when X=0 and otherwise emits WORD X; M2 calls M2(X) when X=0 and otherwise emits WORD X+1. Which loops forever, and give a call.
Tap to enlarge
Answer & solution

Answer: M2 0 (no official key was published)

For M1 0, the recursive invocation receives 1. Its zero test fails, so it emits a word and stops; a nonzero initial argument likewise stops directly. In M2 0, the recursive call receives exactly 0 again, so every expansion repeats the same zero test and invocation with no progress. This causes unbounded expansion until a practical processor limit intervenes. The nonzero WORD branch cannot rescue that call because it is never reached. The analysis assumes expansion-time arithmetic and equality tests on X as intended.

Original paper, page 4

Report issue

Object generation pass

Compiler Phases, Linking & Loading

Question 3(ii.a), GATE 1992: In a conventional two-pass assembler, in which pass is object code generated?
Question 3(ii.a), GATE 1992: In a conventional two-pass assembler, in which pass is object code generated?
Question 3(ii.a), GATE 1992: In a conventional two-pass assembler, in which pass is object code generated?
Tap to enlarge
Answer & solution

Answer: Pass2 (no official key was published)

Pass1 establishes layout and collects symbol addresses, including forward definitions not yet known at their first use. Pass2 revisits instructions with those tables available and encodes opcodes, addresses and relocation information into object output. Thus final object generation is assigned to pass2. An implementation could emit some provisional bytes earlier, but that optimization does not change the conventional two-pass division asked here. The answer concerns final object code, not the intermediate source representation.

Original paper, page 4

Report issue

Literal-table insertion pass

Compiler Phases, Linking & Loading

Question 3(ii.b), GATE 1992: In a conventional two-pass assembler, in which pass are literals added to the literal table?
Question 3(ii.b), GATE 1992: In a conventional two-pass assembler, in which pass are literals added to the literal table?
Question 3(ii.b), GATE 1992: In a conventional two-pass assembler, in which pass are literals added to the literal table?
Tap to enlarge
Answer & solution

Answer: Pass1 (no official key was published)

When pass1 encounters a literal operand, it records its value and storage needs in the literal table. Literal-pool directives or the end of a section determine placement, which must be included in layout before addresses are finalized. Pass2 can then use the assigned literal addresses while emitting instructions and literal data. Adding the literals only after computing all addresses would require revising the layout. Thus entry into the table is a first-pass activity, distinct from outputting its bytes.

Original paper, page 4

Report issue

Assembly listing pass

Compiler Phases, Linking & Loading

Question 3(ii.c), GATE 1992: In a conventional two-pass assembler, in which pass is the final listing printed?
Question 3(ii.c), GATE 1992: In a conventional two-pass assembler, in which pass is the final listing printed?
Question 3(ii.c), GATE 1992: In a conventional two-pass assembler, in which pass is the final listing printed?
Tap to enlarge
Answer & solution

Answer: Pass2 (no official key was published)

A useful final assembly listing combines source statements with assigned addresses and generated machine code, plus diagnostics. Since those final encodings are produced in pass2, the conventional listing is printed there as well. Pass1 may produce temporary listings or diagnostics, but that is not the standard final annotated listing meant in this matching task. The answer therefore follows the output artifact’s dependencies rather than assuming any printed text must wait until pass2 in every implementation.

Original paper, page 4

Report issue

Local-symbol address resolution pass

Compiler Phases, Linking & Loading

Question 3(ii.d), GATE 1992: In a conventional two-pass assembler, in which pass are local-symbol addresses established?
Question 3(ii.d), GATE 1992: In a conventional two-pass assembler, in which pass are local-symbol addresses established?
Question 3(ii.d), GATE 1992: In a conventional two-pass assembler, in which pass are local-symbol addresses established?
Tap to enlarge
Answer & solution

Answer: Pass1 for defining addresses; pass2 for substituting them into uses (no official key was published)

Pass1 advances the location counter and associates each defined label with its address, thereby resolving the address values stored in the symbol table. Pass2 looks up those values when encoding references, especially forward references. Hence the standard matching answer is pass1 when “address resolution” means establishing the local symbol’s address. If it instead means replacing a symbolic operand at a use site with that address, the operation is pass2. The two meanings are explicitly distinguished because the printed wording does not name the phase’s exact suboperation.

Original paper, page 4

2 marks · MSQ
Not in GATE 2027 syllabusReport issue

Link-editor responsibility

Compiler Phases, Linking & Loading

Question 3(ix), GATE 1991: A link editor matches external names to definitions in other modules, macro arguments to parameters, subroutine parameters to arguments, or serves as an editor/compiler user interface?
Question 3(ix), GATE 1991: A link editor matches external names to definitions in other modules, macro arguments to parameters, subroutine parameters to arguments, or serves as an editor/compiler user interface?
Tap to enlarge
Select all that apply
Answer & solution

Answer: B: resolve external names across modules (no official key was published)

Separately compiled modules contain symbol definitions and unresolved references to symbols defined elsewhere. The linker combines modules, locates matching definitions, assigns final locations and adjusts references or relocation records. This is the external-name matching described by B. Macro-parameter substitution belongs to macro expansion, and runtime argument passing or compiler checking handles subroutine parameters. The tool’s name does not mean it is an interactive bridge to a text editor. Dynamic linking can defer some resolution, but the semantic task remains symbol binding across modules.

Original paper, page 4