home *** CD-ROM | disk | FTP | other *** search
/ NeXTSTEP 3.2 (Developer) / NS_dev_3.2.iso / NextDeveloper / Source / GNU / cctools / as / as.h < prev    next >
Encoding:
C/C++ Source or Header  |  1992-10-12  |  9.2 KB  |  327 lines

  1. /* as.h - global header file
  2.    Copyright (C) 1987 Free Software Foundation, Inc.
  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 1, 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.  */
  19.  
  20. #ifndef asH
  21. #define asH            /* Don't declare things twice. */
  22.  
  23. #ifdef USG
  24. #define index strchr
  25. #define bzero(s,n) memset((s),0,(n))
  26. #define bcopy(from,to,n) memcpy((to),(from),(n))
  27. #define setbuffer(a,b,c)
  28. #endif
  29.  
  30. /*
  31.  * CAPITALISED names are #defined.
  32.  * "lowercaseH" is #defined if "lowercase.h" has been #include-d.
  33.  * "lowercaseT" is a typedef of "lowercase" objects.
  34.  * "lowercaseP" is type "pointer to object of type 'lowercase'".
  35.  * "lowercaseS" is typedef struct ... lowercaseS.
  36.  *
  37.  * #define SUSPECT when debugging.
  38.  * #define DUMP to include data-structure dumpers.
  39.  * #define COMMON as "extern" for all modules except one, where you #define
  40.  *    COMMON as "".
  41.  * If TEST is #defined, then we are testing a module: #define COMMON as "".
  42.  */
  43.  
  44.  
  45.  
  46. /* These #defines are for parameters of entire assembler. */
  47.  
  48. /* #define SUSPECT JF remove for speed testing */
  49. /* #define DUMP */
  50. #define NDEBUG        /* JF disable asserts */
  51. /* These #includes are for type definitions etc. */
  52.  
  53. /* #include "style.h" */
  54. #include <stdio.h>
  55. #include <assert.h>
  56. #define obstack_chunk_alloc    xmalloc
  57. #define obstack_chunk_free    xfree
  58.  
  59. /* These defines are potentially useful */
  60. #ifdef NeXT
  61. #undef TRUE
  62. #undef FALSE
  63. #endif NeXT
  64. #define FALSE    (0)
  65. #define TRUE    (!FALSE)
  66. #define ASSERT    assert
  67. #define BAD_CASE(value)                            \
  68. {                                    \
  69.   as_fatal ("Case value %d unexpected at line %d of file \"%s\"\n",    \
  70.        value, __LINE__, __FILE__);                    \
  71. }
  72.  
  73.  
  74.  
  75.  
  76. /* These are assembler-wide concepts */
  77.  
  78.  
  79. #ifndef COMMON
  80. #ifdef TEST
  81. #define COMMON            /* declare our COMMONs storage here. */
  82. #else
  83. #define COMMON extern        /* our commons live elswhere */
  84. #endif
  85. #endif
  86.                 /* COMMON now defined */
  87.  
  88. #ifdef SUSPECT
  89. #define register        /* no registers: helps debugging */
  90. #define know(p) ASSERT(p)    /* know() is less ugly than #ifdef SUSPECT/ */
  91.                 /* assert()/#endif. */
  92. #else
  93. #define know(p)            /* know() checks are no-op.ed */
  94. #endif                /* #ifdef SUSPECT */
  95.  
  96.  
  97. char    *xmalloc();        /* keep C compilers happy */
  98. char    *xrealloc();        /* " */
  99. void    free();            /* " */
  100. #define xfree free
  101.  
  102. /* input_scrub.c */
  103.  
  104. /*
  105.  * Supplies sanitised buffers to read.c.
  106.  * Also understands printing line-number part of error messages.
  107.  */
  108.  
  109.                 /* Line number things. */
  110. int    seen_at_least_1_file();
  111. void    bump_line_counters();
  112. void    new_logical_line();
  113. void    as_where();
  114. void    as_perror();
  115. void    as_howmuch();
  116.                 /* Sanitising things. */
  117. void    input_scrub_begin();
  118. void    input_scrub_end();
  119. char    *input_scrub_new_file();
  120. char    *input_scrub_next_buffer();
  121. #ifdef NeXT    /* .include feature */
  122. /* DJA -- Routines and typedefs to save scrub context so
  123.  *      .include can make recursive calls to the
  124.  *      sanitising routines.
  125.  */
  126. void    save_scrub_context ();
  127. void    restore_scrub_context ();
  128.  
  129. typedef struct scrub_context_data {
  130.     FILE *last_scrub_file;
  131.     int last_state;
  132.     int last_old_state;
  133.     char *last_out_string;
  134.     char last_out_buf[20];
  135.     int last_add_newlines;
  136. } scrub_context_data;
  137. #endif NeXT    /* .include feature */
  138.  
  139. #ifdef NeXT
  140. #import <mach/machine.h>
  141. extern int force_cpusubtype_ALL;
  142. extern cpu_subtype_t archflag_cpusubtype;
  143. extern cpu_subtype_t cpusubtype;
  144. #endif /* NeXT */
  145.  
  146.  
  147. /* subsegs.c     Sub-segments. Also, segment(=expression type)s.*/
  148.  
  149. /*
  150.  * This table describes the use of segments as EXPRESSION types.
  151.  *
  152.  *    X_seg    X_add_symbol  X_subtract_symbol    X_add_number
  153.  * SEG_NONE                        no (legal) expression
  154.  * SEG_PASS1                        no (defined) "
  155.  * SEG_BIG                    *    > 32 bits const.
  156.  * SEG_ABSOLUTE                         0
  157.  * SEG_DATA        *                 0
  158.  * SEG_TEXT        *            0
  159.  * SEG_BSS        *            0
  160.  * SEG_UNKNOWN        *            0
  161.  * SEG_DIFFERENCE    0        *    0
  162.  *
  163.  * The blank fields MUST be 0, and are nugatory.
  164.  * The '0' fields MAY be 0. The '*' fields MAY NOT be 0.
  165.  *
  166.  * SEG_BIG: X_add_number is < 0 if the result is in
  167.  *    generic_floating_point_number.  The value is -'c' where c is the
  168.  *    character that introduced the constant.  e.g. "0f6.9" will have  -'f'
  169.  *    as a X_add_number value.
  170.  *    X_add_number > 0 is a count of how many littlenums it took to
  171.  *    represent a bignum.
  172.  * SEG_DIFFERENCE:
  173.  * If segments of both symbols are known, they are the same segment.
  174.  * X_add_symbol != X_sub_symbol (then we just cancel them, => SEG_ABSOLUTE).
  175.  */
  176.  
  177. typedef enum
  178. {
  179.     SEG_ABSOLUTE,
  180.     SEG_TEXT,
  181.     SEG_DATA,
  182.     SEG_BSS,
  183.     SEG_UNKNOWN,
  184.     SEG_NONE,        /* Mythical Segment: NO expression seen. */
  185.     SEG_PASS1,        /* Mythical Segment: Need another pass. */
  186.     SEG_GOOF,        /* Only happens if AS has a logic error. */
  187.                 /* Invented so we don't crash printing */
  188.                 /* error message involving weird segment. */
  189.     SEG_BIG,            /* Bigger than 32 bits constant. */
  190.     SEG_DIFFERENCE        /* Mythical Segment: absolute difference. */
  191. }        segT;
  192. #define SEG_MAXIMUM_ORDINAL (SEG_DIFFERENCE)
  193.  
  194. typedef unsigned char    subsegT;
  195.  
  196. COMMON subsegT            now_subseg;
  197.                 /* What subseg we are accreting now? */
  198.  
  199.  
  200. COMMON segT            now_seg;
  201.                 /* Segment our instructions emit to. */
  202.                 /* Only OK values are SEG_TEXT or SEG_DATA. */
  203.  
  204.  
  205. extern char    *seg_name[];
  206. extern int    seg_N_TYPE[];
  207. extern segT    N_TYPE_seg[];
  208. void    subsegs_begin();
  209. void    subseg_change();
  210. void    subseg_new();
  211.  
  212. /* relax() */
  213.  
  214. typedef enum
  215. {
  216.     rs_fill,        /* Variable chars to be repeated fr_offset */
  217.                 /* times. Fr_symbol unused. */
  218.                 /* Used with fr_offset == 0 for a constant */
  219.                 /* length frag. */
  220.  
  221.     rs_align,        /* Align: Fr_offset: power of 2. */
  222.                 /* 1 variable char: fill character. */
  223.     rs_org,            /* Org: Fr_offset, fr_symbol: address. */
  224.                 /* 1 variable char: fill character. */
  225.  
  226.     rs_machine_dependent,
  227. #ifndef WORKING_DOT_WORD
  228.     rs_broken_word,        /* JF: gunpoint */
  229. #endif
  230. }
  231. relax_stateT;
  232.  
  233. /* typedef unsigned char relax_substateT; */
  234. /* JF this is more likely to leave the end of a struct frag on an align
  235.    boundry.  Be very careful with this.  */
  236. typedef unsigned long int relax_substateT;
  237.  
  238. typedef unsigned long int relax_addressT;/* Enough bits for address. */
  239.                 /* Still an integer type. */
  240.  
  241.  
  242. /* frags.c */
  243.  
  244. /*
  245.  * A code fragment (frag) is some known number of chars, followed by some
  246.  * unknown number of chars. Typically the unknown number of chars is an
  247.  * instruction address whose size is yet unknown. We always know the greatest
  248.  * possible size the unknown number of chars may become, and reserve that
  249.  * much room at the end of the frag.
  250.  * Once created, frags do not change address during assembly.
  251.  * We chain the frags in (a) forward-linked list(s). The object-file address
  252.  * of the 1st char of a frag is generally not known until after relax().
  253.  * Many things at assembly time describe an address by {object-file-address
  254.  * of a particular frag}+offset.
  255.  
  256.  BUG: it may be smarter to have a single pointer off to various different
  257. notes for different frag kinds. See how code pans out.
  258.  
  259.  
  260.  */
  261. struct frag            /* a code fragment */
  262. {
  263.     long unsigned int fr_address; /* Object file address. */
  264.     struct frag *fr_next;    /* Chain forward; ascending address order. */
  265.                 /* Rooted in frch_root. */
  266.  
  267.     long int fr_fix;    /* (Fixed) number of chars we know we have. */
  268.                 /* May be 0. */
  269.     long int fr_var;    /* (Variable) number of chars after above. */
  270.                 /* May be 0. */
  271.     struct symbol *fr_symbol; /* For variable-length tail. */
  272.     long int fr_offset;    /* For variable-length tail. */
  273.     char    *fr_opcode;    /*->opcode low addr byte,for relax()ation*/
  274.     relax_stateT fr_type;   /* What state is my tail in? */
  275.     relax_substateT    fr_subtype;
  276.         /* These are needed only on the NS32K machines */
  277.     char    fr_pcrel_adjust;
  278.     char    fr_bsr;
  279.     char    fr_literal [1];    /* Chars begin here. */
  280.                 /* One day we will compile fr_literal[0]. */
  281. };
  282. #define SIZEOF_STRUCT_FRAG \
  283.  ((int)zero_address_frag.fr_literal-(int)&zero_address_frag)
  284.                 /* We want to say fr_literal[0] above. */
  285.  
  286. typedef struct frag fragS;
  287.  
  288. COMMON fragS *    frag_now;    /* -> current frag we are building. */
  289.                 /* This frag is incomplete. */
  290.                 /* It is, however, included in frchain_now. */
  291.                 /* Frag_now->fr_fix is bogus. Use: */
  292. /* Virtual frag_now->fr_fix==obstack_next_free(&frags)-frag_now->fr_literal.*/
  293.  
  294. COMMON fragS zero_address_frag;    /* For foreign-segment symbol fixups. */
  295. COMMON fragS  bss_address_frag;    /* For local common (N_BSS segment) fixups. */
  296.  
  297. void        frag_new();
  298. char *        frag_more();
  299. char *        frag_var();
  300. void        frag_wane();
  301. void        frag_align();
  302.  
  303.  
  304. /* main program "as.c" (command arguments etc) */
  305.  
  306. COMMON char
  307. flagseen[128];            /* ['x'] TRUE if "-x" seen. */
  308.  
  309. COMMON char *
  310. out_file_name;            /* name of emitted object file */
  311.  
  312. COMMON int    need_pass_2;    /* TRUE if we need a second pass. */
  313.  
  314.  
  315. #endif                /* #ifdef asH */
  316.  
  317. #ifdef NeXT    /* .include feature */
  318. struct directory_stack    /* DJA -- added -I path for .includes */
  319.   {
  320.     struct directory_stack *next;
  321.     char *fname;
  322.   };
  323. extern struct directory_stack include_defaults[];
  324. #endif NeXT    /* .include feature */
  325.  
  326. /* end: as.h */
  327.