Program for Pass I Direct Linking Loader


Pass ONE Direct Linking Loader

#include<stdio.h>

#include<conio.h>

#include<stdlib.h>

#include<string.h>

#define MAX 10

struct estab

{          char csect[10];

char sym_name[10];

long int add;

int length;

}table[MAX];

void main()

{          FILE *fp1, *fp2;

char input[10];

long int i, count =0, start, length, loc;

clrscr();

fp1=fopen(“linkin.dat”, “r”);

fp2=fopen(“linkout.dat”, “w”);

printf(“Enter the location where the program has to be loaded:”);

scanf(“%lx”, &start);

fprintf(fp2, “CSECT \t symname \t address \t length\n”);

rewind(fp1);

while(!feof(fp1))

{

fscanf(fp1, “%s”, input);

if(strcmp(input, “H”)==0)

{

fscanf(fp1, “%s”, input);

strcpy(table[count].csect, input);

strcpy(table[count].sym_name, “”);

fscanf(fp1, “%s”, input);

table[count].add=atoi(input)+start;

fscanf(fp1, “%s”, input);

length=atoi(input);

table[count++].length=atoi(input);

fscanf(fp1, “%s”, input);

}

if(strcmp(input, “D”)==0)

{

fscanf(fp1, “%s%lx”, input, &loc);

while((strcmp(input, “R”)!=0))

{

strcpy(table[count].csect, “”);

strcpy(table[count].sym_name, input);

table[count].add=loc+start;

table[count++].length=0;

fscanf(fp1, “%s%lx”, input, &loc);

}

while(strcmp(input, “T”)!=0)

fscanf(fp1, “%s”, input);

}

if(strcmp(input, “T”)==0)

while(strcmp(input, “E”)!=0)

fscanf(fp1, “%s”, input);

fscanf(fp1, “%s”, input);

start=start+length;

}

for(i=0; i<count; i++)

fprintf(fp2, “%s\t%s\t%lx\t%d\n”, table[i].csect, table[i].sym_name, table[i].add, table[i].length);

printf(“\nPass 1 of Direct Linking Loaded is completed”);

getch();

}

4 Comments

  1. i need a c or c++ program implementing the pass 2 of a linking loader..pls soon

    • i need c or c++ program implementing pass 2 of a linking loader not the pass 1 in system software lab

  2. i need a direct linking loader for pass 2. reply soon

  3. i need a single pass assembler program for system software lab…….. soon


Sorry, the comment form is closed at this time.

Comments RSS