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

Discussion

Code generation for a stack machine differs from that for a register machine in that it

  • A.needs no register allocation, since operands are on a stack
  • B.cannot express expressions containing more than two operands
  • C.requires the whole program to fit in the stack at once
  • D.produces code that runs faster on every target machine

Answer: A

Correct answer: needs no register allocation, since operands are on a stack

A stack machine takes its operands from the top of the stack implicitly, so there are no registers to allocate and code generation reduces to a postorder walk of the expression tree. That simplicity is why stack code is used for portable intermediate forms - and why it is slower than register code on real hardware.

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

Post your comment

Please log in or register to post a comment.