Role of Code Generator MCQs December 19, 2025December 14, 2024 by u930973931_answers 10 min Score: 0 Attempted: 0/10 Subscribe 1. What is the primary role of the code generator in a compiler? (A) To check syntax errors (B) To generate intermediate representations of the code (C) To optimize the source code (D) To convert high-level language code into machine code 2. Which phase does the code generator follow in the compilation process? (A) Lexical analysis (B) Intermediate code generation (C) Syntax analysis (D) Optimization 3. What does the code generator primarily produce? (A) Machine-specific code (target code) (B) Intermediate code (C) High-level code (D) Assembly code 4. Which of the following is NOT a function of the code generator? (A) Generating the final output in the form of machine code (B) Register allocation (C) Syntax checking (D) Instruction selection 5. In the context of code generation, what is meant by âinstruction selectionâ? (A) Determining the correct sequence of instructions to execute the program (B) Choosing the appropriate instructions for a given operation based on the target machine (C) Removing unused instructions from the generated code (D) Optimizing the flow of control in the program 6. What is the role of the code generator in terms of registers? (A) To allocate variables to machine registers (B) To create variables for the source code (C) To remove unnecessary registers from the code (D) To free up memory used by registers 7. Why is register allocation important in the code generation phase? (A) It ensures that instructions are executed in the correct order (B) It helps in reducing memory access time (C) It minimizes the number of registers used in the program (D) It helps in detecting runtime errors 8. Which of the following does the code generator rely on when selecting machine instructions? (A) The abstract syntax tree (AST) (B) The machine architecture of the target system (C) The intermediate code generated by the syntax analyzer (D) The high-level language constructs 9. Which of the following is typically the output of the code generator? (A) Assembly code specific to the target machine (B) High-level language source code (C) Intermediate representation of the code (D) Syntax tree 10. What is the role of âpeephole optimizationâ in the code generation phase? (A) To select the most efficient instructions from the instruction set (B) To improve the readability of the generated code (C) To optimize small sequences of instructions at the machine level (D) To detect and remove syntax errors