Você está na página 1de 23

SYSTEM SOFTWARE

Chapter – 2 [Language Processors]


Language Processors:
Semantic gap: - To represent the different between the semantics of two domains. Fig
depicts the semantic gap between the application and execution domain.
Semantics: - We use the term semantics to represents the rules of meaning of a domain.
Specification gap: - Specification gap is the semantic gap between two specifications of the
same task.
Execution gap: - Execution gap is the between the semantics of programs (that perform the
dame task) written in different programming language.
• We restrict the use of the term execution gap to situations where one of the two
specification language is closer to the machine language.
• In other situations the term specification gap s more appropriate where one of the two
specification language as closer to the machine language.
 Language processor: - A language processor a software which bridge a specification gap or
execution gap.
 Language processing: - We use the term language processing to describe the activity
performed by a language processor.
 Source program: - A program form input to a language processor as source program
 Target program: - A program form input to a language processor as source program as to
its s output as the target program.
 The languages in which programs are written are called source language and target
language respectively.
 A spectrum of language processors is defined to meet practical requirements: -
 A language translator bridges an execution gap to the machine language (or assembly
language) of a computer system. An assembler is a language translator whose source
language is assembly language.
 A compiler is any language translator which is not an assembler. A de translator bridges
the same in the severs direction.
 A preprocessor is a language processor which bridges an execution gap not a language
translator.
 A language migrator: bridges the specification gap between two pls.
Example: - Fig shows the two language processors. The language processor of part (a)
converts a C++ program into a C
program, hence it is a preprocessor.
The language translator for C++ since
it produces a machine language
program in both cases the programs
are the c program and the machine
language program respectively.
 Problem oriented & procedure oriented languages: - The language which is only be
used for specific applications known as
problem oriented language. They have
large execution gaps. A procedure
oriented language provides general
purpose facilities required in most
application domains. Such a language is
independent of specific application domains. Fig:-Problem oriented
language domain.
LANGUAGE PROCESSING ACTIVITIES
The fundamental language processing activities can be divided into those that bridge
the specification gap and those that bridge execution gap. These activities as :
o Program generation activities
o Program execution activities
 Program Generation activities: -A
program generation activity aims at

NOTES BY – KANAK KUMAR KANAK E-MAIL ID – kkkanak@sify.com


1
SYSTEM SOFTWARE
automatic generation of a program Fig. depicts the program generation is a software
system which accepts the specification of a program to be generated and generates a
program in the target PL. Here the specification gap is now the gap between the
application domain and the program generator domain. This gap is smaller than the gap
between the application domain and the target PL domain.
 Program execution activities: - Two popular models for program execution are
translation and interpretation.
 Program Translation: - The program translation model ridges the execution gap by
translating a program written in a PL, called the source program into an equivalent
program in the machine or assembly language called the target program

Data

Source Translator Target


Machine lang. prog program
program

 Characteristics of the program translation: -


 A program must be translated before it can be executed.
 The translated program may be saved in a file. The saved program nay be
executed repeatedly.
 A program must be retranslated following modifications.
 Program interpretation: - Fig shows a schematic of a program interpretation. The
interpreter reads the source program and stresses it in its memory. During
interpretation it takes a source statement, determines its meaning and performs
actions which implement it.
Interpreter
Memory CPU Memory

PC Source PC Machine
language
Program
program
+
+
data
data

Figure (a) Figure (b)


FUNDAMENTAL OF LANGUAGE PROCESSING
Definition 1.2 (language processing)
Language Processing = Analysis of SP + Synthesis of TP
We refer to the collection of language processor components engaged in analyzing a source
program as the analysis phase of the language processor. Components engaged in
synthesizing target program constitute the synthesis phase. The analysis phase uses each
component of the source language specification to determine relevant information concerning
a statement in the source program. The synthesis phase is concerned with the construction of
target language statement(s) which have the same meaning as a source statement. Typically,
this consists of two main activities:
o Creation of data structures in the target program
o Generation of target code.
Phases and passes of a language processor
Language processor consists of two distinct phases –the main analysis phase and the
synthesis phase.
Definition 1.3 (Forward reference) A forward reference of a program entity is a reference to
the entity which precedes its definition in the program.
Definition 1.4 (Language processor pass) A language processor pass is the processing of
every statement in a source program, or its equivalent representation, to perform a language
processing function (a set of language processing functions).

NOTES BY – KANAK KUMAR KANAK E-MAIL ID – kkkanak@sify.com


1
SYSTEM SOFTWARE
Example it is possible to process the program fragment of previous example in two passes as
follows:
Pass I : Perform analysis of the source program and note relevant information
Pass II: perform synthesis of target program
Definition (intermediate representation(IR)) An intermediate representation (IR) is a
representation of a source program which reflect the effects of some, but not all, analysis and
synthesis tasks performed during language processing. Figure depicts the schematic of a two
pass language processor. The first pass performs analysis of the source program and reflects
its results in the intermediate representation. The second pass reads and analyses the IR,
instead of the source program, to perform synthesis of the tar get program. This avoids
prepared processing of the soured program. The first pass is concerned exclusively with
source language issues. Hence it is called the front end of the language processor. The
second pas is concerned with program synthesis for a specific target language. Hence it is
called the back end of the language processor: This reduces the memory requirements of a
language processor.

IR Front end Back end


Source Target
program program

Intermediate Representation (IR)


Figure: - Two pass schematic for language processing
Desirable properties of an IR are:
 Ease of use: IR should be easy to construct and analyze.
 Processing efficiency: Efficient algorithms must exist of construction and
analyzing the IR.
 Memory efficiency: IR must be compact.
• Semantic actions: -All actions performed by the front end, except lexical and syntax
analysis, are called semantic actions. These include actions for the following:
1. Checking semantic validity of constructs in SP
2. Determining the meaning of SP
3. Constructing an IR.
We briefly describe the front end and the back end of a toy compiler for a Pascal-like
language.
The front end: - The front and performs lexical, syntax and semantic analysis of the source
program. Each
Kind of analysis involves the following functions:
1. Determine validity of a source statement from the viewpoint of the analysis.
2. Determine the ‘content’ of a source statement.
3. Construct a suitable representation of the source statement for use by subsequent
analysis functions, or y the synthesis phase of the language processor.
In the lexical analysis, the content of the lexical class to which each lexical unit belongs,
while in syntax analysis it is the syntactic structure of a source statement. In semantic
analysis it is the meaning of the statement—for a declaration statement, it is the set of
attributes of a declared variable (e.g. type, length and dimensionality), while for an
imperative statement, it is the sequence of actions implied by the statement. For example,
syntax analysis uses information concerning the lexical class of lexical units and constructs a
representation for the syntactic structure of the source statement. Semantic analysis uses
information concerning the syntactic structure and constructs a representation for the
meaning of the statement.
Output of the front end: - The IR produced by the front end consists of two components:
1. Tables of information
2. An intermediate code (IC) which is a description of the source program.

NOTES BY – KANAK KUMAR KANAK E-MAIL ID – kkkanak@sify.com


