Notes of System Programming
Notes of System Programming
Notes of System Programming
B.TECH(CSE)
SEM IV
CSE 206 B
UNIT 1
Introduction to Assemblers
Fundamental functions
translating mnemonic operation codes to their
machine language equivalents
assigning machine addresses to symbolic
labels
Machine dependency
different machine instruction formats and codes
Example Program
Purpose
reads records from input device (code F1)
copies them to output device (code 05)
at the end of the file, writes EOF on the outputdevice, then RSUB to the operating system
Example Program
Data transfer (RD, WD)
a buffer is used to store record
buffering is necessary for different I/O rates
the end of each record is marked with a null
character (0016)
the end of the file is indicated by a zero-length
record
Subroutines (JSUB, RSUB)
RDREC, WRREC
save link register first before nested jump
Assembler Directives
Pseudo-Instructions
Not translated into machine instructions
Providing information to the assembler
Basic assembler directives
START
END
BYTE
WORD
RESB
RESW
Assemblers functions
Convert mnemonic operation codes to their machine language equivalents
Convert symbolic operands to their equivalent machine addresses
Build the machine instructions in the proper format
b) Lexical substitution
Algorithm for macro expansion
1. Initialize the macro expansion counter (MEC)
2. Check the statement which is pointed by MEC is not a MEND
3. Exit from the macro expansion
RDBUFF and WRBUFF are the two macro instruction used in the Fig.
SIC/XE program. MACRO and MEND are the two new assemblerdirectives also used. RDBUFF
is the name of macro which is in the labelfield. The entry in the operand field identify the
parameters of the macroinstruction.
Each parameter begins with the character & which facilities thesubstitution of parameters
during macro expansion.
The macro name and parameters define a pattern or prototype for themacro instruction used by
the programmer. Body of the macro definitionis defined by the MACRO' directive statements.
Macro expansiongenerate these statements. End of the macro definition is defined by the
MEND assembler directive.
In the main program . Macro invocation statement that gives the nameof the macro instruction
being invoked and the arguments to be used inexpanding the macro .
Each macro invocation statement has been expanded into the statementsthat form the body of
the macro, with the arguments from the macroinvocation substituted for the parameters in the
macro prototype.
Parameters and arguments, both are associated with one anotheraccording to their positions.
The argument F1 is substituted for the parameter &INDEV whenever itoccurs in the body of
the macro. BUFFER is substituted for &BUFADRand &LENGTH is substituted for &RECLTH.
After macro processing, the expanded file can be used as input to theassembler.
Macro Processor Algorithm and Data Structures:
For designing two pass macro processor, all macro definitions areprocessed during the first pass
and all macro invocation statements areexpanded during the second pass. This type of two pass
macro processorwould not allow the body of one macro instruction to contain definitions
of other macros. The reason behind is that, all macros defined during thefirst pass before any
macro invocation were expanded.
Following example shows the definition of macros within a macro body.
The body of first macro (MACROS) contains statements that defineRDBUFF WRBUFF and
other macro instructions for a SIC system.Second macro instruction body (MACROX) defines
these same macrosfor a SIC\XE system. The same program could run on either a standard
SIC machine or a SIC\XE machine. Invocation of MACROS orMACROX is only changed for
use. Defining MACROS or MACROXdoes not define RDBUFF and other macro instructions.
These definitionsare processed only when an invocation 0MACROS or MACROX is
expanded.
Macro processor uses three main data structure.
1. Definition table (DEFT AB)
2. Name table (NAMTAB)
3. Argument table (ARGT AB)
Definition table stores macro definitions. It contains the macroprototype and the statements that
make up the macro body. The macronames are also entered into NAMT AB, which serves as an
index toDEFT AB.
When macro instruction defined, NAMTAB contains pointers to thebeginning and end of the
definition in DEFTAB.
Argument table (ARGT AB) is used during the expansion of macroinvocations. When a macro
invocation statement is recognized theargument are stored in ARGTAB according to their
position in theargument list.
Compilers
A compiler is a program that translates a sentencea. from a source language (e.g. Java,
Scheme, LATEX)
b. into a target language (e.g. JVM, Intel x86, PDF)
c. while preserving its meaning in the process
Compiler design has a long history (FORTRAN 1958)
a. lots of experience on how to structure compilers
b. lots of existing designs to study (many freely available)
c. take CS 152: Compiler Design for some of the details. . .
SOFTWARE TOOLS
A software tool is a system program which
a) Interfaces a program with the entity generating its input data or
b) Interfaces the result of a program with the entity consuming them.
Figure below shows the schematic of a software tool.
These tools work on the source program to produce different forms of documentation e.g. flow
charts
6. Design for Software Tools
Program preprocessing techniques are used to support static analysis of programs. Program
instrumentation implies insertion of statements in a program. The instrumented program is
translated using a standard translator.
Figure below shows the schematic of software tools using the techniques of interpretation and
program generation.
Interpreter based tools suffer from poor efficiency and poor portability, since an interpreter base
tool is only as portable as the interpreter it uses. A generate program is more efficient and can be
made portable
TEXT EDITORS:
These are the primary interface to the computer for all types of Knowledge
workers as they
compose, organize, study and manipulate computer-based information.
compiler. The command language processor may invoke the semantic routines
directly. In a text
editor,these semantic routines perform functions lsuch as editing and viewing. The
semantic routines
involve travelling,editing,viewing,and display functions. Editing operations are
always specified by the
user. In editing a document,the start of the area to be edited is determined by the
current editing
pointer maintained by the editing component ,which is the collection of modules
dealing with editing
tasks. The current editing pointer can be set or reset explicitly by the user using
travelling commands
,such as next paragraph and next screen,or implicitly as a side effect of the previous
editing operation
such as delete paragraph. The traveling component of the editor actually performs
the setting of the
current editing and viewing pointers,and thus determines the point at which the
viewing and /or editing
filtering begins. hen the user issues an editing command,the editing component
invokes the editing filter.
This component filters the document to generate a new editing buffer based on the
current editing ponter
as well as on the editing filter parameters. These parameters,which are specified by
both by the user and
the system,provide information such as the range of the text that can be affected
by an operation.
Filtering may consist of the selection of contiguous characters beginning at the
current point.
The editing and viewing buffers, while independent, can be related in many ways.
Ina simplest case
,they are identical:theuser edits the material directly on the screen.On the other
hand ,the editing and
viewing buffers may be completely disjoint. EG The user of a certain editor might
travel to line 75,and
after viewing it,decide to change all occurrences of ugly duckling to swan in
lines 1 through 50 of the
file by using a change command such as[1,50] c/ugly duckling/swan/
As apart of the editing command there is implicit travel to the first line of the file.
Lines 1 through 50 are
then filtered from the document to become the editing buffer.Successive
substitutions take place in this
editing buffer without correspoing updates of the view
Debug Monitors:
Dynamic debugging facility is provided by the debug monitors. It includes
following activities.
1)Setting breakpoints in the program.
2) Initiating a debug conversation when control reaches a breakpoint.
3)Displaying values of variables.
4)Assigning new values to variables.
5)Testing user defined assertions and predicates involving program variables.
When the user a commands to set a breakpoint the debug monitor instruments
the program to introduce a sensing instruction before the start of the statement at
breakpoint.
The debug monitor function can be easily implemented in an interpreter.
When a user gives a command to set a breakpoint at statement 150, The debug
monitor instruments the program to introduce the instruction.
<SI-instrn><code>in place of the no-op instructions preceding no-op 150.
The debug monitors requires two kind of information regarding the user
program.
a) Starting address of program statements in the complied code.
b) Program variables name and address.
Dynamic debugging of a program Following sequence of step involved .in
dynamic debugging of a program.
1)The user compiles the program under the debug option. The compiler produces
two file i.e.
a)Complied code file
b)Debug information file
2)The user activates the debug monitor and indicates the name of program to be
debugged. Debug monitor opens the corresponding two files.
2)User indicates the debug requirements i.e. a list of breakpoints and action to
performed at breakpoints. Debug monitor builds a debug table. This table
_contains, <statement number, debug action.>'
3)The instrumented program gets the control and executes up to a breakpoint.
2)When <SCinstrn> is excuted, software interrupt is generated and control is given
to the debug monitor. Debug monitor construct the debug table and perform the
debug actions associated with it.
Control now returns to the u program.
1) 3)Steps (4) and (5) are repeated until the end of the debug session.
UNIT 2
Two Pass Assembler
Pass 1
Assign addresses to all statements in the program
Save the values assigned to all labels for use in Pass 2
Perform some processing of assembler directives
Pass 2
Assemble instructions
Generate data values defined by BYTE, WORD
Perform processing of assembler directives not done inPass 1
Write the object program and the assembly listing
Two Pass Assembler
Data Structures
Avoids the overhead of writing the objectprogram out and reading it back
Both one-pass and two-pass assemblers canbe designed as load-and-go.
However one-pass also avoids the over headof an additional pass over the source program
For a load-and-go assembler, the actualaddress must be known at assembly time, we can use
an absolute program
Forward Reference in One-pass Assembler
For any symbol that has not yet beendefined
1. omit the address translation
2. insert the symbol into SYMTAB, and mark thissymbol undefined
3. the address that refers to the undefinedsymbol is added to a list of forward
referencesassociated with the symbol table entry
4. when the definition for a symbol isencountered, the proper address for thesymbol is then
inserted into any instructionsprevious generated according to the forwardreference list
Load-and-go Assembler (Cont.)
At the end of the program
any SYMTAB entries that are still marked with *indicate undefined symbols
search SYMTAB for the symbol named in theEND statement and jump to this location to
begin execution
The actual starting address must bespecified at assembly time
Producing Object Code
When external working-storage devices are not available or too slow (for the
intermediate filebetween the two passes
Solution:
When definition of a symbol is encountered, the
assembler must generate another Tex record with the
correct operand address
The loader is used to complete forward references that
could not be handled by the assembler
The object program records must be kept in their
original order when they are presented to the loader
Multi-Pass Assemblers
Restriction on EQU and ORG
no forward reference, since symbols valuecant be defined during the first pass
Example
Use link list to keep track of whose valuedepend on an undefined symbol
UNIT 3
(Macro processors)
Introduction:
A macro represents a commonly used group of statements in thesource pro ramming language.
The macro processor replaces each macroinstruction with the corresponding group of source
language statements.
This is called expanding of macros.
Basic Macro Processor Functions:
We study the fundamental functions that are commonly used by all macro
Macro Definition and Expansion
Macro is a unit of specification for program generation throughexpansion.
A macro consists of a name, a set of formal parameters and body ofcode.
Macro expansion is a macro name with a set of formal parameters isreplaced by some code.
Lexical expansion is replacement of a character string by anothercharacter string during
program generation.
Semantic expansion is generation of instructions tailored to therequirements of specific usage.
Macro definition consists of
i) macro prototype ii) one of more model iii) macro preprocessor
Macro definition is in between a macro header statement and a macro estatement.
Syntax of macro prototype statement
Macro Expansion
Macro call leads to macro expansion.
Macro call statement is replaced by a sequence of assembly statement inmacro expansion.
Two key notions are used in macro expansion
a) Expansion time control flow
b) Lexical substitution
Algorithm for macro expansion
1. Initialize the macro expansion counter (MEC)
2. Check the statement which is pointed by MEC is not a MEND
3. Exit from the macro expansion
RDBUFF and WRBUFF are the two macro instruction used in the Fig.
SIC/XE program. MACRO and MEND are the two new assemblerdirectives also used. RDBUFF
is the name of macro which is in the labelfield. The entry in the operand field identify the
parameters of the macroinstruction.
Each parameter begins with the character & which facilities thesubstitution of parameters
during macro expansion.
The macro name and parameters define a pattern or prototype for themacro instruction used by
the programmer. Body of the macro definitionis defined by the MACRO' directive statements.
Macro expansiongenerate these statements. End of the macro definition is defined by the
MEND assembler directive.
In the main program . Macro invocation statement that gives the nameof the macro instruction
being invoked and the arguments to be used inexpanding the macro .
Each macro invocation statement has been expanded into the statementsthat form the body of
the macro, with the arguments from the macroinvocation substituted for the parameters in the
macro prototype.
Parameters and arguments, both are associated with one anotheraccording to their positions.
The argument F1 is substituted for the parameter &INDEV whenever itoccurs in the body of
the macro. BUFFER is substituted for &BUFADRand &LENGTH is substituted for &RECLTH.
After macro processing, the expanded file can be used as input to theassembler.
Macro Processor Algorithm and Data Structures:
For designing two pass macro processor, all macro definitions areprocessed during the first pass
and all macro invocation statements areexpanded during the second pass. This type of two pass
macro processorwould not allow the body of one macro instruction to contain definitions
of other macros. The reason behind is that, all macros defined during thefirst pass before any
macro invocation were expanded.
Following example shows the definition of macros within a macro body.
The body of first macro (MACROS) contains statements that defineRDBUFF WRBUFF and
other macro instructions for a SIC system.Second macro instruction body (MACROX) defines
these same macrosfor a SIC\XE system. The same program could run on either a standard
SIC machine or a SIC\XE machine. Invocation of MACROS orMACROX is only changed for
use. Defining MACROS or MACROXdoes not define RDBUFF and other macro instructions.
These definitionsare processed only when an invocation 0MACROS or MACROX is
expanded.
Macro processor uses three main data structure.
1. Definition table (DEFT AB)
2. Name table (NAMTAB)
3. Argument table (ARGT AB)
Definition table stores macro definitions. It contains the macroprototype and the statements that
make up the macro body. The macronames are also entered into NAMT AB, which serves as an
index toDEFT AB.
When macro instruction defined, NAMTAB contains pointers to thebeginning and end of the
definition in DEFTAB.
Argument table (ARGT AB) is used during the expansion of macroinvocations. When a macro
invocation statement is recognized theargument are stored in ARGTAB according to their
position in theargument list.
Loader is utility program which takes object code as input prepares it for execution and loads the
executable code into the memory. Thus loader is actually responsible for initiating the execution
process.
Functions of Loader:
The loader is responsible for the activities such as allocation, linking, relocation and loading
1) It allocates the space for program in the memory, by calculating the size of the program. This
activity is called allocation.
2) It resolves the symbolic references (code/data) between the object modules by assigning all
the user subroutine and library subroutine addresses. This activity is called linking.
3) There are some address dependent locations in the program, such address constants must be
adjusted according to allocated space, such activity done by loader is called relocation.
4) Finally it places all the machine instructions and data of corresponding programs and
subroutines into the memory. Thus program now becomes ready for execution, this activity is
called loading.
Loader Schemes:
Based on the various functionalities of loader, there are various types of loaders:
1) compile and go loader: in this type of loader, the instruction is read line by line, its
machine code is obtained and it is directly put in the main memory at some known address. That
means the assembler runs in one part of memory and the assembled machine instructions and
data is directly put into their assigned memory locations. After completion of assembly process,
assign starting address of the program to the location counter. The typical example is WATFOR77, its a FORTRAN compiler which uses such load and go scheme. This loading scheme is
also called as assemble and go.
Advantages:
This scheme is simple to implement. Because assembler is placed at one part of the memory
and loader simply loads assembled machine instructions into the memory.
Disadvantages:
In this scheme some portion of memory is occupied by assembler which is simply a wastage of
memory. As this scheme is combination of assembler and loader activities, this combination
program occupies large block of memory.
There is no production of .obj file, the source code is directly converted to executable form.
Hence even though there is no modification in the source program it needs to be assembled and
executed each time, which then becomes a time consuming activity.
It cannot handle multiple source programs or multiple programs written in different languages.
This is because assembler can translate one source language to other target language.
For a programmer it is very difficult to make an orderly modulator program and also it becomes
difficult to maintain such program, and the compile and go loader cannot handle such
programs.
The execution time will be more in this scheme as every time programis assembled and then
executed.
2) General Loader Scheme: in this loader scheme, the source program is converted to object
program by some translator (assembler). The loader accepts these object modules and puts
machine instruction and data in an executable form at their assigned memory. The loader
occupies some portion of main memory.
Advantages:
The program need not be retranslated each time while running it. This is because initially when
source program gets executed an object program gets generated. Of program is not modified,
then loader can make use of this object program to convert it to executable form.
There is no wastage of memory, because assembler is not placed in the memory, instead of it,
loader occupies some portion of the memory. And size of loader is smaller than assembler, so
more memory is available to the user.
It is possible to write source program with multiple programs and multiple languages, because
the source programs are first converted to object programs always, and loader accepts these
object modules to convert it to executable form.
3) Absolute Loader: Absolute loader is a kind of loader in which relocated object files are
created, loader accepts these files and places them at specified locations in the memory. This type
of loader is called absolute because no relocation information is needed; rather it is obtained
from the programmer or assembler. The starting address of every module is known to the
programmer, this corresponding starting address is stored in the object file, then task of loader
becomes very simple and that is to simply place the executable form of the machine instructions
at the locations mentioned in the object file. In this scheme, the programmer or assembler should
have knowledge of memory management. The resolution of external references or linking of
different subroutines are the issues which need to be handled by the programmer. The
programmer should take care of two things: first thing is : specification of starting address of
each module to be used. If some modification is done in some module then the length of that
module may vary. This causes a change in the starting address of immediate next .modules, its
then the programmer's duty to make necessary changes in the starting addresses of respective
modules. Second thing is ,while branching from one segment to another the absolute starting
address of respective module is to be known by the programmer so that such address can be
specified at respective JMP instruction. For example
Line number
1 MAIN START 1000
..
..
..
1 JMP 5000
16 STORE ;instruction at location 2000
END
5 Dr.ShaimaaH.Shaker
1 SUM START 5000
2
20 JMP 2000
21 END
In this example there are two segments, which are interdependent. At line
number 1 the assembler directive START specifies the physical starting address that can be used
during the execution of the first segment MAIN. Then at line number 15 the JMP instruction is
given which specifies the physical starting address that can be used by the second segment. The
assembler creates the object codes for these two segments by considering the stating addresses of
these two segments. During the execution, the first segment will be loaded at address 1000 and
second segment will be loaded at address 5000 as specified by the programmer. Thus the
problem of linking is manually solved by the programmer itself by taking care of
the mutually dependant dresses. As you can notice that the control is correctly transferred to the
address 5000 for invoking the other segment, and after that at line number 20 the JMP instruction
transfers the control to the location 2000, necessarily at location 2000 the instruction STORE
of line number 16 is present. Thus resolution of mutual references and linking is done by the
programmer. The task of assembler is to create the object codes for the above segments and
along with the information such as starting address of the memory where actually the object code
can be placed at the time of execution. The absolute loader accepts these object modules from
assembler and by reading the information about their starting addresses, it will actually place
(load) them in the memory at specified addresses.
The entire process is modeled in the following figure. Thus the absolute loader is simple to
implement in this scheme
l) Allocation is done by either programmer or assembler
2)Linking is done by the programmer or assembler
3)Resolution is done by assembler
4)Simply loading is done by the loader
As the name suggests, no relocation information is needed, if at all it is required then that task
can be done by either a programmer or assembler
Advantages:
1. It is simple to implement
2. This scheme allows multiple programs or the source programs written different languages. If
there are multiple programs written in different languages then the respective language assembler
will convert it to the language and a common object file can be prepared with the entire ad
resolution.
3. The task of loader becomes simpler as it simply obeys the instruction regarding where to place
the object code in the main memory.
4. The process of execution is efficient.
Disadvantages:
1. In this scheme it is the programmer's duty to adjust all the inter segment addresses and
manually do the linking activity. For that, it is necessary for a programmer to know the memory
management.
If at all any modification is done the some segments, the starting addresses of immediate next
segments may get changed, the programmer has to take care of this issue and he needs to update
the corresponding starting addresses on any modification in the source.
Algorithm for absolute Loader
Input: Object codes and starting address of program segments.
Output: An executable code for corresponding source program. This executable code is to be
placed in the main memory
Method:
Begin
For each program segment
do Begin
Read the first line from object module to
obtain information about memory location. The
starting address say S in corresponding object
END
At the beginning of the MAIN the subroutine B is declared as external. When a call to subroutine
B is made, before making the unconditional jump, the current content of the program counter
should be stored in the system stack maintained internally. Similarly while returning from the
subroutine B (at RET) the pop is performed to restore the program counter of caller routine with
the address of next instruction to be executed.
Concept of relocations:
Relocation is the process of updating the addresses used in the address sensitive instructions of a
program. It is necessary that such a modification should help to execute the program from
designated area of the memory. The assembler generates the object code. This object code gets
executed after loading at storage locations. The addresses of such object code will get specified
only after the assembly process is over. Therefore, after loading, address of object code = Mere
address of object code + relocation constant. There are two types of addresses being generated:
Absolute address and,relative address. The absolute address can be directly used to map the
object code in the main memory. Whereas the relative address is onlyafter the addition of
relocation constant to the object code address. Thiskind of adjustment needs to be done in case of
relative address beforeactual execution of the code. The typical example of relative reference is :
addresses of the symbols defined in the Label field, addresses of the datawhich is defined by the
assembler directive, literals, redefinable symbols.Similarly, the typical example of absolute
address is the constants whichare generated by assembler are absolute.The assembler calculates
which addresses are absolute and whichaddresses are relative during the assembly process.
During the assemblyprocess the assembler calculates the address with the help of simple
expressions.
For example:
LOADA(X)+5
The expression A(X) means the address of variable X. The meaning ofthe above instruction is
that loading of the contents of memory locationwhich is 5 more than the address of variable X.
Suppose if the address ofX is 50 then by above command we try to get the memory location
50+5=55. Therefore as the address of variable X is relative A(X) + 5 isalso relative. To calculate
the relative addresses the simple expressionsare allowed. It is expected that the expression should
possess at the mostaddition and multiplication operations. A simple exercise can be carriedout to
determine whether the given address is absolute or relative. In theexpression if the address is
absolute then put 0 over there and if address isrelative then put lover there. The expression then
gets transformed to sumof O's and l's. If the resultant value of the expression is 0 then
expressionis absolute. And if the resultant value of the expression is 1 then theexpression is
relative. If the resultant is other than 0 or 1then theexpression is illegal. For example:
In the above expression the A, Band C are the variable names. Theassembler is to consider the
relocation attribute and adjust the objectcode by relocation constant. Assembler is then
responsible to convey theinformation loading of object code to the loader. Let us now see how
assembler generates code using relocation information.
Direct Linking Loaders
The direct linking loader is the most common type of loader. This type ofloader is a relocatable
loader. The loader can not have the direct access tothe source code. And to place the object code
in the memory there aretwo situations: either the address of the object code could be absolute
which then can be directly placed at the specified location or the addresscan be relative. If at all
the address is relative then it is the assembler whoinforms the loader about the relative addresses.
The assembler should give the following information to the loader
1)The length of the object code segment
2) The list of all the symbols which are not defined 111 the currentsegment but can be used in the
current segment.
3) The list of all the symbols which are defined in the current segment butcan be referred by the
other segments.The list of symbols which are not defined in the current segment but can
be used in the current segment are stored in a data structure called USEtable. The USE table
holds the information such as name of the symbol,address, address relativity.
The list of symbols which are defined in the current segment and can bereferred by the other
segments are stored in a data structure calledDEFINITION table. The definition table holds the
information such assymbol, address.
Direct linking:
As we have seen in overlay structure certain selectivesubroutines can be resident in the memory.
That means it is not necessaryto resident all the subroutines in the memory for all the time. Only
necessary routines can be present in the main memory and duringexecution the required
subroutines can be loaded in the memory. Thisprocess of postponing linking and loading of
external reference untilexecution is called dynamic linking. For example suppose the subroutine
main calls A,B,C,D then it is not desirable to load A,B,C and D alongwith the main in the
memory. Whether A, B, C or D is called by the mainor not will be known only at the time of
execution. Hence keeping theseroutines already before is really not needed. As the subroutines
getexecuted when the program runs. Also the linking of all the subroutineshas to be performed.
And the code of all the subroutines remains residentin the main memory. As a result of all this is
that memory gets occupiedunnecessarily. Typically 'error routines' are such routines which can
beinvoked rarely. Then one can postpone the loading of these routinesduring the execution. If
linking and loading of such rarely invokedexternal references could be postponed until the
execution time when itwas found to be absolutely necessary, then it increases the efficiency of
overhead of the loader. In dynamic linking, the binder first prepares aload module in which along
with program code the allocation andrelocation information is stored. The loader simply loads
the mainmodule in the main memory. If any external reference to a subroutine
comes, then the execution is suspended for a while, the loader brings therequired subroutine in
the main memory and then the execution process isresumed. Thus dynamic linking both the
loading and linking is donedynamically.
Advantages
1. The overhead on the loader is reduced. The required subroutine will be
load in the main memory only at the time of execution.
2. The system can be dynamically reconfigured.
Disadvantages The linking and loading need to be postponed until the
execution. During the execution if at all any subroutine is needed then the
process of execution needs to be suspended until the required subroutine
gets loaded in the main memory.
Bootstrap Loader:
As we turn on the computer there is nothingmeaningful in the main memory (RAM). A small
program is written andstored in the ROM. This program initially loads the operating system
from secondary storage to main memory. The operating system then takesthe overall control.
This program which is responsible for booting up thesystem is called bootstrap loader. This is the
program which must beexecuted first when the system is first powered on. If the program
startsfrom the location x then to execute this program the program counter ofthis machine should
be loaded with the value x. Thus the task of settingthe initial value of the program counter is to
be done by machinehardware. The bootstrap loader is a very small program which is to befitted
in the ROM. The task of bootstrap loader is to load the necessaryportion of the operating system
in the main memory .The initial addressat which the bootstrap loader is to be loaded is generally
the lowest (maybe at 0th location) or the highest location. .
Concept of Linking:
As we have discussed earlier, the execution ofprogram can be done with the help of following
steps
1. Translation of the program(done by assembler or compiler)
2. Linking of the program with all other programs which are needed forexecution. This also
involves preparation of a program called loadmodule.
3. Loading of the load module prepared by linker to some specifiedmemory location.
The output of translator is a program called object module. The linkerprocesses these object
modules binds with necessary library routines andprepares a ready to execute program. Such a
program is called binaryprogram. The "binary program also contains some necessary
informationabout allocation and relocation. The loader then load s this program into
memory for execution purpose.
Various tasks of linker are 1. Prepare a single load module and adjust all the addresses andsubroutine references with
respect to the offset location.
2. To prepare a load module concatenate all the object modules and adjustall the operand address
references as well as external references to theoffset location.
3. At correct locations in the load module, copy the binary machineinstructions and constant data
in order to prepare ready to executemodule.
The linking process is performed in two passes. Two passes are necessarybecause the linker may
encounter a forward reference before knowing itsaddress. So it is necessary to scan all the
DEFINITION and USE table atleast once. Linker then builds the Global symbol table with the
help ofUSE and DEFINITION table. In Global symbol table name of eachexternally referenced
symbol is included along with its address relative tobeginning of the load module. And during
pass 2, the addresses ofexternal references are replaced by obtaining the addresses from global
symbol table.
UNIT 4
Editors:
An interactive editor is a computer program that allows a user to create and revise a
target document.
The term document includes objects such as computer programs, texts, equations,
tables, diagrams, line
arts and photographs-anything that one might find on a printed page.
Text editor is one in which the primary elements being edited are character strings
of the target text.
For any computing environment interactive text editors has an important part.
Various types of editors are:
Text editor should be the primary interface to the computer for all types 0 knowledge workers.
Overview of the editing process'
An interactive editor is a computer program that allows a user to create anrevise a target
document.
The document means an object such as computer programs, text, equations tables, diagrams,
photographs etc.
The document editing process in an interactive user computer dialogue designed to accomplish
four tasks:
1)Select the part of the target document to be viewed & manipulated.
2)Determine how to format this view online and how to display it.
3)Specify and execute operations that modify the target document.
4)Updatethe view appropriately.
Selection of the part of the document to be viewed and edited involves first travelling through
the document to locate the area of interest.
Travelling implies movement of the editing context to a new position within the text. The
selection of what is to be viewed and manipulated that is controlled by filtering.
Filtering extracts the relevant subset of the target document at the point of interest, such as the
next screenful of text or the next statement.
Formatting determines how the result of the filtering will be seen as a visible representation on
a display screen or other devices.
In the actual editing phase, the target document is created or altered with a set of operations
such as insert, delete, replace, move and copy
.Design of an Editor:
The fundamental functions in editing are travelling, editing, viewing and display.
Travelling implies movement of the editing context to a new position within the text.
Viewing implies formatting the text in a manner desired by the user.
A simple text editor' may choose to combine the viewing and display functions.
Figure below shows the simple editor.
In editing document, the start of the area to be edited is determined by the current editing
pointer maintained by the editing component.
The travelling component of the editor actually performs the setting of the current editing and
viewing pointers. It also determines the point at which the viewing and editing filters.
The current editing pointer can be set or reset explicitly by the user with travelling commands,
such as next paragraph and next screen.
When a user issue an editing command the editing component invokes the editing filter.
Editing component filters the document to generate a new editing buffer based on the current
editing pointer as well as on the editing filter parameters.
Filtering may simply consists of the selection of contiguous characters beginning at the current
point.
Current viewing pointer determined the start of the area to be viewed for viewing a document.
Current viewing pointer can be set or reset explicitly by the user with a travelling command or
implicitly by the user with a travelling command or implicitly by the system as a result of the
previous editing operation.
For a given position of the editing context, the editing and viewing filters operate on the
internal form of text to prepare the forms suitable for editing viewing.
When the cursor position changes, the filters operate on a new portion of text to update the
contents of the buffers.
As editing is performed, the editing filter reflects the changes into the internal form and update
the content of the viewing buffer.
The editing and viewing buffers are independent in some cases. They are identical sometime as
shown is Figure below:
In the above example, an editing filter creates an editing buffer that contains the document from
the selected character of the end of the document.
The viewing buffer contains the part of the document that is visible on the screen. Only the last
part of which is in the editing buffer.
Screen Editors:
Screen editor uses the whatyou see is what you get principle in editor design.
Aeditor displays a screenful of text at a time. The user can move the cursor over the screen,
position it at the point where user desires to perform some editing and proceed with the editing
directly.
Document
Display
Window
Editing buffer
Viewing buffer
8
The user has full control over the entire terminal. For example over an type exiting string which
user wishes to replace. User can bring the cursor over a character to be deleted and press a delete
key.
It is possible to see the effect of an edit operation on the screen.
Line Editor:
Line editor is one of the simplest type of editor which uses a buffer to store information:
It operates in command mode. User give the command to the editor for any operation. Editor
will respond this command.
Buffer is in the main memory. That is set aside to store the information which is entered from
the keyboard.
Merits
1)Simple for read and write.
2)Simplein design and implementation
3)Command and responses are interleaved.
Demerits
1)Not user friendly
2)Contextof the text is not displayed.
3)Onlysingle line is used for editing.
Stream Editor:
A stream editor views the entire text as a stream of characters. This permits edit operations to
cross line boundaries.
Stream editor typically support character line and context orient commands.
In stream editor, the current editing context indicated by the position of text pointer. This
pointer can be manipulated using positioning.
Stream editor maintain multiple representations.
Word Processors:
It is document editors with additional features. It produce well formatted output.
Features of text
a)Merging of text
b)Searchingand replacement of word
c)Moving sections of text
9
User Interface:
User interface simplify the interaction of a user with an application.
UI consists of two components: Dialog manager and presentation manager.
Dialog manager manage the conversation between the user and the application.
Presentation manager displays the data produced by the application in an appropriate manner
on the user display.
Figure below show user interface.
Dialog manager is also responsible for error messages and online help function, and for
organizing changes in the visual context of the user.
User Interface Management System (UIMS) automates the generation of user
Interface.
UIMS takes specification of the presentation and dialog semantics to produce the presentation
and dialog managers of the UI.
Application code
Dialog manager
Presentation manager
Graphics package
10
Commands dialogs Command dialogues are used to issue commands. Command dialogues
are implemented in following ways.
a)Command language.
b)Command menu.
c)Direct manipulation.
User interface is concerned with the input devices output devices and interaction language of
the system.
Input devices are used to enter elements of the text being edited, to enter commands, and to
designate editable elements. These devices as used with editors can be divided into the
categories:
a)Text devices
b)Button devices
c)Locator devices
Text or string devices are typically typewritter like keyboards on which a user presses and
releases keys, sending a unique code for each key.
Button or choice devices generates an interrupt or set a system flag. Such devices typically
include a set of special function keys on an alphanumeric keyboard.
Locator devices are two dimensional analog to digital converters that position a cursor symbol
on the screen by observing the user's movement the device. The most common such devices for
editing applications are the mouse and the data tablet.
Text devices with arrow keys can be used to simulate locator devices. Each these keys shows an
arowthat point up, down, left or right.
The interaction language of a text editor is generally one of several common types.
a)Typing oriented
b)Text command oriented
The user communicates with the editor by typing text strings both for command names and for
operands. These strings are sent to the editor and are usually echoed to the output device.
Typed specification often requires the user to remember the exact form of all commands, or at
least their abbreviations. Function key command specification is typically coupled with cursor
key movement for specifying operands, which eliminates much typing.
Typing oriented systems require familiarity with the system and language, as well as some
expertise in typing. Function key oriented systems often have either too few keys, requiring
multiple keystroke commands, or have too many unique keys, which result in an
unwidelykeyboard.
The menu oriented user interface solve the problem of typing oriented anfunction key oriented
systems. A menu is a multiple choice set of text strings or icons, which are graphic symbols that
represents objects or operations. The user can perform actions by selecting items from the menu.
Problem with a menu oriented system can arise when there are many possible actions and
several choices are required to complete an action.
Debugging Function and Capabilities:
Debugging system should provide functions such as tracing and traceback.
Tracing can be used to track the flow of execution logic and data modifications. It can also be
based on conditional expressions.
Traceback can show the path by which the current statement was reached. It can also show
which statements have modified a given variable or parameter.
Debugging system have a good program display capabilities. It must be possible to display the
program being debugged, complete with statement numbers.
The system should save all the debugging specifications across such a recompilation, so the
user does not need to reissue all of these debugging commands.
Debugging system must be sensitive to the specific languge being debugged so that procedural,
arithmetic and conditional logic can be coded in the syntax of that language.
The debugger should be able to switch its context when a program written in one language calls
a program written in a different language.
. A debugging system must be able to deal with optimized code. Application code used in
production environments is usually optimized. Debug Monitors:
Dynamic debugging facility is provided by the debug monitors. It includes following activities.