You are on page 1of 10

Pune Institute of Computer Technology, Pune-43

DEPARTMENT OF INFORMATION TECHNOLOGY


(Academic Year – 2019-20 Sem-II)
SAMPLE SOLUTION UNIT TEST - I

Subject: Systems Programming Subject Code: 314451


Class: TE ( IT ) Div: XI [ Max. Marks : 30]
Date: 07/02/2020 Day: Friday Duration: 1 Hour

Instructions to the candidate: SET-D


1. All questions are compulsory. Roll No: -
2. Assume suitable data, if necessary.

Ques. Max
Question
No. Marks
For the following piece of assembly language code, show the contents of symbol table,
literal table, pool table and IC (Variant I and Variant II). Assume machine opcodes and
size of instruction as 1.
START 100
A DC 10
MOVER AREG,B
MOVEM BREG, = '1'
ADD AREG, = '2'
1-a SUB BREG, = '1' 07
B EQU A + 20
LTORG
STORE AREG, NUM
MOVER CREG, LOOP
ADD BREG, = '1'
NUM DS 5
LOOP DC 10
END

Index Symbol Address Index Literal Address


0 A 100 0 =’1’ 105
1 B 120 1 =’2’ 106
2 NUM 110 2 =’1’ 116
3 LOOP 115
Sol:- Literal Table
Symbol Table

Pool Table :

Page 1 of 10

Literal
Pool Table
table: :
Pune Institute of Computer Technology, Pune-43
DEPARTMENT OF INFORMATION TECHNOLOGY
(Academic Year – 2019-20 Sem-II)
SAMPLE SOLUTION UNIT TEST - I

IC (variant I) IC (Variant II)


(AD, 01) (C, 100) (AD, 01) (C, 100)
(DL,02) (C,10) (DL,02) (C,10)
(IS, 04) (RG,01) (S,1) (IS, 04) AREG, B
(IS, 05) (RG,02) (L,0) (IS, 05) BREG, (L,0)
(IS, 01) (RG,01) (L,1) (IS, 01) AREG, (L,1)
(IS, 02) (RG,02) (L,0) (IS, 02) AREG, (L,0)
(AD, 04) (S,0)+20 (AD, 04) (A+20)
(AD, 05) (AD, 05)
(IS,09) (RG,01) (S, 2) (IS,09) AREG. NUM
(IS, 04) (RG,01) (S,3) (IS, 04) CREG LOOP
(IS, 01) (RG,02) (L,2) (IS, 01) BREG (L,2)
(DL, 01) (C,1) (DL, 01) (C,5)
(DL, 02) (C,10) (DL, 02) (C,10)
(AD, 02) (AD, 02)
1-b Write a short note on Language Processing Activities. 03
Sol: The fundamental language processing activities divided into two parts.
1. Program generation activities
2. Program execution activities

Program generation activities


• A program generation activity aims to generation of a program. Source is the
application domain and target is the PL domain. It bridges specification gap.
• The generator domain is close to the application domain, it is easy for the
designer or programmer to write the specification of the program to be generated.
• A program generator is software that enables an individual to create a program
with less efforts and prog. Knowledge.
• A user may only be required to specify the step or rules required for the program
Page 2 of 10
Pune Institute of Computer Technology, Pune-43
DEPARTMENT OF INFORMATION TECHNOLOGY
(Academic Year – 2019-20 Sem-II)
SAMPLE SOLUTION UNIT TEST - I

and not need to write and code or less code.


Program execution activities
• A program execution activity aims to execute a program written in PL. source is
PL domain and target is execution domain. It bridges execution gap.
• Two popular models for program execution are:
• Program Translation: The program translation model bridges the execution gap
by translating a program written in a PL called source program(SP), into an
equivalent program in the machine language called target program(TP)
• Program Interpretation: It reads the source program and stores it in its memory.
• During interpretation it takes a source statement, determines its meaning, and
performs actions like computation and I/O which implement it.

2-a Explain basic functions of loader. Also explain the working of compile and go loader. 04
Sol:- A loader is a system program that performs the loading function. It brings object
program into memory and starts its execution. The role of loader is as shown in the
following figure. In figure, translator may be assembler/complier, which generates the
object program and later loaded to the memory by the loader for execution.

compile and go loader.


• In compiler and go loader, the instruction is read line by line, its machine code is
obtained and it is directly put in the main memory at some known address.
• That means the assembler runs in one part of memory and the assembled
machine instructions and data directly put into their assigned memory locations.
• After the completion of loading process, the assembler transfers the control to the
starting instruction of the loaded program.
• This loading scheme is also called as “assemble and go”.
• Example: WATFOR-77, it’s a FORTRAN.
Advantages
• No additional routines are required to load the compiled code into memory.
• Execution speed is generally much superior to interpreted systems.
• They are simple and easier to implement.
Disadvantages
Page 3 of 10
Pune Institute of Computer Technology, Pune-43
DEPARTMENT OF INFORMATION TECHNOLOGY
(Academic Year – 2019-20 Sem-II)
SAMPLE SOLUTION UNIT TEST - I

• There is wastage in memory space due to the presence of the assembler.


• The code must be re-assembled every time it is run.

