Answer any one question from Q1 and Q2
1 (a)
For the 'C' code given below, give the different tables that would be generated as output of lexical analysis.
main ( )
{
int i, sum, n;
float avg;
n=10;
sum=c;
for(i= 1; i<=10 ;i++)
sum =sum + i;
avg = sum / (float)n ;
}
main ( )
{
int i, sum, n;
float avg;
n=10;
sum=c;
for(i= 1; i<=10 ;i++)
sum =sum + i;
avg = sum / (float)n ;
}
8 M
1 (b)
Define macroprocessor and assembler and give examples for each.
2 M
2 (a)
Give the various data structures in the design of pass-1 of a Two-pass direct linking loader.
4 M
2 (b)
What are the assembler directives? Explain how assembler directives LTORG, ORIGIN and EQU are processed in first pass.
6 M
Answer any one question from Q3 and Q4
3 (a)
For the following piece of assembly language code, show the contents of symbol table, literal table and pool-tab. Assume size of instruction equal to one.
START 202
MOVER AREG, ='5
MOVEM AREG, A
LOOP MOVER AREG, A
MOVER CREG, B
ADD CREG, = '1'
MOVEM CREG, B
SUB CREG, A
BC ANY, NEXT
LTORG
ADD CREG,B'
BC LE LOOP
NEXT SUB AREG, = '1'
BC LT, BACK
STOP
ORIGIN 219
MULT CREG, B
A DS 1
BACK EQU LOOP
B DS 1
END
START 202
MOVER AREG, ='5
MOVEM AREG, A
LOOP MOVER AREG, A
MOVER CREG, B
ADD CREG, = '1'
MOVEM CREG, B
SUB CREG, A
BC ANY, NEXT
LTORG
ADD CREG,B'
BC LE LOOP
NEXT SUB AREG, = '1'
BC LT, BACK
STOP
ORIGIN 219
MULT CREG, B
A DS 1
BACK EQU LOOP
B DS 1
END
5 M
3 (b)
Define loader and enlist the basic functions of loader.
5 M
4 (a)
Explain the first three phases of compiler w.r.t. the following statement:
r = a^10 / (c*d^e)
Note: ^ is exponentiation operator
r = a^10 / (c*d^e)
Note: ^ is exponentiation operator
6 M
4 (b)
Explain different parameter passing mechanisms in macro-processor.
4 M
Answer any one question from Q5 and Q6
5 (a)
Consider the grammar
E→E-E
E→E*E
E→id
Perform shift Reduce parsing of i/p string 'id-id * id'
E→E-E
E→E*E
E→id
Perform shift Reduce parsing of i/p string 'id-id * id'
4 M
5 (b)
Define table driven predictive parser. For the following grammar.
S→AaBb
A→ ϵ
B→ϵ
Construct table-driven predictive parser and parse the string 'ab'.
S→AaBb
A→ ϵ
B→ϵ
Construct table-driven predictive parser and parse the string 'ab'.
10 M
5 (c)
Compare bottom up and top down parser.
4 M
6 (a)
Consider the following grammar:
S→L|a
L→L, s|s
Construct SLR parser and parse for the string (a, (a,a)).
S→L|a
L→L, s|s
Construct SLR parser and parse for the string (a, (a,a)).
10 M
6 (b)
Explain YACC file structure.
4 M
6 (c)
Explain problem of left factoring in top down parser.
4 M
Answer any one question from Q7 and Q8
7 (a)
Optimize the following code.
a = x^2
b = 3
c = x
d = c*c
e=b+2
f = a+d
g = e* f
a = x^2
b = 3
c = x
d = c*c
e=b+2
f = a+d
g = e* f
8 M
7 (b)
Write short note on activation record.
4 M
7 (c)
Explain in brief run time storage allocation.
4 M
8 (a)
Explain any one technique of machine dependent code optimization.
6 M
8 (b)
Comparison between static, stack & heap allocation.
6 M
8 (c)
Explain machine dependent optimization issues.
4 M
Answer any one question from Q9 and Q10
9 (a)
Design dependency graph for the following grammar.
S → T List
T → int
T → float
T → char
T → double
List → List 1/id.
S → T List
T → int
T → float
T → char
T → double
List → List 1/id.
4 M
9 (b)
Translate the following C fragment into the three address code.
int i;
int a[10][10];
i = 0;
while (i< 10)
{
a[i][i]=1;
i++;
}
int i;
int a[10][10];
i = 0;
while (i< 10)
{
a[i][i]=1;
i++;
}
6 M
9 (c)
Write quadruple and triple for the expression.
-(a*b)+(c+d)-(a+b+c+d)
-(a*b)+(c+d)-(a+b+c+d)
6 M
10 (a)
For the following statement, Generate intermediate code in the format:
i) Postfix notation
ii) Quadruple
iii) Parse tree
iv) Triple
S = (a+b) / (c-d)
i) Postfix notation
ii) Quadruple
iii) Parse tree
iv) Triple
S = (a+b) / (c-d)
8 M
10 (b)
Explain concept of type checking.
4 M
10 (c)
Generate three address code for
while (i<10)
{
x=0;
i=i+1;
}
while (i<10)
{
x=0;
i=i+1;
}
4 M
More question papers from Systems Programming