2,621 views
25 votes
25 votes
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$$

2 Answers

Best answer
41 votes
41 votes

Each instruction in quadruples presentation is divided into four fields: operator, arg$1,$ arg$2,$ 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 by
3 votes
3 votes
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

7 votes
7 votes
1 answer
2
17 votes
17 votes
2 answers
4
Kathleen asked Sep 13, 2014
4,495 views
Mention the pass number for each of the following activities that occur in a two pass assembler:object code generationliterals added to literal tablelisting printedaddres...