Question:

Consider the following statements about the use of backpatching in a compiler for intermediate code generation: 
1. Backpatching can be used to generate code for Boolean expressions in one pass. 
2. Backpatching can be used to generate code for flow-of-control statements in one pass. 
Which ONE of the following options is CORRECT?

Show Hint

Backpatching is an efficient method for handling jumps and flow-of-control constructs in a single pass, making it ideal for Boolean expressions and control flow.
Updated On: Apr 7, 2025
  • Only (I) is correct.
  • Only (II) is correct.
  • Both (I) and (II) are correct.
  • Neither (I) nor (II) is correct.
Hide Solution
collegedunia
Verified By Collegedunia

The Correct Option is C

Solution and Explanation

Backpatching is a technique used in compiler design to handle intermediate code generation, particularly for Boolean expressions and control flow statements.
  • Statement (I) is correct: Backpatching allows the compiler to generate code for Boolean expressions in one pass by postponing the resolution of jump addresses until they are known. This technique helps in optimizing the generation of code without requiring multiple passes over the code.
  • Statement (II) is correct: Similarly, backpatching is useful for generating code for flow-of-control statements, such as conditional and loop statements, where the target addresses of jumps may not be known initially. Backpatching ensures that the jump addresses can be updated correctly once they are determined during code generation.

Since both statements (I) and (II) are correct, the correct answer is (C) Both (I) and (II) are correct.

Was this answer helpful?
0
0

Questions Asked in GATE CS exam

View More Questions