next up previous
Next: Exercise 2. Up: Quiz3 Previous: Guidelines.

Exercise 1.

We consider an abstract stack machine supporting arithmetic operations and the following instructions (exactly as the one of the course).
push v
which pushes v onto the stack.
rvalue $ \ell$
which pushes the content of data location $ \ell$ onto the stack.
lvalue $ \ell$
which pushes the address of data location $ \ell$ onto the stack .
pop
which throws away the value on top of the stack.
:=
which places the R-value on top in the L-value below it, and both are popped.
copy
which pushes a copy of the top value on the stack.
Translate the following C-like statement for this abstract stack machine.
x = (a + b) * (c + d)

Answer 1  
\fbox{
\begin{minipage}{13 cm}
\begin{center}
\begin{tabular}{l}
lvalue x \\
rv...
...e c \\
rvalue d \\
+ \\
* \\
:= \\
\end{tabular}\end{center}\end{minipage}}


next up previous
Next: Exercise 2. Up: Quiz3 Previous: Guidelines.
Marc Moreno Maza
2004-12-02