Next: About this document ...
Up: Quiz4
Previous: Exercise 2.
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:
- goto L where 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 -, - and *
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: Quiz4
Previous: Exercise 2.
Marc Moreno Maza
2004-12-02