* i386-dis.c (dis386): Use Yb and Yv for scasb and scasS.
[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.
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 19
7f955c18 20#ifndef GAS
fecd2382 21#define GAS 1
fecd2382
RP
22/*
23 * I think this stuff is largely out of date. xoxorich.
24 *
25 * CAPITALISED names are #defined.
26 * "lowercaseH" is #defined if "lowercase.h" has been #include-d.
27 * "lowercaseT" is a typedef of "lowercase" objects.
28 * "lowercaseP" is type "pointer to object of type 'lowercase'".
29 * "lowercaseS" is typedef struct ... lowercaseS.
30 *
31 * #define DEBUG to enable all the "know" assertion tests.
68878ef1 32 * #define SUSPECT when debugging hash code.
fecd2382
RP
33 * #define COMMON as "extern" for all modules except one, where you #define
34 * COMMON as "".
35 * If TEST is #defined, then we are testing a module: #define COMMON as "".
36 */
37
38/* These #defines are for parameters of entire assembler. */
39
fecd2382
RP
40/* These #includes are for type definitions etc. */
41
7f955c18
KR
42#include "config.h"
43
fecd2382 44#include <stdio.h>
68878ef1
KR
45#ifdef DEBUG
46#undef NDEBUG
47#endif
fecd2382 48#include <assert.h>
c593cf41 49
68878ef1
KR
50#include <ansidecl.h>
51#ifdef BFD_ASSEMBLER
52#include <bfd.h>
53#endif
54#include "host.h"
55#include "flonum.h"
56
b17c891e
KR
57/* Make Saber happier on obstack.h. */
58#ifdef SABER
59#undef __PTR_TO_INT
60#define __PTR_TO_INT(P) ((int)(P))
61#undef __INT_TO_PTR
62#define __INT_TO_PTR(P) ((char *)(P))
63#endif
64
68878ef1
KR
65#ifndef __LINE__
66#define __LINE__ "unknown"
67#endif /* __LINE__ */
68
69#ifndef __FILE__
70#define __FILE__ "unknown"
71#endif /* __FILE__ */
72
b17c891e
KR
73#ifndef __STDC__
74#ifndef const
75#define const
76#endif
77#ifndef volatile
78#define volatile
79#endif
80#endif /* ! __STDC__ */
81
7f955c18
KR
82#ifndef FOPEN_WB
83#include "fopen-same.h"
84#endif
85
3340f7e5
RP
86#define obstack_chunk_alloc xmalloc
87#define obstack_chunk_free xfree
fecd2382 88
a39116f1
RP
89#define xfree free
90
b17c891e 91#define BAD_CASE(val) \
a39116f1 92{ \
58d4951d
ILT
93 as_fatal("Case value %ld unexpected at line %d of file \"%s\"\n", \
94 (long) val, __LINE__, __FILE__); \
a39116f1 95 }
fecd2382 96\f
6efd877d 97
fecd2382
RP
98/* These are assembler-wide concepts */
99
68878ef1
KR
100#ifdef BFD_ASSEMBLER
101extern bfd *stdoutput;
b17c891e
KR
102typedef bfd_vma addressT;
103typedef bfd_signed_vma offsetT;
104#else
105typedef unsigned long addressT;
106typedef long offsetT;
68878ef1 107#endif
fecd2382 108
b17c891e
KR
109/* Type of symbol value, etc. For use in prototypes. */
110typedef addressT valueT;
111
fecd2382
RP
112#ifndef COMMON
113#ifdef TEST
114#define COMMON /* declare our COMMONs storage here. */
115#else
116#define COMMON extern /* our commons live elswhere */
117#endif
118#endif
a39116f1 119/* COMMON now defined */
c8c7e0bf 120
fecd2382 121#ifdef DEBUG
ace68c4e 122#ifndef know
fecd2382 123#define know(p) assert(p) /* Verify our assumptions! */
ace68c4e 124#endif /* not yet defined */
fecd2382
RP
125#else
126#define know(p) /* know() checks are no-op.ed */
127#endif
68878ef1
KR
128
129#if defined (BROKEN_ASSERT) && !defined (NDEBUG)
130/* Used on machines where the "assert" macro is buggy. (For example, on the
131 RS/6000, Reiser-cpp substitution is done to put the condition into a
132 string, so if the condition contains a string, parse errors result.) If
133 the condition fails, just drop core file. */
134#undef assert
135#define assert(p) ((p) ? 0 : (abort (), 0))
136#endif
fecd2382
RP
137\f
138/* input_scrub.c */
139
140/*
141 * Supplies sanitised buffers to read.c.
142 * Also understands printing line-number part of error messages.
143 */
fecd2382 144\f
6efd877d 145
fecd2382
RP
146/* subsegs.c Sub-segments. Also, segment(=expression type)s.*/
147
68878ef1 148#ifndef BFD_ASSEMBLER
ace68c4e 149
58721107 150#ifdef MANY_SEGMENTS
c8c7e0bf 151#include "bfd.h"
ace68c4e 152#define N_SEGMENTS 10
58721107 153#define SEG_NORMAL(x) ((x) >= SEG_E0 && (x) <= SEG_E9)
ace68c4e 154#define SEG_LIST SEG_E0,SEG_E1,SEG_E2,SEG_E3,SEG_E4,SEG_E5,SEG_E6,SEG_E7,SEG_E8,SEG_E9
ada269da 155#define SEG_TEXT SEG_E0
68878ef1 156#define SEG_DATA SEG_E1
ada269da 157#define SEG_BSS SEG_E2
58721107 158#else
ace68c4e 159#define N_SEGMENTS 3
58721107 160#define SEG_NORMAL(x) ((x) == SEG_TEXT || (x) == SEG_DATA || (x) == SEG_BSS)
ace68c4e 161#define SEG_LIST SEG_TEXT,SEG_DATA,SEG_BSS
58721107
SC
162#endif
163
6efd877d
KR
164typedef enum _segT
165 {
166 SEG_ABSOLUTE = 0,
167 SEG_LIST,
168 SEG_UNKNOWN,
6efd877d
KR
169 SEG_GOOF, /* Only happens if AS has a logic error. */
170 /* Invented so we don't crash printing */
171 /* error message involving weird segment. */
58d4951d 172 SEG_EXPR, /* Intermediate expression values. */
6efd877d
KR
173 SEG_DEBUG, /* Debug segment */
174 SEG_NTV, /* Transfert vector preload segment */
175 SEG_PTV, /* Transfert vector postload segment */
b17c891e 176 SEG_REGISTER /* Mythical: a register-valued expression */
6efd877d 177 } segT;
fecd2382
RP
178
179#define SEG_MAXIMUM_ORDINAL (SEG_REGISTER)
68878ef1
KR
180#else
181typedef asection *segT;
182#define SEG_NORMAL(SEG) ((SEG) != absolute_section \
183 && (SEG) != undefined_section \
68878ef1 184 && (SEG) != reg_section \
58d4951d 185 && (SEG) != expr_section)
68878ef1 186#endif
fecd2382
RP
187typedef int subsegT;
188
a39116f1 189/* What subseg we are accreting now? */
7f2cb270 190COMMON subsegT now_subseg;
fecd2382 191
a39116f1 192/* Segment our instructions emit to. */
7f2cb270 193COMMON segT now_seg;
fecd2382 194
68878ef1
KR
195#ifdef BFD_ASSEMBLER
196#define segment_name(SEG) bfd_get_section_name (stdoutput, SEG)
197#else
b17c891e 198extern char *const seg_name[];
68878ef1
KR
199#define segment_name(SEG) seg_name[(int) (SEG)]
200#endif
201
202#ifndef BFD_ASSEMBLER
fecd2382 203extern int section_alignment[];
68878ef1 204#endif
fecd2382 205
68878ef1 206#ifdef BFD_ASSEMBLER
58d4951d 207extern segT reg_section, expr_section;
68878ef1
KR
208/* Shouldn't these be eliminated someday? */
209extern segT text_section, data_section, bss_section;
210#define absolute_section (&bfd_abs_section)
211#define undefined_section (&bfd_und_section)
212#else
68878ef1 213#define reg_section SEG_REGISTER
58d4951d 214#define expr_section SEG_EXPR
68878ef1
KR
215#define text_section SEG_TEXT
216#define data_section SEG_DATA
217#define bss_section SEG_BSS
218#define absolute_section SEG_ABSOLUTE
219#define undefined_section SEG_UNKNOWN
220#endif
fecd2382
RP
221
222/* relax() */
223
6efd877d
KR
224typedef enum _relax_state
225 {
7f2cb270
KR
226 /* Variable chars to be repeated fr_offset times.
227 Fr_symbol unused. Used with fr_offset == 0 for a
228 constant length frag. */
229 rs_fill = 1,
6efd877d 230
7f2cb270
KR
231 /* Align: Fr_offset: power of 2. 1 variable char: fill character. */
232 rs_align,
6efd877d 233
7f2cb270
KR
234 /* Org: Fr_offset, fr_symbol: address. 1 variable char: fill
235 character. */
236 rs_org,
6efd877d 237
b17c891e 238 rs_machine_dependent
6efd877d 239
fecd2382 240#ifndef WORKING_DOT_WORD
7f2cb270 241 /* JF: gunpoint */
b17c891e 242 , rs_broken_word
fecd2382 243#endif
6efd877d 244 } relax_stateT;
fecd2382
RP
245
246/* typedef unsigned char relax_substateT; */
247/* JF this is more likely to leave the end of a struct frag on an align
248 boundry. Be very careful with this. */
249typedef unsigned long relax_substateT;
250
7f2cb270
KR
251/* Enough bits for address, but still an integer type.
252 Could be a problem, cross-assembling for 64-bit machines. */
b17c891e 253typedef addressT relax_addressT;
fecd2382 254\f
6efd877d 255
fecd2382
RP
256/* frags.c */
257
258/*
259 * A code fragment (frag) is some known number of chars, followed by some
260 * unknown number of chars. Typically the unknown number of chars is an
261 * instruction address whose size is yet unknown. We always know the greatest
262 * possible size the unknown number of chars may become, and reserve that
263 * much room at the end of the frag.
264 * Once created, frags do not change address during assembly.
265 * We chain the frags in (a) forward-linked list(s). The object-file address
266 * of the 1st char of a frag is generally not known until after relax().
267 * Many things at assembly time describe an address by {object-file-address
268 * of a particular frag}+offset.
6efd877d 269
fecd2382 270 BUG: it may be smarter to have a single pointer off to various different
6efd877d 271 notes for different frag kinds. See how code pans
fecd2382 272 */
68878ef1 273struct frag
fecd2382 274{
7f2cb270 275 /* Object file address. */
b17c891e 276 addressT fr_address;
68878ef1 277 /* Chain forward; ascending address order. Rooted in frch_root. */
7f2cb270 278 struct frag *fr_next;
6efd877d 279
68878ef1 280 /* (Fixed) number of chars we know we have. May be 0. */
b17c891e 281 offsetT fr_fix;
68878ef1 282 /* (Variable) number of chars after above. May be 0. */
b17c891e 283 offsetT fr_var;
7f2cb270
KR
284 /* For variable-length tail. */
285 struct symbol *fr_symbol;
286 /* For variable-length tail. */
b17c891e 287 offsetT fr_offset;
68878ef1 288 /* Points to opcode low addr byte, for relaxation. */
7f2cb270 289 char *fr_opcode;
68878ef1
KR
290
291#ifndef NO_LISTING
292 struct list_info_struct *line;
293#endif
294
7f2cb270
KR
295 /* What state is my tail in? */
296 relax_stateT fr_type;
6efd877d 297 relax_substateT fr_subtype;
7f2cb270 298
6efd877d
KR
299 /* These are needed only on the NS32K machines */
300 char fr_pcrel_adjust;
301 char fr_bsr;
68878ef1 302
7f2cb270
KR
303 /* Chars begin here.
304 One day we will compile fr_literal[0]. */
305 char fr_literal[1];
fecd2382 306};
6efd877d 307
fecd2382 308#define SIZEOF_STRUCT_FRAG \
a39116f1
RP
309((int)zero_address_frag.fr_literal-(int)&zero_address_frag)
310/* We want to say fr_literal[0] above. */
fecd2382
RP
311
312typedef struct frag fragS;
313
7f2cb270
KR
314/* Current frag we are building. This frag is incomplete. It is, however,
315 included in frchain_now. The fr_fix field is bogus; instead, use:
316 obstack_next_free(&frags)-frag_now->fr_literal. */
317COMMON fragS *frag_now;
b17c891e 318#define frag_now_fix() ((char*)obstack_next_free (&frags) - frag_now->fr_literal)
fecd2382 319
7f2cb270
KR
320/* For foreign-segment symbol fixups. */
321COMMON fragS zero_address_frag;
322/* For local common (N_BSS segment) fixups. */
323COMMON fragS bss_address_frag;
fecd2382
RP
324
325/* main program "as.c" (command arguments etc) */
326
7f2cb270
KR
327/* ['x'] TRUE if "-x" seen. */
328COMMON char flagseen[128];
329COMMON unsigned char flag_readonly_data_in_text;
330COMMON unsigned char flag_suppress_warnings;
331COMMON unsigned char flag_always_generate_output;
fecd2382 332
7f2cb270
KR
333/* name of emitted object file */
334COMMON char *out_file_name;
fecd2382 335
7f2cb270
KR
336/* TRUE if we need a second pass. */
337COMMON int need_pass_2;
09952cd9 338
7f2cb270
KR
339/* TRUE if we should do no relaxing, and
340 leave lots of padding. */
341COMMON int linkrelax;
fecd2382 342
7f955c18
KR
343/* TRUE if we should produce a listing. */
344extern int listing;
345
7f2cb270 346struct _pseudo_type
6efd877d 347 {
7f2cb270
KR
348 /* assembler mnemonic, lower case, no '.' */
349 char *poc_name;
350 /* Do the work */
604633ae 351 void (*poc_handler) PARAMS ((int));
7f2cb270
KR
352 /* Value to pass to handler */
353 int poc_val;
354 };
6efd877d 355
7f2cb270 356typedef struct _pseudo_type pseudo_typeS;
fecd2382 357
68878ef1
KR
358#ifdef BFD_ASSEMBLER_xxx
359struct lineno_struct
360 {
361 alent line;
362 fragS *frag;
363 struct lineno_struct *next;
364 };
365typedef struct lineno_struct lineno;
366#endif
fecd2382 367
68878ef1 368#if defined (__STDC__) && !defined(NO_STDARG)
fecd2382 369
68878ef1
KR
370#if __GNUC__ >= 2
371/* for use with -Wformat */
7f955c18 372#define PRINTF_LIKE(FCN) void FCN (const char *format, ...) \
68878ef1
KR
373 __attribute__ ((format (printf, 1, 2)))
374#else /* ANSI C with stdarg, but not GNU C */
7f955c18 375#define PRINTF_LIKE(FCN) void FCN (const char *format, ...)
68878ef1
KR
376#endif
377#else /* not ANSI C, or not stdarg */
378#define PRINTF_LIKE(FCN) void FCN ()
379#endif
fecd2382 380
68878ef1
KR
381PRINTF_LIKE (as_bad);
382PRINTF_LIKE (as_fatal);
383PRINTF_LIKE (as_tsktsk);
384PRINTF_LIKE (as_warn);
7f955c18
KR
385
386#if defined (__STDC__) && !defined (NO_STDARG)
387#if __GNUC__ >= 2
388void as_bad_where (char *file, unsigned int line, const char *format, ...)
389 __attribute__ ((format (printf, 3, 4)));
390#else /* ANSI C with stdarg, but not GNU C */
391void as_bad_where (char *file, unsigned int line, const char *format, ...);
392#endif
393#else /* not ANSI C, or not stdarg */
394void as_bad_where ();
395#endif
396
b17c891e
KR
397void fprint_value PARAMS ((FILE *file, addressT value));
398void sprint_value PARAMS ((char *buf, addressT value));
fecd2382 399
68878ef1
KR
400int had_errors PARAMS ((void));
401int had_warnings PARAMS ((void));
fecd2382 402
604633ae 403void print_version_id PARAMS ((void));
7f2cb270
KR
404char *app_push PARAMS ((void));
405char *atof_ieee PARAMS ((char *str, int what_kind, LITTLENUM_TYPE * words));
406char *input_scrub_include_file PARAMS ((char *filename, char *position));
407char *input_scrub_new_file PARAMS ((char *filename));
408char *input_scrub_next_buffer PARAMS ((char **bufp));
b17c891e 409#if 0 /* incompatible with solaris 2 native cc */
7f2cb270 410char *strstr PARAMS ((const char *s, const char *wanted));
b17c891e 411#endif
604633ae
ILT
412char *xmalloc PARAMS ((unsigned long size));
413char *xrealloc PARAMS ((char *ptr, unsigned long n));
414int do_scrub_next_char PARAMS ((int (*get) (void), void (*unget) (int)));
7f2cb270
KR
415int gen_to_words PARAMS ((LITTLENUM_TYPE * words, int precision,
416 long exponent_bits));
417int had_err PARAMS ((void));
7f2cb270
KR
418int ignore_input PARAMS ((void));
419int scrub_from_file PARAMS ((void));
7f2cb270
KR
420int scrub_from_string PARAMS ((void));
421int seen_at_least_1_file PARAMS ((void));
422void app_pop PARAMS ((char *arg));
423void as_howmuch PARAMS ((FILE * stream));
424void as_perror PARAMS ((char *gripe, char *filename));
7f955c18 425void as_where PARAMS ((char **namep, unsigned int *linep));
7f2cb270
KR
426void bump_line_counters PARAMS ((void));
427void do_scrub_begin PARAMS ((void));
428void input_scrub_begin PARAMS ((void));
429void input_scrub_close PARAMS ((void));
430void input_scrub_end PARAMS ((void));
7f2cb270
KR
431void new_logical_line PARAMS ((char *fname, int line_number));
432void scrub_to_file PARAMS ((int ch));
433void scrub_to_string PARAMS ((int ch));
68878ef1 434void subsegs_begin PARAMS ((void));
7f2cb270 435void subseg_change PARAMS ((segT seg, int subseg));
b17c891e 436segT subseg_new PARAMS ((const char *name, subsegT subseg));
68878ef1 437void subseg_set PARAMS ((segT seg, subsegT subseg));
fecd2382 438
7f955c18
KR
439struct expressionS;
440struct fix;
441struct symbol;
442
443#ifdef BFD_ASSEMBLER
444/* literal.c */
445valueT add_to_literal_pool PARAMS ((struct symbol *, valueT, segT, int));
446#endif
447
a39116f1 448/* this one starts the chain of target dependant headers */
fecd2382
RP
449#include "targ-env.h"
450
85051959 451#include "expr.h"
fecd2382 452#include "struc-symbol.h"
fecd2382 453#include "write.h"
fecd2382
RP
454#include "frags.h"
455#include "hash.h"
456#include "read.h"
457#include "symbols.h"
458
459#include "tc.h"
460#include "obj.h"
461
c593cf41
SC
462#include "listing.h"
463
b17c891e
KR
464#ifdef BFD_ASSEMBLER
465/* Someday perhaps this will be selectable at run-time. */
466#if defined (OBJ_AOUT) || defined (OBJ_BOUT)
467#define OUTPUT_FLAVOR bfd_target_aout_flavour
468#endif
469#ifdef OBJ_COFF
470#define OUTPUT_FLAVOR bfd_target_coff_flavour
471#endif
472#ifdef OBJ_ECOFF
473#define OUTPUT_FLAVOR bfd_target_ecoff_flavour
474#endif
475#ifdef OBJ_ELF
476#define OUTPUT_FLAVOR bfd_target_elf_flavour
477#endif
478#endif /* BFD_ASSEMBLER */
479
7f955c18
KR
480#endif /* GAS */
481
a39116f1 482/* end of as.h */
This page took 0.125799 seconds and 4 git commands to generate.