Вы находитесь на странице: 1из 14

www.Vidyarthiplus.

com

SUDHARSAN ENGINEERING COLLEGE


SATHIYAMANGALAM-622 501

DEPARTMENT OF
COMPUTER SCIENCE AND ENGINEERING

SYSTEM SOFTWARE LAB MANUAL

III YEAR 5th SEMESTER

HANDLED BY

P. SUJATHA
Assoc. Prof. / CSE

2014-15 / SEC /III Yr / CSE / CS2308 – SS Lab /P.Sujatha Page 1

www.Vidyarthiplus.com
www.Vidyarthiplus.com

Ex. No. 1 IMPLEMENTATION OF SYMBOL TABLE


DATE:

Aim:

To implement a symbol table with functions to create, insert, modify, search,


and display, using C language.

Algorithm:

Step 1: Design a menu through which we can create a symbol table and perform
operations as insert, modify, search and display.

Step 2: Create a Symbol table with fields as ‘variable’ and ‘value’ using create()
option.

Step 3: Entries may be added to the table while it’s created itself.

Step 4: Append new contents to the symbol table with the constraints that
there is no duplication of entries, using insert () option.

Step 5: Modify existing content of the table using modify () option.

Step 6: Use display () option to display the contents of the table.

Result:
Thus the program to implement a symbol table with functions to create, insert,
modify, search, and display, using C language was executed successfully.

2014-15 / SEC /III Yr / CSE / CS2308 – SS Lab /P.Sujatha Page 2

www.Vidyarthiplus.com
www.Vidyarthiplus.com

Ex. No. 2 IMPLEMENTATION OF PASS 1 OF A TWO PASS


DATE: ASSEMBLER
Aim:

To implement a PASS 1 of a two pass assembler, using C language.


Algorithm:

Step 1: Read the input line.

Step 2: Check to see if the opcode field in the input line is “START”.

(i). Find if there is any operand field after START; initialize the LOCCTR to the
operand value.
(ii). Other wise if there is no value in the operand field the LOCCTR is set to zero.

Step 3: Write the line to the intermediate file.

Step 4: Repeat the following for the other lines in the program until the opcode field
contains END directive.
1. If there is a symbol in the label field.
i. Check the symbol table to see if has already been stored
over there. If so then it is a duplicate symbol, the error message should be
displayed.
ii. Other wise the symbol is entered into the SYMTAB, along
with the memory address in which it is stored.
2. If there is an opcode in the opcode field
i. Search the OPTAB to see if the opcode is present, if so
increment the location counter (LOCCTR) by three.
ii. a) If the opcode is WORD, increment the LOCCTR by three.
b) If the opcode is BYTE, increment the LOCTR by one.
c) If the opcode is RESW, increment the LOCCTR by
integer equivalent of the operand value *3.
d) If the opcode is RESB, increment the LOCCTR by the
integer equivalent of the operand value.
3 Write each and every line processed to the intermediate file along with their
location counters.

Step 5: Calculate the length of the program by subtracting the starting


address of the program from the final value of the LOCCTR

Step 6: Close all the opened files and exit.

Result:

2014-15 / SEC /III Yr / CSE / CS2308 – SS Lab /P.Sujatha Page 3

www.Vidyarthiplus.com
www.Vidyarthiplus.com

Thus the program to implement a PASS 1 of a two pass assembler, using C


language was executed successfully

Ex. No. 3 IMPLEMENTATION OF PASS 2 OF A TWO PASS


DATE: ASSEMBLER

Aim:

To implement a PASS 2 of a two pass assembler, using C language.

Algorithm:

Step 1: Read the first line from the intermediate file.

Step 2: Check to see if the opcode field in the input line is “START”, if so then
write the line onto the final output file.

Step 3: Repeat the following for the other lines in the intermediate file until the
opcode field contains END directive.

1. If there is a symbol in the operand field, then the object code is assembled by
combining the machine code equivalent of the instruction with the symbol address.

2. If there is no symbol in the operand field, then the operand address is


assigned as zero and it is assembled with the machine code equivalent of the
instruction.

3. If the opcode field is BYTE or WORD or RESB, then convert the constants in
the operand filed to the object code.

4. Write the input line along with the object code onto the final output file.

Step 4: Close all the opened files and exit.

Result:
Thus the program to implement a PASS 2 of a two pass assembler, using C
language was executed successfully.

2014-15 / SEC /III Yr / CSE / CS2308 – SS Lab /P.Sujatha Page 4

www.Vidyarthiplus.com
www.Vidyarthiplus.com

2014-15 / SEC /III Yr / CSE / CS2308 – SS Lab /P.Sujatha Page 5

www.Vidyarthiplus.com
www.Vidyarthiplus.com

Ex. No. 4
IMPLEMENTATION OF A SINGLE PASS ASSEMBLER
DATE:

Aim:
To implement a single pass (Load and Go) assembler, using C language.

Algorithm:

Step 1: Read the input line.

Step 2: Check to see if the opcode field in the input line is “START”.
1. Find if there is any operand field after START; initialize the
LOCCTR to the operand value.
2. Otherwise if there is no value in the operand field the LOCCTR
is set to zero.

Step 3: Write the line onto the output file.

Step 4: Repeat the following for the other lines in the input file until the opcode field
contains END directive.
1. If there is a symbol in the label field.
i. Check the symbol table to see if has already been stored and if it is
marked as undefined entry. If so then update the symbol table with the proper
address and mark it as defined entry.
ii. Otherwise the symbol is entered into the symbol table along with
the memory address in which it is stored.
2. If there is an opcode in the opcode field
i. Search the OPTAB to see if the opcode is present, if so increment
the location counter (LOCCTR) by three.
ii. a) If the opcode is WORD, increment the LOCCTR by three and
convert the constants in the operand field to the object code.
b) If the opcode is BYTE, increment the LOCTR by one and
convert the constants in the operand field to the object code.
c) If the opcode is RESW, increment the LOCCTR by Integer
equivalent of the operand value *3 and convert the constants in the operand field to
the object code.
d) If the opcode is RESB, increment the LOCCTR by the integer
Equivalent of the operand value and convert the constants in the operand field to
the object code.

3. If there is a symbol in the operand field.


i. Check the symbol table to see if has already been stored. If
so, then assemble the object code by combining the machine code equivalent of the
instruction with the symbol address.

2014-15 / SEC /III Yr / CSE / CS2308 – SS Lab /P.Sujatha Page 6

www.Vidyarthiplus.com
www.Vidyarthiplus.com

ii. Otherwise the symbol is entered into the symbol table and it
is marked as undefined entry.

4. If there is no symbol in the operand field, then operand address is assigned as


zero, and it is assembled with the machine code equivalent of the instruction.

5. Write the input line along with the object code onto output file.

Step 5: Close all the opened files and exit.

Result:
Thus the program to implement a single pass (Load and Go) assembler,
using C language was executed successfully.

2014-15 / SEC /III Yr / CSE / CS2308 – SS Lab /P.Sujatha Page 7

www.Vidyarthiplus.com
www.Vidyarthiplus.com

Ex. No. 5
IMPLEMENTATION OF AN ABSOLUTE LOADER
DATE:

Aim:

To implement an absolute loader, using C language.

Algorithm:

Step 1: Read the Header record.

Step 2: Verify the Program name, length and starting address.

Step 3: Read first Text record.

Step 4: Repeat the following process until an end record is encountered


1. Set LOC to starting address of the text record
2. If object code is in character form, then convert into internal
hexadecimal representation.
3. Moves object code to the specified location (LOC) in memory.
4. Increment LOC by three.
5. Read next record from the input file.

Step 5: Jump to address specified in End record.

Step 6: Close all the opened files and exit.

RESULT
Thus the program to implement an absolute loader, using C language
was executed successfully.

2014-15 / SEC /III Yr / CSE / CS2308 – SS Lab /P.Sujatha Page 8

www.Vidyarthiplus.com
www.Vidyarthiplus.com

Ex. No. 6 IMPLEMENTATION OF PASS 1 OF A DIRECT LINKING


DATE: LOADER

AIM:

To implement a pass 1 of a direct linking loader by using C program.

ALGORITHM:

1. Enter the location where the program has to be loaded.


2. Assign the address got from the user as the first control section address.
3. Read the header record of the control section
(i)From the details of the header read store the control section length in a variable
(ii)Enter the control section name with its address into the external symbol table.
4. For each symbol in the subsequent ‘D’ records the symbol must be entered into the
symbol table along with its address, added along with the corresponding control
section address until an end record is reached.
5. Assign the starting address of next control section as the address of the current
control section plus the length of the control section
6. Repeat the process from step 3 to step 5 until there are no more input.

RESULT:
Thus the pass 1 of a direct linking loader were successfully
implemented

2014-15 / SEC /III Yr / CSE / CS2308 – SS Lab /P.Sujatha Page 9

www.Vidyarthiplus.com
www.Vidyarthiplus.com

Ex. No. 7
IMPLEMENTATION OF A RELOCATING LOADER
DATE:

AIM:

To implement a C program for relocation loader.

ALGORITHM:

1. Enter the new starting location to which the object code has to be relocated.
2. Read the content of the input file as strings one at a time in an arrry ”input”.
3. Transfer the string read in array “input” into another array “output”, until “T” is
encountered.
4. Move the consecutive next three strings into array “output”.
5. Convert the current string read which is the relocation bit associated with each text
record to binary form.
6. Make the necessary changes in the corresponding words of object code by adding
the new starting address with the address part of the object code for which the
corresponding relocation bit to set, and store the updated object code into the array
“output”.
7. Move the object code for which the corresponding relocation bit is not set directly to
the array “output” from the array “input” without any change.
8. Repeat step 2 to 8 until an end record is encountered.
9. If object code is in character form convert form it to internal hexadecimal
representation.
10. Move object codes to specified locations in memory.
11. Write the starting location counter value of a block of object code, and the
corresponding internal hexadecimal representations to the output file.

