New Member FAQ | Forums | Earn Revenue


Resources Entrance Ask Experts Exam Papers Jobs English Projects Universities Colleges Courses Schools Training My India



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.

website counter



Direct linking loader pass1 and pass2


Posted Date:     Total Responses: 0    Posted By: R V Vinod Babu   Member Level: Silver   Points/Cash: 8   


//direct linking loader pass1 and pass2//
#include
#include
#include
#include
struct a
{
char b[10][10];
};
struct a mo1[10];
struct a mo2[10];
struct a pro1[10];
struct a pro2[10];
struct a reloc[10];
struct a estab[10];
void main()
{
FILE *f1,*f2,*f3,*f4,*f5,*f6,*f7;
int i,j,k,prop,proq,load,mod1,re,mod2,n,est,s,q,p;
clrscr();
f1=fopen("prop.txt","r");
f2=fopen("proq.txt","r");
f3=fopen("mod1.txt","r");
f4=fopen("mod2.txt","r");
f5=fopen("estab.txt","w");
f6=fopen("outlink.txt","w");
f7=fopen("reloc.txt","r");
k=0;
while(!feof(f1))
{
for(i=0;i<5;i++)
{
fscanf(f1,"%s",&pro1[k].b[i]);
printf("%s",pro1[k].b[i]);
printf("\t");
}
printf("\n");
k++;
}
prop=k-1;
printf("\nthe number of lines present %d",prop);
getch();
clrscr();
k=0;
while(!feof(f2))
{
for(i=0;i<5;i++)
{
fscanf(f2,"%s",&pro2[k].b[i]);
printf("%s\t",pro2[k].b[i]);
}
printf("\n");
k++;
}
proq=k-1;
printf("\n the number of lines present %d",proq);
getch();
clrscr();
k=0;
while(!feof(f3))
{
for(i=0;i<3;i++)
{
fscanf(f3,"%s",&mo1[k].b[i]);
printf("%s\t",mo1[k].b[i]);
}
k++;
printf("\n");
}
mod1=k-1;
printf("\nthe number of lines present %d",mod1);
getch();
clrscr();
k=0;
while(!feof(f4))
{
for(i=0;i<3;i++)
{
fscanf(f4,"%s",&mo2[k].b[i]);
printf("%s\t",&mo2[k].b[i]);
}
k++;
printf("\n");
}
mod2=k;
printf("\n the number of lines present %d",mod2);
getch();
clrscr();
k=0;
while(!feof(f7))
{
for(i=0;i<1;i++)
{
fscanf(f7,"%s",&reloc[k].b[i]);
printf("%s\n",reloc[k].b[i]);
}
k++;
}
re=k;
printf("\nthe number of relocation address %d",re);
getch();
clrscr();
//creation of external symbol table
printf("\nenter the load address:");
scanf("%d",&load);
printf("\n/****EXTERNAL SYMBOL TABLE****/\n");
printf("\nthe load address is %d",load);
k=0;
for(i=0;i{
if(strcmp(mo1[k].b[1],"PD")==0)
{
printf("\n%s\t%d",mo1[k].b[0],(atoi(mo1[k].b[2])+load)-atoi(pro1[0].b[0]));
fprintf(f5,"\n%s\t%d",mo1[k].b[0],(atoi(mo1[k].b[2])+load)-atoi(pro1[0].b[0]));
}
k++;
}
k=0;
for(i=0;i{
if(strcmp(mo2[k].b[1],"PD")==0)
{
printf("\n%s\t%d",mo2[k].b[0],load+prop+(atoi(mo2[k].b[2])-atoi(mo2[0].b[2])));
fprintf(f5,"\n%s\t%d",mo2[k].b[0],load+prop+(atoi(mo2[k].b[2])-atoi(mo2[0].b[2])));
}
k++;
}
fclose(f1);
fclose(f2);
fclose(f3);
fclose(f4);
fclose(f5);
fclose(f7);
f5=fopen("estab.txt","r");
k=0;
printf("\n");
while(!feof(f5))
{
for(i=0;i<2;i++)
{
fscanf(f5,"%s",&estab[k].b[i]);
}
k++;
}
est=k;
printf("\n the ESTAB COUNT %d",est);
getch();
printf("\n/****THE OBJECT CODE****/\n");
fprintf(f6,"\n/****THE OBJECT CODE****/\n");
for(i=0;i{
s=q=p=0;
printf("%d\t+\t",load+i);
printf("%s\t%s\t",pro1[i].b[2],pro1[i].b[3]);
fprintf(f6,"%d\t+\t",load+i);
fprintf(f6,"%s\t%s\t",pro1[i].b[2],pro1[i].b[3]);
for(j=0;jif(strcmp(pro1[i].b[4],reloc[j].b[0])==0)
{
printf("%d\n",load+atoi(reloc[j].b[0])-atoi(pro1[0].b[0]));
fprintf(f6,"%d\n",load+atoi(reloc[j].b[0])-atoi(pro1[0].b[0]));
q=1;
}
if(strcmp(pro1[i].b[4],"000")==0)
for(j=0;jif(strcmp(pro1[i].b[0],mo1[j].b[2])==0 && strcmp(mo1[j].b[1],"EXT")==0)
for(n=0;nif(strcmp(mo1[j].b[0],estab[n].b[0])==0)
{
s=1;
printf("%s\n",estab[n].b[1]);
fprintf(f6,"%s\n",estab[n].b[1]);
}
if(strcmp(pro1[i].b[4],"***")==0)
{
p=1;
printf("***\n");
fprintf(f6,"***\n");
}
if(s!=1 && q!=1 && p!=1)
{
fprintf(f6,"000\n");
printf("000\n");
}
}
for(k=0;k{
printf("%d\t%s\t%s\t%s\t",load+i,pro2[k].b[1],pro2[k].b[2],pro2[k].b[3]);
fprintf(f6,"%d\t%s\t%s\t%s\t",load+i,pro2[k].b[1],pro2[k].b[2],pro2[k].b[3]);
for(j=0;j{
if(strcmp(pro2[k].b[4],reloc[j].b[0])==0)
{
printf("%d\n",load+prop+atoi(reloc[j].b[0])-atoi(pro2[0].b[0]));
fprintf(f6,"%d\n",load+prop+atoi(reloc[j].b[0])-atoi(pro2[0].b[0]));
}
}
if(strcmp(pro2[k].b[4],"000")==0)
for(j=0;jif(strcmp(mo2[j].b[2],pro2[k].b[0])==0 && strcmp(mo2[j].b[1],"EXT")==0)
for(n=0;nif(strcmp(mo2[j].b[0],estab[n].b[0])==0)
{
printf("%s\n",estab[n].b[1]);
fprintf(f6,"%s\n",estab[n].b[1]);
}
if(strcmp(pro2[k].b[4],"***")==0)
{
printf("***\n");
fprintf(f6,"***\n");
}
for(j=0;jif(strcmp(pro2[k].b[4],reloc[n].b[0])==1)
{
printf("000\n");
fprintf(f6,"000\n");
}
}
fclose(f6);
getch();
}









Project Feedbacks


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

Post Feedback
You must Sign In to post a feedback.
Next Project: Editor in C
Previous Project: Macro parameter

Return to Project Index

Post New Project


Related Projects



Advertise Here





Contact Us   Advertise   Editors    Privacy Policy    Terms Of Use   

ISC Technologies.
2006 - 2009 All Rights Reserved.