Introduction / Context:
Compilers pass source through multiple phases: lexical analysis, parsing, semantic analysis, optimization, and code generation. This item pinpoints the phase responsible for turning intermediate representation into target code and resolving label addresses.
Given Data / Assumptions:
- Source language: PL/I (representative of HLLs).
- Activities: assign final addresses/labels and emit machine code.
- Focus on phase naming, not toolchain packaging.
Concept / Approach:
- Code generation maps IR to machine instructions and fixes branch targets/labels.
- Syntax analysis only parses structure; storage assignment plans memory layout but doesn’t emit target code.
- “Assembly and output” is an output step but address resolution in HLL compilers is classically part of code generation and later relocation.
Step-by-Step Solution:
Identify tasks (emit code, resolve labels) → code generation.Eliminate parsing (syntax analysis) and purely planning steps (storage assignment).Recognize that emitting final machine code is quintessential code generation.
Verification / Alternative check:
Standard compiler texts list label fix-ups and target emission under code generation and backend phases.
Why Other Options Are Wrong:
- Assembly and output: Output format step; not the principal phase for label resolution in HLL compilation.
- Storage assignment: Memory layout planning, not code emission.
- Syntax analysis: Parsing only; no machine code.
- None of the above: Incorrect; code generation is correct.
Common Pitfalls:
- Assuming parsing includes address resolution; it does not.
Final Answer:
Code generation
Discussion & Comments