1
SYSTEM SOFTWARE
Table: - Tables contain the information obtained during different analyses of SP. The most
important table is the symbol table which contains information concerning all identifiers used
in the SP.
Intermediate code(IC): -The IC is a
sequence of IC units; each IC unit
representing the meaning of one action
in SP. IC units may contain references to
the information in various tables.
Figure shows the schematic of the front
end where arrows indicate flow of data.
The back end: -The back end performs
memory allocation and code generation.
Front end of the toy complier
Memory Allocation.: -Memory allocation is a simple task given the presence of the symbol
table. The memory requirement of an
identifier is computer from its type, length
and dimensionality, and memory is allocated
to it. The address of the memory area is
entered in the symbol table.
Code generation: -code generation uses
knowledge of the target architecture, viz.
knowledge of instructions and addressing
modes in the target computer, to select the
appropriate instructions. The important
issues in code generation are;
1. Determine the places where the
intermediate results should be kept, i.e. whether they should be kept in machine
registers. This is a preparatory step for code generation.
Figure shows back end of the toy compiler
2. Determine which instructions should be used for accessing variables.
3. Determine which addressing modes should be used for accessing variables.
Grammar: - A grammar G of a language LG is a quadruple (∑, SNT, S, P)
Where
→ is the alphabet of LG i.e. the set of Ts(Terminal symbols)
SNT is the set of NTs,
Sis the distinguished symbol, and
P is the set of productions.
Classification of Grammar:-
Grammars are classified on the basis of the nature of productions used in them (Chomsky,
1963).Each grammar class has its own characteristics and limitations.
Type-0 grammars:-These grammars, known as phrase structure grammars, contain
productions of the form, α :: =β
Where both α and β can be strings of Ts and NTs. Such productions permit arbitrary
substitution of strings during derivation or reduction, hence they are not relevant to
specification of programming languages.
Type -1 grammar:-These are known as context sensitive grammars because their
productions specify that derivation or reduction of strings can take place only in specific
contexts. A Type -1 production has the form α A β : : = α π β
Thus, a string π in a sentential form can be replaced by ‘A’ (or vice versa) only when it is
enclosed by the strings α and β .
These grammars are also not particularly relevant for PL specification since recognition PL
constructs is not context sensitive in nature.
Type -2 grammars:-These grammars impose no context requirements on derivations or
reductions. A typical Type-2 production is of form A::= π
Which can be applied independent of its context; these grammars are therefore known a
context free grammars (CFG).CFGs is ideally suited for programming language

NOTES BY – KANAK KUMAR KANAK E-MAIL ID – kkkanak@sify.com


1
SYSTEM SOFTWARE
specification. Two best known uses of Type-2 grammars in PL specification are ALGOL-60
specification (Naur, 1963) and Pascal specification (Jensen, Wirth, 1975)
.Type-3 grammars:-
Type -3 grammar s are characterized by productions of the form
A:: = t B| t or
A:: = B t| t
Those productions also satisfy the requirements of Type-2 grammars. The specific form of
the RHS alternatives – namely a single T or a sting containing a single T and a single NT –
gibes some practical advantages in scanning. Type 3 grammars are also known as linear
grammars or regular grammars. These are further categorized into left-linear and right-
linear grammars depending on whether the NT in the RGS alternative appears at the
extreme left or extreme right.
Binding: -A binding is the association of an attribute of a program entity with a value. Binding
time is the time a t which a binding is performed. Thus the type attribute of a variable var is
bound to typ when declaration is processed. The size attribute of typ ins bound to a value
sometime prior to this to this binding. We are
interested in the following binding times:
1. Language definition time of L
2. Language implementation time of L
3. compilation time of P
4. Execution init time of proc
5. Execution time of proc.
Where L is a programming language, P is
a program written in L and proc is a procedure
in P.
Importance of binding time: -The binding
time of an attribute of a program entity
determines the manner in which a language
processor can handle the use of the entity. A
compiler can generate code specifically tailored to a binding performed during or before
compilation time. However, a compiler cannot generate such code for bindings performed
later than compilation time.
Static and dynamic bindings: -A static binding is a binding performed before the execution
of a program begins. A dynamic binding is binding performed after the execution of a
program has begun.
LANGUAGE PROCESSOR DEVELOPMENT TOOLS
Figure shows a schematic of an LPDT which generates the analysis phase of a language
processor whose source language is L. The LPDT requires the following two inputs:
1. Specification of a grammar of language L
2. Specification of semantic actions to be performed in the analysis phase.
It generates programs that perform lexical, syntax and semantic analysis of the source
program and construct the IR. These programs collectively form the analysis phase of the
language processor.
There are two widely used LPDTs in practice. These are, the lexical analyzer generator
LEX, and the parse generator YACC. The input to these tools is a specification of the lexical
and syntactic constructs of L, and the semantic actions to be performed on recognizing the
constructs. The specification consists of a set of translation rules of the form.
<string specification> {<semantic action>} where <semantic action> consists of C
code. This code is executed when a string matching <string specification> is encountered in
the input. LEX and YACC generate C programs which contain the code for scanning and
parsing, respectively, and the semantic actions contained in the specification. Figure shows a
schematic for developing the analysis phase of a compiler or language L using LEX and YACC.

NOTES BY – KANAK KUMAR KANAK E-MAIL ID – kkkanak@sify.com


1
SYSTEM SOFTWARE
Source program in L

Lexical
Specification LEX Scanner

Syntax IRl
Specification YACC Parser

Specification of L IR/ Target code

Figure : - Using LEX and YACC.


LEX: - LEX accepts an input specification which consists of two components. The first
component is a specification of strings representing the lexical units in L, e.g. id’s and
constants. This specification is in the form of regular expressions. The second component is a
specification of semantic actions aimed at building an IR.
LEX has been widely used to specify lexical analyzer for variety of languages. We prefer
to tool as Lex compiler so its
input specification as Lex
language. Lex is a software that
takes as input specification of a
set of regular expression
together with actions to be
taken. The output of Lex is a
program that recognizes the regular expression and acts appropriately on each.

YACC: - The parse generated by TACC performs reduction according to this grammar. The
actions associated with a string specification are executed when a reduction is made
according to the specification according to the specification. An attribute is associated with
every no terminal symbol. The attribute can be given any user-designed structure.
Yacc assist in the next phase of the compiler. It creates a parser. Yacc is available as
utility on the unix system. A parser can be
created using Yacc in the following manner.
Parser.y containing a Yacc specification.
The unix system command translates the file
Parser.y into a ‘C’ program alled y.tab.c which is a
representation of parser written in ‘C’ language.
y.tab.c is run through ‘C’ compiler and procedure
object program a.out. a.out performs the
translation specified by original Yacc program.

Chapter – 3[Data Structure for Language Processor]

