Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

SP Question Bank

Download as pdf or txt
Download as pdf or txt
You are on page 1of 6

Vishwakarma Government Engineering College

Dept: CE SEM: 5th


Subject Name: System Programming (2150708)
Question Bank

PART-1

1 Define the following terms.


1) Handle 2) Program Relocation 3) literals 4) Forward Reference
5) pass 6) Frequency reduction 7) triples
2 What is grammar? Explain types of grammar. Write an unambiguous grammar for an
arithmetic expression containing the operators ↑ (exponentiation), +,*.
3 Write unambiguous production rules to produce arithmetic expression consisting of +, -
, *, / , ^ (exponent), id.
Use them for parsing id ^ id ^ id * id + id / id using shift -reduce parser (Naïve bottom
up parsing). Also lists limitation(s) of the method
4 Explain Language processing activities.
5 Draw Optimized DFA for following regular expression.
(1*)*0(0/1)*#
6 Construct DFA for following regular expression:
(a* | b* )a*ab #
7 A language consists of all strings of a’s and b’s which ends with b and does not contain aa.
Write regular expression for the language.
8 Build a DFA for following regular expression.
(a | b)*aab#
9 Draw a DFA for the following Regular Expression.
(a/b)* abb
10 Draw Optimized DFA for following regular expression.
(1*)*0(0/1)*#
11 Write a regular expression for the language consisting of all strings ending with 1 and does
not contain substring 00. Convert the resultant regular expression into Deterministic Finite
Automata.
12 Write Regular expression and DFA for valid exponential number .
13 Consider following grammar
s- > aSbS | bSaS | epsilon
Drive the string abab. Draw corresponding parse tree.
Are these rules ambiguous? Justify

PART-2

1 Explain working of LL (1) parser. Parse following string:


id + id - (id * id )
2 Remove left recursion from following production
rules:
A -> AaB | x
B -> BCb | y
C -> Cc | epsilon
3 Explain left recursion and left factoring with suitable example
4 Given a grammar
S→XS | dS | ε
X→Y | Zb | aY
Y→cZ
Z→e
Develop an LL(1) parsing table and check whether the string “dace” is accepted or not?
5 Construct LL(1) parsing table for following grammar.
E->TE’
E’ ->+TE’ | Є
T ->FT’
T’ ->*FT’ | Є
F-> (E) | id
6 Construct operator precedence parser for following grammar :
E ->E+E | E*E | id
7 Define Simple Phrase and Handle. Using Handle and Simple Phrase trace the bottom up
parsing algorithm.
Grammar is :
E ->T+ E | T – E | T
T -> T *V | T / V | V
V->a | b | c | d
String is : a - b * c + d
8 When Left- factoring on a grammar is applied? Apply left- factoring on the below given
grammar and perform Predictive Parsing.
Grammar is
S ->i E t S | i E t S e S | a
E ->b
String is : i b t a e i b t a
9 Explain recursive descent parsing algorithm
10 Write operator precedence table for arithmetic operators “+”, “*”, “-”, “/” .
Parse following expression using the table. id * id + id * id

PART-3

1 Explain in brief design of a Single Pass Assembler.


2 Differentiate one pass and two pass assembler. Explain how forward references are
handled in two pass assembler.
3 Explain and compare two variants of the intermediate code generated from multi pass
assembler.
4 List out various assembler directives. Explain any three with example.
5 Consider the following assembly program
START 500
READ N
MOVER CREG, ZERO
BK READ A
MOVER AREG, A
COMP AREG, MAX
BC LE, NT
MOVEM AREG, MAX
NT ADD CREG, ONE
COMP CREG, N
BC LT, BK
PRINT MAX
STOP
N DS 1
A DS 1
ZERO DC ‘0’
ONE DC ‘1’
MAX DC ‘0’
END
Instruction opcodes:
READ-09, MOVER-04,MOVEM-05, ADD-01,COMP-06, BC-07, PRINT-10, STOP-00
Assembler directive codes: START 01, END-02
Register code: AREG-01, CREG-03
1. Identify task performed by above program.
2. Generate symbol table
3. Show intermediate code generated by above program

6 Given the source program:


