← Sem VI PYQs
Paper Code: 89281  ·  TE / COMP / Sem VI · C-Scheme

System Programming &
Compiler Construction — Question Bank

📄 6 Question Papers 📚 6 Modules ⏱ 3 Hours · 80 Marks 🗓 2022 – 2025
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
Q1.a P1 Theory 5 marks
Define "System Programming". Differentiate between system software & application software.
Q1.A P3 Theory 5 marks
Compare Application Software and System Software.
Q1.A P5 Theory 5 marks
Differentiate between Application Software and System Software.
Q1.A P2 Theory 5 marks
With a neat diagram, explain the sequence of system programs involved from writing source code to executing a program.
Q1.B / Q4.A P4 P5 Theory 5 marks
Compare between Compiler and Interpreter. (P5: Q1.A Differentiate between Application Software and System Software.)
Q1 MCQ P6 MCQ 2 marks
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
Q2 MCQ P6 MCQ 2 marks
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
Q2.a P1 Theory 10 marks
Draw the flowchart of Pass-1 of assembler and explain its working with the databases.
Q2.A / Q6.B P2 P3 P5 Theory 10 marks
Explain with flowchart the design of two-pass assembler.
Q6.B / Q4 Q4A P4 P5 P6 Theory 10 marks
Draw and explain the flowchart of Pass-I of two-pass assembler with a suitable example.
Q2.A P2 Numerical 10 marks
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
Q3.A P6 Numerical 10 marks
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
Q4.a / Q2.B P1 P4 Theory 10 marks
State and explain the types of assembly language statements with examples.
Q1.b / Q1.C / Q1.D P1 P3 P4 Theory 5 marks
Explain in brief the "forward reference problem". Explain how the Two-Pass Assembler (TII) handles the forward reference problem in a single-pass assembler.
Q7 MCQ P6 MCQ 2 marks
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
Q9 MCQ P6 MCQ 2 marks
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
Q1.c P1 Theory 5 marks
Explain conditional macro with a suitable example.
Q3.A P5 Theory 10 marks
Explain different features of macros with a suitable example.
Q6.B P3 Theory 10 marks
Explain advanced macro facilities with suitable examples.
Q4.B / Q1.C P4 P5 Theory 5–10 marks
Explain Macro and Macro Expansion with example. (P4 short note: Macro facilities.)
Q1.C P2 Theory 5 marks
Write the structure of a simple macro definition and a corresponding macro call with a suitable example.
Q3.A P2 Theory 10 marks
Explain macro calls within macros (nested macros) with an appropriate example.
Q4.A P3 P5 Theory 10 marks
Explain the working of a Single-pass macro processor with a neat flowchart.
Q4.A P2 Theory 10 marks
List and describe the data structures used in the design of a two-pass macro processor with a suitable example.
Q3.a P1 Numerical 10 marks
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
Q3.B P4 Numerical 10 marks
Explain with a flowchart the first pass of two-pass macro processor.
Q6 MCQ P6 MCQ 2 marks
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
Q1 MCQ P6 MCQ 2 marks
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
Q1.D / Q1.B P3 P5 P2 Theory 5 marks
Explain the functions of a Loader. Enlist the loader schemes. (P2: Explain the process of loading and linking with a neat diagram.)
Q1.C P4 Theory 5 marks
Explain absolute loader. State its advantages and disadvantages.
Q6.A P2 Theory 10 marks
Discuss the concept of "Relocation" in loaders. Explain the various methods of handling relocation during the loading process with examples.
Q4 MCQ P6 MCQ 2 marks
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
Q4 MCQ P6 MCQ 2 marks
What is relocation and linking concept in Loaders? (P6 Q4.A ii short note)
Q4.b / Q3.A / Q5.B / Q6.A P1 P3 P4 P5 Theory 10 marks
Explain Direct Linking Loader in detail. Discuss the databases used.
Q6.a P1 Theory 10 marks
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
10 HRS
Q5.b / Q6.B / Q2.B / Q6.B / Q4.A P1 P2 P4 P5 P6 Theory 10 marks
Explain the phases of a compiler with a suitable example. Discuss the action taken in each phase to compile the given statement:
P1:   P = Q + R – S * 3
P4:   a = b*c + 10   (where a, b, c are of type real)
P5/P6: General phases with example
Q1.D P2 Theory 5 marks
What are tokens, lexemes, and patterns in lexical analysis? Give examples.
Q4 MCQ P6 MCQ 2 marks
Compare Pattern, Lexeme and token with example. (P6 Q4A iii — short note)
Q1.d P1 Numerical 5 marks
Compute FIRST and FOLLOW for the following grammar:
S → Aa A → BD B → b | ε D → d | ε
Q1 MCQ (Q4) P6 MCQ 2 marks
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 ε
Q3.B P2 Design 10 marks
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
Q3.B P3 Design 10 marks
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
Q3.B P5 Design 10 marks
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 | ε
Q6.A P4 Design 10 marks
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
Q3.C P6 Design 10 marks
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)
Q3.b P1 Design 10 marks
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
Q2.A P4 Design 10 marks
Construct SLR parser for the following grammar and parse the input "( )( )":
S → (S)S | ε
Q1.B / Q4.B P3 P2 Design 5–10 marks
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.)
Q1.D P5 Theory 5 marks
Compare Bottom-Up and Top-Down Parser.
Q8 MCQ P6 MCQ 2 marks
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
Q4.B P4 Theory 5 marks
Write short note on Syntax-directed Translation.
Q1 MCQ P6 MCQ 2 marks
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
8 HRS
Q2.b / Q2.B / Q4.B / Q1.A P1 P2 P5 P6 Theory 10 marks
What are the different ways of Intermediate Code representation? Explain with examples. (Include: Triples, Quadruples, Indirect Triples, Postfix, Syntax Tree.)
Q5.a P1 Numerical 10 marks
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++; }
Q2.B P3 P5 Numerical 10 marks
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; }
Q1.A P4 Numerical 5 marks
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
Q3.A P4 Theory 10 marks
Explain the concept of basic blocks and flow graph with an example of the three-address code.
Q2 MCQ P6 MCQ 2 marks
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
Q5.B / Q5.B P3 P5 Numerical 10 marks
Explain DAG (Directed Acyclic Graph) with a suitable example.
P5: Construct DAG for the following expression:
x = m + p/q – t + p/q * y
Q5.A / Q4.B / Q6.b / Q3.B P2 P3 P1 P6 Theory 10 marks
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.)
Q5.A P4 Theory 10 marks
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
Q5.A P2 Theory 10 marks
Define Code Optimization. What are the different types of code optimization techniques used in compilers? Provide an example of each.
Q5 MCQ P6 MCQ 2 marks
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
Q2 MCQ short P6 MCQ 5 marks
Write a short note on Peephole Optimization.
Q5.B / Q5.A P2 P3 Theory 10 marks
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.)