summaryrefslogtreecommitdiff
path: root/as/const.h
blob: 1b98a8be2e38865623426efb8d528237716ef9d8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318

/* Speed and space hacks for BCC */
#ifdef __AS386_16__
#define LOW_BYTE	0	/* must be changed for big-endian */
#else

#define S_ALIGNMENT	sizeof(long)
#endif

/* const.h - constants for assembler */

/* major switches */

/* #define MC6809 */		/* generate 6809 code */
#ifndef MC6809
#define I80386			/* generate 80386 code */
#endif
#define MNSIZE			/* allow byte size in mnemonic, e.g. "movb" */
#undef SOS_EDOS			/* source OS is EDOS */

/* defaults */

#define DIRCHAR		'/'	/* character separating filename from dir */
#define INBUFSIZE	8192
#define SOS_EOLSTR	"\012"

/* defaults modified by switches */

#ifdef SOS_EDOS
# undef INBUFSIZE
# define INBUFSIZE	512
# undef SOS_EOLSTR
# define SOS_EOLSTR	"\015\012"
# define STAKSIZ	256	/* table grows up to stack less this */
#endif

#ifdef __AS386_16__
# undef INBUFSIZE
# define INBUFSIZE	512
# define STAKSIZ	512	/* table grows up to stack less this */
#endif

/* booleans */

#define FALSE		0
#define TRUE		1

/* ASCII constants */

#define ETB		23

/* C tricks */

#define EXTERN		extern
#define FORWARD		static
#define PRIVATE		static
#define PUBLIC
#define NUL_PTR		((void*)0)

/* O/S constants */

#define CREAT_PERMS	0666
#define EOF		(-1)
#define STDIN		0
#define STDOUT		1

enum
{
/* Register codes (internal to assembler). */
#ifdef I80386

/* Index regs must be first. */
    BPREG,
    BXREG,
    DIREG,
    SIREG,
#define MAX16BITINDREG	SIREG

    EAXREG,
    EBPREG,
    EBXREG,
    ECXREG,
    EDIREG,
    EDXREG,
    ESIREG,
    ESPREG,
#define MAXINDREG	ESPREG

    AXREG,
    CXREG,
    DXREG,
    SPREG,

    AHREG,
    ALREG,
    BHREG,
    BLREG,
    CHREG,
    CLREG,
    DHREG,
    DLREG,

    CSREG,
    DSREG,
    ESREG,
    FSREG,
    GSREG,
    SSREG,

    CR0REG,
    CR2REG,
    CR3REG,
    DR0REG,
    DR1REG,
    DR2REG,
    DR3REG,
    DR6REG,
    DR7REG,
    TR3REG,
    TR4REG,
    TR5REG,
    TR6REG,
    TR7REG,

    ST0REG,
    ST1REG,
    ST2REG,
    ST3REG,
    ST4REG,
    ST5REG,
    ST6REG,
    ST7REG,
#endif /* I80386 */

#ifdef MC6809

/* Index regs must be first, then PC. */
    SREG,
    UREG,
    XREG,
    YREG,
#define MAXINDREG	YREG

    PCREG,
    AREG,
    BREG,
    CCREG,
    DPREG,
    DREG,
#endif /* MC6809 */

    NOREG
};

#ifdef I80386
enum
{
/* Type and size keywords. */
    BYTEOP,
    DWORDOP,
    FWORDOP,
    FAROP,
    PTROP,
    PWORDOP,
    QWORDOP,
    TBYTEOP,
    WORDOP
};
#endif /* I80386 */

/* special chars */

#define EOL		0
#define MACROCHAR	'?'

enum
{
/* Symbol codes. */

/* The first 2 must be from chars in identifiers. */
    IDENT,
    INTCONST,

/* The next few are best for other possibly-multi-char tokens. */
    ADDOP,			/* also ++ */
    BINCONST,
    CHARCONST,
    GREATERTHAN,		/* also >> and context-sensitive */
    HEXCONST,
    LESSTHAN,			/* also << and context-sensitive */
    SUBOP,			/* also -- */
    WHITESPACE,

    ANDOP,
    COMMA,
    EOLSYM,
    EQOP,
    IMMEDIATE,
    INDIRECT,
    LBRACKET,
    LPAREN,
    MACROARG,
    NOTOP,
    OROP,
    OTHERSYM,
    POSTINCOP,
    PREDECOP,
    RBRACKET,
    RPAREN,
    SLASH,			/* context-sensitive */
    SLOP,
    SROP,
    STAR,			/* context-sensitive */
    STRINGCONST,
    COLON
};

/* symbol table entry */

				/* type entry contains following flags */
#define ENTBIT		(1<<0)	/* entry point (= OBJ_N_MASK) */
#define COMMBIT		(1<<1)	/* common */
#define LABIT		(1<<2)	/* label (a PC location or defined by EQU) */
#define MNREGBIT	(1<<3)	/* mnemonic for op or pseudo-op, or register */
#define MACBIT		(1<<4)	/* macro */
#define REDBIT		(1<<5)	/* redefined (if with LABIT or VARBIT), to do
				 * with SA_MASK (if with COMMBIT), otherwise
				 * means globl */
