Friday 28 September 2012

Absolute Loader in System Software - Anna University Lab Experiment No: 4

Ex:4 Absolute loader

#include<stdio.h>
#include<conio.h>
#include<string.h>
#include<stdlib.h>
int len;
char sub[10];
void substr(char *ip, int i, int j)
{
int k,x=0;
char str[10];
for(k=i;k<=j;k++)
if(ip[k]!=' ')
sub[x++]=ip[k];
sub[x]='\0';
}
void main()
{
int i,j,n,length,pstart,s,plength,e;
char str1[10],str2[10],str[20][80],pname[10];
clrscr();
printf("Enter the object program:\n");
n=0;
while(strcmp(gets(str[n++]),"END")!=0);
n=7;
substr(str[0],1,6);
strcpy(pname,sub);
printf("\nProgram name %s\n",pname);
substr(str[0],7,12);
strcpy(str1,sub);
pstart=atoi(str1);
e=pstart;
printf("\nStart location: %d\n",pstart);
substr(str[0],13,18);
strcpy(str2,sub);
plength=atoi(str2);
printf("\n Program length: %d\n",plength);
for(i=1;i<n;i++)
{
if(str[i][0]!='E')
{
substr(str[i],1,6);
strcpy(str1,sub);
s=atoi(str1);
if(e<s)
{
int s1=e+length;
for(j=s1;j<s;j++)
{
printf("\n %d\t XX",j);
}
}
substr(str[i],7,8);
strcpy(str1,sub);
length=atoi(str1);

e=s+length;
for(j=9;j<strlen(str[i]);j=j+2)
{
substr(str[i],j,j+1);
strcpy(str1,sub);
printf("\n %d \t %s",s,str1);
s+=2;
}
}
else
break;
}
getch();
}

Output:

Enter the object program:

HSAARAH001000001040

T00100006101010101010

T001016021010

END

Program name SAARAH

Start location: 1000

Program length: 1040

1000 10

1002 10

1004 10

1006 10

1008 10

1010 10

1012 XX

1013 XX

1014 XX

1015 XX

1016 10

1018 10

No comments:

Don't You Think this Awesome Post should be shared ??
| Absolute Loader in System Software - Anna University Lab Experiment No: 4 |
Back To Top Related Posts Plugin for WordPress, Blogger...