P1 · 39189 (Nov 2023)
P2 · 82559 (Jan 2025)
P3 · 65655 (Dec 2024)
P4 · 27651
P5 · 15311 (Dec 2022)
P6 · 91398 (Summer 2022 MCQ)
MathJax enabled
01
Introduction to System Software
1.1 Concept & Goals of System Software · System Program vs System Programming · Assembler · Macro Processor · Loader · Linker · Compiler · Interpreter · Device Drivers · OS · Editors · Debuggers
2 HRS
Define "System Programming". Differentiate between system software & application software.
Compare Application Software and System Software.
Differentiate between Application Software and System Software.
With a neat diagram, explain the sequence of system programs involved from writing source code to executing a program.
Compare between Compiler and Interpreter. (P5: Q1.A Differentiate between Application Software and System Software.)
Rearrange the Compilation Process in the correct order — a. Linking b. Assembling c. Pre-Processing d. Compiling:
A) c→d→b→a B) c→d→a→b C) d→c→b→a D) c→b→d→a
Differentiate between Application and System Software. (P6 Q2 short note)
02
Assemblers
2.1 Elements of Assembly Language · Assembly Scheme · Pass Structure · Two-Pass Assembler Design · Single-Pass Assembler Design for X86 · Data Structures Used
7 HRS
Draw the flowchart of Pass-1 of assembler and explain its working with the databases.
Explain with flowchart the design of two-pass assembler.
Draw and explain the flowchart of Pass-I of two-pass assembler with a suitable example.
Consider the following Assembly Program. Generate Pass-1 and Pass-2 and show the content of Database table involved in it.
START 100
READ N
MOVER BREG, '=1'
MOVEM BREG, TERM
A: MULT BREG, TERM
LTORG
MOVER CREG, '=2'
MOVEM BREG, '=5'
LTORG
N DS 1
TERM DS 1
END
Consider the following Assembly Program. Generate Pass-1 and Pass-2 and also show the content of Database table involved in it.
START 501
A DS 1
B DS 1
C DS 1
READ A
READ B
MOVER AREG, A
ADD AREG, B
MOVEM AREG, C
PRINT C
END
State and explain the types of assembly language statements with examples.
Explain in brief the "forward reference problem". Explain how the Two-Pass Assembler (TII) handles the forward reference problem in a single-pass assembler.
Consider the Assembly code and identify the type of statement:
START 300
Line-1 ADD AREG, A
Line-2 A DC '4'
--
END
A) Line-1 is Imperative and Line-2 is Assembler Directive B) Line-1 is Assembler Directive and Line-2 is Declaration Directive C) Line-1 is Imperative and Line-2 is Declaration Statement D) Line-1 is Declaration Directive and Line-2 is Assembler Directive
Consider the Assembly code and identify the intermediate code and Current Location Counter for Line-2:
START 100
Line-1 MOVER AREG, First
Line-2 ADD AREG, Second
Line-3 MOVEM AREG, Result
Line-4 PRINT Result
A) LC=101, (IS,02)(RG,01)(S,1) B) LC=101, (IS,01)(RG,01)(S,1) C) LC=102, (IS,01)(RG,01)(S,1) D) LC=102, (IS,02)(RG,01)(S,1)
03
Macros and Macro Processor
3.1 Introduction · Macro Definition & Call · Features of Macro Facility: Simple, Parameterized, Conditional & Nested · Two-Pass Macro Processor Design · Data Structures Used
6 HRS
Explain conditional macro with a suitable example.
Explain different features of macros with a suitable example.
Explain advanced macro facilities with suitable examples.
Explain Macro and Macro Expansion with example. (P4 short note: Macro facilities.)
Write the structure of a simple macro definition and a corresponding macro call with a suitable example.
Explain macro calls within macros (nested macros) with an appropriate example.
Explain the working of a Single-pass macro processor with a neat flowchart.
List and describe the data structures used in the design of a two-pass macro processor with a suitable example.
Construct the necessary data structures after compiling the following code by Pass-1 of two-pass macro processor:
1. MACRO
2. COMPUTE &x, &a, &p
3. MOVER &a, &x
4. MULT &a, ='4'
5. MOVEM &a, &p
6. MEND
7. MACRO &g, &k, &r
8. MOVER &r, &k
9. SUB &r, ='4'
10. MEND
Explain with a flowchart the first pass of two-pass macro processor.
Consider the code:
MACRO
&TEST ABC &X, &Y, &Z
&TEST A 1, &X
A 2, &Y
A 3, &Z
MEND
LOOP1 SPCC P1, P2, P3
What will be the value in MDTC and MNTC after processing macro definition?
A) MDTC=5, MNTC=1 B) MDTC=6, MNTC=2 C) MDTC=2, MNTC=6 D) MDTC=1, MNTC=5
Identify the correct statement with respect to inherited attributes:
A) Attributes can take values from parents and left siblings but not right sibling B) From parents and right siblings but not left C) From parent or siblings D) Only from siblings
04
Loaders and Linkers
4.1 Introduction · Functions of Loaders · Relocation & Linking Concept · Different Loading Schemes: Relocating Loader · Direct Linking Loader · Dynamic Linking and Loading
6 HRS
Explain the functions of a Loader. Enlist the loader schemes. (P2: Explain the process of loading and linking with a neat diagram.)
Explain absolute loader. State its advantages and disadvantages.
Discuss the concept of "Relocation" in loaders. Explain the various methods of handling relocation during the loading process with examples.
In terms of relocating the loader, which of the following is used to overcome the problem of linking?
A) Transfer Vector B) Relocation bits C) Transfer Array D) Program length
What is relocation and linking concept in Loaders? (P6 Q4.A ii short note)
Explain Direct Linking Loader in detail. Discuss the databases used.
Explain Dynamic Linking Loader in detail.
05
Compilers: Analysis Phase
5.1 Intro to Compilers · Phases of Compiler · Lexical Analysis: FSA role, Lexical Analyzer Design, Data Structures
5.2 Syntax Analysis: CFG, Parsers — LL(1), SR, Operator Precedence, SLR · Semantic Analysis: Syntax Directed Definitions
5.2 Syntax Analysis: CFG, Parsers — LL(1), SR, Operator Precedence, SLR · Semantic Analysis: Syntax Directed Definitions
10 HRS
Explain the phases of a compiler with a suitable example. Discuss the action taken in each phase to compile the given statement:
P1:
P4:
P5/P6: General phases with example
P = Q + R – S * 3P4:
a = b*c + 10 (where a, b, c are of type real)P5/P6: General phases with example
What are tokens, lexemes, and patterns in lexical analysis? Give examples.
Compare Pattern, Lexeme and token with example. (P6 Q4A iii — short note)
Compute FIRST and FOLLOW for the following grammar:
S → Aa
A → BD
B → b | ε
D → d | ε
What will be the FOLLOW(A) for the following grammar?
S → AaAb
S → BaBb
A → ε
B → ε
A) Only a B) a, b C) Only b D) Only ε
Design a Predictive (LL(1)) Parser for the given grammar. Mention all steps.
E → TQ
T → FR
Q → +TQ | -TQ | E
R → *FR | /FR | E
F → (E) | id
Design LL(1) parsing table for the given grammar. Also state whether the grammar is LL(1) or not.
S → iCtSE | a
E → eS | ε
C → b
Design LL(1) parsing table for the given grammar. Also state whether the grammar is LL(1) or not.
S → Ad
A → aB | BC
B → b
C → e | ε
Test whether the following grammar is LL(1) or not. If it is LL(1), construct the parsing table:
S → 1AB | ε
A → 1AC | 0C
B → 0S
C → 1
Test whether the given grammar is LL(1) or not. Construct LL(1) Parsing Table.
S → AB / gDa
A → ab/c
B → dC
C → gC/g
D → fD/g
(a,b,c,d,f,g are terminals; S,A,B,C,D are Non-Terminals)
Construct LR(0) parsing table for the following grammar and analyze the contents of stack and input buffer and action taken after each step while parsing the input string "abbcbcde":
S → aCDe
C → Cbc
C → b
D → d
Construct SLR parser for the following grammar and parse the input "( )( )":
S → (S)S | ε
Construct operator precedence parser for the grammar:
E → E+E | E*E | a
Parse the string "a+a*a" using the same parser. (P2: Explain the operator precedence parser with a suitable example.)
Compare Bottom-Up and Top-Down Parser.
Which of the following grammar is appropriate for operator precedence grammar?
A) S→EF B) S→E*F|ε C) S→E+F D) S→+EF
Write short note on Syntax-directed Translation.
Identify the correct statement with respect to inherited attributes:
A) Attributes take values from parents and left siblings but not right sibling B) From parents and right siblings but not left C) From parent or siblings D) Only from siblings
06
Compilers: Synthesis Phase
6.1 Intermediate Code Generation: Syntax Tree · Postfix Notation · Three-Address Codes: Triples, Quadruples, Indirect Triple
6.2 Code Optimization: Need & Sources · Techniques: Machine Dependent & Independent
6.3 Code Generation: Issues in Design · Code Generation Algorithm · Basic Block & Flow Graph
6.2 Code Optimization: Need & Sources · Techniques: Machine Dependent & Independent
6.3 Code Generation: Issues in Design · Code Generation Algorithm · Basic Block & Flow Graph
8 HRS
What are the different ways of Intermediate Code representation? Explain with examples. (Include: Triples, Quadruples, Indirect Triples, Postfix, Syntax Tree.)
Generate 3-address code for the following C program and construct flow graph with the help of basic blocks:
i=1; j=1; x=5;
while(i<3) {
switch(i) {
case 1: a[j++]=i+x; break;
case 2: a[j++]=i-x; break;
}
i++;
}
Construct Three-address code for the following program:
/* P3 */
i= 1;
x = 0;
while (i <= n) {
x = x + 1;
i = i + 1;
}
/* P5 */
For(i=0; i<10; i++) {
if (i<5)
a=b+c*3;
else
x=y+z;
}
What is three-address code? Generate three-address code for:
while (a<b) do
if(c<d) then
x:=y+z
else
x:=y-z
Explain the concept of basic blocks and flow graph with an example of the three-address code.
Which of the following is the graphical representation that shows the basic blocks and their successor relationship?
A) Hamiltonian graph B) Control graph C) Flow graph D) DAG
Explain DAG (Directed Acyclic Graph) with a suitable example.
P5: Construct DAG for the following expression:
P5: Construct DAG for the following expression:
x = m + p/q – t + p/q * y
Explain different Code Optimization Techniques in detail with examples. (Include: constant folding, copy propagation, dead code elimination, common sub-expression elimination, code motion, induction variable reduction.)
What is code optimization? Explain with example the following code optimization techniques:
(i) Common sub-expression elimination (ii) Code motion
(iii) Dead code elimination (iv) Constant propagation
(iii) Dead code elimination (iv) Constant propagation
Define Code Optimization. What are the different types of code optimization techniques used in compilers? Provide an example of each.
Which technique is applicable to optimize the given code?
t=c*4
for(j=0; j<c*4; j++) { … }
A) Constant Propagation B) Copy Propagation C) Induction Variable Reduction D) Common Sub-expression Elimination
Write a short note on Peephole Optimization.
Explain the role of a code generator in a compiler. What are the issues to be considered in the design of a code generator? (P3: Explain different issues in code generation phase of compiler.)