1 #ifndef YACASL2_ASSEMBLE_H_INCLUDED
2 #define YACASL2_ASSEMBLE_H_INCLUDED
3
4 #include <stdio.h>
5 #include <stdlib.h>
6 #include <string.h>
7 #include <stdbool.h>
8 #include <ctype.h>
9 #include <assert.h>
10 #include <errno.h>
11 #include "cerr.h"
12 #include "struct.h"
13 #include "token.h"
14
15
16
17
18 typedef struct {
19 bool src;
20 bool label;
21 bool onlylabel;
22 bool asdetail;
23 bool onlyassemble;
24 } ASMODE;
25
26
27
28
29 extern ASMODE asmode;
30
31
32
33
34 typedef struct {
35 WORD ptr;
36 WORD lptr;
37 char *prog;
38 } ASPTR;
39
40
41
42
43 extern ASPTR *asptr;
44
45
46
47
48 typedef struct {
49 char *prog;
50 char *label;
51 WORD adr;
52 } LABELARRAY;
53
54
55
56
57 typedef struct _LABELTAB {
58 struct _LABELTAB *next;
59 LABELARRAY *label;
60 } LABELTAB;
61
62
63
64
65 enum {
66 LABELTABSIZE = 251,
67 };
68
69
70
71
72 typedef enum {
73 FIRST = 0,
74 SECOND = 1,
75 } PASS;
76
77
78
79
80
81
82 void addcerrlist_label();
83
84
85
86
87
88
89
90
91
92 WORD getlabel(const char *prog, const char *label);
93
94
95
96
97
98
99
100
101
102
103 bool addlabel(const char *prog, const char *label, WORD adr);
104
105
106
107
108
109
110 void printlabel();
111
112
113
114
115
116
117 void freelabel();
118
119
120
121
122
123
124 void addcerrlist_assemble();
125
126
127
128
129
130
131
132
133
134
135
136 bool assemblefile(const char *file, PASS pass);
137
138
139
140
141
142
143
144
145
146
147 bool assemble(int filec, char *filev[], WORD adr);
148
149
150
151
152
153
154
155
156 void outassemble(const char *file);
157
158 #endif