Data structures: -
The data structures used in language processing can be classified on the basis of the
following criteria:-
1. Nature of a data structure- whether a linear or nonlinear data structure
2. Purpose of a data structure- whether a search data structure data structure.
3. Lifetime of a data structure- whether used during language processing or during target
program execution.
A linear data structure consists of a linear arrangement of element in the memory.
Advantage of linear data structure:-
Dynamic memory allocation is generally not allowed.
Sequential as well as Binary searching is allowed.
Data is stored and accessed on the bases of location name.
NOTES BY – KANAK KUMAR KANAK E-MAIL ID – kkkanak@sify.com
1
SYSTEM SOFTWARE
Example of linear data structures stack, etc.
Non –linear:-
→ Allocation of non –contiguous memory location.
→ Dynamic memory allocation is frequently & efficiently performed.
→ Sequential as well as binary search can be performed.
→ Data is stored and accessed on the basis of address i.e. using pointer.
→ Examples of non-linear data structure are linked list, tree, graph, etc.
Array: -Array is the features, that allows to represent multiple similar elements with single
name.
→ It reduces the complexity of a program.
→ It reduces the size of a program. Contiguous memory locations are essentially
required.
→ Array can be of single dimension or multidimensional.
→ Array is considered as static data structure. Because size of an array is specified in
advance, i.e. before program execution begins.
Linked list: -Linked list is basically collection nodes, Each node contains the
address/references of next node. Address of first node is assigned to the list pointer. A node
at least consists of two fields i.e. data field and pointer field. Pointer field of last node contains
doubly linked list.
→ Several operations can be performed with a linked list like creation of list, display the
items, insertion of items, etc.
→ Size of linked list can be dynamically in decreased or decreases (i.e. grow and shrink
→ A linked list can be several types.
Memory Management
 Static partitioning
 Dynamic partitioning.
Static Partitioning: -
→ User’s memory area is divided into fixed sized partitions, in advance.
→ Two mechanisms are used to select the appropriate free partition from available
partitions for requested process, i.e. first fit and best fit.
Dynamic partitioning: -
→ Partitions are not created in advance.
→ But partitions are created for requested process after request has been made.
Drawback – External fragmentation, complexion process
Tree: - Tree is considered as linear data structures. Nodes of a tree are organized in
hierarchical order, starting from root.
A tree can be of: -
→ Binary Tree
→ Binary Search tree
→ AVL Tree (Height Balance Tree)
→ B-Tree (M-way Search Tree)
Graph: - A Graph consists of vertices and edges. A graph can be implement through
adjacency matrix and adjacency linked list.
Graph can be of:
→ Un-directed Graph
→ Directed Graph
Hashing: - Hashing is the process to search the information in a file, directory on the basis of
given key value. In hashing, a function namely hash() is used which requires key value as
argument, to return the address of exact location.
Stack: – Stack is a type of linear data structure, which organizes the data on the basis of Last
in First out Mechanism. Means that push and POP operations are performed at one end i.e.
TOP of stack.

Chapter – 4[Scanning and Parsing]

NOTES BY – KANAK KUMAR KANAK E-MAIL ID – kkkanak@sify.com


1
SYSTEM SOFTWARE

Scanning: - Scanning is the process in which legal string is scanned character by character
and grouting the similar character altogether for specific purpose .In other words, scanning is
the process of recognizing the lexical components in a source string.
Parsing: - Main purpose of the process parsing is to check the validity of a source string and
to determine its syntactic structure. For an invalid string, the parser issues diagnostic
massages. For a valid string it builds a parse tree.
A parse tree demonstrate the steps in parsing hence it is useful for understanding the
process of parsing.
Top down Parsing: - Top down parsing, according to a grammar, attempts to derive a string
matching through a source string using a sequence of derivations starting form the
distinguished symbol of grammar.
Implementing Top down parsing:-
Following features are needed to implement top –down parsing:-
1. SSM (source string Marker):- it points to the first unmatched symbol in the source string.
2. PMM (Prediction Making Mechanism): - This mechanism syntactically selects the R.H.S.
Alternatives of a production during predictions making.
3. Matching and backtracking mechanism: - This mechanism matches every term symbol
generated during a derivation with the source symbol pointed by SSM. Backtracking is
performed when matching fails.

Chapter – 5 [Assemblers]

ADVANTAGE OF A TRANSLATOR:
A translator allows a programmer to express his thought (algorithm) in a language
other than that of machine language, which is to execute the algorithm. The reason is that
machine language is very complex to understand and design a problem. Some of the benefits
to write a program other than the machine language, these are: -
 Increase in the Programmers productivity
 Machine Independence
The input to a translation program is expressed in a source language. a source
language might be assembly language or any high level language. The output of a translator
is a target language.
Source Target
Translator
Language Code
Types of Assembler: -
There are three types of translators:
 Interpreters
 Compiler
 Assembler
ASSEMBLER: -
An assembler is a program that accepts assembly language program as input and
produces its machine language equivalent along with information for the loader.
For the simplest assembler, the target language is machine language and its source
language has instruction in one to one correspondence with those of machine language but
with symbolic name for both operators and operands.
ASSEMBLER and its related Program: -
The Assembler program contains three types of entities: - Absolute entities, Relative
entities and the Object Program.
 Absolute Entities: - It includes operation code, numeric and string constant and fix
addresses.
 Relative Entities: - It includes the address of instruction and working storage area.
 The Object Program: - It includes identification of which address are relative which
symbols are defined externally and which internally defined symbols are expected to
be referenced externally. These external references are resolved for two or more

NOTES BY – KANAK KUMAR KANAK E-MAIL ID – kkkanak@sify.com


1
SYSTEM SOFTWARE
program by a Linker. A Linker accepts the several object program as input and
produces a single program ready for loading.

Load and Go Assembler: -


The simplest Assembler program is the Load and Go Assembler. It accepts as input a
program whose instructions are essentially one to one corresponding of machine language. It
produces machine language as output which is directly loaded in main memory and gets
executed. The translation is usually performed in a single pass on the input program
instruction. The output program occupies storage locations which are fixed at the time of
translation.
The Load and Go Assembler has the following advantages:
 The ability to design code and test several components of program in parallel.
 Change in one particular module doesn’t require the scanning of rest of the program.
One Pass Assembler: -
Basically, the translation perform by an assembler is essentially a collection of
substitutions i.e. machine operation code for mnemonic, machine address for symbolic
constants, machine encoding for its character representation. These substitutions could all be
performed in one sequential pass. That factor is the forward reference. These one pass
Assemblers are particularly attractive when secondary storage is slow.
Two pass Assembler: -
Mostly assemblers are designed in two asses (phases), therefore they are called two-
pass Assembler. The pass-wise grouping of tasks in a two-pass Assembler is as follows: -
(i) Pass-One
 Separate the symbols, mnemonics and operational fields.
 Determine the storage requirements for every assembly language statement.
 Build the symbol table.
(ii) Pass-Two
 Generate object code
Implementation: -
The assembler uses a counter to keep track of machine language address because
these address will ultimately specify locations in main storage, the counter is called the
location counter. Before assembly the location counter is initializing to zero. After each source
line has been examined on the first pass, the location counter is incremented by the length of
the machine language code which will be generated to correspond to the source line.
The Important Function: -
The Assembler must perform in translating assembly language program.
 Replace symbolic address by numeric address.
 Replace symbolic operation ode by machine operation code.
 Reserve storage for instruction and data.
 Translates constant into machine representation.

Chapter – 6[Macro and Macro Expansion]

MACRO EXPANSION
The use of a macro name with a set of actual parameters is replaced by some code
generation from its body. This is called macro expansion. Two kinds or expansion can be
readily identified: -
NOTES BY – KANAK KUMAR KANAK E-MAIL ID – kkkanak@sify.com
1
SYSTEM SOFTWARE
(i) Lexical Expansion: -lexical expansion implies replacement of a character string by
another character string during program generation. Lexical expansion is typically
employed to replace occurrences of formal parameters by corresponding actual
parameters.
(ii) Semantic Expansion: - Semantic expansion implies generation of instructions tailored to
the requirements of a specific usage – for example, generation of type specific
instructions for manipulation of byte and word operands.
 A macro call leads to macro expansion during macro expansion; the macro call statement
is replaced by a sequence of assembly statements.
 Two key notions concerning macro expansion are : -
1. Expansion time control flow: - This determines the order in which model statements are
visited during macro expansion.
2. Lexical substitution: - Lexical substitution is used to generate an assembly statement
from model statements.

Macro Expansion: -
Macro expansion process is some how similar to language translation. The source program
containing macro definition and calls is translated into an assembly language program without any
macro definition or call. This program is handed over to assembler to obtain the target languages. The
translator which performs Macro expansion in this manner is called a Macro pre-processor.
Source
Macro pre-processor Assembler Target Code
Program
Issues Related to the Design of a Macro Pre-processor
As for as design issues of Macro Pre-processor is concerned that the definition and use
of macros in an assembly language program. For generating a statement during expansion,
we need to develop a simple scheme for substituting the appearance of formal parameter
with its value. Correspondence between a formal parameter and its value will have to be
established for this purpose.
MACRO DEFINITION AND CALL
 Macro Definition: - A macro definition is enclosed between a macro header statement
and a macro end statement. Macro definitions are typically located at the starts of a
program. A macro definition consists of: -
(i) A macro prototype statement
(ii) One or more model statement
(iii)Macro preprocessor statements
 The macro prototype statements declare the name of a macro and the names and
kinds of its parameters.
 A model statement is a statement from which and assembly language statement
may b generated during macro expansion.
 A preprocessor statement is used to perform auxiliary functions during macro
expansion.
 The macro prototype statement has the following syntax: -
<macro name> [<formal parameter spec>[,..]] where <macro name> appears
in the mnemonic field of an assembly statement and <formal parameter spec> is of
the form, & <parameter name> [<parameter kind>].

NOTES BY – KANAK KUMAR KANAK E-MAIL ID – kkkanak@sify.com


1
SYSTEM SOFTWARE
In other words, A Macro definition is placed at the start of a program, enclosed
between the statements macro and ENDM. A macro statement indicates that a macro
statement starts while the ENDM indicates the end of macro definition thus a group of
statements starting with MACRO and ending with ENDM called one macro definition unit. If
many macros are to be defined in the program, as many definition modules will exist at the
start of the program. Each definition module contains a new operation and defines it t consist
of a sequence of assembly language statements.
Positional Parameters: -
The prototype statements indicates how operands in a macro called would be written. These
operands are called parameters or arguments. All parameters used in the prototype
statement, have names starting with special character ‘Ampersand’. These parameters are
known as formal parameters. A macro call is written using parameter names which do not
starts with special character ‘Ampersand’. These parameters are called actual parameters.

 Macro Call: - A macro is called by writing the macro name in the mnemonic field of an
assembly statement. The macro call has the syntax: -
<macro name>[<actual parameter spec>[,..]] where an actual parameter typically
resembles an operand specification in an assembly statement.
 Nested Macro Calls: - A model statement is a macro may constitute a call on another
macro. Such calls are known as nested macro calls. We refer to the macro containing the
nested call as the outer macro and the called macro as the inner macro. Expansion of
nested macro calls follows the last-in-first-out (LIFO) rule. Thus, in a structure of nested
macro calls, expansion of the latest macro calls call (i.e. the innermost macro call in the
structure) is completed first.
ADVANCED MACRO FACILITIES
Advanced macro facilities are aimed at supporting semantic expansion. These facilities
can be grouped into: -
(i) Facilities for alteration of flow of control during expansion: - Two features are
provided to facilitate alteration of flow of control during expansion: -
(a) Expansion time sequencing symbols
(b) Expansion time statements AIF, AGO and ANOP.
A sequencing symbol (SS) has the syntax : <ordinary string>
A SS is defined by putting it in the label field of a statement in the macro body. It is used as
an operand in an AFO or AGO statements to designate the destination of an expansion time
control transfer. An AIF statements has the syntax AIF (<expression>) <sequencing symbol>
where <expression> is a relational expression involving ordinary strings, formal parameters
and their attributes and expansion time variables. If the relational expression evaluates to
true, expansion time control is transferred to the statement containing <sequence symbol> in
its lavel field. An AGO statement has the syntax: -
AGO <sequencing symbol> and unconditionally transfers expansion. Time control to
the statement containing <sequencing symbol> in its label field. ANOP and simply has the
effect of defining the sequencing symbol.
(ii) Expansion Time Variables: - Expansion time variables (EV’s) are variables which can
only be used during the expansion of macro calls. A local EV is created for use only during
a particular macro call. A global EV exists across all macro calls situated in a program and
can be use in any macro which has a declaration for it. Local and global EV’s are created
through declaration statements with the following syntax: -
LCL <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. A SET
statement is written as:
<EV specification> SET <SET-expansion> where <EV specification> appears in the
label field and SET in the mnemonic field. A SET statement assigns the value of <SET-
expansion> to the EV specified in <EV specification>. The value of EV can be used in any
field of a model statement and in the expression of an AIF statement.
(iii) Attributes of formal parameters: - An attribute is written using the syntax:

NOTES BY – KANAK KUMAR KANAK E-MAIL ID – kkkanak@sify.com


1
SYSTEM SOFTWARE
<attribute name> ‘ <formal parameter spec> and represents information about the value
of the formal parameter, i.e. about the corresponding actual parameter. The type, length
and size attributes have the names T, L and S
MACROPROESSOR
The Assembly language programmer often finds it necessary to repeat some
statements or blocks of code several time in a program in this situation, programmer find a
macro instruction facility, useful. Macro instruction often called macros is single line
description. For multiple instruction/group of instructions the programmers essentially define
a single instruction to represent a block of code. For every occurrences of this single line
macro instruction to represent a block of code, micro processing assembler substitute the
entire block.
DESIGN OF A MACRO PROCESSOR
The macro preprocessor accepts an assembly program containing definitions and calls
and translates into an assembly program which does not calls. Figure shows a schematic of a
macro preprocessor.
Thus the macro processor segregates macro expansion from the process of program
assembly. It is economical because it can use an existing assembler.

Macro Assemble
Preprocessor r

Program with
Macro Definitions Target program
and calls
Program without
Macros
Figure: - A schematic of a macro preprocessor.
Design Overview: -
We begin the design by listing all tasks involved in macro expansion:-
i) Identify macro calls in the program
ii) Determine the values of formal parameters.
iii) Maintain the values of expansion time variables declared in a macro.
iv) Organize expansion time control flow
v) Determine the values of sequencing symbols
vi) Perform expansion of a model statement.
 Identify Macro calls: - A table called the macro name table (MNT) is designed to hold the
