Chapter 8: Intermediate Code Generation

Example:
Code for a < b or c < d and e < f

 

100: if a < b goto 103
if e < f goto 111
101: t1 = 0 109: t3 = 0
102: goto 104 110: goto 112
103: t1 = 1 111: t3 = 1
104: 112:
if c < d goto 107
t4 = t2 and t3
105: t2 = 0 113: t5 = t1 or t 4
106: goto 108  
107: t2 = 1  
108:  
   

A relational expression a < b is equivalent to the conditional statement if a < b then 1 else 0 and three address code for this expression is:

100: if a < b goto 103.

101: t = 0

102: goto 104

103: t = 1

104:

It is continued from 104 in the same manner as the above written block.