0
|
1 /* Micro-C header file */
|
|
2
|
|
3 #define DEBUG error(-1)
|
|
4
|
|
5 /*#include "CCLIB.TXT" */
|
19
|
6 #ifdef __micro_c__
|
|
7 #include "stdio.h"
|
|
8 #else
|
|
9 #include <stdio.h>
|
|
10 #endif
|
0
|
11
|
|
12 #define SIZE_INT 4
|
|
13
|
|
14 #define INT (-1)
|
|
15 #define CHAR (-2)
|
|
16 #define UNSIGNED (-3)
|
|
17 #define POINTER (-4)
|
|
18 #define ARRAY (-5)
|
|
19 #define STRUCT (-6)
|
|
20 #define UNION (-7)
|
|
21 #define FUNCTION (-8)
|
|
22
|
|
23 #define STATIC (-10)
|
|
24 #define GOTO (-11)
|
|
25 #define RETURN (-12)
|
|
26 #define BREAK (-13)
|
|
27 #define CONTINUE (-14)
|
|
28 #define IF (-15)
|
|
29 #define ELSE (-16)
|
|
30 #define FOR (-17)
|
|
31 #define DO (-18)
|
|
32 #define WHILE (-19)
|
|
33 #define SWITCH (-20)
|
|
34 #define CASE (-21)
|
|
35 #define DEFAULT (-22)
|
|
36 #define RESERVE (-23)
|
|
37 #define TAG (-24)
|
|
38 #define FIELD (-25)
|
|
39 #define IDENT (-26)
|
|
40 #define STRING (-27)
|
|
41 #define MACRO (-28)
|
|
42 #define BLABEL (-29)
|
|
43 #define FLABEL (-30)
|
|
44 #define TYPEDEF (-31)
|
|
45 #define SIZEOF (-32)
|
|
46 #define TYPE (-33)
|
|
47 #define LONG (-34)
|
|
48 #define SHORT (-35)
|
|
49 #define EXTRN (-36)
|
97
|
50 #define EXTRN1 (-37)
|
|
51 #define VOID (-38)
|
|
52 #define REGISTER (-39)
|
|
53 #define CODE (-40)
|
|
54 #define ENVIRONMENT (-41)
|
|
55 #define DEFINED (-42)
|
|
56 #define KONST (-43)
|
|
57 #define FMACRO (-44)
|
|
58 #define LMACRO (-45)
|
|
59 #define DOTS (-46)
|
0
|
60
|
97
|
61 #define FLOAT (-47)
|
|
62 #define DOUBLE (-48)
|
150
|
63 #define LONGLONG (-49)
|
|
64 #define FREGISTER (-50)
|
|
65 #define DREGISTER (-51)
|
78
|
66
|
103
|
67 #define EMPTY (-99)
|
|
68
|
0
|
69 #define TOP 0
|
|
70 #define GDECL 1
|
|
71 #define GSDECL 2
|
|
72 #define GUDECL 3
|
|
73 #define ADECL 4
|
|
74 #define LDECL 5
|
|
75 #define LSDECL 6
|
|
76 #define LUDECL 7
|
|
77 #define STADECL 8
|
|
78 #define STAT 9
|
|
79 #define GTDECL 10
|
|
80 #define LTDECL 11
|
18
|
81 #define IFDEF 12
|
29
|
82 #define MDECL 13
|
0
|
83
|
|
84 #define GVAR 1
|
|
85 #define RGVAR 2
|
|
86 #define CRGVAR 3
|
|
87 #define LVAR 4
|
|
88 #define RLVAR 5
|
|
89 #define CRLVAR 6
|
|
90 #define CONST 7
|
|
91 #define FNAME 8
|
|
92 #define INDIRECT 9
|
|
93 #define RINDIRECT 10
|
|
94 #define CRINDIRECT 11
|
|
95 #define ADDRESS 12
|
|
96 #define MINUS 13
|
|
97 #define LNOT 14
|
|
98 #define BNOT 15
|
|
99 #define INC 16
|
|
100 #define POSTINC 17
|
|
101 #define PREINC 18
|
|
102 #define CPOSTINC 19
|
|
103 #define CPREINC 20
|
|
104 #define DEC 21
|
|
105 #define CPOSTDEC 22
|
|
106 #define CPREDEC 23
|
|
107 #define MUL 24
|
|
108 #define UMUL 25
|
|
109 #define DIV 26
|
|
110 #define UDIV 27
|
|
111 #define MOD 28
|
|
112 #define UMOD 29
|
|
113 #define ADD 30
|
|
114 #define SUB 31
|
89
|
115 #define CMP 32
|
|
116 #define RSHIFT 33
|
|
117 #define URSHIFT 34
|
|
118 #define LSHIFT 35
|
|
119 #define ULSHIFT 36
|
|
120 #define GT 37
|
|
121 #define UGT 38
|
|
122 #define GE 39
|
|
123 #define UGE 40
|
|
124 #define LT 41
|
|
125 #define ULT 42
|
|
126 #define LE 43
|
|
127 #define ULE 44
|
|
128 #define EQ 45
|
|
129 #define NEQ 46
|
|
130 #define BAND 47
|
|
131 #define EOR 48
|
|
132 #define BOR 49
|
|
133 #define LAND 50
|
|
134 #define LOR 51
|
|
135 #define COND 52
|
|
136 #define ASS 53
|
|
137 #define CASS 54
|
|
138 #define ASSOP 55
|
|
139 #define CASSOP 56
|
|
140 #define COMMA 57
|
|
141 #define LPAR 58
|
|
142 #define RPAR 59
|
|
143 #define LBRA 60
|
|
144 #define RBRA 61
|
|
145 #define LC 62
|
|
146 #define RC 63
|
|
147 #define COLON 64
|
|
148 #define SM 65
|
|
149 #define PERIOD 66
|
|
150 #define ARROW 67
|
|
151 #define CNAME 68
|
|
152 #define SASS 69
|
|
153 #define RSTRUCT 70
|
0
|
154
|
89
|
155 #define DASSOP (DOP+ASSOP)
|
|
156 #define DCMP (DOP+CMP)
|
|
157 #define DMINUS (DOP+MINUS)
|
82
|
158 #define DMUL (DOP+MUL)
|
|
159 #define DDIV (DOP+DIV)
|
|
160 #define DADD (DOP+ADD)
|
|
161 #define DSUB (DOP+SUB)
|
133
|
162 #define FASSOP (FOP+ASSOP)
|
|
163 #define FCMP (FOP+CMP)
|
|
164 #define FMINUS (FOP+MINUS)
|
|
165 #define FMUL (FOP+MUL)
|
|
166 #define FDIV (FOP+DIV)
|
|
167 #define FADD (FOP+ADD)
|
|
168 #define FSUB (FOP+SUB)
|
|
169 #define CMPGE 72
|
|
170 #define DCMPGE (DOP+CMPGE)
|
|
171 #define FCMPGE (FOP+CMPGE)
|
91
|
172 #define LMUL 73
|
|
173 #define LDIV 74
|
|
174 #define LADD 75
|
|
175 #define LSUB 76
|
78
|
176
|
81
|
177 #define FRGVAR 82
|
|
178 #define FRLVAR 83
|
|
179 #define FRINDIRECT 84
|
|
180 #define DRGVAR 85
|
|
181 #define DRLVAR 86
|
|
182 #define DRINDIRECT 87
|
|
183 #define LRGVAR 88
|
|
184 #define LRLVAR 89
|
|
185 #define LRINDIRECT 90
|
133
|
186 #define DCONST (DOP+CONST)
|
|
187 #define FCONST (FOP+CONST)
|
85
|
188 #define LCONST 93
|
|
189 #define DASS 94
|
|
190 #define FASS 95
|
|
191 #define LASS 96
|
|
192 #define SHASS 97
|
81
|
193
|
85
|
194 #define I2D 98
|
|
195 #define D2I 99
|
|
196 #define U2D 100
|
|
197 #define D2U 101
|
133
|
198 #define F2D 108
|
|
199 #define D2F 109
|
|
200 #define I2F 110
|
|
201 #define F2I 111
|
|
202 #define U2F 112
|
|
203 #define F2U 113
|
|
204 #define FPOSTINC (FOP+POSTINC)
|
|
205 #define DPOSTINC (DOP+POSTINC)
|
|
206 #define FPREINC (FOP+PREINC)
|
|
207 #define DPREINC (DOP+PREINC)
|
|
208 #define DCOND (DOP+COND)
|
|
209 #define FCOND (FOP+COND)
|
108
|
210 #define CONV 107
|
81
|
211
|
0
|
212 #define US 1
|
81
|
213 #define AS 200
|
83
|
214 #define DOP 400
|
133
|
215 #define FOP 600
|
0
|
216
|
|
217 #define FILERR 1
|
|
218 #define DCERR 2
|
|
219 #define STERR 3
|
|
220 #define EXERR 4
|
|
221 #define CNERR 5
|
|
222 #define CHERR 6
|
|
223 #define GSERR 7
|
|
224 #define LSERR 8
|
|
225 #define STRERR 9
|
|
226 #define LNERR 10
|
|
227 #define EOFERR 11
|
|
228 #define MCERR 12
|
|
229 #define INCERR 13
|
|
230 #define HPERR 14
|
|
231 #define TYERR 15
|
|
232 #define LVERR 16
|
|
233 #define UDERR 17
|
|
234 #define OPTION 18
|
|
235 #define REG_ERR 19
|
|
236 #define CODE_ERR 20
|
29
|
237 #define MSERR 21
|
0
|
238
|
|
239 #define GSYMS 9000
|
|
240 #define LSYMS 500
|
32
|
241 #define MSYMS 3000
|
0
|
242
|
|
243 #define HEAPSIZE 10000
|
|
244 /* #define CHEAPSIZE 3000 */
|
|
245 #define CHEAPSIZE 256000
|
|
246 #define LBUFSIZE 4096
|
34
|
247 #define MACROSIZE 16000
|
0
|
248
|
25
|
249 #define FILES 10
|
0
|
250 #define OUTPUT_FILE_NAME "mcout.s"
|
|
251
|
29
|
252 EXTERN int sym,ch,type,mode,stmode,gfree,lfree,mflag,lineno,glineno;
|
0
|
253 EXTERN int labelno,gpc,disp,reg_var,debug;
|
|
254 EXTERN int symval,args,init_vars,heap[HEAPSIZE];
|
|
255 EXTERN int blabel,clabel,dlabel,cslabel,ilabel,control,ac,ac2,lsrc,chk,asmf;
|
|
256 EXTERN int MAX_REGISTER_VAR;
|
81
|
257 EXTERN double dsymval;
|
0
|
258
|
|
259 EXTERN unsigned hash;
|
|
260
|
34
|
261 EXTERN int chsave;
|
115
|
262 EXTERN int chptrsave;
|
29
|
263 EXTERN char linebuf[LBUFSIZE],namebuf[LBUFSIZE],*chptr;
|
0
|
264 EXTERN char *name,*cheapp,**av,/*obuf[320],*/*sptr,escape(void);
|
42
|
265 EXTERN int arg_offset,stat_no,size_of_int,disp_offset,endian,csvalue1;
|
0
|
266 EXTERN int code_arg_offset;
|
81
|
267 EXTERN int size_of_double,size_of_float,size_of_longlong;
|
0
|
268 EXTERN int retlabel,retpending,retcont;
|
77
|
269 EXTERN int arglist;
|
0
|
270
|
|
271 EXTERN FILE *obuf;
|
|
272
|
110
|
273 #if 0
|
0
|
274 typedef struct nametable {
|
|
275 char *nm;
|
|
276 int sc,ty,dsp; } NMTBL;
|
110
|
277 #else
|
|
278 typedef struct nametable {
|
|
279 char *nm;
|
|
280 int sc; int ty; int dsp; } NMTBL;
|
|
281 #endif
|
0
|
282
|
30
|
283 EXTERN NMTBL mtable[MSYMS];
|
28
|
284 EXTERN NMTBL ntable[GSYMS+LSYMS];
|
|
285 EXTERN NMTBL *nptr,*gnptr;
|
0
|
286 EXTERN NMTBL *fnptr;
|
105
|
287 EXTERN NMTBL null_nptr;
|
72
|
288 EXTERN int typedefed,gtypedefed;
|
0
|
289
|
25
|
290 EXTERN struct {int fd,ln;char *name0;FILE *fcb;} *filep,filestack[FILES];
|
0
|
291 EXTERN char cheap[CHEAPSIZE];
|
34
|
292 EXTERN char *macropp,macro_buf[MACROSIZE];
|
0
|
293
|
61
|
294 extern void error(int n);
|
|
295 extern int size(int t);
|
|
296 extern int scalar(int t);
|
81
|
297 extern int dlist2(int e1, double e2);
|
61
|
298 extern int list2(int e1, int e2);
|
|
299 extern int list3(int e1, int e2, int e3);
|
|
300 extern int list4(int e1, int e2, int e3,int e4);
|
|
301 extern int reverse0(int t1);
|
|
302 extern int assign_data(int e, int t, NMTBL *n,int offset);
|
|
303 extern int assign_expr0(int e1,int e2,int t,int type) ;
|
|
304 extern int assign_expr(int e1,int e2,int t,int type) ;
|
|
305 extern int append4(int p,int a1,int a2,int a3);
|
|
306
|
|
307
|
|
308
|
33
|
309 #define car(e) (heap[(int)(e)])
|
|
310
|
|
311 #define cadr(e) (heap[((int)(e))+1])
|
|
312
|
|
313 #define caddr(e) (heap[((int)(e))+2])
|
|
314
|
|
315 #define cadddr(e) (heap[((int)(e))+3])
|
|
316
|
81
|
317 #define dcadr(e) (*(double*)&heap[((int)(e))+1])
|
|
318 #define dcaddr(e) (*(double*)&heap[((int)(e))+2])
|
|
319
|
66
|
320 #include "conv/conv.h"
|
|
321 /*
|
59
|
322 #include "conv/c2cbc.h"
|
|
323 #include "conv/cbc2c.h"
|
66
|
324 */
|
59
|
325
|
62
|
326 extern Converter *conv;
|
59
|
327
|
119
|
328 EXTERN void extern_define(char *s,int dsp,int type,int use);
|
61
|
329 EXTERN void error(int n);
|
|
330 EXTERN int append4(int p,int a1,int a2,int a3);
|
|
331 EXTERN int assign_expr(int e1,int e2,int t,int type);
|
|
332 EXTERN int assign_expr0(int e1,int e2,int t,int type);
|
|
333 EXTERN int backdef(void);
|
|
334 EXTERN int fwdlabel(void);
|
|
335 EXTERN int glist2(int e1,int e2);
|
95
|
336 EXTERN int glist3(int e1,int e2,int e3);
|
117
|
337 EXTERN void free_glist2(int e1);
|
|
338 EXTERN void free_glist3(int e1);
|
|
339 EXTERN int integral(int t);
|
61
|
340 EXTERN int integral(int t);
|
|
341 EXTERN int list2(int e1, int e2);
|
|
342 EXTERN int list3(int e1, int e2, int e3);
|
|
343 EXTERN int list4(int e1, int e2, int e3, int e4);
|
|
344 EXTERN int reverse0(int t1);
|
|
345 EXTERN int rplacad(int e, int n);
|
|
346 EXTERN int rplacadd(int e, int n);
|
|
347 EXTERN int rvalue_t(int e,int type);
|
|
348 EXTERN int scalar(int t);
|
|
349 EXTERN void bexpr(int e1, char cond, int l1);
|
|
350 EXTERN void def_label(int cslabel, int dlabel);
|
|
351 EXTERN void display_ntable(NMTBL *n, char *s);
|
|
352 EXTERN void exit(int l);
|
|
353 EXTERN void fwddef(int l);
|
94
|
354 EXTERN int new_lvar(int size);
|
|
355
|
117
|
356 EXTERN void free_lvar(int lvar);
|
|
357 EXTERN void init_free_lvar_list();
|
61
|
358
|
33
|
359 /* end */
|