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

Discussion

Arrange the steps a simple code generator takes for the instruction x = y + z.
1. generate the add instruction with z as the second operand
2. find a location for the result, preferring a register
3. update the register and address descriptors for x
4. ensure that y is available in a register

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

Answer: A

Correct answer: 2 - 4 - 1 - 3

A location for the result is chosen first, since it may determine which register the addition targets. The first operand is then brought into a register, the add is emitted with the second operand wherever it lies, and the descriptors are updated last so that they record where x now is.

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

Post your comment

Please log in or register to post a comment.