img
Question:
Published on: 25 April, 2024

Compare quadruples, triples and indirect triples.

x= (a + b) * - c / d

Represent this expression in quadruples, triples and indirect triples forms. Generate the machine code for the following instruction:

V=a+(b*c)-d.

Answer:

The three address code can be using following methods:

  1. Quadruple: the quadruple is a structure with at most 4 fields such as OP, arg1, arg2, and result.
  2. Triples: In triple representation, the use of temporary variables is avoided by referring the pointers in the symbol table.
  3. Indirect Triples: In indirect triple representation the listing of triples is been done ad listing pointers are used instead of using statements.

In quadruple representation the result of the operation is stored in some temporary variable. In target code generation one can quickly access the value of temporary variable using symbol table. Whereas in triple representation, use of temporary variables is avoided. The pointers to symbol table hold the result of computation.

The quadruple representation is beneficial for optimizing compilers. The level of indirection is applied by introducing temporary variables between value of computation and its use. Whereas in triple representation references to arg1 and arg2 define value of temporary variable which is not suitable method for optimizing “compiler".

Whereas in indirect triple list of all references to computations is made separately. Thus indirect triple and quadruple representations are similar as far as their utility is concerned. But indirect triple saves amount of space as compared to quadruple.

                          

                            

 

Machine code for V = a+(b*c)-d: 

Random questions