1 /*	File defs.h: 2.1 (83/03/21,02:07:20) */
2 
3 #ifndef INCLUDE_DEFS_H
4 #define INCLUDE_DEFS_H
5 
6 /*
7  *	INTSIZE is the size of an integer in the target machine
8  *	BYTEOFF is the offset of an byte within an integer on the
9  *		target machine. (ie: 8080,pdp11 = 0, 6809 = 1,
10  *		360 = 3)
11  *	This compiler assumes that an integer is the SAME length as
12  *	a pointer - in fact, the compiler uses INTSIZE for both.
13  */
14 
15 #define	INTSIZE	2
16 #define	BYTEOFF	0
17 
18 /* pseudo instruction arg types */
19 #define T_NOP		-1
20 #define T_VALUE		 1
21 #define T_LABEL		 2
22 #define T_SYMBOL	 3
23 #define T_PTR		 4
24 #define T_STACK		 5
25 #define T_STRING	 6
26 #define T_LIB		 7
27 #define T_SIZE		 8
28 #define T_BANK		 9
29 #define T_VRAM		10
30 #define T_PAL		11
31 
32 /* basic pseudo instructions */
33 #define I_LDB		 1
34 #define I_LDBP		 2
35 #define I_LDW		 3
36 #define I_LDWI		 4
37 #define I_LDWP		 5
38 #define I_STB		 6
39 #define I_STBPS		 7
40 #define I_STW		 8
41 #define I_STWPS		 9
42 #define I_ADDWI		 10
43 #define I_ADDWS		 11
44 #define I_ADDMI		 12
45 #define I_SUBWI		 13
46 #define I_SUBWS		 14
47 #define I_ORWS		 15
48 #define I_EORWS		 16
49 #define I_ANDWS		 17
50 #define I_ASLW		 18
51 #define I_ASLWS		 19
52 #define I_ASRW		 20
53 #define I_COMW		 21
54 #define I_NEGW		 22
55 #define I_SWAPW		 23
56 #define I_EXTW		 24
57 #define I_BOOLW		 25
58 #define I_NOTW		 26
59 #define I_JMP		 27
60 #define I_JSR		 28
61 #define I_RTS		 29
62 #define I_CALL		 30
63 #define I_CALLS      31
64 #define I_PUSHW      32
65 #define I_POPW       33
66 #define I_TSTW       34
67 #define I_LBRA       35
68 #define I_LBEQ       36
69 #define I_LBNE       37
70 #define I_BANK       38
71 #define I_OFFSET     39
72 #define I_FARPTR     40
73 #define I_FARPTR_I   41
74 #define I_FARPTR_GET 42
75 #define I_FGETB      43
76 #define I_FGETW      44
77 #define I_VGETW      45
78 #define I_VPUTW      46
79 #define I_NARGS      47
80 #define I_PHB        48
81 #define I_PHW        49
82 #define I_INCW       50
83 #define I_ANDWI      51
84 #define I_ORWI       52
85 #define I_ADDW       53
86 #define I_SUBW       54
87 
88 /* optimized pseudo instructions */
89 #define X_MASK		0xFFFF0
90 #define X_LDB		0x10000
91 #define X_LDB_S		0x10001
92 #define X_LDB_P		0x10002
93 #define X_LDW_S		0x10011
94 #define X_LDD_I		0x10100
95 #define X_LDD_B		0x10101
96 #define X_LDD_W		0x10102
97 #define X_LDD_S_B	0x10105
98 #define X_LDD_S_W	0x10106
99 #define X_LEA_S		0x10021
100 #define X_PEA		0x10030
101 #define X_PEA_S		0x10031
102 #define X_PUSHW_A	0x10040
103 #define X_STB_S		0x10051
104 #define X_STW_S		0x10061
105 #define X_STBI_S	0x10071
106 #define X_STWI_S	0x10081
107 #define X_ADDW_S	0x10091
108 #define X_INCW_S	0x100A1
109 #define X_DECW_S	0x100B1
110 
111 
112 #define	FOREVER	for(;;)
113 #define	FALSE	0
114 #define	TRUE	1
115 #define	NO	0
116 #define	YES	1
117 
118 /* miscellaneous */
119 
120 #define	EOS	0
121 #define	EOL	10
122 #define	BKSP	8
123 #define	CR	13
124 #define	FFEED	12
125 #define TAB	9
126 
127 #define FILENAMESIZE	256
128 
129 /* symbol table parameters */
130 
131 /* old values, too restrictive
132  * #define	SYMSIZ	14
133  * #define	SYMTBSZ	32768
134  * #define	NUMGLBS	1500
135  */
136 #define SYMSIZ	32
137 #define SYMTBSZ	131072
138 #define NUMGLBS	2048
139 
140 #define	STARTGLB	symtab
141 #define	ENDGLB	(STARTGLB+NUMGLBS*SYMSIZ)
142 #define	STARTLOC	(ENDGLB+SYMSIZ)
143 #define	ENDLOC	(symtab+SYMTBSZ-SYMSIZ)
144 
145 /* symbol table entry format */
146 
147 /* old values, too restrictive
148  * #define	NAME	0
149  * #define	IDENT	9
150  * #define	TYPE	10
151  * #define	STORAGE	11
152  * #define	OFFSET	12
153  */
154 
155 #define NAME    0
156 #define IDENT   26
157 #define TYPE    27
158 #define STORAGE 28
159 #define FAR     29
160 #define OFFSET  30
161 
162 /* system-wide name size (for symbols) */
163 
164 /* old values, too restrictive
165  * #define	NAMESIZE	9
166  * #define	NAMEMAX	8
167  */
168 
169 #define NAMESIZE	26
170 #define NAMEMAX	25
171 
172 /* possible entries for "ident" */
173 
174 #define	VARIABLE	1
175 #define	ARRAY	2
176 #define	POINTER	3
177 #define	FUNCTION	4
178 
179 /* possible entries for "type" */
180 
181 #define	CCHAR	1
182 #define	CINT	2
183 
184 /* possible entries for storage */
185 
186 #define	PUBLIC	1
187 #define	AUTO	2
188 #define	EXTERN	3
189 
190 #define	STATIC	4
191 #define	LSTATIC	5
192 #define	DEFAUTO	6
193 #define	CONST	7
194 
195 #define WRITTEN 128
196 
197 /* "do"/"for"/"while"/"switch" statement stack */
198 
199 #define	WSTABSZ	100
200 #define	WSSIZ	7
201 #define	WSMAX	ws+WSTABSZ-WSSIZ
202 
203 /* entry offsets in "do"/"for"/"while"/"switch" stack */
204 
205 #define	WSSYM	0
206 #define	WSSP	1
207 #define	WSTYP	2
208 #define	WSCASEP	3
209 #define	WSTEST	3
210 #define	WSINCR	4
211 #define	WSDEF	4
212 #define	WSBODY	5
213 #define	WSTAB	5
214 #define	WSEXIT	6
215 
216 /* possible entries for "wstyp" */
217 
218 #define	WSWHILE	0
219 #define	WSFOR	1
220 #define	WSDO	2
221 #define	WSSWITCH	3
222 
223 /* "switch" label stack */
224 
225 #define	SWSTSZ	100
226 
227 /* literal pool */
228 
229 #define	LITABSZ	8192
230 #define	LITMAX	LITABSZ-1
231 
232 /* input string */
233 
234 #define	LITMAX2	LITABSZ-1
235 
236 /* input line */
237 
238 #define	LINESIZE	150
239 #define	LINEMAX	(LINESIZE-1)
240 #define	MPMAX	LINEMAX
241 
242 /* macro (define) pool */
243 
244 #define	MACQSIZE	16384
245 #define	MACMAX	(MACQSIZE-1)
246 
247 /* "include" stack */
248 
249 #define	INCLSIZ	3
250 
251 /* statement types (tokens) */
252 
253 #define	STIF	1
254 #define	STWHILE	2
255 #define	STRETURN	3
256 #define	STBREAK	4
257 #define	STCONT	5
258 #define	STASM	6
259 #define	STEXP	7
260 #define	STDO	8
261 #define	STFOR	9
262 #define	STSWITCH	10
263 
264 #define DEFLIB	""
265 
266 /* pseudo instruction structure */
267 
268 typedef struct {
269 	int   code;
270 	int   type;
271 	int   data;
272 	int   imm;
273 	int   arg[3];
274 	char *sym;
275 } INS;
276 
277 /* constant array struct */
278 
279 #define MAX_CONST        1024
280 #define MAX_CONST_VALUE  8192
281 #define MAX_CONST_DATA  65536
282 
283 struct const_array {
284 	char *sym;
285 	int   typ;
286 	int   size;
287 	int   data;
288 };
289 
290 /* fastcall func struct */
291 
292 struct fastcall {
293 	struct fastcall *next;
294 	char   fname[NAMESIZE];
295 	int    nargs;
296 	int    argsize;
297 	int    flags;
298 	char   argtype[8];
299 	char   argname[8][NAMESIZE];
300 };
301 
302 #endif
303