START 100
A DS 3
L1 MOVER AREG,B
ADD AREG,C
MOVEM AREG,D
MOVER BREG,=’2’
MOVER CREG,=’4’
D EQU A+1
L2 PRINT D
LTROG
=’2’
=’4’
ORIGIN A-1
C DC 5
ORIGIN L2+3
STOP
B DC ‘19’
END L1
=’5’
1) Show the contents of symbol table at the end of pass I.
2) Explain the significance of EQU and ORIGIN statements in the
program and explain how they are processed by the assembler.
3) Show the intermediate code generated from the program.
7 Given the source program:
START 200
X DS 4
L1 MOVER AREG,Y
SUB AREG,Z
MOVEM AREG,W
W EQU X+2
L2 PRINT W
ORIGIN X-5
Z DC ‘9’
ORIGIN L2+1
STOP
Y DC ‘7’
END
1) Show the contents of symbol table at the end of pass I.
2) Explain the significance of EQU and ORIGIN statements in the
program and explain how they are processed by the assembler.
3) Show the intermediate code generated from the program.
8 Given an assembly language program for finding factorial of a given
number N with Mnemonic code details. Write an equivalent machine
language program.

9 Consider following assembly program. Show (i) Contents of Symbol Table (ii) 07
intermediate codes using Variant I representation (iii) corresponding machine codes
START 100
READ A
READ B
READ C
MOVER AREG, A
ADD AREG, B
ADD AREG, C
MULT AREG, C
MOVEM AREG, RESULT
PRINT RESULT
STOP
A DS 1
B DS 1
C DS 1
RESULT DS 1
END
Instruction opcodes:
READ – 09, MOVER – 04, MOVEM – 05, ADD – 01, MULT – 03, PRINT – 10, STOP
– 00
Assembler-directive codes: START – 01, END - 02
Register code: AREG – 01

PART-4

1 Differentiate passes and phases of complier. Explain in brief syntax analysis phase
2 What is need and importance of intermediate code? Create quadruple and Triple for
following statement.
a= (a+b)*(c-d)
3 Consider the statement a=b+c*10.where a, b, c are of type float. Show the translation of the
given statement by different phases of compiler to produce assembly language statement .
4 What is code optimization? Explain with example various optimizing transformations.

5 Define static pointer. Find Register Requirement (RR) for the below given expression
f + ( x + y ) * ( ( a + b) / (c - d) )
6 Prepare Symbol Table & Quadruple Table using Value Numbers method
Stmt No Statement
5 A = 29.3 * D
17 B=24.5
31 C=A*B +W
49 X=A*B + Y
7 Given following expression = - (a+b) *(c+d) + (a+b+c)
1. Draw a Syntax tree for the expression
2. Write a three-address code for the expression
3. Give triple representation for the three address code of the expression
8 Perform lexical, syntax and semantic analysis on below C statement
a=b+c*d*100+e/f
Where data type of b, c & e are integers and remaining all variables are float
9 Explain operand and register descriptor with example. Also give best evaluation order for
arithmetic expression: a+b*c+d*e^f

10 Show quadruple table for local optimization using value numbers


Stmt. No. Stmt
14 g=25.2
15 x=z+2
07
16 h=x*y+d
: ……..
34 w=x*y
11 What are the issues in code generation in relation to compilation of
expression? Explain each issue in brief.
12 Write Three address codes and triple representation for
x=x*y*z+x*y+y*z
13 What is need and importance of intermediate code? Create quadruple and Triple for
following statement.
a= (a+b)*(c-d)

PART-5

1 Explain macro expansion in details.


Or
Explain lexical and semantic expansion of macro with example
2 Explain with example expansion time sequencing symbols and expansion time variable
3 Write general purpose macro to move the contents of one area of memory into another area of
memory. Assume that destination area is larger in size, remaining part of it should be padded
with zeroes at the end of the area
4 Explain use and field of following tables of a macro
KPDTAB, MDT, EVTAB, SSTAB
OR
Explain various data structures of Macro definition processing with
example
5 Define Lexical and Semantic Expansion. Write a macro which takes A,
B, C and D as parameters and calculates A*B+C*D in AREG.
6 Define a macro taking A and B as parameters to
compute A = A * B + B * B + A + B
7 Illustrate expansion of nested macro calls by giving
example.
PART-6

1 Explain self relocating program and overlay structured program.


2 Explain in brief design of an absolute Loader
3 Explain program relocation with example.
4 Write a short note on MS-DOS Linker.
5 Draw flow chart of “program linking”
6 Write an algorithm for first pass of a linker.
7 Explain functioning of interpreter.
8 Explain object module of the program.
9 Explain relocation and linking requirements in segmented addressing with
suitable example

You might also like