Cia 2
Cia 2
Cia 2
11.(a) (i) Describe the various methods of implementing the three 8 K2 CO3
address statements with an example?
(ii) Write down the translation scheme to generate code for 8 K1 CO3
assignment statements. Use the scheme for generating three
address code for the assignment statements
x:=(a+b)*(c*d).Also draw its annotated parse tree for the
assignment statements.
(OR)
11.(b) (i) Generate intermediate code for the following code segment 16 K3 CO3
along with the required syntax directed translation scheme.
int main()
{
int a, b, c;
printf("Enter the numbers A, B and C: ");
scanf("%d %d %d", &a &b, &c);
// finding max using compound expressions
if (a >= b && a >= c)
printf("%d is the largest number.", a);
else if (b >= a && b >= c)
printf("%d is the largest number.", b);
else
printf("%d is the largest number.", c);
return 0;
}
12.(a) (i) Explain in detail about concepts of back patching using flow 16 K2 CO3
control statements. Also generate three address code and
syntax tree for the given expression a < b or c < d and e < f.
(OR)
12.(b) (i) Discuss the various methods for translating Boolean 16 K2 CO3
expression
13.(a) (i) Describe the principle sources of optimization with relevant 16 K2 CO4
examples.
(OR)
13.(b) (i) Explain peephole optimization and various code improving 16 K2 CO4
transformations.
14.(a) (i) Construct DAG representation of the following code and list 8 K3 CO4
out the applications of DAG representation:
I=1,s=0
While(i<10)
S=s+a[i][i]
i=i+1
(ii) Elaborate loops in flow graph with example. 8 K2 CO4
(OR)
14.(b) (i) Explain in detail about data flow analysis of flow graphs 16 K2 CO4
with relevant example.
15.(a) (i) Construct the flow graph and apply the possible 16 K3 CO4
optimizations for the following program segment.
sum := 0
i := 1
do
sum := prod + a[i] * b[i]
i := i+1
while i <= 20
(OR)
15.(b) (i) Explain in detail about how loops are represented in flow 16 K3 CO2
graph with relevant example.