Professional Documents
Culture Documents
LAB MANUAL
(Dr.R.Murugeswari) (Dr.R.Ramalakshmi)
1
UNIVERSITY
VISION
MISSION
DEPARTMENT
VISION
To become a Centre of Excellence in Teaching and Research in the field of Computer Science and
Engineering.
MISSION
To prepare the students for a prospective career in IT industry and for higher learning by
imparting sound technical knowledge.
To carry out research in cutting edge technologies in computer engineering to meet the
requirement of the industry and society.
2
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING
CSE282 - SYSTEM SOFTWARE LAB
INDEX
3
Introduction
System software
Acts as an intermediary between users and hardware
Creates a virtual environment for the user that hides the actual computer
architecture
Virtual machine (or virtual environment)
Set of services and resources created by the system software and seen by
the user
4
Activates system programs, applications packages, or user programs to
carry out user requests
User interface
Graphical user interface (GUI) provides graphical control of the
capabilities and services of the computer
Language services
Assemblers, compilers, and interpreters
Allow you to write programs in a high-level, user-oriented
language, and then execute them
Memory managers
Allocate and retrieve memory space
Information managers
Handle the organization, storage, and retrieval of information on mass storage
devices
I/O systems
Allow the use of different types of input and output devices
5
KALASALINGAM UNIVERSITY
(KALASALINGAM ACADEMY OF RESEARCH AND EDUCATION)
ANAND NAGAR, KRISHNAN KOIL – 626 126
Pre-requisite:
Course Description:
6
1. PSO1: Problem-Solving Skills: The ability to apply mathematics, science and
computer engineering knowledge to analyze, design and develop cost effective
computing solutions for complex problems with environmental considerations.
2. PSO2: Professional Skills: The ability to apply modern tools and strategies in
software project development using modern programming environments to
deliver a quality product for business accomplishment.
3. PSO 3 : Communication and Team Skill : The ability to exhibit proficiency in
oral and written communication as individual or as part of a team to work
effectively with professional behaviors and ethics.
4. PSO 4 : Successful Career and Entrepreneurship : The ability to create a
inventive career path by applying innovative project management techniques to
become a successful software professional, an entrepreneur or zest for higher
studies
PROGRAMME OUTCOMES
PO Description
1 Engineering knowledge: Apply the knowledge of mathematics, science,
engineering fundamentals, and an engineering specialization to the solution
of complex engineering problems.
2 Problem analysis: Identify, formulate, review research literature, and analyze
complex engineering problems reaching substantiated conclusions using first
principles of mathematics, natural sciences, and engineering sciences.
3 Design/development of solutions: Design solutions for complex engineering
problems and design system components or processes that meet the specified
needs with appropriate consideration for the public health and safety, and the
cultural, societal, and environmental considerations.
4 Conduct investigations of complex problems: Use research-based
knowledge and research methods including design of experiments, analysis
and interpretation of data, and synthesis of the information to provide valid
conclusions.
5 Modern tool usage: Create, select, and apply appropriate techniques,
7
resources, and modern engineering and IT tools including prediction and
modeling to complex engineering activities with an understanding of the
limitations.
6 The engineer and society: Apply reasoning informed by the contextual
knowledge to assess societal, health, safety, legal and cultural issues and the
consequent responsibilities relevant to the professional engineering practice.
7 Environment and sustainability: Understand the impact of the professional
engineering solutions in societal and environmental contexts, and
demonstrate the knowledge of, and need for sustainable development.
8 Ethics: Apply ethical principles and commit to professional ethics and
responsibilities and norms of the engineering practice.
9 Individual and team work: Function effectively as an individual, and as a
member or leader in diverse teams, and in multidisciplinary settings.
10 Communication: Communicate effectively on complex engineering activities
with the engineering community and with society at large, such as, being able
to comprehend and write effective reports and design documentation, make
effective presentations, and give and receive clear instructions.
11 Project management and finance: Demonstrate knowledge and
understanding of the
12 Engineering and management principles and apply these to one’s own work,
as a member and leader in a team, to manage projects and in
multidisciplinary environments.
13 Life -long learning: Recognize the need for, and have the preparation and
ability to engage in independent and life -long learning in the broadest
context of technological change.
Course Outcomes:
CO1. Write efficient algorithms with good space and time complexity to simulate
functions of system softwares.
CO2. Design and develop code to demonstrate various system softwares like
assembler, loader, macro-processor and text editors.
8
CO3. Work effectively as an individual and communicate effectively with technical
community.
CO and PO Mapping
PO1 PO2 PO3 PO4 PO5 PO6 PO7 PO8 PO9 PO10 PO11 PO12 PSO PSO PSO
1 2 3
CO1 S M M M
CO2 S S S S S S M
CO3 S S
Projects:
1. Design and Implement a simple compiler
2. Develop a simple application using DBMS.
9
3. Develop a debugging system for your own language.
10
50% - 80% - 11 - 15 Marks
questions 25% - 50 % - 6- 10 Marks
0%-25% - 0 - 5 Marks
Ex. No : 1
SYMBOL TABLE CREATION
Date :
Aim:
Theory
Symbol table is a data structure to store the details about the symbols present in the
source program. It is created during pass 1 and will be used during pass 2. This table
stores the informations like symbol name, data type and address. The possible
operations on symbol table are insert, search and remove. The following built-in
functions of C can be used for implementation.
fscanf()
Description
The C library function int fscanf(FILE *stream, const char *format, ...) reads
formatted input from a stream.
Declaration
Following is the declaration for fscanf() function.
11
int fscanf(FILE *stream, const char *format, …)
Parameters
stream -- This is the pointer to a FILE object that identifies the stream.
format -- This is the C string that contains one or more of the following
items: Whitespace character, Non-whitespace character and Format specifiers. A
format specifier will be as [=%[*][width][modifiers]type=].
fprintf()
Description
The C library function int fprintf(FILE *stream, const char *format, ...) sends
formatted output to a stream.
Declaration
Following is the declaration for fprintf() function.
int fprintf(FILE *stream, const char *format, …)
Parameters
stream -- This is the pointer to a FILE object that identifies the stream.
format -- This is the C string that contains the text to be written to the
stream.It can optionally contain embedded format tags that are replaced
by the values specified in subsequent additional arguments and formatted
as requested.
fclose()
Description
The C library function int fclose(FILE *stream) closes the stream. All buffers are
flushed.
Declaration
Following is the declaration for fclose() function.
int fclose(FILE *stream)
Parameters
stream - This is the pointer to a FILE object that specifies the stream to be
closed.
12
This method returns zero if the stream is successfully closed.On failure, EOF is
returned.
feof()
Description
The C library function int feof(FILE *stream) tests the end-of-file indicator for
the given stream.
Declaration
Parameters
stream -- This is the pointer to a FILE object that identifies the stream.
This function returns a non-zero value when End-of-File indicator associated with the
stream is set, else zero is returned.
Example
#include <stdio.h>
#include <stdlib.h>
int main()
{
FILE * fp1, *fp2;
while(1)
{
c = fgetc(fp2);
if( feof(fp2) )
{
break ;
}
fprintf(fp1,"%c", c);
}
13
fclose(fp1);
fclose(fp2)
return(0);
}
Algorithm:
INPUT.c
#include <stdio.h>
int main()
{
int sum, m1, m2, m3;
float avg;
char name[20];
14
…
…
}
SYMTAB.c
15
16
17
Viva Questions:
Sl. Marks
Module Max. Marks
No Obtained
1 Efficiency of Algorithm 10
2 Efficiency of program 10
3 Output 10
4 Technical Skill 10
5 Communication Skill 10
Total 50
Faculty Signature
Date :
18
Aim:
Theory
Assembler's functions
Functions of PASS 1
19
strcmp()
Description
The C library function int strcmp(const char *str1, const char *str2) compares the
string pointed to by str1 to the string pointed to by str2.
Declaration
Following is the declaration for strcmp() function.
int strcmp(const char *str1, const char *str2)
Parameters
Example
#include <stdio.h>
#include <string.h>
int main ()
{
char str1[15];
char str2[15];
int ret;
strcpy(str1, "abcdef");
strcpy(str2, "ABCDEF");
if(ret < 0)
{
printf("str1 is less than str2");
20
}
else if(ret > 0)
{
printf("str2 is less than str1");
}
else
{
printf("str1 is equal to str2");
}
return (0); }
begin
if starting address is given
LOCCTR = starting address;
else
LOCCTR = 0;
while OPCODE != END do ;; or EOF
begin
read a line from the code
if there is a label
if this label is in SYMTAB, then error
else insert (label, LOCCTR) into SYMTAB
search OPTAB for the op code
if found
LOCCTR += N ;; N is the length of this
instruction (4 for MIPS)
else if this is an assembly directive
update LOCCTR as directed
else error
write line to intermediate file
end
program size = LOCCTR - starting address;
end
Pass1 Algorithm
21
4. Read the input file until end of file is reached
a) Read a line from the input file using fscanf function.
b) Split it into three parts using strtok function ( LABEL, OPCODE and
OPERAND)
c) If ( strcmp(OPERATOR, “START”) == 0)
i. Initialize LOCCTR = atoi(OPERAND)
d) Otherwise
i. Initialize LOCCTR = 0
e) Check whether LABEL is not EMPTY
f) If so, write the LABEL and LOCCTR value into SYMTAB.txt using fprintf
function.
g) Write LOCCTR, LABEL , OPERATOR and OPERAND into the output file
(INTERMEDIATE.txt).
h) Update the LOCCTR by incrementing it by 3.
5. Close the files.
INPUT.ASM
SYMTAB.txt
22
SYMBOL ADDRESS
FIRST 1000
CLOOP 1003
ENDFIL 1015
EOF 1018
ZERO 101B
RETADR 101E
LENGTH 1021
INTERMEDIATE.txt
23
Program and Rough Work
24
25
26
Viva Questions
Sl. Marks
Module Max. Marks
No Obtained
1 Efficiency of Algorithm 10
2 Efficiency of program 10
3 Output 10
4 Technical Skill 10
5 Communication Skill 10
Total 50
Faculty Signature
27
Ex. No : 3
PASS TWO OF A TWO PASS ASSEMBLER
Date :
Aim
Theory
Functions of pass-2
28
fscanf()
fprintf()
feof()
fclose()
strtok()
strtok()
Description
The C library function char *strtok(char *str, const char *delim) breaks string str
into a series of tokens using the delimitrer delim.
Declaration
Following is the declaration for strtok() function.
char *strtok(char *str, const char *delim)
Parameters
str -- The contents of this string are modified and broken into smaller strings
(tokens).
delim -- This is the C string containing the delimiters. These may vary from one
call to another.
Return Value
This function returns a pointer to the last token found in string. A null pointer is
returned if there are no tokens left to retrieve.
Example
The following example shows the usage of strtok() function.
#include <string.h>
#include <stdio.h>
int main()
{
const char str[80] = "This is - www.tutorialspoint.com - website";
const char s[2] = "-";
char *token;
29
/* walk through other tokens */
while( token != NULL )
{
printf( " %s\n", token );
Begin
read 1st input line
if OPCODE = „START‟ then
begin
write listing line
read next input line
end
write Header record to object program
initialize 1st Text record
while OPCODE != “END”
do
begin
if this is not comment line then
begin
search OPTAB for OPCODE
if found then
begin
if there is a symbol in OPERAND field then
begin
search SYMTAB for OPERAND
if found then
begin
store symbol value as operand address
else
begin
store 0 as operand address
set error flag (undefined symbol)
end
end (if symbol)
30
else
store 0 as operand address
assemble the object code instruction
else if
OPCODE = “BYTE” or “WORD” then
convert constant to object code
if object code doesn‟t fit into current Text record then
begin
Write text record to object code
initialize new Text record
end
add object code to Text record
end {if not comment}
write listing line
read next input line
end
write last listing line
End {Pass 2}
Here the first input line is read from the intermediate file. If the opcode is START, then
this line is directly written to the list file. A header record is written in the object
program which gives the starting address and the length of the program (which is
calculated during pass 1). Then the first text record is initialized. Comment lines are
ignored. In the instruction, for the opcode the OPTAB is searched to find the object
code. If a symbol is there in the operand field, the symbol table is searched to get the
address value for this which gets added to the object code of the opcode. If the address
not found thenzero value is stored as operands address. An error flag is set indicating it
as undefined. If symbol itself is not found then store 0 as operand address and the
object code instruction is assembled.
If the opcode is BYTE or WORD, then the constant value is converted to its equivalent
object code (for example, for character EOF, its equivalent hexadecimal value „454f46‟ is
stored). If the object code cannot fit into the current text record, a new text record is
created and the rest of the instructions object code is listed. The text records are written
31
to the object program. Once the whole program is assembled and when the END
directive is encountered, the End record is written.
Algorithm
1.Start the program
2. Initialize all the variables
3. Open a file by name
4. fp1=fopen("assmlist.dat","w");
fp2=fopen("symtab.dat","r");
fp3=fopen("intermediate.dat","r");
fp4=fopen("optab.dat","r");
5. Read the content of the file
6. If opcode is BYTE
if(strcmp(opcode,"BYTE")==0)
Then
fprintf(fp1,"%d\t%s\t%s\t%s\t",address,label,opcode,operand);
Else if opcode is WORD
7. else if(strcmp(opcode,"WORD")==0)
then
fprintf(fp1,"%d\t%s\t%s\t%s\t00000%s\n",address,label,opcode,operand,a);
8. else if((strcmp(opcode,"RESB")==0)(strcmp(opcode,"RESW")==0))
fprintf(fp1,"%d\t%s\t%s\t%s\n",address,label,opcode,operand);
else
fprintf(fp1,"%d\t%s\t%s\t%s\t%d\n",address,label,opcode,operand,code);
9.Finally terminate the of pass two of pass two assembler
32
33
34
Viva Questions
Sl. Marks
Module Max. Marks
No Obtained
1 Efficiency of Algorithm 10
2 Efficiency of program 10
3 Output 10
4 Technical Skill 10
5 Communication Skill 10
Total 50
Faculty Signature
35
Ex. No : 4
IMPLEMENTATION OF SINGLE PASS ASSEMBLER
Date :
Aim:
To write a C program to implement a One pass assembler or Single Pass
assemblers.
Theory :
Load-and-go assembler
Load-and-go assembler generates their object code in memory for immediate
execution.
No object program is written out, no loader is needed.
It is useful in a system oriented toward program development and testing such that
the efficiency of the assembly process is an important consideration
Forward Reference:
o Load-and-go assembler
Omits the operand address if the symbol has not yet been defined
Enters this undefined symbol into SYMTAB and indicates that it is
undefined
Adds the address of this operand address to a list of forward
references associated with the SYMTAB entry
Scans the reference list and inserts the address when the definition for
the symbol is encountered.
Reports the error if there are still SYMTAB entries indicated
undefined symbols at the end of the program
36
Search SYMTAB for the symbol named in the END statement and
jumps to this location to begin execution if there is no error
Example
37
Algorithm:
38
39
40
Viva Questions
Marks
Sl.No Module Max. Marks
Obtained
1 Efficiency of Algorithm 10
2 Efficiency of program 10
3 Output 10
4 Technical Skill 10
5 Communication Skill 10
Total 50
Faculty Signature
41
Ex. No : 5
IMPLEMENTATION OF TWO PASS MACRO
Date :
Aim
Theory
A macro processor enables you to define and to use macros in your assembly programs.
When you define a macro, you provide text (usually assembly code) that you want to
associate with a macro name. Then, when you want to include the macro text in your
assembly program, you provide the name of the macro. The assembler replaces the
macro name with the text specified in the macro definition.
Advantages :
Algorithm
42
a. Enter the macro name present in the operand field into the array named
‘m’.
b. Write the line to the expanded output file.
c. Enter lines in the body of each macro nto the corresponding files already
opened in step4.
d. Write the body of each macro to the expanded output file also, until a
“mend” is reached.
7. Otherwise if the opcode is call the line must be a macro invocation statement so,
the macro body is retrieved from the corresponding file and written to the
expanded output file.
8. Write all the remaining lines directly to the expanded file.
43
Program and Rough Work
44
45
46
Viva Questions
Max. Marks
Sl.No Module
Marks Obtained
1 Efficiency of Algorithm 10
2 Efficiency of program 10
3 Output 10
4 Technical Skill 10
5 Communication Skill 10
Total 50
Faculty Signature
47
Ex. No : 6
IMPLEMENTATION OF SINGLE PASS MACRO
Date :
Aim
To implement a C program for Single Pass Macro.
Theory :
A macro may be thought of as a subroutine call with the exception that the code that
would be contained in the subroutine is included in–line at the point of the macro call.
Macros should not be used to replace subroutines. Each invocation of a subroutine
requires only the code necessary to call the subroutine. Each invocation of a macro
includes the assembly code associated with the macro in–line in the assembly program.
This can cause a program's size to grow rapidly if a large macro is used frequently.
A macro processor enables you to define and to use macros in your assembly programs.
When you define a macro, you provide text (usually assembly code) that you want to
associate with a macro name. Then, when you want to include the macro text in your
assembly program, you provide the name of the macro. The assembler replaces the
macro name with the text specified in the macro definition.
Macros provide several advantages when writing assembly programs.
• The frequent use of macros can reduce programmer-induced errors. A macro
allows you to define instruction sequences that are used repetitively throughout your
program. Subsequent use of the macro faithfully provides the same results each time. A
macro reduces the likelihood of errors introduced in repetitive programming sequences.
Of course, introduction of an error into a macro definition causes that error to
propagate through the program wherever the macro is used.
• The scope of symbols used in a macro is limited to that macro. You need not be
concerned about using a previously used symbol name.
48
• Macros are well-suited for creating simple code tables. Producing tables by hand
is both tedious and error-prone.
Algorithm
49
INPUT FILE: MACIN.DAT
CALC START 1000
SUM MACRO **
** LDA #5
** ADD #10
** STA 2000
** MEND **
** LDA LENGTH
** COMP ZERO
** JEQ LOOP
** SUM **
LENGTH WORD 5
ZERO WORD 0
LOOP SUM **
** END **
DEFTAB.DAT
** LDA #5
** ADD #10
** STA 2000
50
Program and Rough Work
51
52
53
Viva Questions
Max. Marks
Sl.No Module
Marks Obtained
1 Efficiency of Algorithm 10
2 Efficiency of program 10
3 Output 10
4 Technical Skill 10
5 Communication Skill 10
Total 50
Faculty Signature
54
Ex. No : 7
IMPLEMENTATION OF ABSOLUTE LOADER
Date :
Aim:
To write a C program to implement a absolute loader.
Theory :
An absolute loader is the simplest type of loader scheme that fits the general
model of loaders. The assembler produces the output in the same way as in the
"complier and go loader”. The assembler outputs the machine language translation of
the source program.
The assembler generates the object code equivalent of the source program but
the output is punched on to the cads forming the object decks instead of loading in
memory. The function of the loader is to read these cads and load them into memory
specified by the assembler. The four functions as performed in and absolute loader are :
1.Allocation
2.Linking
3.Relocation
4.Loading
Advantages of Absolute Loader:
Simple, easy to design and implement.
Since more core memory is available to the user there is no memory limit.
Disadvantages of Absolute Loader:.
When subroutines are referenced, the programmer must specify their
address whenever they are called.
The programmer must specifically tell the assembler the address where
the program is to be loaded
55
Algorithm:
INPUT FILE
INPUT.DAT
H 1000 232
T 1000 142033 483039 102036
T 2000 298300 230000 282030 302015
56
E
OUTPUT FILE
OUTPUT.DAT
1000 14
1001 20
1002 33
1003 48
1004 30
1005 39
1006 10
1007 20
1008 36
2000 29
2001 83
2002 00
2003 23
2004 00
2005 00
2006 28
2007 20
2008 30
2009 30
2010 20
2011 15
57
58
59
60
Viva Questions
Max. Marks
Sl.No Module
Marks Obtained
1 Efficiency of Algorithm 10
2 Efficiency of program 10
3 Output 10
4 Technical Skill 10
5 Communication Skill 10
Total 50
Faculty Signature
61
Ex. No : 8
IMPLEMENTATION OF RELOCATION LOADER
Date :
Aim:
To write a C program to implement a relocation loader.
Theory :
Loaders that allow for program relocation are called relocating loaders/relative loaders.
There are two methods for this purpose.
1. In the first method, a modification record is used to describe each part of the object
code that must be changed when the program is relocated. There is one modification
record for each value that must be changed during relocation. Each modification record
specifies the starting address and length of the field whose value is to be altered. It then
describes the modification to be performed. This method is not well suited for all
machine architectures.
2. On a machine that primarily uses direct addressing and has a fixed instruction
format, different techniques is used. The text records are same as before except that
there is a relocation bit with each word of object code. These relocation bits are gathered
together into a bit mask following a length indicator in each text record. If the bit is set
to 1, the program’s starting address must be added to the word when program is
relocated. If bit is 0, then no modification is necessary. The bits for unused words are
also set to 0.
Algorithm
Step 1: Start the program
Step 2: Include the necessary header file and variable
Step 3: Open the two file for
Step 4: fp1= relinput.dat and give read
Step 5: fp2= reloutput.dat and give write
Step 6: Read the content
Step 7: Using while loop perform the loop until character is not equal to E
Step 8: while(strcmp(input,"E")!=0)
Step 9: If the character is H
62
Step 10: Get the variable add, length, and input
Step 11: Else if the character is T
Step 12: Get the variable address and bitmask
Step 13: And perform the for loop for starting zero to up to len
Step 14: Get the opcode ,addr and assign relocbit to bitmask
Step 15: If relocabit is zero Then
Step 16: actualadd=addr;
Step 17 :else Add the addr and star value
Step 18: Finally terminate the program
Sample Input & Output:
INPUT: RELINPUT.DAT
H 1000 200
T 1000 11001 14 1033 48 1039 90 1776 92 1765 57 1765
T 2011 11110 23 1838 43 1979 89 1060 66 1849 99 1477
E 1000
OUTPUT:
Enter the actual starting address :4000
RELOUTPUT.DAT
4000 144033
4003 484039
4006 901776
4009 921765
4012 574765
5011 234838
5014 434979
5017 894060
5020 664849
5023 991477
63
64
65
66
Viva Question
1. Compare relocatable with absolute loader.
2. What are the records used for indicating relocating addresses?
3. Write the structure of modification record.
4. What is control section linking?
5. Compare dynamic linking with dynamic loading.
6. List the advantages of relocatable loader.
Max. Marks
Sl.No Module
Marks Obtained
1 Efficiency of Algorithm 10
2 Efficiency of program 10
3 Output 10
4 Technical Skill 10
5 Communication Skill 10
Total 50
Faculty Signature
67
Ex. No : 9
IMPLEMENTATION OF PASS ONE OF LINKING LOADER
Date :
Aim
Theory
A program unit interacts with another by using the addresses latter's instructions and
data in its own instructions. To enable this, the program units must contain public
definitions and external references. A public definition in a program unit may be
reference in others. An external reference is a reference to symbol, which is not defined
in the program unit containing the reference.
EXTRN and ENTRY statements are used to deal with the above cases. ENTRY
statement lists the public definitions of program unit; which may be referenced in other
program units. EXTRN statement lists the symbols to which the external references are
made in the program units.
Before executing the program A, for each of its program units, every external reference
should bound to the correct link time address. This is called "LINKING”. Once it is
linked, it is said to be resolved.
Algorithm
68
Step 1: Start the program
Step 2: Include the necessary variables
Step 3: get PROGADDR from operating system
Step 4: set CSADDR to PROGADDR {for first control section}
Step5: Open the two file for
Step6: fp1= linkin.dat and give read
Step7: fp2= linkout .dat and give write
Step 8: Input the location where the program has to be loaded
Step 9: while not end of input do
begin
read next input record {Header record for control section}
set CSLTH to control section length
search ESTAB for control section name
if found then
set error flag {duplicate external symbol}
else
enter control section name into ESTAB with value CSADDR
Step 10: while record type ≠ 'E' do
begin
read next input record
if record type = 'D' then
for each symbol in the record do
begin
search ESTAB for symbol name
if found then
set error flag (duplicate external symbol)
else
enter symbol into ESTAB with value
(CSADDR + indicated address)
69
end {for}
end {while ≠ 'E'}
Step 11: add CSLTH to CSADDR {starting address for next control section
Step 12: end {while not EOF}
Step 13: Halt the program
70
71
Viva Questions
Max. Marks
Sl.No Module
Marks Obtained
1 Efficiency of Algorithm 10
2 Efficiency of program 10
3 Output 10
4 Technical Skill 10
5 Communication Skill 10
Total 50
Faculty Signature
72
Ex. No : 10
IMPLEMENTATION OF PASS TWO OF LINKING LOADER
Date :
Aim:
To write a C program to generate a pass two of direct linking loader.
Theory :
• Modification record:
– Make the linking and relocation to be processed similarly.
• Two passes:
– Assign addresses to all external symbols
– Perform actual loading, relocation, and linking.
• Data structures used by linking loaders
– External symbol tab: ESTAB
• Name, address, and control session belonging to
• Also control sessions (name, address, length)
• Hash table
• ESTAB with control sessions and external symbols
– Program load address : PROGADDR
• The beginning address in memory where the
linked program is to be loaded.
• Supplied to loader by OS
– Control session address: CSADDR
• The starting address of the current control session.
• Added to all relative addresses in the control
session to get actual addresses.
– Execution starting address: EXECADDR.
Algorithm:
73
5: If the record type is’T’, place the object code in location which is sum of CSADDR
and specified address
6: If the record type is M, search the ESTAB for symbol name.
(1) If found add or subtract symbol value at location CSADDR+ specified
address
74
Max. Marks
Sl.No Module
Marks Obtained
1 Efficiency of Algorithm 10
2 Efficiency of program 10
3 Output 10
4 Technical Skill 10
5 Communication Skill 10
Total 50
75
Faculty Signature
76
Ex. No : 11
IMPLEMENTATION OF TEXT EDITOR
Date :
Aim
Theory :
A text editor is a type of program used for editing plain text files. Text editors are
often provided with operating systems or software development packages, and can be
used to change configuration files and programming language source code.
77
Text editors geared for professional computer users place no limit on the size of the file
being opened. In particular, they start quickly even when editing large files, and are
capable of editing files that are too large to fit the computer's main memory. Simpler
text editors often just read files into an array in RAM. On larger files this is a slow
process, and very large files often do not fit.
The ability to read and write very large files is needed by many professional computer
users. For example, system administrators may need to read long log files.
Programmers may need to change large source code files, or examine unusually large
texts, such as an entire dictionary placed in a single file.
Some text editors include specialized computer languages to customize the editor
(programmable editors). For example, Emacs can be customized by programming in
Lisp. These usually permit the editor to simulate the keystroke combinations and
features of other editors, so that users do not have to learn the native command
combinations.
Many text editors for software developers include source code syntax
highlighting and automatic completion to make programs easier to read and write.
Programming editors often permit one to select the name of a subprogram or variable,
and then jump to its definition and back. Often an auxiliary utility like ctags is used to
locate the definitions.
Operations on Text Editor
• Cut, copy, and paste
Most text editors provide methods to duplicate and move text within the file, or
between files.
• Text formatting
Text editors often provide basic formatting features like line wrap, auto-indentation,
bullet list formatting, comment formatting, and so on.
• Undo and redo
78
As with word processors, text editors will provide a way to undo and redo the last edit.
Often—especially with older text editors—there is only one level of edit history
remembered and successively issuing the undo command will only "toggle" the last
change. Modern or more complex editors usually provide a multiple level history such
that issuing the undo command repeatedly will revert the document to successively
older edits. A separate redo command will cycle the edits "forward" toward the most
recent changes. The number of changes remembered depends upon the editor and is
often configurable by the user.
• Importing
Reading or merging the contents of another text file into the file currently being
edited. Some text editors provide a way to insert the output of a command issued to the
operating system's shell.
• Filtering
Some advanced text editors allow you to send all or sections of the file being
edited to another utility and read the result back into the file in place of the lines being
"filtered". This, for example, is useful for sorting a series of lines alphabetically or
numerically, doing mathematical computations, and so on.
• Syntax Highlighting
Another useful feature of many text editors is syntax highlighting, where the
editor can recognize or be instructed that you are writing in a particular language, such
as HTML or C++, and can color code your code for you, to break up text and easily
identify tags, etc.
79
Program and Rough Work
80
81
Viva Questions
82
1. Mention the features of word processors.
2. List all the components of editor structure.
3. What are the basic types of computing environment used in editor function?
4. Define travelling phase.
5. List the various types of text editors available
Max. Marks
Sl.No Module
Marks Obtained
1 Efficiency of Algorithm 10
2 Efficiency of program 10
3 Output 10
4 Technical Skill 10
5 Communication Skill 10
Total 50
Faculty Signature
83