31
Page 1 of 31 MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION (Autonomous) (ISO/IEC - 27001 - 2005 Certified) SUMMER 12 EXAMINATIONS Subject code: 12263 Model Answer Q.1. a) Attempt any THREE of the following: i) List various applications of system software (1 mark for each point, any four points) 1) It increases the productivity of computer which depends upon the effectiveness, efficiency and sophistication of the systems programs. 2) Compilers are system programs that accept people like languages and translate them into machine language. 3) Loaders are system programs that prepare machine language program for execution. 4) Macro processors allow programmers to use abbreviation. 5) Provides efficient management of various resources. 6) It manages multiprocessing, paging, segmentation, resource allocation. 7) Operating system and file systems allow flexible storing and retrieval of information. ii) Distinguish between multiprogramming and multiprocessing (1 mark for each difference) Multiprogramming Multiprocessing 1) It is the interlarded execution of two of more processed by a processor without waiting for external event. 1) It is the simultaneous execution of two or more processes by a multiprocessor within a single computer system. 2) Multiprogramming loads more than one program in to the memory, so that processor can switch between any of the loaded program. 2) Multiprocessing involves the execution of multiple concurrent processes in a system instead of processing a single process at any one instant. 3) These systems are designed to maximize CPU usage. i.e. Number of processes run on a single processor 3) It means a process is run on multiple processors. So execution speed up is achieved 4) In these several programmes are running at a time, like windows with many programmes open. 4) It means that computer can process more than one thing at a time.

Page 1 31 MAHARASHTRA STATE BOARD OF · PDF filePage 1 of 31 MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION (Autonomous) (ISO/IEC - 27001 - 2005 Certified) SUMMER – 12 EXAMINATIONS

Embed Size (px)

Citation preview

Page 1 of 31 MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION (Autonomous)

(ISO/IEC - 27001 - 2005 Certified)

SUMMER – 12 EXAMINATIONS

Subject code: 12263 Model Answer

Q.1. a) Attempt any THREE of the following:

i) List various applications of system software (1 mark for each point, any four

points)

1) It increases the productivity of computer which depends upon the effectiveness, efficiency and sophistication of the systems programs. 2) Compilers are system programs that accept people like languages and translate them into machine language. 3) Loaders are system programs that prepare machine language program for execution. 4) Macro processors allow programmers to use abbreviation. 5) Provides efficient management of various resources. 6) It manages multiprocessing, paging, segmentation, resource allocation. 7) Operating system and file systems allow flexible storing and retrieval of information. ii) Distinguish between multiprogramming and multiprocessing (1 mark for each difference)

Multiprogramming Multiprocessing

1) It is the interlarded execution of two of more processed by a processor without waiting for external event.

1) It is the simultaneous execution of two or more processes by a multiprocessor within a single computer system.

2) Multiprogramming loads more than one program in to the memory, so that processor can switch between any of the loaded program.

2) Multiprocessing involves the execution of multiple concurrent processes in a system instead of processing a single process at any one instant.

3) These systems are designed to maximize CPU usage. i.e. Number of processes run on a single processor

3) It means a process is run on multiple processors. So execution speed up is achieved

4) In these several programmes are running at a time, like windows with many programmes open.

4) It means that computer can process more than one thing at a time.

Page 2 of 31 MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION (Autonomous)

(ISO/IEC - 27001 - 2005 Certified)

SUMMER – 12 EXAMINATIONS

Subject code: 12263 Model Answer

iii) Explain the working of Bucket Sort. (2 marks for explanation, 2 marks for

example)

The sort involves examine the least significant digit of the keyword first, and the item is then assigned to a bucket uniquely depend on the value of the digit. After all items have been distributed the buckets items are merged in order and then the process is repeated until no more digits are left. A number system of base P requires P buckets. There are serious disadvantages to using it internally on a digital compiler

1) It takes two separate processes, a separation and a merge 2) It requires a lot of extra Storage for the buckets.

The average time required for the sort is ( N log P(K) ) where N is the table size, K is the maximum key size & P is the radix of the radix sort.

The extra storage required is N P.

Page 3 of 31 MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION (Autonomous)

(ISO/IEC - 27001 - 2005 Certified)

SUMMER – 12 EXAMINATIONS

Subject code: 12263 Model Answer

iv) Explain hash and random entry search (1 mark for hash, 3 marks for random entry) Ans. In hash and random entry search the random entry number K generated from the key by methods similar to their used in address calculation. If the K th position s avoid, then the new element is put there; is not then some other call must be found for the insertion.

