-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathobject.c
More file actions
76 lines (62 loc) · 2.15 KB
/
object.c
File metadata and controls
76 lines (62 loc) · 2.15 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
66
67
68
69
70
71
72
73
74
75
76
/********************************************************************
* File Name: object.c *
* File Type: source file *
********************************************************************/
/*-------------------------------------------------------------------*/
/* object.c - builds the object (*.ob) file */
/*-------------------------------------------------------------------*/
#include "header.h"
extern int dc,ic,data_zone[DATA_ZONE],code_zone[DATA_ZONE],external[DATA_ZONE],
relocatable[DATA_ZONE];
/*********************************************************************/
/* function build_object_file builds the output object (*.ob) file */
/*********************************************************************/
void build_object_file(char *argv)
{
FILE *obj;
char *object;
object=build_new_file_name(argv,"ob");
if ((obj=fopen(object,"w"))==NULL)
printf("canno't open file %s\n\n",object);
else
{
print_object_file(obj);
fclose(obj);
}
}
/*********************************************************************/
/* function print_object_file writes all needed data into the ob file*/
/*********************************************************************/
void print_object_file(FILE* obj)
{
int i;
fprintf(obj," Octal Octal Absolute\n");
fprintf(obj," Address: machine relocatable\n");
fprintf(obj," code: or external\n");
fprintf(obj,"\n");
fprintf(obj, " %o %o\n\n",ic,dc);
for (i=0;i<ic;i++)
{
fprintf(obj," ");
if (i==0)
add_zero(obj,64);
else
add_zero (obj,(i*64));
fprintf(obj,"%o ",i);
add_zero (obj,code_zone[i]);
fprintf(obj,"%o ",code_zone[i]);
if (external[i])
fprintf(obj,"e\n");
else if(relocatable[i])
fprintf(obj,"r\n");
else fprintf(obj,"a\n");
}
for (i=0;i<dc;i++)
{
fprintf(obj," ");
add_zero (obj,((i+ic)*64));
fprintf(obj,"%o ",i+ic);
add_zero (obj,data_zone[i]);
fprintf(obj,"%o\n",data_zone[i]);
}
}