# GATE1992-11b

1.4k views
Write $3$ address intermediate code (quadruples) for the following boolean expression in the sequence as it would be generated by a compiler. Partial evaluation of boolean expressions is not permitted. Assume the usual rules of precedence of the operators.$$(a+b) > (c+d) \text{ or } a > c \text{ and }b < d$$

Each instruction in quadruples presentation is divided into four fields: operator, arg1, arg2, and result. The above example is represented below in quadruples format:

$(a+b)>(c+d)$ OR $a>c$ AND $b<d$

$(t1>t2)$ OR $a>c$ AND $b<d$

$t3$ OR $t4$ AND $t5$

$t3$ OR $t6$

$t1= a+b$

$t2= c+d$

$t3= t1>t2$

$t4= a>c$

$t5= b<d$

$t6= t4$ AND $t5$

$t7 =t3$ OR $t6$

\begin{array}{|l|l|l|l|} \hline \text{Op} & \text{arg1} & \text{arg2} & \text{Result} \\\hline \text {+} &  \text{a} &  \text{b} &  \text{t1} \\\hline \text {+} &  \text{c} &  \text{d} &  \text{t2}  \\\hline  \text {>} &  \text{t1} &  \text{t2} &  \text{t3} \\\hline \text {.>} &  \text{a} &  \text{c} &  \text{t4} \\\hline \text {<} &  \text{b} &  \text{d} &  \text{t5} \\\hline \text {AND} &  \text{t4} &  \text{t5} &  \text{t6} \\\hline \text {OR} &  \text{t3} &  \text{t6} &  \text{t7} \\\hline   \end{array}

edited
quadruples consists of the 4-section they are operator, operand1, operand2, result

operator                 operand1           operand2                    result

+                               a                     b                              t1

+                               c                      d                             t2

>                               t1                     t2                            t3

>                                a                     c                             t4

<                               b                      d                             t5

and                            t4                    t5                             t6

or                              t3                     t6                            t7

## Related questions

Write syntax directed definitions (semantic rules) for the following grammar to add the type of each identifier to its entry in the symbol table during semantic analysis. Rewriting the grammar is not permitted and semantic rules are to be added to the ends of productions only. $D \rightarrow TL;$ $T \rightarrow \text{int}$ $T \rightarrow \text{real}$ $L \rightarrow L,id$ $L \rightarrow id$