The first problem is the generation of a random number from the key. The four character EBCDIC keywords divide the keywords by the table length N and use the remainder. This scheme works well as long as N and the key size have no common factors. For a given group of in keywords the remainder should be fairly evenly distributed over O---(N-1). Another method is to treat the keyword as a binary fraction and multiply it by another binary fraction. The second problem is the procedure to be followed when the first trial entry result in a filled position. There are a member of methods of resolving this problem.

1) Random entry with replacement: A sequence of random numbers is generated from the keyword from each of these a number between 1 and N is formed and the table is protect at the position. Probing are terminated when a void space is found. Notice that the random numbers generated are independence and it is perfectly possible to probe the same position twice.

2) Random entry without replacement: This is the same as above except that any attempt to prove the same position twice is bypassed. This method holds advantage over the only when proves are expensive e.g. for files on tape or drum.

3) Open addressing: If the first probe gives a position K and that position is filled, then the next location K+1 is probed and so on until a free position is found. If the search runs off the bottom of the table, then it is renewed at the top.

Page 4 of 31 MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION (Autonomous)

(ISO/IEC - 27001 - 2005 Certified)

SUMMER – 12 EXAMINATIONS

Subject code: 12263 Model Answer

Q.1. b) Attempt any ONE of the following: i) Describe database required by each pass of loader. (3 marks for pass1 database, 3 marks for pass2 database) Ans. Pass 1 data bases

1) Input object decks 2) Initial program load Address (IPLA) supplied by the programmer on the

operating system that specifies the address to load the first segment. 3) A program load address (PLA) counter, used to rap truck of each segments

assigned location. 4) A tab, global External symbol table (GEST) that is used to store each

external symbol and its corresponding assigned core address. 5) A copy of the input to be used by pass2. This may be stored on an auxiliary

storage device, such as magnetic tape, disk on drum, on the original object deck may be reread by loader a second time for pass 2.

Pass 2 data bases 1) Copy of object programs inputted to pass 1 2) Initial Program Load address parameter (IPLA) 3) The Program load address counter (PLA) 4) The Global External symbol table (GEST) prepared by pass 1, containing

each symbol and its corresponding absolute address value. 5) An array, the Local External Symbol Array (LESA), which is used to

establish a correspondence between the ESD ID numbers, used an ESO and RLD cards and the corresponding External Symbols absolute address value.

ii) With neat diagram explain intermediate phase of compiler. (3 marks for diagram, 3 marks for explanation) Ans. The compiler creates an intermediate form of source program. It affords 2 advantages

1) It facilitates optimization of object code. 2) It allows a logical separation between machine independent and machine

dependent. One intermediate form is a parse tree. For E.G

Page 5 of 31 MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION (Autonomous)

(ISO/IEC - 27001 - 2005 Certified)

SUMMER – 12 EXAMINATIONS

Subject code: 12263 Model Answer

Q.2) Attempt any TWO of the following: a) (2 marks for each technique)

The possible algorithm for four optimization techniques are as follows:-

1) Elimination of common sub expression 2) Compile time compute. 3) Boolean expression optimization. 4) Move invariant computations outside of loops.

1) Elimination of common sub expression: -The elimination of duplicate matrix entries can result in a more can use and efficient object program. The common subexpression must be identical and must be in the same statement.

The elimination algorithm is as follows:- i) Place the matrix in a form so that common subexpression can be recognized.

ii) Recognize two subexpressins as being equivalent. iii) Eliminate one of them. iv) After the rest of the matrix to reflect the elimination of this entry.

Page 6 of 31 MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION (Autonomous)

(ISO/IEC - 27001 - 2005 Certified)

SUMMER – 12 EXAMINATIONS

Subject code: 12263 Model Answer

For example:-

2) Compile time compute:- Doing computation involving constants at compile

time save both space and execution time for the object program.

The algorithm for this optimization is as follows:- i) Scan the matrix. ii) Look for operators, both of whose operands were literals. iii) When it found such an operation it would evaluate it, create new literal, delete old line iv) Replace all references to it with the uniform symbol for the new literal. v) Continue scanning the matrix for more possible computation.

For e.g.-

A = 2 276 / 92 B The compile time computation would be

Page 7 of 31 MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION (Autonomous)

(ISO/IEC - 27001 - 2005 Certified)

SUMMER – 12 EXAMINATIONS

Subject code: 12263 Model Answer

Matrix Before optimization Matrix After optimization

