-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathabsloader.c
More file actions
65 lines (46 loc) · 1.27 KB
/
absloader.c
File metadata and controls
65 lines (46 loc) · 1.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
void main(){
FILE *objcode,*tempFile;
objcode=fopen("objcode.txt","r");
char record[200],address[10];
int i,start,count=0,j=0,change=0;
fscanf(objcode,"%s",record);
for(i=0;record[i]!='\0';i++){
if(record[i]=='^')
count++;
if(count==2 && record[i]!='^')
address[j++]=record[i];
if(count==3)
break;
}
tempFile=fopen("tempFile.txt","w");
fprintf(tempFile,"%s",address);
fclose(tempFile);
tempFile=fopen("tempFile.txt","r");
fscanf(tempFile,"%x",&start);
fclose(tempFile);
fscanf(objcode,"%s",record);
printf("adress\tobjectCode");
while (record[0]!='E' && !feof(objcode))
{
count=0;
change=0;
for(i=0;record[i]!='\0';i++){
if(record[i]=='^'){
count++;
}
if(count>=3 && record[i]!='^'){
if(change==0){
printf("\n%x\t",start);
start+=1;
}
printf("%c",record[i]);
change=!change;
}
}
fscanf(objcode,"%s",record);
}
fclose(objcode);
}