#define VARBIT		(1<<6)	/* variable (i.e. something defined by SET) */
#define EXPBIT		(1<<7)	/* exported (= OBJ_E_MASK) */

				/* data entry contains following flags, valid */
				/* for expressions as well as syms */
#define PAGE1		(1<<0)	/* page 1 machine op = MNREGBIT | PAGE1 */
#define PAGE2		(1<<1)	/* page 2 machine op = MNREGBIT | PAGE2 */
#define REGBIT		(1<<2)	/* register = MNREGBIT | REGBIT */
#define SIZEBIT		(1<<3)	/* sizing mnemonic = MNREGBIT | SIZEBIT */
#define SEGM		0x0F	/* 1st 4 bits reused for segment if !MNREGBIT */
#define RELBIT		(1<<4)	/* relative (= OBJ_A_MASK) */
#define FORBIT		(1<<5)	/* forward referenced */
#define IMPBIT		(1<<6)	/* imported (= OBJ_I_MASK) */
#define UNDBIT		(1<<7)	/* undefined */

/* object code format (Introl) */

#define OBJ_SEGSZ_TWO	0x02	/* size 2 code for segment size descriptor */

#define OBJ_MAX_ABS_LEN	64	/* max length of chunk of absolute code */

#define OBJ_ABS		0x40	/* absolute code command */
#define OBJ_OFFSET_REL	0x80	/* offset relocation command */
#define OBJ_SET_SEG	0x20	/* set segment command */
#define OBJ_SKIP_1	0x11	/* skip with 1 byte count */
#define OBJ_SKIP_2	0x12	/* skip with 2 byte count */
#define OBJ_SKIP_4	0x13	/* skip with 4 byte count */
#define OBJ_SYMBOL_REL	0xC0	/* symbol relocation command */

#define OBJ_A_MASK	0x10	/* absolute bit(symbols) */
#if OBJ_A_MASK - RELBIT		/* must match internal format (~byte 1 -> 0) */
oops - RELBIT misplaced
#endif
#define OBJ_E_MASK	0x80	/* exported bit (symbols) */
#if OBJ_E_MASK - EXPBIT		/* must match internal format (byte 0 -> 0) */
oops - EXPBIT misplaced
#endif
#define OBJ_I_MASK	0x40	/* imported bit (symbols) */
#if OBJ_I_MASK - IMPBIT		/* must match internal format (byte 1 -> 0) */
oops - IMPBIT misplaced
#endif
#define OBJ_N_MASK	0x01	/* entry bit (symbols) */
#if OBJ_N_MASK - ENTBIT		/* must match internal format (byte 0 -> 1) */
oops - ENTBIT misplaced
#endif
#define OBJ_SA_MASK	0x20	/* size allocation bit (symbols) */
#define OBJ_SZ_ONE	0x40	/* size one code for symbol value */
#define OBJ_SZ_TWO	0x80	/* size two code for symbol value */
#define OBJ_SZ_FOUR	0xC0	/* size four code for symbol value */

#define OBJ_R_MASK	0x20	/* PC-rel bit (off & sym reloc commands) */
#define OBJ_SEGM_MASK	0x0F	/* segment mask (symbols, off reloc command) */

#define OBJ_OF_MASK	0x03	/* offset size code for symbol reloc */
#define OBJ_S_MASK	0x04	/* symbol number size code for symbol reloc */

#define SYMLIS_NAMELEN	26
#define SYMLIS_LEN	(sizeof (struct sym_listing_s))

#define FILNAMLEN	64	/* max length of a file name */
#define LINLEN		256	/* max length of input line */
#define LINUM_LEN	5	/* length of formatted line number */

#define SPTSIZ		1024	/* number of symbol ptrs */
				/* pseudo-op flags */
#define POPHI		1	/* set to print hi byte of adr */
#define POPLO		2	/* to print lo byte of ADR */
#define POPLC		4	/* to print LC */
#define POPLONG		8	/* to print high word of ADR */
#define MAXBLOCK	8	/* max nesting level of BLOCK stack */
#define MAXGET		8	/* max nesting level of GET stack */
#define MAXIF		8	/* max nesting level of IF stack */
#define MACPSIZ		(128 / sizeof (struct schain_s))
				/* size of macro param buffer */
#define MAXMAC		8	/* max nesting level of macro stack */
#define NLOC		16	/* number of location counters */
#ifdef I80386
#define NO_SIB		0340	/* illegal sib (3 with 4) to mean no sib */
#endif

/* special segments */

#define BSSLOC		3
#define DATALOC		3
#define DPLOC		2
#define STRLOC		1
#define TEXTLOC		0

#include "errors.h"