1 /* $Id: comm0.h,v 2.12 1994/06/24 13:21:52 ceriel Exp $ */
3 * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
4 * See the copyright notice in the ACK home directory, in the file "Copyright".
8 * All preprocessor based options/constants/functions
11 /* ========== ON/OFF options (use #define in mach0.c) ========== */
14 * The following options are available, to be set/removed in "mach0.c":
15 * THREE_PASS: three passes needed for branch optimization
16 * BYTES_REVERSED: lowest target address for word high-order byte
17 * WORDS_REVERSED: lowest target address for long high-order byte
18 * LISTING: include listing facilities
19 * RELOCATION: relocatable code generated
20 * DEBUG: for debugging purposes only
21 * TMPDIR: directory for temporary files
22 * ASLD: combined assembler/linker
25 /* ========== constants (use #undef, #define in mach0.c) ========== */
28 #define STRINGMAX 200 /* <= 256 */
33 /* Some character constants for parsing */
39 #define ISALPHA(c) (isalpha(c) || (c) == '_' || (c) == '.')
40 #define ISALNUM(c) (isalnum(c) || (c) == '_')
42 #define GENLAB "I" /* compiler generated labels */
44 #define valu_t short /* type of expression values */
45 #define ADDR_T unsigned short /* type of dot */
46 #define word_t short /* type of keyword value */
48 * NOTE: word_t is introduced to reduce the tokenfile size for machines
49 * with large expressions but smaller opcodes (68000)
55 #define machstart(x) /* nothing */
56 #define machfinish(x) /* nothing */
58 #define SETBASE(sp) ((long)(sp)->s_base)
62 /* ========== Machine dependent option/constant settings ========== */
66 /* ========== default option setting ========== */
70 separate linker only possible if relocation info produced
71 #endif /* RELOCATION */
78 /* ========== Machine independent type declarations ========== */
96 #define assert(ex) /* nothing */
100 #define assert(ex) {if (!(ex)) assert1();}
104 #define assert(ex) {if (!(ex)) assert2(__FILE__, __LINE__);}
107 #define CTRL(x) ((x) & 037)
109 #define lowb(z) ((int)(z) & 0xFF)
110 #define loww(z) ((int)(z) & 0xFFFF)
112 #define fitb(x) ((((x) + 0x80) & ~((int)0xFF)) == 0)
113 #define fitw(x) ((((x) + 0x8000L) & ~0xFFFFL) == 0)
115 #define fit(x) if (!(x)) nofit()
122 #define PASS_SYMB (pass != PASS_1)
123 #define PASS_RELO (pass != PASS_1)
127 #endif /* THREE_PASS */
130 #define RELOMOVE(a,b) /* empty */
132 #define RELOMOVE(a,b) {a = b; b = 0;}
135 /* symbol table management */
136 #define H_SIZE 307 /* hash size, must be od */
137 #define H_KEY (0*H_SIZE) /* key symbol headers */
138 #define H_LOCAL (1*H_SIZE) /* module symbol headers */
140 #define H_GLOBAL (2*H_SIZE) /* external symbol headers */
141 #define H_TOTAL (3*H_SIZE)
143 #define H_TOTAL (2*H_SIZE)
146 /* numeric label table management */
148 #define FB_HEAD (0*FB_SIZE)
149 #define FB_TAIL (1*FB_SIZE)
150 #define FB_BACK (2*FB_SIZE)
151 #define FB_FORW (3*FB_SIZE)
156 #define DOTGAIN DOTSCT->s_gain
158 /* ========== type declarations ========== */
165 typedef struct expr_t expr_t;
169 i_next; /* linked lists with same hash value */
172 * the i_type field is used for two different purposes:
173 * - the token type for keywords, returned by yylex()
174 * - the symbol type for IDENT and FBSYM tokens
176 valu_t i_valu; /* symbol value */
177 char *i_name; /* symbol name */
189 typedef struct common_t common_t;
191 typedef struct item_t item_t;
194 short s_flag; /* some flag bits */
195 ADDR_T s_base; /* section base */
196 ADDR_T s_size; /* section size */
197 ADDR_T s_comm; /* length of commons */
198 ADDR_T s_zero; /* delayed emit1(0) */
199 ADDR_T s_lign; /* section alignment */
200 long s_foff; /* section file offset */
201 item_t *s_item; /* points to section name */
203 ADDR_T s_gain; /* gain in PASS_2 */
207 typedef struct sect_t sect_t;
209 /* ========== flag field bits ========== */
212 #define BASED 1 /* at fixed position */
215 #define SYM_EXT 001 /* external symbols */
216 #define SYM_LOC 002 /* local symbols */
217 #define SYM_LAB 004 /* local, compiler-generated labels */
218 #define SYM_SMB 010 /* .symb symbols */
219 #define SYM_LIN 020 /* .line and .file */
220 #define SYM_SCT 040 /* section names */
221 #define SYM_DEF 073 /* default value */
224 * extra type bits out of S_ETC, internal use only
226 * - type not known at end of PASS_1 (S_VAR|S_UND)
227 * - value not known at end of PASS_2 (S_VAR|S_ABS)
233 /* should be tested by preprocessor
234 * due to error in preprocessor it cannot
235 * test performed at compiletime by a switch now
236 * #if (S_ETC|S_COM|S_VAR|S_DOT) != S_ETC
237 * incorrect type bits
241 /* parts of the a.out file */
248 #ifdef BYTES_REVERSED
249 #ifdef WORDS_REVERSED
250 #define MACHREL_BWR (RELBR|RELWR)
252 #define MACHREL_BWR (RELBR)
255 #ifdef WORDS_REVERSED
256 #define MACHREL_BWR (RELWR)
258 #define MACHREL_BWR (0)
262 extern FILE *fopen(); /* some systems don't have this in stdio.h */