RESULT:
Thus the relocation loader were implemented and executed
successfully

2014-15 / SEC /III Yr / CSE / CS2308 – SS Lab /P.Sujatha Page 10

www.Vidyarthiplus.com
www.Vidyarthiplus.com

Ex. No. 8 IMPLEMENTATION OF PASS 2 OF A DIRECT LINKING


DATE: LOADER

AIM:
To implement a pass2 of a direct linking loader using C.

ALGORITHM:

1. Assign the control section address in a variable, CSADR.


2. Read the header record.
(i)From the information available in the header record, store the control section
length in a variable.

3. Do the following process until an ‘end’ record is reached.

(i)If the subsequent records read is a text record ‘T’, and if the object code is in
character form convert it into machine representation ,and move the object code
from the record to the memory location control sections address plus the specified
address in the text record.
(ii)If the subsequent records read is modification record ‘M’ then search for the
modifying symbol name in the external symbol table created by pass1 if it is found
then add, or subtract the corresponding symbol address found with the value
starting at the location

4. Add the control section length to the current control sections address to find
the address of the next control section, and repeat the entire process until
there are no more input.

Result:
Thus the program to implement a pass2 of a direct linking loader using
C was executed successfully.

2014-15 / SEC /III Yr / CSE / CS2308 – SS Lab /P.Sujatha Page 11

www.Vidyarthiplus.com
www.Vidyarthiplus.com

Ex. No. 9 IMPLEMENTATION OF A SINGLE PASS


Date: MACRO PROCESSOR

Aim:

To implement a single pass macro processor, using C language.

Algorithm:

Step 1: Get the line from the input file.

Step 2: Repeat the following until the opcode field contains END directive.

1. Check if the opcode field contains MACRO directive. If so,


i. Enter the macro name into the NAMTAB.
ii. Read the next line.
iii. Repeat the following until the opcode field contains MEND directive.
a. Enter the line into DEFTAB.
b. Read the next line.
iv. Mark the pointers in the NAMTAB to the beginning and end of the macro
definition in DEFTAB.

2. Check if the opcode field contains Macro Name. If so,


i. Read the corresponding macro definition from the DEFTAB.
ii. Write the macro definition onto the expanded source file.

3. Otherwise, write the line onto the expanded source file.

Step 3: Close all the opened files and exit.

Result:
Thus the program to implement a single pass macro processor was
executed Successfully.

2014-15 / SEC /III Yr / CSE / CS2308 – SS Lab /P.Sujatha Page 12

www.Vidyarthiplus.com
www.Vidyarthiplus.com

Ex. No. 10 IMPLEMENTATION OF A TWO PASS MACRO


Date: PROCESSOR

Aim:

To implement a two pass macro processor, using C language.


Algorithm:

Step 1: Get the line from the input file.


Step 2: Repeat the following until the opcode field contains END directive.

1. Check if the opcode field contains MACRO directive. If so,


i. Enter the macro name into the NAMTAB.
ii. Read the next line.
iii. Repeat the following until the opcode field contains MEND directive.
a. Enter the line into DEFTAB.
b. Read the next line.
iv. Mark the pointers in the NAMTAB to the beginning and end of the macro
definition in DEFTAB.

2. Check if the opcode field contains Macro Name. If so,


i. Read the corresponding macro definition from the DEFTAB.
ii. Write the macro definition onto the expanded source file.

3. Otherwise, write the line onto the expanded source file.

Step 3: Close all the opened files and exit.

Result:
Thus the program to implement two pass macro processor was executed
successfully.

2014-15 / SEC /III Yr / CSE / CS2308 – SS Lab /P.Sujatha Page 13

www.Vidyarthiplus.com
www.Vidyarthiplus.com

Ex.no.11
IMPLEMENTATION OF A SIMPLE TEXT EDITOR
Date:

Aim:
To write a c program to implement a simple text editor with features like
insertion/deletion of a character, word, and sentence.

Algorithm:
Step 1: Start

Step 2: Design a text editor menu which contains the options like INSERT,
SEARCH and DISPLAY.

Step 3: If the option selected is INSERT, then


1. Provide a blank screen for the user to type the text
2. Type the required statement.

Else if the option is SEARCH


1. Search the typed text
2. If the text is found, return the corresponding text
Then type the required text.
3. Else print string not found.

Step 4: Using the DISPLAY() function, display the text.

Step 5: Stop the execution.

Result:
Thus, the c program to implement a simple text editor with features like
insertion/deletion of a character, word, and sentence was implemented successfully.

2014-15 / SEC /III Yr / CSE / CS2308 – SS Lab /P.Sujatha Page 14

www.Vidyarthiplus.com

Вам также может понравиться