At first I am not sure that this question belongs to this domain. If it does not, I am sorry.

As you know, structure of a compiler consists of two parts which are analysis phase and synthesis phase. Intermediate Code Generation is the first section of synthesis phase, and three types of intermediate code can be used:

1) Abstract Syntax Tree

2) Postfix

3) Three Address Code

Three address codes are stored in the memory as quadruples. Although I made a lot of researches, I could not find how I can represent some three address codes in the quadruples.

For example, if you use this code x := call f, 3 you can denote it in quadruple like this:

op    arg1  arg2  result

call   f      3     x

In this point, I have two questions:

1) How can I denote this operation (a = b[i] + c[i]) with three address code ? (I have two alternatives in my mind)

First One:

t1 := b[i]
t2 := c[i]
a  := t1 + t2

Second One:

a := b[i] + c[i]

However, I think that second one is wrong because b and i are regarded as two arguments. In this case, we use 6 arguments and three operations. In three address code, at most two arguments and one operation can exist.

2) How can I denote this operation in quadruple ?

  • $\begingroup$ Hint: the function is +. $\endgroup$ – Yuval Filmus Jan 2 at 13:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.