names of all macro name is entered in this table when a macro definitions is processed.
 Determine values of formal parameters: - A table called the actual parameter table (APT) is
designed to hold the values of formal parameters during the expansion of a macro call.
Each entry in the table is a pair, (<formal parameter name>, <values>) Two items of
information are needed to construct this table, names of formal parameter and default
values of keyword parameters.
 Maintain the value of expansion time variables: - An expansion time variables table (EVT)
is maintained for this purpose. The table contains pairs of the form,
(<EV name>, <values> ) The value fields of a pair is accessed when a preprocessor
statement or a model statements under expansion refers to an EV.
 Organize expansion time control flow: - The body of a macro, i.e. the set of preprocessor
statements and model statements in it, is stored in a table called the macro definition
table (MDT) for use during macro expansion.
 Determine values of sequencing symbols: - A sequencing symbol table (SST) is maintained
to hold this information. The table contains pairs of the form;-
(<sequencing symbol name>, <MDT entry#>) where <MDT entry#> is the number of the
MDT entry which contains the model statement defining the sequencing symbol.

NOTES BY – KANAK KUMAR KANAK E-MAIL ID – kkkanak@sify.com


1
SYSTEM SOFTWARE
 Perform expansion of a model statement: - Expansion of a model statement is achieved by
performing a lexical substitution for the parameters and EV’s use in the model statement.

Chapter – 7[Compiler and Interpreters]

ASPECT OF COMPILATION
Two aspects of compilation are:
 Generate code to implement meaning of a source program.
 Provide diagnostics for violation of program language Symantec in a source program.
MEMORY ALLOCATION
Memory allocation involves three important tasks: -
(i) Determine the amount of memory required to represent the value of a data item.
(ii) Use an appropriate memory allocation model to implement the lifelines and scope of
data items.
(iii) Determine appropriate memory mapping to access the values in a non scalar data item
e.g. values in an array.
Types of Memory Allocation: - Typically memory allocations are two types:
(i) Static Memory allocation
(ii) Dynamic Memory allocation
 Memory binding: - A memory binding is an association between the memory address’
attribute of data item and the address of memory area.
 Memory allocation is the procedure used to perform memory binding.
 Memory binding can be dynamic or static in nature, giving rise to the static and dynamic
models.
 In static memory allocation, memory is allocation to a variable before the execution of a
program begins .
 Static memory allocation is typically performed during compilation.
 No memory allocation or deallocation actions are performed during the execution of a
program.
 In dynamic memory allocation, memory bindings are established and destroyed during the
execution of a program. Typical examples of the use of these memory allocation models
are Fortran for static allocation and block structured language like PL/L Pascal, Ada etc. for
dynamic allocation
 Dynamic memory allocation has two flavors: -
a. Automatic allocation
b. Program controlled allocation.
 The former implies memory bindings performed at execution in it time of a program until,
while the latter implies memory bindings performed during the execution of a program
unit.
 In automatic dynamic allocation, memory is allocated to the variables declared in a
program unit is entered during execution and is deallocated when the program unit is
exited. Thus the same memory area may be used for the variable of different program
units. It is also possible that different memory area may be allocated to the same variable
in different activations of a program unit.
 In program controlled dynamic allocation, a program can allocate or deallocate memory at
arbitrary points during its execution.
 It is obvious that in both automatic and program controlled allocation address of the
memory area allocated to a program unit cannot be determined at compilation time.
 Dynamic memory allocation is implemented using stacks and heaps, thus necessating
pointer based access to variables.
 Automatic dynamic allocation is implemented using stack since entry and exit from
programs units is LIFO in nature.
 Program controlled dynamic allocation is implemented using a heap. A pointer is now
needed to point to each allocated memory area.

NOTES BY – KANAK KUMAR KANAK E-MAIL ID – kkkanak@sify.com


1
SYSTEM SOFTWARE
 Dynamic allocation provides some significant advantages. Recursion can be implemented
easily because memory is allocated which a program unit is entered during execution.
 Dynamic allocation can also support data structures whose sizes are determined
dynamically, e.g. an array declaration A[m,n], where m and n are variables.
Array allocation and Access: -When an n dimensional array is organized in a computer’s
memory, the order in which the array elements are arranged in the memory is governed by
the rules of the PL. We shall assume array elements to be ordered such a[1,1]
that element s occupying memory locations. For two dimensional arrays,
this
implies a column-wise arrangement of elements. Figure shows the
allocation for an array a[5,10]. It is obvious that static memory allocation is a[5,1]
feasible only if dimension bounds of an array are known at compilation a[1,2]
time.
The arrangement of array elements in the memory determines the a[5,2]
memory mapping to be used in computing the address of an array
element. In figure, it has been assumed that the lower bound of each
dimension to be 1under this assumption, address of array element a[S1,S2] a[1,10]
can be determined as follows:
Ad.a[S1,S2]=Ad.a[1,1]+{(S2-1) * n + (S1-1)}* k where n is the number of
rows in the array and k is the number of memory locations (words or byte) a[5,10]
occupied by each element of the array. For a general tow dimensional array, a[l1:u1,l2:u2]
where li and ui are the lower and upper bound of the with subscript, respectively; address of
a[S1,S2] is given by the formula
Ad.a[S1,S2]=Ad.a[l1,l2]+[(S2-l2) * (u2-l1+1) + (S1-l1)} *k
COMPILATION OF EXPRESSIONS
Step: - 1
 A toy code generator for expressions: The major issues in code generation for expressions
are as follows:
i) Determination of an evaluation order for the operator in an expression.
ii) Selection of instructions to be used in the target code.
iii) Use of registers and handling of partial results.
 The evaluation order of operators depends on operator precedence in an obvious way-an
