Machine-translated by Google. Questions are authored in English.
Top

Discussion

Arrange the steps of translating an assignment statement into three address code.
1. generate the instruction combining the operand temporaries
2. parse the right hand side into a tree or during the parse
3. generate the copy assigning the result to the left hand side
4. generate code for each subexpression into a temporary

  • A.3 - 1 - 4 - 2
  • B.4 - 2 - 1 - 3
  • C.2 - 1 - 4 - 3
  • D.2 - 4 - 1 - 3

Answer: D

Correct answer: 2 - 4 - 1 - 3

The order follows the structure of the expression. The right hand side is parsed, each subexpression is evaluated into a temporary, those temporaries are combined by the operator, and the result is finally copied to the left hand side. Generating the copy first would have nothing to copy.

No comment is present. Be the first to comment.
Loading…

Post your comment

Please log in or register to post a comment.