3)Boolean expression optimization:- We may use the properties of boolean expression to shorten their computation. e.g. In a statement If a OR b Or c, Then …… when a, b & c are expression rather than generate code that will always test each expression a, b, c. We generate code so that if a computed as true, then b OR c is not computed, and similarly for b. 4) Move invariant computation outside of loops:- If computation within a loop depends on a variable that does not change within that loop, then computation may be moved outside the loop. This requires a reordering of a part of the matrix. There are 3 general problems that need to be solved in an algorithm.

i) Recognition of invariant computation. ii) Discovering where to move the invariant computation. ii) Moving the invariant computation.

b) State and explain four basic task of Macroprocessor? (2 marks for each task) Ans: The 4 basic task of Macroprocessor is as follows:-

1) Recognize the macro definitions. 2) Save the Macro definition. 3) Recognize the Macro calls. 4) Perform Macro Expansion.

1) Recognize the Macro definitions:- A macroprocessor must recognize macro definitions identified by the MACRO and MEND pseudo-ops. When MACROS

M1 M2

M3

M4

* 2 276

/ M1 92

M2 B

= A M3

M1

M2

M3

M4

* 6 B

= A M3

Page 8 of 31 MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION (Autonomous)

(ISO/IEC - 27001 - 2005 Certified)

SUMMER – 12 EXAMINATIONS

Subject code: 12263 Model Answer

and MENDS are nested, the macroprocessor must recognize the nesting and correctly match the last or outer MEND with the first MACRO.

2) Save the Macro definition:- The processor must store the macro instruction

definitions which it will need for expanding macro calls. 3) Recognize the Macro calls:- The processor must recognize macro call that

appear as operation mnemonics. This suggest that macro names be handled as a type of opcode.

4) Perform Macro Expansion:- The processor must substitute for macro

definition arguments the corresponding arguments from a macro call, the resulting symbolic text is then substituted for the macro call.

c) Explain the purpose of various phases of a compiler. Clearly mention the required input and output generated by each of these phases. (For correct listing of phases 1 mark, 1 mark for each phase) Ans: The different phases of compiler is as follows:- 1) Lexical Phase:- i) Its main task is to read the source program and if the elements of the program are correct it generates as output a sequence of tokens that the parser uses for syntax analysis.

ii) The reading or parsing of source program is called as scanning of the source program. iii) It recognizes keywords, operators and identifiers, integers, floating point numbers, character strings and other similar items that form the source program. iv) The lexical analyzer collects information about tokens in to their associated attributes.

2) Syntax Phase:- 1st i) In this phase the compiler must recognize the phases (syntatic construction); each phrase is a semantic entry and is a string of tokens that has meaning, and 2nd Interpret the meaning of the constructions. ii) Syntactic analysis also notes syntax errors and assure some sort of recovery. Once the syntax of statement is correct, the second step is to interpret the meaning (semantic). There are many ways of recognizing the basic constructs and interpreting the meaning.

Page 9 of 31 MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION (Autonomous)

(ISO/IEC - 27001 - 2005 Certified)

SUMMER – 12 EXAMINATIONS

Subject code: 12263 Model Answer

iii) Syntax analysis uses rules (reductions) which specifies the syntax form of source language. iv) These reduction defines the basic syntax construction and appropriate compiler routine (action routine) to be executed when a construction is recognized.

v) The action routine interpret the meaning and generate either code or intermediate form of construction.

3) Interpretation Phase:- This phase is typically a routine that are called when a construct is recognized. The purpose of these routines is to on intermediate form of source program and add information to identifier table.

4) Code optimization Phase:- Two types of optimization is performed by

compiler, machine dependent and machine independent. Machine dependent optimization is so intimately related to instruction that the generated. It was incorporated into the code generation phase. Where are Machine independent optimization was done in a separate optimization phase.

5) Storage Assignment:- The purpose of this phase is as follows:-

i) Assign storage to all variables referenced in source program. ii) Assign storage to all temporary locations that are necessary for intermediate results. iii) Assign storage to literals. iv) Ensure that storage is allocated and appropriate locations are intralized.

6) Code generation:- i) This phase produce a program which can be in Assembly or machine language. ii)This phase has matrix as input.

iii) It uses the code production in the matrix to produce code. iv)It also reference the identifier table in order to generate address & code conversion.

Page 10 of 31 MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION (Autonomous)

(ISO/IEC - 27001 - 2005 Certified)

SUMMER – 12 EXAMINATIONS

Subject code: 12263 Model Answer

7) Assembly phase:-The compiler has to generate the machine language code for computer to understand. The task to be done is as follows:- i) Generating code ii) Resolving all references. iii) Defining all labels. iv) Resolving literals and symbolic table.

OR

Q.2)c) (1mark for each phase) Ans. 1) Lexical Analysis:- This phase takes as input the original program and if the