operator which precedes its left and right neighbors must be evaluated before either of
them. Hence, a feasible evaluation order in the order in which operators are reduced
during a bottom-up parse or the reverse of the order in which operators are produced
during top down parse.
 The choice of an instruction to be used in the target code.
i) The type and the length of each operand.
ii) The addressability of each operand i.e. where the operand is located and how it can
be accessed.
The addressability of an operand indicates where an operand is located and how it can
be accessed.
 An operand descriptor to maintain the type, length and addressability information for each
operand. Thus the choice of an instruction can be made by analyzing an operator and the
descriptor of its operand.
 A partial result is the value of some sub expression computed while evaluating an
expression
 An important issue in code generation is when and how to move partial result between
memory and CPU registers and how to know which partial result is contained in a register.
We use a register descriptor to maintain information for the latter purpose. We develop a
toy code generator for expression using a YACC like bottom-up parse generator.
 Operand descriptor : - An operand descriptor has the following fields: -
i) Attributes:- Contains the subfields type. Length and miscellaneous information.
ii) Addressability: - specifies where the operand is located and how it can be accessed.
It has two subfields:-

NOTES BY – KANAK KUMAR KANAK E-MAIL ID – kkkanak@sify.com


1
SYSTEM SOFTWARE
a. Addressability code: - Takes the values ‘M’ (operand in memory), and ‘R’
(operand is in register), other addressability codes. e.g. address in register(‘AR’)
and address in memory (‘AM’) are also possible.
b. Address:- Address of a CPU register or memory word. An operand descriptor is
built for every operand participating in an expression, i.e. for id’s, constants and
partial results. A descriptor is built for an id when the id is reduced during
parsing. A partial result pri is the result of evaluating some operator OPj. A
descriptor is built for pri immediately after code is generated for operator OPj.
 Register Descriptor: - A register descriptor has two fields:
i) Status: - contains the code free or occupied to indicate register status.
ii) Operand Descriptor#. If status occupied this field contains the descriptor # for the
operand contained in the register. Register dexcriptors are stored in an array called
Register – descriptor. One register descriptor exists for each CPU register.
Step: - 2
Generating an instruction: - When an operand OPi is reduced by the parser, the function
codegen is called with OPi and descriptors of its operand as parameters. A single instruction
can be generated to evaluate OPi if the descriptors indicate that one operand is in a register
and the other is in memory, if both operands are in memory an instruction is generated to
move one of them into a register.
Step: - 3
Saving partial results: - if all registers are occupied (i.e. they contain partial results) when
operator OPi is to be evaluated a register r is field by copying its contents into a temporary
location in the memory. R is now used to evaluate operator OPi. For simplicity we assume that
an array temp is declared in the target program (i.e. in the generated code) to hold partial
results. A partial result is always stored in the next free entry of temp. When a partial result is
moved to a temporary location. The descriptor of the partial result must change.
COMPILATION OF CONTROL STRUCTURE
 Control Structure: The control structure of a programming language is the collection of
language features which gives growth the sequencing of control structure of aPL consist of
constructs for control transfer, conditional execution, iteration control and procedure calls.
 Control transfer implemented through conditional and unconditional goto’s are the most
primitive control structure.
 When the target language of a compiler is a machine language, compilation of control
transfers is analogous to the assembly of forward or backward goto’s in an assembly
language program.
 When the target language is an assembly language a statement goto lab can be imply
compiled as the assembly statement BC, ANY, LAB.
 Control structure like if, for and while cause significant semantic gap between the PL
domain and the execution domain because the control transfers are implicit rater than
explicit. This semantic gap is bridged in two steps. In the first step a control structure is
mapped into an equivalent program containing explicit goto’s. Since the destination of a
goto may not have a label in the source program, the compiler generates its own labels
and puts them against the appropriate statements. Fig, illustrates programs equivalent to
the if and while statements wherin the labels int1, int2 are introduced by the compiler for
its own purpose. In the second step: These programs are translated into assembly
programs. The first step need not be carried out explicitly.

NOTES BY – KANAK KUMAR KANAK E-MAIL ID – kkkanak@sify.com


1
SYSTEM SOFTWARE

If (e1) then if (e1bar) then goto intt


S1; S1;
Else => goto int2;
S2; int1: S2;
S3; int2: S3;
Figure (a)

While (e2) do int3:if (e1 bar) then.


S1; goto int4;
S2; => S1;
| S2;
Sn; |.
End while Sn;
<next statement> goto int3;
Int4:<next statement>
Figure (b)
Figure:- Control structure compilation

 Function and Procedure Calls –


A function calls, vi2. the callon fn-1 in the statement.
X = fn-1 (*y,2) + b*c
Executes the body of fn-1, and returns its value to the calling program. The function clall may
also result in some side effects.
• Side Effect: - A side effect of a function (procedure) call change in the value of a variable;
which is not local to the called function.
• While implementing a function call, the compiler must ensure the following: -
1) Actual parameters are accessible in the called function.
2) The called function is able to produce side effects according to the rules of the
PC.
3) Control is transferred to, and is returned from the called function.
4) The function value is returned to the calling program.
5) All other aspects of execution of the calling programs are unaffected by the
function call.
The Compiler uses a set of features to implement function calls.
1) Parameter list: - The parameters list contains a descriptor for each actual
parameter of the function call.
2) Save area: -The called function saves the contents of CPU registers in this area
before beginning its execution.
3) Calling Conventions: -These are execution time assumptions shared by he called
function and its callers. The conventions include the following:
a. How the parameter list is accessed?
b. How the save area is accessed?
c. How the transfers of control at all and return are implemented.
d. How the function value is returned to the calling program.
• Calling Conventions: -
 In a static memory allocation environment, the parameter list and the save area are
allocated in the calling program. The calling conventions requires the addresses of the
function, the parameter list ad the save area to be contained in specific CPU registers
at the time of call. Let rpra-list denote the register containing the address of the
parameters list and get (Dpp) par-list denote the displacement of Dp in the parameter
list. (dPP) par-list is comuted while processing the formal parameter list of the function
and is stored in the symbol table entry of P. During execution. Dp has the address
<rpar-list> =(dPP) par-list.
 In dynamic memory allocation environment, the calling program construct the
parameter list and the save area on the stack. These become a part of the called
functions AR when its execution is initiated. Start of the parameters list has a known

NOTES BY – KANAK KUMAR KANAK E-MAIL ID – kkkanak@sify.com


1
SYSTEM SOFTWARE
displacement dpar-list in the AR. For every format parameter p the displacement of Dp
in the AR, denotes as (dDp) AR is computed and stroed in the symbol table entry of P.
During execution, Dp has the address <ARB> + (dDp) AR. Figure

CODE OPTIMIZATION
Main purpose of code optimization is to improve the efficiency of program execution. It
can be achieved in two ways. That is:
(i) Redundancies in a program are eliminated.
(ii) Computations in a program are rearranged to make it execution efficiency.
Two points concerning the scope of optimization should also be considered. That is:
 Optimization seeks to improve a program rather than the algorithm of the program.
 Efficient code generation for a target machine.
INTERPRETERS
The another type of software which also does the translation is called an Interpreter.
The compiler and Interpreter have different approaches to translation. Interpreter translates
the program line by line. Each time the program is executed, Interpreter have checked every
line for syntax error and then converted to equivalent machine code. Interpreter does fast
debugging but its execution time is more respect to the compiler.
Compiler Vs Interpreter
Compiler Interpreter
1. Scans the entire program first and then Translates the program line by line.
translates it into machine code.
2. Converts the entire program to machine Each time the program executed, every line is
code; when all the syntax errors are removed checked for syntax error and then converted
execution takes place to equivalent machine ode
3. Slow for debugging Good for fast debugging
4. Execution time is less Execution time is more
5. Associated with object code Not associated with object code
6. (a) If no error, generate object/executable If error encounters in a particular line,
code program execution temporarily suspend and
(b) If error, displays listing of errors control is transferred at that line for debug.
After debugging, program execution
continues.

Chapter – 8 [Linkers]

