From Stack Machine to Register Machine
Translate each of these stack machine instructions into register machine:
Bipush(c : Int) Iadd Imul Iload(slot : Int) Istore(slot : Int)
using register machine instructions
- with arbitrary addressing
- assuming arithmetic operations are done only on registers
In both cases, assume special registers
- SP for stack pointer - current top of stack
- FP for frame pointer - first non-parameter local variable
Concrete example:
def f(x : Int, y : Int) = { val z = x + y z * x } def g(u : Int) = { val v = u + 3 f(u,v) + 5 }