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

Discussion

Backpatching is a technique used to

  • A.correct semantic errors discovered after the code has been generated
  • B.revert an optimisation that turned out to worsen the program
  • C.reassign registers after the target program has been assembled
  • D.fill in addresses that were not known when the code was first emitted

Answer: D

Correct answer: fill in addresses that were not known when the code was first emitted

A forward jump must be emitted before its destination has been reached, so the address field is left blank and its location recorded on a list.

When the target label is finally seen, the compiler walks the list and patches every waiting instruction with the now-known address. The technique is what lets a single-pass compiler handle forward branches in conditionals and loops without a second traversal - it defers only the address, not the code.

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

Post your comment

Please log in or register to post a comment.