LINKER
The need for linking a program with other programs arises because a program written
by a programmer is rarely of a stand alone nature. That is a program generally cannot
execute on its own, without requiring the presence of some other program in the computer
memory. For example consider a program written in high level language like ‘C’. Such a
program may contain calls on certain input output functions like printf() and scanf(). Which
are not written by the programmer himself. During program execution those standard
programs must reside in the memory.
The linking function makes address f program known to each other.
NOTES BY – KANAK KUMAR KANAK E-MAIL ID – kkkanak@sify.com
1
SYSTEM SOFTWARE
RELOCATION
Another function i.e. commonly perform by a loader is that relocation. This function can
be explained as follows:
Suppose a program written in ‘C’ calls standard function printf(). Assume that the
program which calls standard function printf() has name ‘A’. ‘A’ and printf() would have to be
linked with each other but where is main storage cell reload ‘A’ and printf(). A possible
solution would be to load then according to the address assigned when they were translated.
It should be noted that relocation is a simply moving a program from one area to another in
the storage. It refers to adjustment of address field. The part of a loader which performs
relocation is called relocating loader.
LOADER
Loader is a program which accepts an object de and prepares them for execution. An
object code produced by an assembler/compiler cannot be executed without any modification.
As many as four more functions must be performed. These functions are performed by the
loader. These functions are:-
(i) Allocation of space in main memory for the programs.
(ii) Linking of a program with each other like library function.
(iii)Adjust all address dependent allocation called Relocation.
(iv) Physically load the machine instruction and data into memory.
LOADER SCHEMES
There are several schemes accomplishing the fourth loading functions. These schemes
are:
(i) Absolute Loader: - Absolute Loader simply accepts the machine language code produce by
the assembler and places it into main memory.
(ii) Relocating Loader: - To avoid possible reassembling of all functions when a single sub-
routine is changed and to perform the tasks allocation and linking for the programmer. The
general class of relocating loader was introducing. The output of a relocating loader is the
object program and information about all other program it references.
(iii) Direct Linking Loader: - It is general relocatable loader and is perhaps the most popular
loading scheme presently used. It has the advantage of allowing the programmer multiple
procedure segments and multiple data segments and of giving him complete freedom in
referencing data or instructions contend in other segments.
(iv) Dynamic Loader: - In each of the previous loader schemes we have assume that all of the
sub-routines needed and loaded into main memory of the same time. If the total amount
of memory required by all these sub-routines exceed the amount available then an error

message is displayed. There are several hardware techniques such as paging and
segmentation, that attempts to solve the problem. Here such problem can be solved by
dynamic loading schemes in following manner.
Usually the sub-routines of a program are needed at different times. So it is possible
to produce an overlay structure that identifies mutually exclusive sub-routines.

NOTES BY – KANAK KUMAR KANAK E-MAIL ID – kkkanak@sify.com


1
SYSTEM SOFTWARE
(v) Dynamic Linking: - The major
disadvantage of the entire previous
loading scheme is that if a sub-routine is
referenced but never executed. In such
case linking with that sub-routine is
considered as process overhead. All of
these schemes required the programmer
to explicitly name all procedures that
might be called. A general of loading scheme i.e. called ‘Dynamic Linking’. That is the
mechanism by which loading and linking of external references post-pond until the time of
execution. The loader only loads the main program. If the main program should execute a
transfer instruction to an external address the loader is called. An advantage of such
loader is that no overhead until the procedure to be called. Example – Implementation of
an absolute loader.

Chapter – 9 [Software Tools]

Software Tools - Computing involves tow main activities program development and use of
application software. Language processors and operating system pay an obvious role in these
activities. A less obvious but vital role is played by program that help in developing and using
other programs. These programs, called software tools, perform various housekeeping tasks
involved in program development and application usage.
Software tools is a system program which:
 Interface a program with the entity generating its input data or
 Interfaces the results of a program with the entity consuming them.
Figure shows a schematic of a software tool:

Originator Software Tools Consumer

Raw program or data Transformed program or data


Generally two kinds of software tools –
 Software tools for program development, and
 Software tools for user interfaces.
1. Software Tools for Program Development
The fundamental steps in program development are –
i) Program design, coding and documentation.
ii) Preparation of programs in machine readable form
iii) Program translation, linking and loading.
iv) Program testing and debugging
v) Performance tuning
vi) Reformatting the data and / or results of a program to suit other programs.
(i) Program design and coding: - Two categories of tools used in program design and coding
are:-
 Program generators
 Programming environment.
A program generator generates a program which performs a set of functions. User
of a program generator saves substantial design effort since a programmer merely
specifies what functions a program should perform rather than how the function should be
implemented. A programming environment supports program coding by incorporating
awareness of the programming language syntax and semantics in the language editor.
(ii) Program Documentation: - Most programming projects suffer from lack of up-to-data
documentation. Automatic documentation tools are motivated by the desire to overcome
this efficiency. These tools work on the source program to produce different forms of
documentation, e.g. flow charts, IO specifications showing files and their records etc.
NOTES BY – KANAK KUMAR KANAK E-MAIL ID – kkkanak@sify.com
1
SYSTEM SOFTWARE
(iii) Program Entity and Editing: - These tools are text editor or more sophisticated programs
with text editors as front end. The editor functions in two modes command mode and data
mode. In the command mode, it accepts use commands specifying the editing function to
be performed. In the data mode, the user keys in the text to be added to the file.
(iv) Program Translation, Linking and Loading:-These steps require use of language processors.
(v) Program Testing and Debugging: - Important steps in program testing and debugging are
selection of test data for the program, analysis of test results to detect errors and
debugging. Software tools to assist these steps come in the following forms:-
(a) Test data generators help the user in selecting test data for his program.
(b) Automated test drives help in regression testing, Regression testing is performed as
follows: Many steps of test data are prepared for a program. These are given as input
to the test drivers. The driver selects one set of test data at a time and organizes
execution of the program on the data.
(c) Debug monitors help in obtaining information for localization of errors.
(d) Source code control systems help to keep track of modifications in the source code.
(vi) Performance Tuning:-/ Program Performance: - Program efficiency depends on two factors-
the efficiency of the algorithm and the effiecency of its coding. An optimizing compiler can
improve efficiency of the code but it cannot improve efficiency of the algorithm. Only a
program designer can improve efficiency designer can improve efficiency of an algorithm.
A performance tuning tool helps in identifying such parts, those sections of a program
which consume a considerable amount of execution time. A profile monitor is a software
tool that collects information regarding the execution behavior of a program.
 Program Preprocessing:- Program preprocessing techniques are used to support static
analysis of programs. Tools generating cross reference listings and lists of unreferenced
symbols: test data generators and documentation aids use this technique.
 Program instrumentation:- Program instrumentation implies insertion of statements in
program. The instrumented program is translated using a standard translated. Profile and
debug monitors typically use these technique.
In a profile monitor, an inserted statement updates a counter indication the
number of times a statement is executed, whereas in debug monitors an Inserted
statement indicates that execution has reached a specific point in the source program.
2. EDITORS
These tools are mainly used to program entry and editing, as a front ends Tool. The
editor functions in two modes-command mode and data mode.
In command mode, it accepts user commands specifying the editing function to be
performed. In the data mode, the user keys in the text to be added to the file.
Text Editors come in the following forms: -
(i) Line editors
(ii) Stream editors
(iii)Screen editors
(iv) Word processors
(v) Structured editors
(i) Line Editors & Stream editors: - The scope of edit operations in a line editor is limited
to a line of text. The line is designated positionally. e.g. by specifying its serial number in
the text, or contextually e.g. by specifying a context which uniquely identifies it. The
primary advantage of line editors is their simplicity.
 A stream editor views the entire text as a stream of characters. These permits edit