elements of the program are correct it generates some meaningful units called “tokens” 2) Syntax Analysis:- This phase takes as input the tokens generated by lexical phase and if the syntax of the statement is correct it generates a parse tree representation. 3) Sementic Analysis:- This phase performs the check on the meaning of the st statement and performs the necessary modifications in the parse tree representation. (If the structure of compiler does not include sementic analysis then in such a case sementic analysis is assumed to take place within the syntax an analysis phase) 4) Intermediate code generation:- This phase takes as input the pass tree Representation and generates an intermediate representation to break the complexity of the statement and hence helps in faster translation. 5) Code optimization:- This phase is responsible for generating an optimized Intermediate representation so that the resulting code would get executed Faster. 6) Code Generation:- This phase is responsible for generating the target

program which can be assembly language program or machine language Program. 7) Symbol table:- It is used for keeping a track on the symbols encountered in the program. 8) Error handler:- It is responsible for the detection reporting and the handling of the errors which can occur in any of the compilation phase.

Page 11 of 31 MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION (Autonomous)

(ISO/IEC - 27001 - 2005 Certified)

SUMMER – 12 EXAMINATIONS

Subject code: 12263 Model Answer

Q.3) Attempt any FOUR of the following:

a) What is loader? How it works? Explain with diagramatically?

(2 marks for diagram, 2 marks for explanation)

Ans: The loader is a program which accepts the object program decks prepares these

programs for execution by the computer and initiates the execution.

The loader must perform four functions.

1) Allocate space in memory for the program (allocation) 2) Resolve symbolic references between object decks (linking) 3) Adjust all address dependent locations, such as address constants, to

corresponds to the allocated space (relocation) 4) Physically place the machine instruction and data into memory (loading).

Fig General loading scheme

In simple loading scheme, the assembler o/p the machine language translation

of a program on a secondary storage device and a loader is placed in core. The

loader places into memory the machine language version of the users program

and transfers control to it. Since the loader program is much smaller than the

assembler, this makes more core available to the users program

Page 12 of 31 MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION (Autonomous)

(ISO/IEC - 27001 - 2005 Certified)

SUMMER – 12 EXAMINATIONS

Subject code: 12263 Model Answer

There are different types of loader scheme.

1) Compile and Go loader 2) Absolute loaders 3) Binary symbolic subroutine (BSS) loaders 4) Direct linking loader.

b) State functions of relocating loader (4 marks for explanation)

Ans. Relocating loader avoids possible reassembling of all subroutines when a single

subroutine is changed and perform the tasks of allocation and linking for the

programmer. The BSS loader allows many procedure segments yet only one data

segment.

The assembler assembles each procedure segment independently and passes on

to the loader the text and information as to relocation and intersegment references.

The o/p of a relocating assembler using a BSS scheme is the object program and

information about all other program it references.

For each source program the assembler o/p a text prefixed by a transfer vector

that consist of addresses containing names of the subroutines referenced by the

source program. The assembler would also provide the loader with additional

information such as the length of the entire program and the length of the transfer

vector position. After loading the text and the transfer vector into core, the loader

would load each subroutine identified in the transfer vector. It would the place a

transfer instruction to the corresponding subroutine in each entry in the transfer

vector.

The BSS loader scheme is other used on compiler with a fixed length direct

address instruction format.

The relocation bit solves the problem of relocation, the transfer vector is used to

solve the problem of linking and the program length information solves the problem of

allocation.

Page 13 of 31 MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION (Autonomous)

(ISO/IEC - 27001 - 2005 Certified)

SUMMER – 12 EXAMINATIONS

Subject code: 12263 Model Answer

c) State the use of macro with suitable example (2 marks for explanation, 2 marks for

example)

Ans. Macros are single line abbreviation for groups of instructions. For every

occurrence of this one. Line macro instruction, the macro processing assemble will

substitute the entire block.

By defining the appropriate macro instruction can assembly language

programmer can tailor his own higher level facility in a convenient manner, at no cost

in control over the structured of his program.

He can achieve the conciseness and ease in coding of high level language

without losing the basic advantage of assembly language programming.

Integral macro operation simplifies debugging and program modification and

they facilitate standardization.

Many computer manufactures use macro instructions to automate the writing of

“tailors” operating systems in a process called system generation.

Macro instructions are usually considered an extension of the basic assembler language and macro processor is viewed as an extension of the basic assembler algorithm. Macro expanded sources INCR A 1, Data A 2, Data A 3, Data MENO . . INCR . . A 1, Data A 2, Data INCR A 3, Data . . . . DATA OC F’ S’ A 1, Data A 2, Data A 3, Data . . Data DC F’ S’