With format explain the following macro directives: MACRO, MEND, AIF, AGO, LBL
2-b 06
and GBL.
Sol: Macro and MEND:
 “A macro is a unit of specification for program generation through expansion.
 Macro definition consist of name, a set of formal parameters and a body of code.
 It replaces macro call into macro definition.
 “The use of macro name with a set of actual parameters (macro call) is replaced
by some code generated from its body (macro definition), this is called macro
expansion.”
 MEND Statement describes end of Macro.

AIF:
• Syntax:
AIF (<expression>) <sequencing symbol>
• Where <expression> is a relational expression consists of:
1. Ordinary strings.
2. Formal parameters with their attributes.
3. Expansion time variables.
• If the relational expression evaluates to true, expansion time control is transferred
to the statement containing <sequencing symbol> in its label field.
• Sequencing symbol(SS) has syntax
.<ordinary string>
Page 4 of 10
Pune Institute of Computer Technology, Pune-43
DEPARTMENT OF INFORMATION TECHNOLOGY
(Academic Year – 2019-20 Sem-II)
SAMPLE SOLUTION UNIT TEST - I

• A SS is defined by putting it in the label field of statement in the macro body. It


is used as operand in an AIF, AGO statement for expansion control transfer.

AGO:
• Syntax:
AGO <sequencing symbol>
• It unconditionally transfers expansion time control to the statement containing
<sequencing symbol> in its label field.

LCL and GBL:


• Local expansion time variables can be used only within one macro and it does
not retain its value across the macro call.
• Syantax: LCL <EV specification> [,<EV specification> .. ]
• Global expansion time variables can be used in every macro definition that has a
declaration for it and it retains its value across the macro call.
• Syntax: GBL <EV specification> [,<EV specification> .. ]
• <EV specification> has the syntax &<EV name>, where <EV name> is an
ordinary string.
• Values of EV's can be manipulated through the preprocessor statement SET.
• Syntax: < EV specification > SET <SET-expression>
Example:

3-a Write a neat diagram explain the phases of compiler. 05

Page 5 of 10
Pune Institute of Computer Technology, Pune-43
DEPARTMENT OF INFORMATION TECHNOLOGY
(Academic Year – 2019-20 Sem-II)
SAMPLE SOLUTION UNIT TEST - I

Sol:

 Lexical Analysis: Lexical Analyzer divides the given source statement into the
tokens.
 Syntax Analysis: The syntax analyzer checks each line of the code and spots
every tiny mistake. If code is error free then syntax analyzer generates the tree.

 Semantic analyzer determines the meaning of a source string. It performs


operations like: matching of parenthesis in the expression, Matching of if else
statement, Performing arithmetic operation that are type compatible and
Checking the scope of operation.

Page 6 of 10
Pune Institute of Computer Technology, Pune-43
DEPARTMENT OF INFORMATION TECHNOLOGY
(Academic Year – 2019-20 Sem-II)
SAMPLE SOLUTION UNIT TEST - I

 Intermediate code generator


 Two important properties of intermediate code : It should be easy to produce.
And easy to translate into target program. Intermediate form can be represented
using “three address code”. Three address code consist of a sequence of
instruction, each of which has at most three operands.

 Code Optimization: It improves the intermediate code.This is necessary to have a


faster execution of code or less consumption of memory.

Page 7 of 10
Pune Institute of Computer Technology, Pune-43
DEPARTMENT OF INFORMATION TECHNOLOGY
(Academic Year – 2019-20 Sem-II)
SAMPLE SOLUTION UNIT TEST - I

 Code Generation: The intermediate code instructions are translated into sequence
of machine instruction.

Using RE to DFA algorithm generate the DFA for the given Regular Expression.
3-b 05
(a+b)*a*b.
Sol:- Syntax Tree For RE:- (a+b)*a*b#

Page 8 of 10
Pune Institute of Computer Technology, Pune-43
DEPARTMENT OF INFORMATION TECHNOLOGY
(Academic Year – 2019-20 Sem-II)
SAMPLE SOLUTION UNIT TEST - I

Step 2: Calculate Nullable (Red Circle), Firstpos and Lastpos

Step 3: Calculate Followpos


Position follopos
5
4 5
3 3,4
2 1,2,3,4
1 1,2,3,4

Step 4: Design DFA


Initial state = firstpos of root = {1,2,3,4} ----- A
State A:
δ( (1,2,3,4),a) = followpos(1) U followpos(3)
=(1,2,3,4) U (3,4) = {1,2,3,4} ----- A

Page 9 of 10
Pune Institute of Computer Technology, Pune-43
DEPARTMENT OF INFORMATION TECHNOLOGY
(Academic Year – 2019-20 Sem-II)
SAMPLE SOLUTION UNIT TEST - I

δ( (1,2,3,4),b) = followpos (2) U followpos (4)


= (1,2,3,4) U {5}
= {1,2,3,4,5} ----- B
State B:
δ( (1,2,3,4,5),a) = followpos (1) U followpos (3)
= (1,2,3,4) U {3,4}
= {1,2,3,4} ----- A
δ( (1,2,3,4,5),b) = followpos (2) U followpos (4)
= (1,2,3,4) U {5}
= {1,2,3,4,5} ----- B
Transition Table:-

State a b
A={1,2,3,4} A B
B={1,2,3,4,5} A B
DFA:

-----------******-----------

Page 10 of 10

You might also like