Skip to content

Instantly share code, notes, and snippets.

@hatim-the-dark-knight
Created April 26, 2022 18:35
Show Gist options
  • Save hatim-the-dark-knight/d7046e8285345607fecc71bdff2baa27 to your computer and use it in GitHub Desktop.
Save hatim-the-dark-knight/d7046e8285345607fecc71bdff2baa27 to your computer and use it in GitHub Desktop.
H COPY 001000 00107A
T 000000 1E 140033 481039 100036 280030 300015 481061 3C0003 20002A 1C0039 30002D
T 002500 15 1D0036 481061 180033 4C1000 801000 601003
E 000000
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
void main()
{
char rec[20];
char progname[20];
char ch;
int length,start,locctr;
FILE *fp1,*objptr;
printf("\nThe Contents of Input File:\n");
fp1 = fopen("abs_input.txt","r");
ch = fgetc(fp1);
while(ch!= EOF)
{
printf("%c",ch);
ch = fgetc(fp1);
}
fclose(fp1);
printf("\n\n*****Program Loaded In Memory*****\n");
printf("\nADDRESS\tOBJECT CODE\n");
objptr = fopen("abs_input.txt","r");
fscanf(objptr,"%s",rec);
if(strcmp(rec,"H")==0)
{
fscanf(objptr,"%s",progname);
fscanf(objptr,"%X",&start);
locctr = start;
fscanf(objptr,"%X",&length);
fscanf(objptr,"%s",rec);
}
else
{
fclose(objptr);
exit(0);
}
while(strcmp(rec,"E")!=0)
{
if(strcmp(rec,"T")==0)
{
fscanf(objptr,"%X",&start);
locctr = start;
fscanf(objptr,"%X",&length);
}
else
{
if(locctr > 0xFFFF)
printf("0");
else if(locctr > 0xFFF)
printf("00");
else if(locctr > 0xFF)
printf("000");
else if(locctr > 0xF)
printf("0000");
else
printf("00000");
printf("%X\t%s\n",locctr,rec);
locctr+=3;
}
fscanf(objptr,"%s",rec);
}
fclose(objptr);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment