Members BookmarksPolls Fresher Jobs Funny Pictures MCA Projects New Member FAQ  



My Profile
Active Members
TodayLast 7 Days more...



Awards & Gifts
Online Exams

Fresher Jobs


Our fresher job section is exclusively for fresh graduates! Find jobs for freshers in major Indian cities including Bangalore, Chennai, Hyderabad, Pune or Kochi

Resources


Find educational articles, blogs, discussion threads and other resources.

Colleges


Find details about any college in India or search for courses.

Advertisements


website counter



To create a Symbol Table


Posted Date: 21 Jul 2008    Resource Type: Articles/Knowledge Sharing    Category: Computer & Technology

Posted By: Nithya Krishna       Member Level: Gold
Rating:     Points: 2





#include
#include
#include
#include
#include
struct list
{
char la[50];
char mne[50];
char op[50];
}a[50];
struct symtab
{
char nam[50];
int add;
}s[50];
struct optab
{
char opc[50];
char value[50];
}o[50];
void main()
{
int i,j,t;
long int lc;
clrscr();
printf("INPUT PROGRAM\n");
printf("***** *******\n");
strcpy(a[0].la," ");
strcpy(a[0].mne,"START");
strcpy(a[0].op,"1000");
strcpy(a[1].la," ");
strcpy(a[1].mne,"LDA");
strcpy(a[1].op,"#2");
strcpy(a[2].la," ");
strcpy(a[2].mne,"ADD");
strcpy(a[2].op,"#3");
strcpy(a[3].la," ");
strcpy(a[3].mne,"STA");
strcpy(a[3].op,"VAR1");
strcpy(a[4].la,"VAR1 ");
strcpy(a[4].mne,"RESW");
strcpy(a[4].op,"1");
strcpy(a[5].la," ");
strcpy(a[5].mne,"END");
strcpy(a[5].op," ");
for(i=0;i<10;i++)
printf("%s\t%s\t%s\t\n",a[i].la,a[i].mne,a[i].op);
strcpy(o[0].opc,"LDA");
strcpy(o[0].value,"00");
strcpy(o[1].opc,"ADD");
strcpy(o[1].value,"18");
strcpy(o[2].opc,"STA");
strcpy(o[2].value,"0c");
strcpy(o[3].opc,"SUB");
strcpy(o[3].value,"16");
i=0;
j=0;
if(strcmp(a[i].mne,"START")==0)
{
lc=atoi(a[i].op);
}
else
lc=0;
while(strncmp(a[i].mne,"END",5)!=0)
{
if(strcmp(a[i].la," ")!=0)
{
for(t=0;t<=j;t++)
{
if(strcmp(s[t].nam,a[i].la)==0)
{
printf("Duplicate Declaration");
printf("%s",a[i].mne);
getch();
exit(0);
}
}
strcpy(s[j].nam,a[i].la);
s[j].add=lc;
j++;
}
for(t=0;t<9;t++)
{
if(strcmp(a[i].mne,o[t].opc)==0)
{
lc=lc+3;
break;
}
}
if(strcmp(a[i].mne,"RESW")==0)
lc=lc+(3*atoi(a[i].op));
else if(strcmp(a[i].mne,"WORD")==0);
lc=lc+3;
if(strcmp(a[i].mne,"RESB")==0);
lc=lc+atoi(a[i].op);
i++;
}
printf("SYMBOL TABLE\n");
printf("****** *****\n\n");
printf("SYMBOL\t VALUE\n");
printf("______\t _____\n");
for(t=0;tprintf("\n%s\t%d",s[t].nam,s[t].add);
getch();
}




Responses


No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
C program  .  

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: How to add a new HARD DRIVE to your PC
Previous Resource: how to customerize the task bar grouping?
Return to Discussion Resource Index
Post New Resource
Category: Computer & Technology


Post resources and earn money!
 
Related Resources


Contact Us    Privacy Policy    Terms Of Use   

SpiderWorks Technologies Pvt Ltd. 2006 - 2007 All Rights Reserved.