Welcome to Scribd, the world's digital library. Read, publish, and share books and documents. See more
Download
Standard view
Full view
of .
Look up keyword or section
Like this
64Activity
P. 1
System Software Lab

System Software Lab

Ratings:

5.0

(1)
|Views: 3,785 |Likes:
Published by rajesh1158
System software lab - IT & CSE
System software lab - IT & CSE

More info:

Published by: rajesh1158 on Aug 16, 2010
Copyright:Attribution Non-commercial

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as DOC, PDF, TXT or read online from Scribd
See more
See less

11/06/2012

pdf

text

original

 
1.
IMPLENTATION OF A SYMBOL
 
TABLE
Aim:
 To write a C program to implement Symbol Table
Algorithm:
 Start the program for performing insert, display, delete, search and modify option insymbol tableDefine the structure of the Symbol TableEnter the choice for performing the operations in the symbol TableIf the entered choice is 1, search the symbol table for the symbol to be inserted. If thesymbol is already present, it displays "Duplicate Symbol". Else, insert the symbol and thecorresponding address in the symbol table.If the entered choice is 2, the symbols present in the symbol table are displayed.If the entered choice is 3, the symbol to be deleted is searched in the symbol table. If it isnot found in the symbol table it displays "Label Not found". Else, the symbol is deleted.If the entered choice is 5, the symbol to be modified is searched in the symbol table. Thelabel or address or both can be modified.
Source Program:
#include<stdio.h>#include<conio.h>#include<string.h>int line_no,j=0;void create();void insert();void modify();void search();void display();void input();struct al{char label[10];char opcode[10];char operand[10];}a[20];struct sym{char symb[10];int addr;}s[20];void main(){int op;
 
char ch[5];clrscr();input();display();do{ printf("1.Create\n2.Modify\n3.Insert\n4.Search\n5.Exit\n"); printf("Enter Your Choice");scanf("%d",&op);switch(op){case 1:create(); break;case 2:modify(); printf("Symbol table Modified.."); break;case 3:insert(); printf("Insertion operation Performed.."); break;case 4:search(); break;case 5:exit(0);} printf("\n Do you want to continue(Y orN):");scanf("%s",ch);}while(strcmp(ch,"Y")==0);getch();}void input(){int i=0; printf("Enter the program:\n\n"); printf("LABEL\tOPCODE\tOPERAND\n");do{scanf("%s\t%s\t%s",a[i].label,a[i].opcode,a[i].operand);i++;}while(strcmp(a[i-1].opcode,"END"));line_no =i;
 
}void display(){int i; printf("The assembly Language program is \n");for(i=0;i<line_no;i++){ printf("\n%d\t%s\t%s\t%s\n",i,a[i].label,a[i].opcode,a[i].operand);}}void create(){int locctr,i;for(i=0;i<line_no;i++){if(strcmp(a[i].opcode,"START")==0)locctr=atoi(a[i].operand);else if(strcmp(a[i-1].opcode,"START")==0);else{if(strcmp(a[i-1].opcode,"WORD")==0)locctr=locctr+3;else if(strcmp(a[i-1].opcode,"RESW")==0)locctr = locctr+3*atoi(a[i-1].operand);else if(strcmp(a[i-1].opcode,"BYTE")==0)locctr = locctr+strlen(a[i-1].operand);elselocctr = locctr+3;}if(strcmp(a[i].label,"$")!=0){strcpy(s[j].symb,a[i].label);s[j].addr = locctr; printf("\n%s\t%d\n",s[j].symb,s[j].addr);} j++;}}void modify(){int ln; printf("Enter the line number to be modified:");scanf("%d",&ln);scanf("%s\t%s\t%s",a[ln].label,a[ln].opcode,a[ln].operand);display();create();}

Activity (64)

You've already reviewed this. Edit your review.
1 hundred reads
1 thousand reads
Woz Niak liked this
Divya Unique liked this
Premma Kutty S liked this
sudhasengan liked this
Gopinaath Mano liked this
Jeevaraj Jeeva liked this
PRINCESS_11 liked this
Ali Nawaz Ahmed liked this

You're Reading a Free Preview

Download
scribd
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->