Page 14 of 31 MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION (Autonomous)

(ISO/IEC - 27001 - 2005 Certified)

SUMMER – 12 EXAMINATIONS

Subject code: 12263 Model Answer

d) Draw the flowchart of Pass-I of assembler. (4 marks for correct flow chart)

Page 15 of 31 MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION (Autonomous)

(ISO/IEC - 27001 - 2005 Certified)

SUMMER – 12 EXAMINATIONS

Subject code: 12263 Model Answer

e) Explain the foundation of system programming (2 marks for diagram, 2 marks for

explanation)

Ans.

System programs leg compiler, loaders, macro processor, operating systems

were developed to make computer better adapted to the needs of their users.

Compiler is system program that accept people life languages and translate

them into machine language.

Loaders are system programs that prepare machine language programs for

execution.

Macro processors allow programmers to use abbreviations. Operating system

and file system allows flexible storing and retrieval of information. The productivity of

each computer is heavily dependent upon the effectiveness, efficiency and

sophistication of the system programs.

Q.4) a) Attempt any THREE of the following:

i) What is macro? Explain macroprocessor and macro definition. (2 mark for macro, 1

marks for macroprocessor, 1 mark for macro definition)

Ans. The assembly language programmer often finds that certain set of instructions get

repeated often in the code. Instead of repeating the set of instructions the

programmer can take advantage of macro facility where macro is defined as “Single

line abbreviation for group of instructions”

People

Application Programming

Compilers Assemblers Macro processors

Loaders Text editor be baggily aids searching and sorting

I/O program File system Schedule Libraries Memory management device management

Page 16 of 31 MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION (Autonomous)

(ISO/IEC - 27001 - 2005 Certified)

SUMMER – 12 EXAMINATIONS

Subject code: 12263 Model Answer

For e.g.:-

The requirement of programmer is as follows:-

. . .

A 1, Data

A 2, Data

A 3, Data

. . . A 1, Data

A 2, Data

A 3, Data

. . .

The above requirement can be achieved by using macro facility as follows:-

MACRO

INCR

A 1, Data

Macro A 2, Data

definition A 3, Data

MEND

. . . INCR

. . INCR

.

END

Page 17 of 31 MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION (Autonomous)

(ISO/IEC - 27001 - 2005 Certified)

SUMMER – 12 EXAMINATIONS

Subject code: 12263 Model Answer

The meaning of INCR is not known to the assembler because it is programmer

defined and hence we need a Macroprocessor that would take if and process it.

Macroprocessor is responsible for processing a Macro.

There are 4 functions (task) of Macroprocessor,

i) Recognize macro definition.

ii) Save the Macro definition.

iii) Recognize the Macro calls

iv) Perform macro expansion.

Macro definition:- As seen in previous example i.e.

MACRO

INCR

A 1, Data

A 2, Data

A 3, Data

MEND

Macro definition is nothing but a code or a program that would be enclosed

within an MACRO and MEND pseudo opcode. It is requires by Macroprocessor for

recognizing and saving it for Macro expansion.

ii) Explain different data structures used by Phase-II assembler. (4 marks for

explanation)

Ans. The various data structure used is as follows:-

i) Copy file:- It is prepared by pass 1 to be used by pass 2.

ii) Location counter:- It is used to assign address to instruction and addressed to

symbol defined in the program.

Page 18 of 31 MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION (Autonomous)

(ISO/IEC - 27001 - 2005 Certified)

SUMMER – 12 EXAMINATIONS

Subject code: 12263 Model Answer

iii) Machine operation Table (MOT) or Mnemonic Opcode Table (MOT):- It is

used to indicate for each instruction.

a) Symbolic mnemonic b) Instruction length c) Binary machine opcode. d) Format.

iv) Pseudo-operation Table (POT):- It indicate for each pseudo-op the symbolic

mnemonic and action to be taken in pass 2

Or

It is consulted to process pseudo like DS, DC, Drop & using.

v) Symbol Table (ST):- It is used to generate the address of the symbol address in

the program.

vi) Base table (BT):- It indicate which registers are currently specified as base

register by USING Pseudo-ops.

vii) INST workspace:- It is used for holding each instruction and its various parts

are being getting assembled.

viii) PUNCH CARD workspace:- It is used for punching (outputting) the assembled

instruction on to cards.

ix) PRINT LINE workspace:- It is used for generating a printed assembly listing for

programmers reference.

x) Object card:- This card contain the object program in a format required by the

loader.

