Next: About this document ...
Up: Quiz3
Previous: Exercise 2.
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:
- goto L where L is a symbolic label (like L1, L2, ...)
- if x relop y goto L where relop can be = or <
- x:= y op z where op can be -
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
Next: About this document ...
Up: Quiz3
Previous: Exercise 2.
Marc Moreno Maza
2004-12-02