next up previous
Next: About this document ... Up: Quiz4 Previous: Exercise 2.

Exercise 3.

Translate the following C-like piece of code into three-address code.
a = x * y + u * v - w * t; 
b = w * t - m * n;
while (b != 0) {
   tmp = a;
   a = b;
   while (tmp > b) {
      tmp = tmp - b;
   }
   b = tmp;
}
The three-address code instructions you may need are of one of the forms: Moreover your solution does not need to be obtained by one of the algorithms of the course. Just consider that you are programming a very basic calculator.

Answer 3  
\fbox{
\begin{minipage}{13 cm}
\begin{center}
\begin{tabular}{ll}
& {\tt tmp :=...
...
& {\tt goto L1 } \\
L4 & {\tt } \\
\end{tabular}\end{center}\end{minipage}}


next up previous
Next: About this document ... Up: Quiz4 Previous: Exercise 2.
Marc Moreno Maza
2004-12-02