iii) Explain how to reduce different process in compiler. (1 mark for each process)

Ans. There are 4 different ways to reduce process in compiler. They are as follows:-

1) Elimination of common subexpression 2) Compile time compute. 3) Boolean expression optimization 4) Move invariant computation outside of loop.

Page 19 of 31 MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION (Autonomous)

(ISO/IEC - 27001 - 2005 Certified)

SUMMER – 12 EXAMINATIONS

Subject code: 12263 Model Answer

1) Elimination of common subexpression:- The elimination of duplicate matrix enteries can result in more concise and efficient object program. The common subexpression must be identical and must be in same statement.

2) Compile time compute:- Doing computation involving constants at compile time save both space and execution time for the object program.

3) Boolean expression optimization:- We may use the properties of Boolean expression to shorten their computation.

4) Move invariant computation outside of the loops :-If computation within a loop depends on a variable that does not change within that loop, then computation may be moved outside the loop.

a) Recognition of invariant computation b) Discovering where to move the invariant computation. c) Moving the invariant computation.

iv) Compare linker and loader

Ans. (1 mark for each difference)

Linker Loader

1) Linker is s system program which

link different object module to

form a program.

1) Loader is a system program that

places the object program in

memory and prepare it for

execution and start the execution.

2) Many object module are

combined and given to loader

2) Loader accept the combined

version of object module.

3) Linker accepts the input (.obj

file) from compiler or assembler.

3) Loader accepts the input from

linker.

4) Source code is given to complier

which generates object code,

which is given to linker, which

forms machine code and is given to

loader

4) Source code is given to complier

which generates object code,

which is given to linker, which

forms machine code and is given to

loader which then makes it

executable in processor memory

and is executed.

Page 20 of 31 MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION (Autonomous)

(ISO/IEC - 27001 - 2005 Certified)

SUMMER – 12 EXAMINATIONS

Subject code: 12263 Model Answer

Q.4) b) Attempt any ONE of the following:

i) Describe the function of interpretation phase of compiler. (6 marks for

explanation)

Ans. The interpretation phase is typically a collection of routines that are called

when a construct is recognized in the syntactic phase. The purpose of these routine is

to create an intermediate form of the source program and add information to the

identifier table.

The separation of the syntactic phase from the interpretation phase is a logical

division. The former phase recognizes syntactic constructs while the latter interpret

the precise meaning in to the matrix or identifier table.

The database used by interpretation phase is as follows:-

1) Uniform symbol table. 2) Stack 3) Identifier table. 4) Matrix

1) Uniform Symbol table:- It contains source program in uniform table. 2) Stack:- It contains the tokens currently being parsed by the syntax and

interpretation phase. 3) Identifier table:- It describes the identifiers used in the source program. 4) Matrix:- It is the primary intermediate form of the program.

ii) Describe the main function of lexical phase of compiler.

Ans. (6 marks for explanation)

i) It is the only phase which is allowed to communicate with the original source

program.

ii) This phase take as input the original source program and generate some

meaningful units called “tokens”.

iii) The other functions performed by lexical phase are as follows:-

Page 21 of 31 MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION (Autonomous)

(ISO/IEC - 27001 - 2005 Certified)

SUMMER – 12 EXAMINATIONS

Subject code: 12263 Model Answer

a) It is responsible for removing the comments and white space from the

program.

b) It is also responsible for generating the copy of a program with errors

marked in it.

c) The program that perform lexical analysis is called as lexical analyzer or

scanner.

The three tasks of lexical analysis phase are:-

1) To parse the source program in to basic elements or tokens of the language. 2) To build a literal table and an identifier table. 3) To build a uniform symbol table. The database used are:-

1) Source program:- Original form of program appear to the compiler as string of character.

2) Terminal table:- A permanent database that has an entry for each terminal symbol.

3) Literal table:- It describe literals used in the source program. 4) Identifier table:- Describe identifiers used in the source program. 5) Uniform symbol table.

Q.5) Attempt any TWO of the following:

a) Explain overlay structure in detail. (2 mark for diagram, 6 marks for explanation)

Ans. The subroutines of a program are needed at different times. For e.g. Pass 1 and pass 2 of an assembler are call other subroutine it is possible to produce an

overlay structure that identifiers mutually exclusive subroutines. In order for the overlay structure to work it is necessary for the module

loader to the various procedures as they are needed. The portion of the loader

that actually intercepts the “calls” and loads the necessary procedure is collect

the overlay supervision or simply the upper.

Page 22 of 31 MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION (Autonomous)

(ISO/IEC - 27001 - 2005 Certified)

SUMMER – 12 EXAMINATIONS

