Analysis & Synthesis Process
of Compilation (Unit-5)
Multiple Choice Questions (MCQ)
1) Three-Address Code is called “Three Address” because: (i) Each instruction can have atmost three operators (ii) Each instruction can have atmost three addresses (operands) (iii) Each instruction can have exactly three operators (iv) Each instruction can have exactly three addresses (operands)
2) The main advantage of generating Intermediate Code in a compiler is that: (i) It allows better optimization independant of machine architecture (ii) It eliminates the need for lexical analysis (iii) It directly increases the run-time speed of the compiler (iv) It reduces the number of syntax errors
3) Consider the expression a = b + c * dA possible three-address code sequence is: (i) t1 = b + c; a = t1 * d (ii) t1 = c * d; a = b + t1 (iii) a = b + c * d (iv) t1 = b * c; a = t1 + d
4) Which of the following techniques allows the compiler to fill in the address of forward jumps later (as the destinations of jump instructions are not known immediate) during intermedia code generation? (i) Peephole Optimization (ii) Backpatching (iii) Register Allocation (iv) Code Scheduling
5) Consider the following statements:S1: A three-address code instruction contains at most three addressesS2: The process of backpatching is used to know the forward jump addresses in control flow statements
Choose the correct optionn
(i) Only S1 is true
(ii) Only S2 is true
(iii) Both S1 and S2 are true
(iv) Neither S1 nor S2 is true
6) Consider the following three-address code: If a < b goto L1
t1 = a + b
L1: t2 = a * b
Which of the following is incorrect regarding the flow control in the code?
(i) The expression will jump to L1 if a < b
(ii) The addition t1 = a+b will execute when a >= b
(iii) The multiplication t2 = a * b will execute only if a < b
(iv) The multiplication t2 = a * b will always execute
7) Which of the following is NOT a task of the code generation phase of a compiler (i) Instruction selection (ii) Register allocation (iii) Syntax analysis (iv) Instruction ordering
8) In most modern compilers, the code generation phase takes which of the following as the input? (i) The original source program (ii) Intermediate code and information from the symbol table (iii) Only the syntax tree (iv) Target machine instruction
9) During a procedure call, which of the following actions are performed by the calling function (caller) before transferring the program control to the called function?
(i) Evaluating actual arguments
(ii) Passing parameters to the called function
(iii) Saving necessary machine state such as return address
(iv) All of the above
10) When the called function finishes execution, which component is used to determine where execution should resume in the calling function?
(i) Control Link
(ii) Access Link
(iii) Return Address
(iv) Local Variables
S2: The process of backpatching is used to know the forward jump addresses in control flow statements
Choose the correct optionn
(i) Only S1 is true (ii) Only S2 is true (iii) Both S1 and S2 are true (iv) Neither S1 nor S2 is true
If a < b goto L1
t1 = a + b
L1: t2 = a * b
Which of the following is incorrect regarding the flow control in the code? (i) The expression will jump to L1 if a < b (ii) The addition t1 = a+b will execute when a >= b (iii) The multiplication t2 = a * b will execute only if a < b (iv) The multiplication t2 = a * b will always execute
9) During a procedure call, which of the following actions are performed by the calling function (caller) before transferring the program control to the called function? (i) Evaluating actual arguments (ii) Passing parameters to the called function (iii) Saving necessary machine state such as return address (iv) All of the above
10) When the called function finishes execution, which component is used to determine where execution should resume in the calling function? (i) Control Link (ii) Access Link (iii) Return Address (iv) Local Variables
Descriptive Questions
Q1. What is the runtime environment and what role does it play in program execution?
Q2. Write three address code for the expression :
a+b*c – d /e
Q3. Distinguish Syntax Directed Definition and Syntax Directed Translation?
Q4. Discuss about various storage allocation strategies in runtime environment?
Q5. Explain about different storage allocation strategies.
Q6. Compare and contrast the three main runtime storage organization techniques: static allocation, stack allocation, and heap allocation.
Q7. Write the comparison among Static allocation, Stack allocation and Heap Allocation with their merits and limitations.
Q8. Define Loop unrolling and Loop jamming? Also explain constant folding?
Q9. Define Three Address Codes. Outline various Three Address code representations for the expression:
x + - y * (- y + z)
Q10. Explain the procedure to translate Control Statements into Three address code with example.
Q11. Explain the Code optimization techniques with example.
Q12. Describe Register Allocation. Briefly explain the strategies available for register allocation and assignment.
Q13. Explain the various issues in the design of code generation.
Q14. Define object code generation and describe its importance in the compilation process.

.png)
.png)
.png)
.png)


.png)











.png)



