]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gas/as.h
Ran "indent", for GNU coding style; some code & comments still need fixup.
[thirdparty/binutils-gdb.git] / gas / as.h
CommitLineData
fecd2382 1/* as.h - global header file
3340f7e5 2 Copyright (C) 1987, 1990, 1991, 1992 Free Software Foundation, Inc.
6efd877d 3
a39116f1 4 This file is part of GAS, the GNU Assembler.
6efd877d 5
a39116f1
RP
6 GAS is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
9 any later version.
6efd877d 10
a39116f1
RP
11 GAS is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
6efd877d 15
a39116f1
RP
16 You should have received a copy of the GNU General Public License
17 along with GAS; see the file COPYING. If not, write to
18 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
fecd2382
RP
19
20#define GAS 1
a39116f1 21#include <ansidecl.h>
fecd2382
RP
22#include "host.h"
23#include "flonum.h"
24
6efd877d
KR
25#ifndef __STDC__
26#define volatile /**/
fecd2382 27#ifndef const
6efd877d 28#define const /**/
fecd2382
RP
29#endif /* const */
30#endif /* __STDC__ */
31
32#ifdef __GNUC__
33#define alloca __builtin_alloca
34#define register
35#endif /* __GNUC__ */
36
37#ifndef __LINE__
38#define __LINE__ "unknown"
39#endif /* __LINE__ */
40
41#ifndef __FILE__
42#define __FILE__ "unknown"
43#endif /* __FILE__ */
44
45/*
46 * I think this stuff is largely out of date. xoxorich.
47 *
48 * CAPITALISED names are #defined.
49 * "lowercaseH" is #defined if "lowercase.h" has been #include-d.
50 * "lowercaseT" is a typedef of "lowercase" objects.
51 * "lowercaseP" is type "pointer to object of type 'lowercase'".
52 * "lowercaseS" is typedef struct ... lowercaseS.
53 *
54 * #define DEBUG to enable all the "know" assertion tests.
55 * #define SUSPECT when debugging.
56 * #define COMMON as "extern" for all modules except one, where you #define
57 * COMMON as "".
58 * If TEST is #defined, then we are testing a module: #define COMMON as "".
59 */
60
61/* These #defines are for parameters of entire assembler. */
62
63/* #define SUSPECT JF remove for speed testing */
64/* These #includes are for type definitions etc. */
65
66#include <stdio.h>
67#include <assert.h>
c593cf41 68
3340f7e5
RP
69#define obstack_chunk_alloc xmalloc
70#define obstack_chunk_free xfree
fecd2382 71
a39116f1
RP
72#define xfree free
73
74#define BAD_CASE(value) \
75{ \
76 as_fatal("Case value %d unexpected at line %d of file \"%s\"\n", \
77 value, __LINE__, __FILE__); \
78 }
fecd2382 79\f
6efd877d 80
fecd2382
RP
81/* These are assembler-wide concepts */
82
83
84#ifndef COMMON
85#ifdef TEST
86#define COMMON /* declare our COMMONs storage here. */
87#else
88#define COMMON extern /* our commons live elswhere */
89#endif
90#endif
a39116f1 91/* COMMON now defined */
6efd877d 92#define DEBUG /* temporary */
fecd2382 93
c8c7e0bf
KR
94#ifdef BROKEN_ASSERT
95/* turn off all assertion checks */
96#undef DEBUG
97#define NDEBUG
98#endif
99
fecd2382
RP
100#ifdef DEBUG
101#undef NDEBUG
ace68c4e 102#ifndef know
fecd2382 103#define know(p) assert(p) /* Verify our assumptions! */
ace68c4e 104#endif /* not yet defined */
fecd2382
RP
105#else
106#define know(p) /* know() checks are no-op.ed */
107#endif
fecd2382
RP
108\f
109/* input_scrub.c */
110
111/*
112 * Supplies sanitised buffers to read.c.
113 * Also understands printing line-number part of error messages.
114 */
fecd2382 115\f
6efd877d 116
fecd2382
RP
117/* subsegs.c Sub-segments. Also, segment(=expression type)s.*/
118
119/*
120 * This table describes the use of segments as EXPRESSION types.
121 *
122 * X_seg X_add_symbol X_subtract_symbol X_add_number
123 * SEG_ABSENT no (legal) expression
124 * SEG_PASS1 no (defined) "
125 * SEG_BIG * > 32 bits const.
126 * SEG_ABSOLUTE 0
127 * SEG_DATA * 0
128 * SEG_TEXT * 0
129 * SEG_BSS * 0
130 * SEG_UNKNOWN * 0
131 * SEG_DIFFERENCE 0 * 0
132 * SEG_REGISTER *
133 *
134 * The blank fields MUST be 0, and are nugatory.
135 * The '0' fields MAY be 0. The '*' fields MAY NOT be 0.
136 *
137 * SEG_BIG: X_add_number is < 0 if the result is in
138 * generic_floating_point_number. The value is -'c' where c is the
139 * character that introduced the constant. e.g. "0f6.9" will have -'f'
140 * as a X_add_number value.
141 * X_add_number > 0 is a count of how many littlenums it took to
142 * represent a bignum.
143 * SEG_DIFFERENCE:
144 * If segments of both symbols are known, they are the same segment.
145 * X_add_symbol != X_sub_symbol (then we just cancel them, => SEG_ABSOLUTE).
146 */
147
ace68c4e 148
58721107 149#ifdef MANY_SEGMENTS
c8c7e0bf 150#include "bfd.h"
ace68c4e 151#define N_SEGMENTS 10
58721107 152#define SEG_NORMAL(x) ((x) >= SEG_E0 && (x) <= SEG_E9)
ace68c4e 153#define SEG_LIST SEG_E0,SEG_E1,SEG_E2,SEG_E3,SEG_E4,SEG_E5,SEG_E6,SEG_E7,SEG_E8,SEG_E9
ada269da
SC
154#define SEG_DATA SEG_E1
155#define SEG_TEXT SEG_E0
156#define SEG_BSS SEG_E2
58721107 157#else
ace68c4e 158#define N_SEGMENTS 3
58721107 159#define SEG_NORMAL(x) ((x) == SEG_TEXT || (x) == SEG_DATA || (x) == SEG_BSS)
ace68c4e 160#define SEG_LIST SEG_TEXT,SEG_DATA,SEG_BSS
58721107
SC
161#endif
162
6efd877d
KR
163typedef enum _segT
164 {
165 SEG_ABSOLUTE = 0,
166 SEG_LIST,
167 SEG_UNKNOWN,
168 SEG_ABSENT, /* Mythical Segment (absent): NO expression seen. */
169 SEG_PASS1, /* Mythical Segment: Need another pass. */
170 SEG_GOOF, /* Only happens if AS has a logic error. */
171 /* Invented so we don't crash printing */
172 /* error message involving weird segment. */
173 SEG_BIG, /* Bigger than 32 bits constant. */
174 SEG_DIFFERENCE, /* Mythical Segment: absolute difference. */
175 SEG_DEBUG, /* Debug segment */
176 SEG_NTV, /* Transfert vector preload segment */
177 SEG_PTV, /* Transfert vector postload segment */
178 SEG_REGISTER, /* Mythical: a register-valued expression */
179 } segT;
fecd2382
RP
180
181#define SEG_MAXIMUM_ORDINAL (SEG_REGISTER)
182
183typedef int subsegT;
184
6efd877d 185COMMON subsegT now_subseg;
a39116f1 186/* What subseg we are accreting now? */
fecd2382
RP
187
188
6efd877d 189COMMON segT now_seg;
a39116f1
RP
190/* Segment our instructions emit to. */
191/* Only OK values are SEG_TEXT or SEG_DATA. */
fecd2382
RP
192
193
194extern char *const seg_name[];
195extern int section_alignment[];
196
197
198/* relax() */
199
6efd877d
KR
200typedef enum _relax_state
201 {
202 rs_fill = 1, /* Variable chars to be repeated fr_offset times.
09952cd9
KR
203 Fr_symbol unused. Used with fr_offset == 0 for a
204 constant length frag. */
6efd877d
KR
205
206 rs_align, /* Align: Fr_offset: power of 2. 1 variable char: fill
617ee8ed 207 character. */
6efd877d
KR
208
209 rs_org, /* Org: Fr_offset, fr_symbol: address. 1 variable char: fill
617ee8ed 210 character. */
6efd877d
KR
211
212 rs_machine_dependent,
213
fecd2382 214#ifndef WORKING_DOT_WORD
6efd877d 215 rs_broken_word, /* JF: gunpoint */
fecd2382 216#endif
6efd877d 217 } relax_stateT;
fecd2382
RP
218
219/* typedef unsigned char relax_substateT; */
220/* JF this is more likely to leave the end of a struct frag on an align
221 boundry. Be very careful with this. */
222typedef unsigned long relax_substateT;
223
6efd877d 224typedef unsigned long relax_addressT; /* Enough bits for address. */
a39116f1 225/* Still an integer type. */
fecd2382 226\f
6efd877d 227
fecd2382
RP
228/* frags.c */
229
230/*
231 * A code fragment (frag) is some known number of chars, followed by some
232 * unknown number of chars. Typically the unknown number of chars is an
233 * instruction address whose size is yet unknown. We always know the greatest
234 * possible size the unknown number of chars may become, and reserve that
235 * much room at the end of the frag.
236 * Once created, frags do not change address during assembly.
237 * We chain the frags in (a) forward-linked list(s). The object-file address
238 * of the 1st char of a frag is generally not known until after relax().
239 * Many things at assembly time describe an address by {object-file-address
240 * of a particular frag}+offset.
6efd877d 241
fecd2382 242 BUG: it may be smarter to have a single pointer off to various different
6efd877d 243 notes for different frag kinds. See how code pans
fecd2382
RP
244 */
245struct frag /* a code fragment */
246{
6efd877d
KR
247 unsigned long fr_address; /* Object file address. */
248 struct frag *fr_next; /* Chain forward; ascending address order. */
249 /* Rooted in frch_root. */
250
251 long fr_fix; /* (Fixed) number of chars we know we have. */
252 /* May be 0. */
253 long fr_var; /* (Variable) number of chars after above. */
254 /* May be 0. */
255 struct symbol *fr_symbol; /* For variable-length tail. */
256 long fr_offset; /* For variable-length tail. */
257 char *fr_opcode; /*->opcode low addr byte,for relax()ation*/
258 relax_stateT fr_type; /* What state is my tail in? */
259 relax_substateT fr_subtype;
260 /* These are needed only on the NS32K machines */
261 char fr_pcrel_adjust;
262 char fr_bsr;
a39116f1 263#ifndef NO_LISTING
6efd877d 264 struct list_info_struct *line;
a39116f1 265#endif
6efd877d
KR
266 char fr_literal[1]; /* Chars begin here. */
267 /* One day we will compile fr_literal[0]. */
fecd2382 268};
6efd877d 269
fecd2382 270#define SIZEOF_STRUCT_FRAG \
a39116f1
RP
271((int)zero_address_frag.fr_literal-(int)&zero_address_frag)
272/* We want to say fr_literal[0] above. */
fecd2382
RP
273
274typedef struct frag fragS;
275
6efd877d 276COMMON fragS *frag_now; /* -> current frag we are building. */
a39116f1
RP
277/* This frag is incomplete. */
278/* It is, however, included in frchain_now. */
279/* Frag_now->fr_fix is bogus. Use: */
fecd2382
RP
280/* Virtual frag_now->fr_fix==obstack_next_free(&frags)-frag_now->fr_literal.*/
281
282COMMON fragS zero_address_frag; /* For foreign-segment symbol fixups. */
6efd877d 283COMMON fragS bss_address_frag; /* For local common (N_BSS segment) fixups. */
fecd2382
RP
284
285/* main program "as.c" (command arguments etc) */
286
09952cd9 287COMMON char flagseen[128]; /* ['x'] TRUE if "-x" seen. */
fecd2382 288
6efd877d 289COMMON char *out_file_name; /* name of emitted object file */
fecd2382 290
09952cd9
KR
291COMMON int need_pass_2; /* TRUE if we need a second pass. */
292
293COMMON int linkrelax; /* TRUE if we should do no relaxing, and
294 leave lots of padding. */
fecd2382 295
6efd877d
KR
296typedef struct
297 {
298 char *poc_name; /* assembler mnemonic, lower case, no '.' */
299 void (*poc_handler) (); /* Do the work */
300 int poc_val; /* Value to pass to handler */
301 }
302
303pseudo_typeS;
fecd2382 304
6efd877d 305#ifdef __STDC__
fecd2382 306
6efd877d
KR
307int had_errors (void);
308int had_warnings (void);
309void as_bad (const char *Format,...);
310void as_fatal (const char *Format,...);
311void as_tsktsk (const char *Format,...);
312void as_warn (const char *Format,...);
fecd2382
RP
313
314#else
315
6efd877d
KR
316int had_errors ();
317int had_warnings ();
318void as_bad ();
319void as_fatal ();
320void as_tsktsk ();
321void as_warn ();
fecd2382
RP
322
323#endif /* __STDC__ & !NO_STDARG */
324
6efd877d
KR
325#ifdef __STDC__
326
327char *app_push (void);
328char *atof_ieee (char *str, int what_kind, LITTLENUM_TYPE * words);
329char *input_scrub_include_file (char *filename, char *position);
330char *input_scrub_new_file (char *filename);
331char *input_scrub_next_buffer (char **bufp);
332char *strstr (const char *s, const char *wanted);
333char *xmalloc (int size);
334char *xrealloc (char *ptr, long n);
335int do_scrub_next_char (int (*get) (), void (*unget) ());
336int gen_to_words (LITTLENUM_TYPE * words, int precision, long exponent_bits);
337int had_err (void);
338int had_errors (void);
339int had_warnings (void);
340int ignore_input (void);
341int scrub_from_file (void);
342int scrub_from_file (void);
343int scrub_from_string (void);
344int seen_at_least_1_file (void);
345void app_pop (char *arg);
346void as_howmuch (FILE * stream);
347void as_perror (char *gripe, char *filename);
348void as_where (void);
349void bump_line_counters (void);
350void do_scrub_begin (void);
351void input_scrub_begin (void);
352void input_scrub_close (void);
353void input_scrub_end (void);
354void int_to_gen (long x);
355void new_logical_line (char *fname, int line_number);
356void scrub_to_file (int ch);
357void scrub_to_string (int ch);
358void subseg_change (segT seg, int subseg);
359void subseg_new (segT seg, subsegT subseg);
360void subsegs_begin (void);
fecd2382 361
3340f7e5 362#else /* not __STDC__ */
fecd2382 363
6efd877d
KR
364char *app_push ();
365char *atof_ieee ();
366char *input_scrub_include_file ();
367char *input_scrub_new_file ();
368char *input_scrub_next_buffer ();
369char *strstr ();
370char *xmalloc ();
371char *xrealloc ();
372int do_scrub_next_char ();
373int gen_to_words ();
374int had_err ();
375int had_errors ();
376int had_warnings ();
377int ignore_input ();
378int scrub_from_file ();
379int scrub_from_file ();
380int scrub_from_string ();
381int seen_at_least_1_file ();
382void app_pop ();
383void as_howmuch ();
384void as_perror ();
385void as_where ();
386void bump_line_counters ();
387void do_scrub_begin ();
388void input_scrub_begin ();
389void input_scrub_close ();
390void input_scrub_end ();
391void int_to_gen ();
392void new_logical_line ();
393void scrub_to_file ();
394void scrub_to_string ();
395void subseg_change ();
396void subseg_new ();
397void subsegs_begin ();
fecd2382 398
3340f7e5 399#endif /* not __STDC__ */
fecd2382 400
a39116f1 401/* this one starts the chain of target dependant headers */
fecd2382
RP
402#include "targ-env.h"
403
a39116f1 404/* these define types needed by the interfaces */
fecd2382 405#include "struc-symbol.h"
c593cf41
SC
406/*#include "aout/reloc.h"*/
407
fecd2382
RP
408#include "write.h"
409#include "expr.h"
410#include "frags.h"
411#include "hash.h"
412#include "read.h"
413#include "symbols.h"
414
415#include "tc.h"
416#include "obj.h"
417
c593cf41
SC
418#include "listing.h"
419
fecd2382
RP
420/*
421 * Local Variables:
422 * comment-column: 0
423 * fill-column: 131
424 * End:
425 */
426
a39116f1 427/* end of as.h */