Pass 2 of 2 pass assembler


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


//pass 2 of 2 pass assembler//
#include
#include
#include
#include
struct a
{
char b[10][10];
};
struct a source[10];
struct a symtab[10];
struct a littab[10];
void main()
{
FILE *f1,*f2,*f3;//*f4;
char c;
int i,j,k,n,pro,sym,lit,start,e,f,s,l,w;
clrscr();
f1=fopen("2pinput.txt","r");
f2=fopen("symbol2.txt","r");
f3=fopen("littab.txt","r");
//f4=fopen("2poutput.txt","w");
k=0;
printf("/****the intermediate code****/\n");
while(!feof(f1))
{
for(i=0;i<3;i++)
{
fscanf(f1,"%s",&source[k].b[i]);
printf("%s\t",source[k].b[i]);
}
printf("\n");
k++;
}
pro=k;
printf("the number of lines %d",pro);
getch();
clrscr();
k=0;
printf("/****symbol table****/\n");
while(!feof(f2))
{
for(i=0;i<3;i++)
{
fscanf(f2,"%s",&symtab[k].b[i]);
printf("%s\t",symtab[k].b[i]);
}
printf("\n");
k++;
}
sym=k;
printf("the number of lines %d",sym);
getch();
clrscr();
k=0;
printf("/****litteral table****/\n");
while(!feof(f3))
{
for(i=0;i<3;i++)
{
fscanf(f3,"%s",&littab[k].b[i]);
printf("%s\t",littab[k].b[i]);
}
printf("\n");
k++;
}
lit=k;
printf("the number of lines %d",lit);
getch();
clrscr();
c=source[0].b[2][3];
start=c-'0';
start=start*100;
printf("the starting address %d",start);
printf("\n/*****object code*****/\n");
for(i=1;i{
s=l=w=0;
printf("%d\t+\t",(start+i)-1);
e=source[i].b[0][4]-'0';
f=source[i].b[0][5]-'0';
printf("%d%d\t%c\t",e,f,source[i].b[1][1]);
if(source[i].b[2][1] == 'S')
{
s=1;
for(j=0;jif(source[i].b[2][3] == symtab[j].b[0][0])
printf("%s",symtab[j].b[2]);
}
if(source[i].b[2][1] == 'L')
{
l=1;
for(j=0;jif(source[i].b[2][3] == littab[j].b[0][0])
printf("%s",littab[j].b[2]);
}
if(source[i].b[2][1] == 'C')
{
w=1;
n=source[i].b[2][3]-'0';
printf("%d",n);
}
if(s!=1 && l!=1 && w!=1)
printf("000");
printf("\n");
}
getch();
}


Project Feedbacks


No feedbacks found. Be the first to respond...

Post Feedback
You must Sign In to post a feedback.
Next Project: ASS 1 OF AN TWO PASS ASSEMBLER
Previous Project: Absolute loader

Return to Project Index

Post New Project


Related Projects


Complete the action items below to enter to win an iPad Mini from India Study Channel! in India Study Channel - Locker on LockerDome
Awards & Gifts
Active Members
TodayLast 7 Daysmore...

 
ISC Technologies, Kochi - India. © All Rights Reserved.