:01
IMPLEMENTATION OF SYMBOL TABLE
Aim:
To write a c program to implement a symbol table with function to create,
insert, modify, search, display and exit.
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.
Entries may be added to the table while it is created itself.
Step 3: Append new contents to the symbol table with the constraint that there is
no
duplication of entries, using “insert” option.
Step 4: Modify existing content of the table using modify option.
Step 5: Use display option to display the contents of the table.
EX. NO.:02
Aim:
To write a c program to implement pass one of the two pass assembler by
creating symbol table and intermediate file.
Algorithm:
Step 1: Read the input line.
Step 2: Check to see if the opcode in the input line is “START”.
a. Find if there is any operand field after START, if so that indicates the
location from which the program has to be loaded in the memory, so
initialize the LOCCTR to the operand value.
b. Other wise if there is no value in the operand field the LOCCTR is set
to zero and the program starts loading from the starting address zero.
Step 5: Subtract the starting address of the program from the final value of the
LOCCTR, to calculate the length of the program.
Step 6: Close all the operand files and exit.
EX. NO.: 03
Algorithm:
Step 1: Read the first line from the intermediate file.
Step 2: Check to see if the opcode from the first line read is “START”.
a. If so then write the label, opcode and operand field values of the
corresponding statement directly to the final output file.
Step 3: Start the following processing, for the other lines in the intermediate file
if it is not a comment line until an “END” statement is reached.
a. Start writing the location counter, opcode and operand fields of the
corresponding statement to the output file, along with the object code.
The object code is found by assembling each statement opcodes
machine equivalent with the label address.
b. If there is no symbol/label in the operand field, then the operand
address is assigned as zero, and it is assembled with the object code of
the instruction.
c. If the opcode is BYTE, WORD, RESB etc. convert the constants to the
object code.
EX. NO.: 04
EX. NO.: 05
IMPLEMENTAION OF A SINGLE PASS MACRO PROCESSOR
Aim:
To write a c program to implement a macro processor.
Algorithm:
Step 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.
Step 8: Write all the remaining lines directly to the expanded lines.
EX. NO. 6
IMPLEMENTATION OF AN ABSOLUTE LOADER
Aim:
To write a c program to implement an absolute loader.
Algorithm:
Step 1: Read header record and filter the starting location and other details.
Step 2: Read first text record
Step 3: Do the following processing until an end record is reached.
a. If object code is in character form convert it to internal hexadecimal
representation.
b. Move object codes to specified locations in memory.
c. Write the starting location counter value of a block of object code and
corresponding internal hexadecimal representation to the output file.
d. Read next text record from the input file.
EX. NO. 07
Aim:
To write a c program to implement a relocation loader.
Algorithm:
Step 1: Enter the new starting location to which the object code has to be
relocated.
Step 2: Read the content of the input file as strings one at a time in array “input”.
Step 3: Transfer the string read in array “input” into another array “output” until
‘T’ is
encountered.
Step 4: Move the consecutive next three strings into array “output”.
Step 5: Convert the current string read which is relocation bit associated with
each text
record to binary form.
Step 6: Make the necessary changes in the corresponding words of object code
by
adding the new starting address with address part of the object code which
the
corresponding relocation bit is set, and store the updated object code into
the
array “output”.
Step 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.
Step 8: Repeat step 2 to 8 until an end record is encountered.
Step 9: If object code is in character form converts it to internal hexadecimal
representation.
Step 10: Move object codes to specified locations in memory.
Step 11: Write the starting location counter value of a block of object code, and
corresponding internal hexadecimal representations to the output file.
EX. NO.: 08
Aim:
To write a c program to implement pass one of direct linking loader.
Algorithm:
Step 1: Enter the location where the program has to be loaded.
Step 2: Assign the address got from the user as the first control section address.
Step 3: Read the header record of the control section
a. From the details of the header read store the control section length in a
variable.
b. Enter the control section name with its address into the external
symbol table.
Step 4: For each symbol in the subsequence ‘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.
Step 5: Assign the starting address of next control section as the address of the
current
control section plus the length of the control section.
Step 6: Repeat the process from step 3 to 5 until there are no more inputs.
EX. NO. 09
Aim:
To write a c program to implement pass two of direct linking loader.
Algorithm:
Step 1: Assign the control section address in a variable, CSADR.
Step 2: Read the header record
a. From the information available in the header record read, store the
control section length in a variable.
Step 4: Add the control section length to the control sections address to find the
address of the next control section, and repeat the entire process until there is no
more input.
EX. NO.: 10
IMPLEMENTAION OF A SIMPLE TEXT EDITOR
Aim:
To write a c program to implement a simple text editor.
Algorithm:
Step 1: Provide a blank screen for the user to type the document.
Step 2: Instruct the user to enter the text using the editor.
Step 3: Display the entered character on the screen.
Step 4: Characters displayed on the screen are stored in a character array.
Step 5: Specify if the content has to be saved or not.
Step 6: If SAVE option is selected.
a. Get the data file name from the user.
b. Open the file in write mode.
c. Move the content of the character array to the file and close the file.