Subject code: 12263 Model Answer

70 K

Overlay structure

Above program consisting of five subprogram (A, B, C, D & E) that require look

bytes of core. The arrow indicate that subprogram A only calls B, D and E; subprogram

B only calls C and E; subprogram D only calls E; and subprogram C and E do not call any

other routine procedures B and D are never in use at the same time; neither are C and

E. If are load only those procedures that are actually to be used at any particular time,

the amount of core needed is equal to the longest path of the overlay structure. This

happens to be 70k.

Overlay reduces the memory requirement of a program. It also makes it possible

to execute program where size exceeds the amount of memory which cane ne

allocated to them.

For the execution of overlay structured program, the root is loaded in

memory and given control for the execution. Other overlays are loaded as and when

headed. Loading of an overlay overwrite a previously loaded overlay with the same

load origin.

A (20 K)

B (20 K) D (10 K)

e (30 K) E (20 K)

Page 23 of 31 MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION (Autonomous)

(ISO/IEC - 27001 - 2005 Certified)

SUMMER – 12 EXAMINATIONS

Subject code: 12263 Model Answer

b) Draw the block diagram of the phases of compiler. (8 marks for correct complete

diagram)

Ans.

OR

(There are two diagrams for this question. so any one diagram can be considered)

Page 24 of 31 MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION (Autonomous)

(ISO/IEC - 27001 - 2005 Certified)

SUMMER – 12 EXAMINATIONS

Subject code: 12263 Model Answer

c) Explain Binary search and Linear search. (4 marks for each search)

Ans. Binary search:- A more systematic copy of searching an ordered table is: start at

the middle of the table and compare the keyword with the middle entry. The keyword

may be equal to greater than or smaller than the item checked. The next action taken

for each of these outcomes is as follows:

1) If equal , the symbol is found 2) If greater, use the top half of the given table as a new table to search

Page 25 of 31 MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION (Autonomous)

(ISO/IEC - 27001 - 2005 Certified)

SUMMER – 12 EXAMINATIONS

Subject code: 12263 Model Answer

3) If smaller, use the bottom half of the table. This method effectively divides the table in half an every probe, systematically bracketing the item searched for. The search is terminate with a ‘not found’ condition when the length of the last suitable searched is down to 1 and the item has not been found.

Symbol probe1 probe2 probe3 probe4

1 AL 2 EX 3 FN 4 FU IF>FU 5 IF 6 IW IF<IW IF=IF 7 LE 8 LO IF<LO 9 NC 10 OP 11 OR 12 RO 13 RN 14 JE 15 T1

Linear search:- In linear search the given keyword id compare exhaustively with

every entry in the table with the given keyword. Element examined sequentially

starting from the first element and ended when list exhausted.

2) The time complexity = o(n)

3) Number of comparison in worst case 2 20

4) Linear search is suitable for short tables.

5) This search is not suitable for large number of data.

6) This linear search method do not need sorting of elements.

7) It provides little comfort to know that on the average only search half of the

dictionary.

Page 26 of 31 MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION (Autonomous)

(ISO/IEC - 27001 - 2005 Certified)

SUMMER – 12 EXAMINATIONS

Subject code: 12263 Model Answer

8) The average length of time to find and entry is

T(avg)=[ overhead associated with entry probe] * 2

N

Q.6) Attempt any FOUR of the following:

a) Explain Insertion sort. (2 marks for explanation, 2 marks for example)

Ans. Insertion sort is based on the principle of inserting the element at a correct place

in a previously sorted list. It can be varied from 1 to n-1 to sort the entire array.

Index - 0 1 2 3 4 5 6 Initial unsorted list

Elements 5 0 1 9 2 6 4

to be sorted

A list of sorted element A list of unsorted element

(a list of single element is always sorted)

1st Iteration (place element at location ‘1’ i.e. a[1]; at its correct place)

0 1 2 3 4 5 6

0 5 1 9 2 6 4

Sorted unsorted

2nd Iteration (Place a[2] at its correct place)

0 1 5 9 2 6 4

Sorted unsorted

Page 27 of 31 MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION (Autonomous)

(ISO/IEC - 27001 - 2005 Certified)

SUMMER – 12 EXAMINATIONS

Subject code: 12263 Model Answer

3rd Iteration (place a[3] at its correct place)

0 1 5 9 2 6 4

Sorted unsorted

4th Iteration (place a[4] at its correct place)

0 1 2 5 6 9 4

Sorted unsorted

6th Iteration (place a[6] at its correct place)

0 1 2 4 5 6 9

b) Define syntactic analysis (4 marks for explanation)

