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