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

Exercise 3.

Translate the following MOOL piece of code into three-address code.
while not (a = b) repeat {
    if (a < b) then {
       b := b - a;
   } else {
       a := a - b;
   };
};
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}
L1 & {\tt if a...
...- b } \\
L4 & {\tt goto L1 } \\
L5 &
\end{tabular}\end{center}\end{minipage}}


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