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 #define EMPTY (-9)
|
|
23
|
|
24 #define STATIC (-10)
|
|
25 #define GOTO (-11)
|
|
26 #define RETURN (-12)
|
|
27 #define BREAK (-13)
|
|
28 #define CONTINUE (-14)
|
|
29 #define IF (-15)
|
|
30 #define ELSE (-16)
|
|
31 #define FOR (-17)
|
|
32 #define DO (-18)
|
|
33 #define WHILE (-19)
|
|
34 #define SWITCH (-20)
|
|
35 #define CASE (-21)
|
|
36 #define DEFAULT (-22)
|
|
37 #define RESERVE (-23)
|
|
38 #define TAG (-24)
|
|
39 #define FIELD (-25)
|
|
40 #define IDENT (-26)
|
|
41 #define STRING (-27)
|
|
42 #define MACRO (-28)
|
|
43 #define BLABEL (-29)
|
|
44 #define FLABEL (-30)
|
|
45 #define TYPEDEF (-31)
|
|
46 #define SIZEOF (-32)
|
|
47 #define TYPE (-33)
|
|
48 #define LONG (-34)
|
|
49 #define SHORT (-35)
|
|
50 #define EXTRN (-36)
|
|
51 #define VOID (-37)
|
|
52 #define REGISTER (-38)
|
|
53 #define CODE (-39)
|
|
54 #define ENVIRONMENT (-40)
|
18
|
55 #define DEFINED (-41)
|
20
|
56 #define KONST (-42)
|
28
|
57 #define FMACRO (-43)
|
|
58 #define LMACRO (-44)
|
67
|
59 #define DOTS (-45)
|
0
|
60
|
|
61 #define TOP 0
|
|
62 #define GDECL 1
|
|
63 #define GSDECL 2
|
|
64 #define GUDECL 3
|
|
65 #define ADECL 4
|
|
66 #define LDECL 5
|
|
67 #define LSDECL 6
|
|
68 #define LUDECL 7
|
|
69 #define STADECL 8
|
|
70 #define STAT 9
|
|
71 #define GTDECL 10
|
|
72 #define LTDECL 11
|
18
|
73 #define IFDEF 12
|
29
|
74 #define MDECL 13
|
0
|
75
|
|
76 #define GVAR 1
|
|
77 #define RGVAR 2
|
|
78 #define CRGVAR 3
|
|
79 #define LVAR 4
|
|
80 #define RLVAR 5
|
|
81 #define CRLVAR 6
|
|
82 #define CONST 7
|
|
83 #define FNAME 8
|
|
84 #define INDIRECT 9
|
|
85 #define RINDIRECT 10
|
|
86 #define CRINDIRECT 11
|
|
87 #define ADDRESS 12
|
|
88 #define MINUS 13
|
|
89 #define LNOT 14
|
|
90 #define BNOT 15
|
|
91 #define INC 16
|
|
92 #define POSTINC 17
|
|
93 #define PREINC 18
|
|
94 #define CPOSTINC 19
|
|
95 #define CPREINC 20
|
|
96 #define DEC 21
|
|
97 #define CPOSTDEC 22
|
|
98 #define CPREDEC 23
|
|
99 #define MUL 24
|
|
100 #define UMUL 25
|
|
101 #define DIV 26
|
|
102 #define UDIV 27
|
|
103 #define MOD 28
|
|
104 #define UMOD 29
|
|
105 #define ADD 30
|
|
106 #define SUB 31
|
|
107 #define RSHIFT 32
|
|
108 #define URSHIFT 33
|
|
109 #define LSHIFT 34
|
|
110 #define ULSHIFT 35
|
|
111 #define GT 36
|
|
112 #define UGT 37
|
|
113 #define GE 38
|
|
114 #define UGE 39
|
|
115 #define LT 40
|
|
116 #define ULT 41
|
|
117 #define LE 42
|
|
118 #define ULE 43
|
|
119 #define EQ 44
|
|
120 #define NEQ 45
|
|
121 #define BAND 46
|
|
122 #define EOR 47
|
|
123 #define BOR 48
|
|
124 #define LAND 49
|
|
125 #define LOR 50
|
|
126 #define COND 51
|
|
127 #define ASS 52
|
|
128 #define CASS 53
|
|
129 #define ASSOP 54
|
|
130 #define CASSOP 55
|
|
131 #define COMMA 56
|
|
132 #define LPAR 57
|
|
133 #define RPAR 58
|
|
134 #define LBRA 59
|
|
135 #define RBRA 60
|
|
136 #define LC 61
|
|
137 #define RC 62
|
|
138 #define COLON 63
|
|
139 #define SM 64
|
|
140 #define PERIOD 65
|
|
141 #define ARROW 66
|
|
142 #define CNAME 67
|
|
143 #define SASS 68
|
67
|
144 #define RSTRUCT 69
|
0
|
145
|
|
146 #define US 1
|
|
147 #define AS 100
|
|
148
|
|
149 #define FILERR 1
|
|
150 #define DCERR 2
|
|
151 #define STERR 3
|
|
152 #define EXERR 4
|
|
153 #define CNERR 5
|
|
154 #define CHERR 6
|
|
155 #define GSERR 7
|
|
156 #define LSERR 8
|
|
157 #define STRERR 9
|
|
158 #define LNERR 10
|
|
159 #define EOFERR 11
|
|
160 #define MCERR 12
|
|
161 #define INCERR 13
|
|
162 #define HPERR 14
|
|
163 #define TYERR 15
|
|
164 #define LVERR 16
|
|
165 #define UDERR 17
|
|
166 #define OPTION 18
|
|
167 #define REG_ERR 19
|
|
168 #define CODE_ERR 20
|
29
|
169 #define MSERR 21
|
0
|
170
|
|
171 #define GSYMS 9000
|
|
172 #define LSYMS 500
|
32
|
173 #define MSYMS 3000
|
0
|
174
|
|
175 #define HEAPSIZE 10000
|
|
176 /* #define CHEAPSIZE 3000 */
|
|
177 #define CHEAPSIZE 256000
|
|
178 #define LBUFSIZE 4096
|
34
|
179 #define MACROSIZE 16000
|
0
|
180
|
25
|
181 #define FILES 10
|
0
|
182 #define OUTPUT_FILE_NAME "mcout.s"
|
|
183
|
29
|
184 EXTERN int sym,ch,type,mode,stmode,gfree,lfree,mflag,lineno,glineno;
|
0
|
185 EXTERN int labelno,gpc,disp,reg_var,debug;
|
|
186 EXTERN int symval,args,init_vars,heap[HEAPSIZE];
|
|
187 EXTERN int blabel,clabel,dlabel,cslabel,ilabel,control,ac,ac2,lsrc,chk,asmf;
|
|
188 EXTERN int MAX_REGISTER_VAR;
|
|
189
|
|
190 EXTERN unsigned hash;
|
|
191
|
34
|
192 EXTERN int chsave;
|
|
193 EXTERN char *chptrsave;
|
29
|
194 EXTERN char linebuf[LBUFSIZE],namebuf[LBUFSIZE],*chptr;
|
0
|
195 EXTERN char *name,*cheapp,**av,/*obuf[320],*/*sptr,escape(void);
|
42
|
196 EXTERN int arg_offset,stat_no,size_of_int,disp_offset,endian,csvalue1;
|
0
|
197 EXTERN int code_arg_offset;
|
|
198 EXTERN int retlabel,retpending,retcont;
|
|
199
|
|
200 EXTERN FILE *obuf;
|
|
201
|
|
202 typedef struct nametable {
|
|
203 char *nm;
|
|
204 int sc,ty,dsp; } NMTBL;
|
|
205
|
30
|
206 EXTERN NMTBL mtable[MSYMS];
|
28
|
207 EXTERN NMTBL ntable[GSYMS+LSYMS];
|
|
208 EXTERN NMTBL *nptr,*gnptr;
|
0
|
209 EXTERN NMTBL *fnptr;
|
70
|
210 EXTERN int typedefed;
|
0
|
211
|
25
|
212 EXTERN struct {int fd,ln;char *name0;FILE *fcb;} *filep,filestack[FILES];
|
0
|
213 EXTERN char cheap[CHEAPSIZE];
|
34
|
214 EXTERN char *macropp,macro_buf[MACROSIZE];
|
0
|
215
|
61
|
216 extern void error(int n);
|
|
217 extern int size(int t);
|
|
218 extern int scalar(int t);
|
|
219 extern int list2(int e1, int e2);
|
|
220 extern int list3(int e1, int e2, int e3);
|
|
221 extern int list4(int e1, int e2, int e3,int e4);
|
|
222 extern int reverse0(int t1);
|
|
223 extern int assign_data(int e, int t, NMTBL *n,int offset);
|
|
224 extern int assign_expr0(int e1,int e2,int t,int type) ;
|
|
225 extern int assign_expr(int e1,int e2,int t,int type) ;
|
|
226 extern int append4(int p,int a1,int a2,int a3);
|
|
227
|
|
228
|
|
229
|
33
|
230 #define car(e) (heap[(int)(e)])
|
|
231
|
|
232 #define cadr(e) (heap[((int)(e))+1])
|
|
233
|
|
234 #define caddr(e) (heap[((int)(e))+2])
|
|
235
|
|
236 #define cadddr(e) (heap[((int)(e))+3])
|
|
237
|
66
|
238 #include "conv/conv.h"
|
|
239 #include "conv/c.h"
|
|
240 /*
|
59
|
241 #include "conv/c2cbc.h"
|
|
242 #include "conv/cbc2c.h"
|
|
243 #include "conv/null.h"
|
66
|
244 */
|
59
|
245
|
62
|
246 extern Converter *conv;
|
59
|
247
|
61
|
248
|
|
249 EXTERN void error(int n);
|
|
250 EXTERN int append4(int p,int a1,int a2,int a3);
|
|
251 EXTERN int assign_expr(int e1,int e2,int t,int type);
|
|
252 EXTERN int assign_expr0(int e1,int e2,int t,int type);
|
|
253 EXTERN int backdef(void);
|
|
254 EXTERN int fwdlabel(void);
|
|
255 EXTERN int get_register_var(void);
|
|
256 EXTERN int glist2(int e1,int e2);
|
|
257 EXTERN int integral(int t);
|
|
258 EXTERN int list2(int e1, int e2);
|
|
259 EXTERN int list3(int e1, int e2, int e3);
|
|
260 EXTERN int list4(int e1, int e2, int e3, int e4);
|
|
261 EXTERN int reverse0(int t1);
|
|
262 EXTERN int rplacad(int e, int n);
|
|
263 EXTERN int rplacadd(int e, int n);
|
|
264 EXTERN int rvalue_t(int e,int type);
|
|
265 EXTERN int scalar(int t);
|
|
266 EXTERN void bexpr(int e1, char cond, int l1);
|
|
267 EXTERN void def_label(int cslabel, int dlabel);
|
|
268 EXTERN void display_ntable(NMTBL *n, char *s);
|
|
269 EXTERN void exit(int l);
|
|
270 EXTERN void fwddef(int l);
|
|
271
|
33
|
272 /* end */
|