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

Discussion

Translating an array reference a[i] into three address code requires

  • A.computing an offset from the index, the base and the element width
  • B.a single instruction naming both the array and the index directly
  • C.the index to be a compile time constant in every case
  • D.the array to be stored in registers rather than in memory

Answer: A

The address is the base plus the index times the element width. Multi dimensional arrays extend the same idea, with one multiplication per dimension in row major order. The multiplications by constant bounds are usually strength reduced afterwards.

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

Post your comment

Please log in or register to post a comment.