Ans. i) in syntactic analysis the compiler must recognize the phrases (syntactic

construction), each phrase is a semantic entry and is a string of tokens that has

meaning and interpret the meaning of the construction.

ii) Syntactic analysis also notes syntax errors and assure some sort of recovery. Once

the syntax of statement is correct, the second step is to interpret the meaning

(semantic).

iii) There are many ways of recognizing the basic construct and interpreting the

meaning.

iv) Syntax analysis uses rules (reductions) which specifies the syntax form of source

language.

v) These reduction defines the basic syntax construction and appropriate action

routine to be executed when a construction is recognized.

Page 28 of 31 MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION (Autonomous)

(ISO/IEC - 27001 - 2005 Certified)

SUMMER – 12 EXAMINATIONS

Subject code: 12263 Model Answer

vi) The action routine interprets the meaning and generates either code or

intermediate form of construction.

c) Explain conditional macro with an example. (2 marks for explanation, 2 marks for

example)

Ans. Two important macroprocessor pseudo-ops AIF and AGO permit conditional

reordering of the sequence of macro expansion. This allows conditional selection of

the machine instructions that appear in expansions of Macro call.

Consider the following program.

. . . Loop 1 A1, DATA 1

A2, DATA 2

A3, DATA 3

. . .

Loop 2 A1, DATA 3

A2, DATA 2

. . .

Loop 3 A1, DATA1

.

. .

DATA 1 D C F ‘5’

DATA 2 D C F ‘10’

DATA 3 D C F ‘15’

Page 29 of 31 MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION (Autonomous)

(ISO/IEC - 27001 - 2005 Certified)

SUMMER – 12 EXAMINATIONS

Subject code: 12263 Model Answer

In the below example, the operands, labels and the number of instructions generated

change in each sequence. The program can written as follows:-

.

.

. MACRO

& ARGO VARY & COUNT, & ARG1, &ARG2, &ARG3

& ARGO A 1, &ARG1

AIF (& COUNT EQ1).FINI

A 2, & ARG2

AIF (& COUNT EQ2).FINI

A 3, & ARG3

.FINI MEND

.

.

. LOOP1 VARY 3, DATA1, DATA2, DATA3 loop 1 A1, DATA1

. A2, DATA2 . A3, DATA3 . LOOP2 VARY 1, DATA1 loop 2 A1,DATA3 . A2, DATA2 . . DATA 1 D C F ‘5’

DATA 2 D C F ‘10’

DATA 3 D C F ‘15’

Page 30 of 31 MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION (Autonomous)

(ISO/IEC - 27001 - 2005 Certified)

SUMMER – 12 EXAMINATIONS

Subject code: 12263 Model Answer

Labels starting with a period(.) such as .FINI are macro labels and do not appear in the

output of the macroprocessor . The statement AIF ( & COUNT EQ1) .FINI direct the

macroprocessor to skip to the statement. Labeled .FINI if the parameter corresponding

to & COUNT is a1; otherwise the macroprocessor is to continue with the statement

following the AIF pseudo-ops.

AIF is a conditional branch pseudo ops it performs an arithmetic test and branches only

if the tested condition is true.

AGO is an unconditional branch pseudo-ops or ‘Go to’ statement. It specifies label

appearing on some other statement.

AIF & AGOcontrol the sequence in which the macroprocessor expands the

statements in macro instructions.

d) Explain disadvantage of BSS loader? (1 mark for each disadvantage, 1 mark for

function of BSS)

Ans. The BSS loader allows many procedure segments, but only one data segments.

The disadvantage of BSS loader is as follows:-

1) The transfer vector increases the size of object program in memory. 2) The transfer vector linkage is only useful for transfers. 3) Not well suited for loading or storing external data.

E) What is Macro language? (4 marks for explanation) (Any other suitable example can be considered) Ans. Macro language is a language which is understand by macroprocessor. Macro requires an overhead of macroprocessor . Macro language is always enclosed in MACRO & MEND pseudo-opcode. Macro is a single line abbreviation for group of instructions. The template for defining a macro is as follows:- MACRO Start of definition _____ Macro name _____ _____ Body of macro

Page 31 of 31 MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION (Autonomous)

(ISO/IEC - 27001 - 2005 Certified)

SUMMER – 12 EXAMINATIONS

Subject code: 12263 Model Answer

_____ MEND End of macro E.g:- MACRO INCR A1, DATA A2, DATA A3, DATA MEND . . . INCR . . . END The meaning of INCR is not known to assembler because it is programmer defined and hence we need macroprocessor. So macro language requires a macroprocessor.