Sunday 25 September 2011


                                                     ABSOLUTE LOADER

AIM:
To perform the operation of absolute loader.
ALGORITHM:
Step 1: Start the program.
Step 2: Set an array for text, opcode and object code.
Step 3: Read object program from the user.
Step 4: If the record type is header record, set the starting address of the program.
Step 5: If the record type is TEXT record, the object code is placed ion the corresponding memory address.
Step 6: If the word type is END record, the control is transferred to beginning of program.
Step 7: Stop the program.

SOURCE CODE:
/* ABSOLUTE LOADER */
#include<stdio.h>
#include<conio.h>
#include<string.h>
struct object
{
char text[10],opcode[10];
}obj[10];
struct output
{
int addr;
char ob1,ob2;
}op[10];
void main()
{
int i,j,n,k,x,start=0,z;
clrscr();
i=0;
do
{
i++;
printf("\nEnter the text:");
scanf("%s",obj[i].text);
printf("\nEnter the object code:");
scanf("%s",obj[i].opcode);
//if(strcmp(obj[i].opcode);
if(strcmp(obj[i].text,"H")==0)
start=atoi(obj[i].opcode);
}
while(strcmp(obj[i].text,"E")!=0);
z=1;
printf("Address\tObject code\n");
for(k=1;k<i;k++)
{
if(strcmp(obj[k].text,"H")==0)
continue;
for(x=0;x<6;x+=2)
{
op[z].addr=start;
op[z].ob1=obj[k].opcode[x];
op[z].ob2=obj[k].opcode[x+1];
start++;
z++;
}
}
for(k=1;k<z;k++)
{
printf("\n%d\t%c%c",op[k].addr,op[k].ob1,op[k].ob2);
}
getch();
}
OUTPUT:

Enter the text:H

Enter the object code:1000

Enter the text:T

Enter the object code:123456

Enter the text:T

Enter the object code:904523

Enter the text:E

Enter the object code:1000


Address Object code

1000    12
1001    34
1002    56
1003    90
1004    45
1005    23
Result
Thus above program executed and output verified

0 comments:

Post a Comment