changes, what else?
[deliverable/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.
a39116f1
RP
3
4 This file is part of GAS, the GNU Assembler.
5
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.
10
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.
15
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
3340f7e5 25#if __STDC__ != 1
fecd2382
RP
26#define volatile /**/
27#ifndef const
28#define const /**/
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
RP
79
80\f
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 */
fecd2382
RP
92#define DEBUG /* temporary */
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 */
115
116\f
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
617ee8ed 163typedef enum _segT {
fecd2382 164 SEG_ABSOLUTE = 0,
ace68c4e 165 SEG_LIST,
fecd2382
RP
166 SEG_UNKNOWN,
167 SEG_ABSENT, /* Mythical Segment (absent): NO expression seen. */
168 SEG_PASS1, /* Mythical Segment: Need another pass. */
169 SEG_GOOF, /* Only happens if AS has a logic error. */
a39116f1
RP
170 /* Invented so we don't crash printing */
171 /* error message involving weird segment. */
fecd2382
RP
172 SEG_BIG, /* Bigger than 32 bits constant. */
173 SEG_DIFFERENCE, /* Mythical Segment: absolute difference. */
174 SEG_DEBUG, /* Debug segment */
175 SEG_NTV, /* Transfert vector preload segment */
176 SEG_PTV, /* Transfert vector postload segment */
177 SEG_REGISTER, /* Mythical: a register-valued expression */
178} segT;
179
180#define SEG_MAXIMUM_ORDINAL (SEG_REGISTER)
181
182typedef int subsegT;
183
184COMMON subsegT now_subseg;
a39116f1 185/* What subseg we are accreting now? */
fecd2382
RP
186
187
188COMMON segT now_seg;
a39116f1
RP
189/* Segment our instructions emit to. */
190/* Only OK values are SEG_TEXT or SEG_DATA. */
fecd2382
RP
191
192
193extern char *const seg_name[];
194extern int section_alignment[];
195
196
197/* relax() */
198
617ee8ed 199typedef enum _relax_state {
09952cd9
KR
200 rs_fill = 1, /* Variable chars to be repeated fr_offset times.
201 Fr_symbol unused. Used with fr_offset == 0 for a
202 constant length frag. */
617ee8ed
RP
203
204 rs_align, /* Align: Fr_offset: power of 2. 1 variable char: fill
205 character. */
a39116f1 206
617ee8ed
RP
207 rs_org, /* Org: Fr_offset, fr_symbol: address. 1 variable char: fill
208 character. */
209
fecd2382 210 rs_machine_dependent,
a39116f1 211
fecd2382
RP
212#ifndef WORKING_DOT_WORD
213 rs_broken_word, /* JF: gunpoint */
214#endif
617ee8ed 215} relax_stateT;
fecd2382
RP
216
217/* typedef unsigned char relax_substateT; */
218/* JF this is more likely to leave the end of a struct frag on an align
219 boundry. Be very careful with this. */
220typedef unsigned long relax_substateT;
221
222typedef unsigned long relax_addressT;/* Enough bits for address. */
a39116f1 223/* Still an integer type. */
fecd2382
RP
224
225\f
226/* frags.c */
227
228/*
229 * A code fragment (frag) is some known number of chars, followed by some
230 * unknown number of chars. Typically the unknown number of chars is an
231 * instruction address whose size is yet unknown. We always know the greatest
232 * possible size the unknown number of chars may become, and reserve that
233 * much room at the end of the frag.
234 * Once created, frags do not change address during assembly.
235 * We chain the frags in (a) forward-linked list(s). The object-file address
236 * of the 1st char of a frag is generally not known until after relax().
237 * Many things at assembly time describe an address by {object-file-address
238 * of a particular frag}+offset.
a39116f1 239
fecd2382 240 BUG: it may be smarter to have a single pointer off to various different
a39116f1 241 notes for different frag kinds. See how code pans
fecd2382
RP
242 */
243struct frag /* a code fragment */
244{
245 unsigned long fr_address; /* Object file address. */
246 struct frag *fr_next; /* Chain forward; ascending address order. */
a39116f1
RP
247 /* Rooted in frch_root. */
248
fecd2382 249 long fr_fix; /* (Fixed) number of chars we know we have. */
a39116f1 250 /* May be 0. */
fecd2382 251 long fr_var; /* (Variable) number of chars after above. */
a39116f1 252 /* May be 0. */
fecd2382
RP
253 struct symbol *fr_symbol; /* For variable-length tail. */
254 long fr_offset; /* For variable-length tail. */
255 char *fr_opcode; /*->opcode low addr byte,for relax()ation*/
256 relax_stateT fr_type; /* What state is my tail in? */
257 relax_substateT fr_subtype;
a39116f1 258 /* These are needed only on the NS32K machines */
fecd2382
RP
259 char fr_pcrel_adjust;
260 char fr_bsr;
a39116f1
RP
261#ifndef NO_LISTING
262 struct list_info_struct *line;
263#endif
fecd2382 264 char fr_literal [1]; /* Chars begin here. */
a39116f1 265 /* One day we will compile fr_literal[0]. */
fecd2382
RP
266};
267#define SIZEOF_STRUCT_FRAG \
a39116f1
RP
268((int)zero_address_frag.fr_literal-(int)&zero_address_frag)
269/* We want to say fr_literal[0] above. */
fecd2382
RP
270
271typedef struct frag fragS;
272
c593cf41 273COMMON fragS *frag_now; /* -> current frag we are building. */
a39116f1
RP
274/* This frag is incomplete. */
275/* It is, however, included in frchain_now. */
276/* Frag_now->fr_fix is bogus. Use: */
fecd2382
RP
277/* Virtual frag_now->fr_fix==obstack_next_free(&frags)-frag_now->fr_literal.*/
278
279COMMON fragS zero_address_frag; /* For foreign-segment symbol fixups. */
280COMMON fragS bss_address_frag; /* For local common (N_BSS segment) fixups. */
281
282/* main program "as.c" (command arguments etc) */
283
09952cd9 284COMMON char flagseen[128]; /* ['x'] TRUE if "-x" seen. */
fecd2382 285
09952cd9 286COMMON char * out_file_name; /* name of emitted object file */
fecd2382 287
09952cd9
KR
288COMMON int need_pass_2; /* TRUE if we need a second pass. */
289
290COMMON int linkrelax; /* TRUE if we should do no relaxing, and
291 leave lots of padding. */
fecd2382
RP
292
293typedef struct {
a39116f1
RP
294 char * poc_name; /* assembler mnemonic, lower case, no '.' */
295 void (*poc_handler)(); /* Do the work */
296 int poc_val; /* Value to pass to handler */
fecd2382
RP
297} pseudo_typeS;
298
3340f7e5 299#if (__STDC__ == 1) & !defined(NO_STDARG)
fecd2382
RP
300
301int had_errors(void);
302int had_warnings(void);
303void as_bad(const char *Format, ...);
304void as_fatal(const char *Format, ...);
305void as_tsktsk(const char *Format, ...);
306void as_warn(const char *Format, ...);
307
308#else
309
310int had_errors();
311int had_warnings();
312void as_bad();
313void as_fatal();
314void as_tsktsk();
315void as_warn();
316
317#endif /* __STDC__ & !NO_STDARG */
318
3340f7e5 319#if __STDC__ == 1
fecd2382
RP
320
321char *app_push(void);
322char *atof_ieee(char *str, int what_kind, LITTLENUM_TYPE *words);
323char *input_scrub_include_file(char *filename, char *position);
324char *input_scrub_new_file(char *filename);
325char *input_scrub_next_buffer(char **bufp);
326char *strstr(const char *s, const char *wanted);
327char *xmalloc(int size);
328char *xrealloc(char *ptr, long n);
329int do_scrub_next_char(int (*get)(), void (*unget)());
330int gen_to_words(LITTLENUM_TYPE *words, int precision, long exponent_bits);
331int had_err(void);
332int had_errors(void);
333int had_warnings(void);
334int ignore_input(void);
335int scrub_from_file(void);
336int scrub_from_file(void);
337int scrub_from_string(void);
338int seen_at_least_1_file(void);
339void app_pop(char *arg);
340void as_howmuch(FILE *stream);
341void as_perror(char *gripe, char *filename);
342void as_where(void);
343void bump_line_counters(void);
344void do_scrub_begin(void);
345void input_scrub_begin(void);
346void input_scrub_close(void);
347void input_scrub_end(void);
348void int_to_gen(long x);
349void new_logical_line(char *fname, int line_number);
350void scrub_to_file(int ch);
351void scrub_to_string(int ch);
352void subseg_change(segT seg, int subseg);
353void subseg_new(segT seg, subsegT subseg);
354void subsegs_begin(void);
355
3340f7e5 356#else /* not __STDC__ */
fecd2382
RP
357
358char *app_push();
359char *atof_ieee();
360char *input_scrub_include_file();
361char *input_scrub_new_file();
362char *input_scrub_next_buffer();
363char *strstr();
364char *xmalloc();
365char *xrealloc();
366int do_scrub_next_char();
367int gen_to_words();
368int had_err();
369int had_errors();
370int had_warnings();
371int ignore_input();
372int scrub_from_file();
373int scrub_from_file();
374int scrub_from_string();
375int seen_at_least_1_file();
376void app_pop();
377void as_howmuch();
378void as_perror();
379void as_where();
380void bump_line_counters();
381void do_scrub_begin();
382void input_scrub_begin();
383void input_scrub_close();
384void input_scrub_end();
385void int_to_gen();
386void new_logical_line();
387void scrub_to_file();
388void scrub_to_string();
389void subseg_change();
390void subseg_new();
391void subsegs_begin();
392
3340f7e5 393#endif /* not __STDC__ */
fecd2382 394
a39116f1 395/* this one starts the chain of target dependant headers */
fecd2382
RP
396#include "targ-env.h"
397
a39116f1 398/* these define types needed by the interfaces */
fecd2382 399#include "struc-symbol.h"
c593cf41
SC
400/*#include "aout/reloc.h"*/
401
fecd2382
RP
402#include "write.h"
403#include "expr.h"
404#include "frags.h"
405#include "hash.h"
406#include "read.h"
407#include "symbols.h"
408
409#include "tc.h"
410#include "obj.h"
411
c593cf41
SC
412#include "listing.h"
413
fecd2382
RP
414/*
415 * Local Variables:
416 * comment-column: 0
417 * fill-column: 131
418 * End:
419 */
420
a39116f1 421/* end of as.h */
This page took 0.068594 seconds and 4 git commands to generate.