0% found this document useful (0 votes)
63 views3 pages

ECE3073 Computer Systems Practice Questions Program Design and Analysis: Compilation

This document contains practice questions for the ECE3073 Computer Systems course. It includes questions on program design patterns, data flow graphs, control flow graphs, assembler symbol tables, array storage formats, and code optimization techniques including constant folding, algebraic simplification, strength reduction, dead code elimination, procedure inlining, and loop unrolling.

Uploaded by

kewancam
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
63 views3 pages

ECE3073 Computer Systems Practice Questions Program Design and Analysis: Compilation

This document contains practice questions for the ECE3073 Computer Systems course. It includes questions on program design patterns, data flow graphs, control flow graphs, assembler symbol tables, array storage formats, and code optimization techniques including constant folding, algebraic simplification, strength reduction, dead code elimination, procedure inlining, and loop unrolling.

Uploaded by

kewancam
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

ECE3073 Computer Systems

Practice Questions

Program Design and Analysis: Compilation

i) Design patterns list four programming design patterns and suggest one typical
application for each pattern:

ii) Data Flow Graph

For each block of code given below rewrite in single assignment form and then draw
the data flow graph for that form. From the graph determine the partial order.

a) x=a+b
y=c+d
z=x+e

b) r=a+b-c
s=2*r
t=b+d
r=d+e

c) w=a-b+c
x =w-d
y=x-2
w=a+bc
z=y+d
y=b*c

ii) Draw the Control Data Flow Graph for the following code fragments:

a) if( y == 2 ) {r = a + b; s = c d;}
else r = a c;

b) x = 1;
if ( y == 2 ) {r = a + b; s = c d;}
else ( r = a c}

c) x = 2;
while ( x < 40 ) {
x = foo[x];
}

d) for ( i = 0; i < N; i++)


x[i] = a[1] * b[i];
e) for ( i = 0; i < N; i++) {
if ( a[i] == 0 ) x[i] = 5;
else x[i] = a[i] * b[i];

Show the contents of the assemblers symbol table at the end of code generation for
the following programs (Note that each instruction occupies 4 bytes)

a)
ORG 200
p1 ADR r4,a
LDR r0.[r4]
ADR r4,e
LDR r1,[r4]
ADD r0,r0,r1
CMP r0,r1
BNE q1
p2 ADR r4,e

b)
ORG 100
p1 CMP r0,r1
BEQ x1
p2 CMP r0,r2
BEQ x2
p3 CMP r0,r3
BEQ x3

iii) Explain the difference between row major format and column major format for
storing arrays.

iv) In code optimisation

a) In the context of expression simplification briefly explain:

1) Constant folding

2) Algebraic expression simplification

3) Strength reduction

b) Explain what is meant by dead code elimination and point out a situation where
this could cause a problem.

c) Describe procedure inlining and explain its advantages and disadvantages


d) Describe loop unrolling and explain its advantages and disadvantages

Andy Russell 03/03/2013

You might also like