operations to cross line boundaries.
 Stream editors typically support character, line and context oriented commands
based on the current editing context indicated by the positions of a text pointers.
(iii) Screen Editors: - A line or stream editor does not display the text in the manner it
would appear if printed. A screen editor uses the what you-see-is-what-you-get principle in
editor design. The screen editor displays a screen full of text at a time. The user can move
the cursor over the screen, position it at the point where he desires to perform some
editing and proceed with the editing directly. Thus it is possible to see the effect of an edit

NOTES BY – KANAK KUMAR KANAK E-MAIL ID – kkkanak@sify.com


1
SYSTEM SOFTWARE
operation on the screen. This i is very useful while formatting the text to produce printed
documents.
(iv) Word Processors: -Word processors are basically documents edtor with additional
features to produce will formatted hard copy output. Essential features of word processors
are commands for moving sections of text from one place to another, merging of text, and
searching and replacements of words. Many word processors support a spell-check option.
WordStar is a popular editor of this class.
(v) Structure Editors: - A structure editors incorporates an awareness of the structure of a
document. This is useful in browsing through a document e.g. if a programmer wishes to
edit a specific function in a program file. A special class of structure editors, called syntax
directed editors, is used in programming environments.
3. DEBUG MONITORS
A debug monitor is software which provides debugging support for a program. The
debug monitor executes the program being debugged under its own control. This provides
execution efficiency during debugging. A debug monitor can be made language independent,
in which case it can handle programs written in many languages.
Debug monitors provide the following facilities for dynamic debugging: -
 Setting breakpoints in the program
 Initiating a debug conversation when control reaches a breakpoint.
 Displaying values of variables
 Assuming new values to variables
 Testing user defined assertions and predicates involving program variables.
The sequence of steps involved in dynamic debugging of a program is as follows: -
(i) The user compiles the program under the debug option. The compiler produces two
files – the command code file and the debug information file.
(ii) The user activities the debug monitors and indicates the name of a program to be
debugged. The debug monitor opens the compiled code and debugs information files
for the program.
(iii)The user specifies his debug requirements – a list of breakpoints and actions to be
performed at breakpoints. The debug monitor instruments the program and builds a
debug table containing the pairs (statement number, debug action).
(iv) The instrumented program gets control and executes up to a breakpoint.
(v) The software interrupt is generated when the <SI – instn> is executed. Control is given
to the debug monitor which consults the debug table and performs the debug actions
specified for the breakpoint. A debug concession is now opened during which the user
may issue some debug commands or modify breakpoints and debug actions associated
with breakpoints. Control now returns to the instrumented program.
(vi) Step - iv and v are repeated until the end of the debug session.
4. PROGRAMMING ENVIRONMENTS
A programming environment is a software system that provides integrated facilities for
program creation, editing, execution, testing and debugging. It consists of the following
components: -
(i) A syntax directed editor
(ii) A language processor
(iii)A debug monitor
(iv) A dialog monitor
All components are accessed through the dialog monitor.
The syntax directed editor incorporates a front for the programming language as a user keys
in his program. The editor performs syntax analysis and converts it into an intermediate
representation (IR), typically an abstract syntax tree. The compiler (or interpreter) and the
debug monitor share the IR. If a compiler is used, it is activated after the editor has converted
a statement to IR. The compiler works incrementally to generate code for the statement.
Thus, program execution or interpretation can be supported immediately after the last
statement has been input.
The dialog monitor may also provide other program development and testing functions.
For example, it may permit a programmer to execute a partially completed program. The

NOTES BY – KANAK KUMAR KANAK E-MAIL ID – kkkanak@sify.com


1
SYSTEM SOFTWARE
programmer can be alerted if an undeclared variable or an incomplete statement is
encountered during execution. The programmer can insert necessary declarations or
statements and resume execution. This permits major interfaces in the program to be tested
prior to the development of a module. Some programming environments also support
reversible execution.
5. MACRO AND MACRO EXPANSION
Macros are used to provide a program generation facility through macro expansion.
Many languages provide built-in-facilities for writing macros well known examples of these are
the higher level language PL/L, C, Ada and C++.
A macro is a unit of specification for program generation through expansion. A macro
consists of a name. A set of formal parameters and a body of code. The use of a macro name
with a set of actual parameters is replaced by some code generated from its body. This is
called macro expansion. Macros differ from subroutines in one fundamental respect. Use of a
macro name in the mnemonic field of an assembly statements leads to its expansion,
whereas use of a subroutine name.
6. USER INTERFACES
A user interface (UI) plays a vital role in simplifying the interaction of a user with an
application. Classically, UI functionalities have two important aspects issuing of commands
and exchange of data. Basically user interface is a combination of menus, screen design,
keyboard commands and language which together create the way a user interact with the
system. User interface establishes the dialog between the users and the computers the dialog
provides user friendly instructive approach to starting the system, setting options, getting
helps etc. use of menus, hyperlinks, dialog boxes and drop down list provides a very pleasant
interface but design a programming are complicated.
A UI can be visualized to consist of two components – a dialog manger and presentation
manger.
 The dialog manager manages the conversation between the user and the application. This
involves prompting the use for a command and transmitting the command to the
application.
 The presentation manager displays the data produced by the application in an appropriate
manner on the user’s displays or printer device.
Features of a Good User Interface
The following points should be kept in mind while designing a user interface:
 Know the requirements of the users.
 Involve these users as much as possible in the screen and dialog design.
 User interface must be helpful.
 The interface must be robust.
 It feasible graphical ion must be used.
 Test the user interface on actual users.
Structure of a User Interface: - Figure shows a UI schematic using a standard graphics
package. The UI consists of two main components, presentation manager and dialog
manager.
 The presentation manager is responsible for managing the user’s screen and for
accepting data and presenting results.
 The dialog manager is responsible for interpretation user commands and
implementing them by invoking
different modules of the
application code. The dialog
manager is also responsible for
error messages and on line
help functions.
Designing User Interface: -
Designing the user interface involves
the following steps:
(i) Sketch the user interface dialogs.
(ii) Prototype the user interface.
NOTES BY – KANAK KUMAR KANAK E-MAIL ID – kkkanak@sify.com
1
SYSTEM SOFTWARE
(iii) Obtain user feed back.
(iv) If negative feedback is received, repeat steps 1 to 3 again.
User Interface design is an area of work in which user should play a significant role. However
he needs the professional assistance of the system analyst. Following are the three common
method for data entry input:
(i) Menu Method: - A menu method is used to select one out of many alternatives.
Selecting a menu will result in the appearance of related sub-menus.
(ii) Template Method: - Template are like forms on computer screen. The user is requested
to fill in the form. Labeled fields are provided and user enters data into the blank
spaces.
(iii) Command Method: - In the command method the computer asks the user for specific
inputs. On getting the input the computer may either ask for further input or provide
some output.

NOTES BY – KANAK KUMAR KANAK E-MAIL ID – kkkanak@sify.com


1

Você também pode gostar