= Solution
We specify a small <stack machine> instruction convention because the paper does not prescribe instruction spellings or numeric <stack frame> offsets. `PUSHFP` pushes the current <frame pointer>. `LOAD k` replaces a <stack>-top frame address by the value at fixed offset `k` in that frame. Let `SL` be the <static link> offset, `X` the offset of `p`'s `x`, and `Y` the offset of `q`'s parameter `y`. `ADD` pops two <integers> and pushes their sum. `RETVAL` returns the <stack>-top value, removes the current activation and restores the caller through the usual <calling convention>.
``
PUSHFP ; address of q's frame
LOAD SL ; q's static link: address of p's frame
LOAD X ; value of p.x
PUSHFP ; address of q's frame, above x
LOAD Y ; q's local parameter y
ADD ; x + y
RETVAL ; return the sum to s
``
One <static link> traversal suffices for `x`, despite three intervening calls in the <dynamic chain>. `y` is local to `q`. In this execution the two loads produce $3$ and $3$, so the returned <integer> is $\boxed{6}$.
Back to article page