home *** CD-ROM | disk | FTP | other *** search
/ Geek Gadgets 1 / ADE-1.bin / ade-dist / binutils-2.7-src.tgz / tar.out / fsf / binutils / gas / read.c < prev    next >
C/C++ Source or Header  |  1996-09-28  |  99KB  |  4,161 lines

  1. /* read.c - read a source file -
  2.    Copyright (C) 1986, 87, 90, 91, 92, 93, 94, 95, 1996
  3.    Free Software Foundation, Inc.
  4.  
  5. This file is part of GAS, the GNU Assembler.
  6.  
  7. GAS is free software; you can redistribute it and/or modify
  8. it under the terms of the GNU General Public License as published by
  9. the Free Software Foundation; either version 2, or (at your option)
  10. any later version.
  11.  
  12. GAS is distributed in the hope that it will be useful,
  13. but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15. GNU General Public License for more details.
  16.  
  17. You should have received a copy of the GNU General Public License
  18. along with GAS; see the file COPYING.  If not, write to
  19. the Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
  20.  
  21. #if 0
  22. #define MASK_CHAR (0xFF)    /* If your chars aren't 8 bits, you will
  23.                    change this a bit.  But then, GNU isn't
  24.                    spozed to run on your machine anyway.
  25.                    (RMS is so shortsighted sometimes.)
  26.                    */
  27. #else
  28. #define MASK_CHAR ((int)(unsigned char)-1)
  29. #endif
  30.  
  31.  
  32. /* This is the largest known floating point format (for now). It will
  33.    grow when we do 4361 style flonums. */
  34.  
  35. #define MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT (16)
  36.  
  37. /* Routines that read assembler source text to build spagetti in memory.
  38.    Another group of these functions is in the expr.c module.  */
  39.  
  40. /* for isdigit() */
  41. #include <ctype.h>
  42.  
  43. #include "as.h"
  44. #include "subsegs.h"
  45. #include "sb.h"
  46. #include "macro.h"
  47. #include "libiberty.h"
  48. #include "obstack.h"
  49. #include "listing.h"
  50. #include "ecoff.h"
  51.  
  52. #ifndef TC_START_LABEL
  53. #define TC_START_LABEL(x,y) (x==':')
  54. #endif
  55.  
  56. /* The NOP_OPCODE is for the alignment fill value.
  57.  * fill it a nop instruction so that the disassembler does not choke
  58.  * on it
  59.  */
  60. #ifndef NOP_OPCODE
  61. #define NOP_OPCODE 0x00
  62. #endif
  63.  
  64. char *input_line_pointer;    /*->next char of source file to parse. */
  65.  
  66. int generate_asm_lineno = 0;    /* flag to generate line stab for .s file */
  67.  
  68. #if BITS_PER_CHAR != 8
  69. /*  The following table is indexed by[(char)] and will break if
  70.     a char does not have exactly 256 states (hopefully 0:255!)!  */
  71. die horribly;
  72. #endif
  73.  
  74. #ifndef LEX_AT
  75. /* The m88k unfortunately uses @ as a label beginner.  */
  76. #define LEX_AT 0
  77. #endif
  78.  
  79. #ifndef LEX_BR
  80. /* The RS/6000 assembler uses {,},[,] as parts of symbol names.  */
  81. #define LEX_BR 0
  82. #endif
  83.  
  84. #ifndef LEX_PCT
  85. /* The Delta 68k assembler permits % inside label names.  */
  86. #define LEX_PCT 0
  87. #endif
  88.  
  89. #ifndef LEX_QM
  90. /* The PowerPC Windows NT assemblers permits ? inside label names.  */
  91. #define LEX_QM 0
  92. #endif
  93.  
  94. #ifndef LEX_DOLLAR
  95. /* The a29k assembler does not permits labels to start with $.  */
  96. #define LEX_DOLLAR 3
  97. #endif
  98.  
  99. /* used by is_... macros. our ctype[] */
  100. char lex_type[256] =
  101. {
  102.   0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,    /* @ABCDEFGHIJKLMNO */
  103.   0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,    /* PQRSTUVWXYZ[\]^_ */
  104.   0, 0, 0, 0, LEX_DOLLAR, LEX_PCT, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, /* _!"#$%&'()*+,-./ */
  105.   1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, LEX_QM,    /* 0123456789:;<=>? */
  106.   LEX_AT, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,    /* @ABCDEFGHIJKLMNO */
  107.   3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, LEX_BR, 0, LEX_BR, 0, 3, /* PQRSTUVWXYZ[\]^_ */
  108.   0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,    /* `abcdefghijklmno */
  109.   3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, LEX_BR, 0, LEX_BR, 0, 0, /* pqrstuvwxyz{|}~. */
  110.   0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  111.   0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  112.   0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  113.   0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  114.   0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  115.   0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  116.   0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  117. };
  118.  
  119.  
  120. /*
  121.  * In: a character.
  122.  * Out: 1 if this character ends a line.
  123.  */
  124. #define _ (0)
  125. char is_end_of_line[256] =
  126. {
  127. #ifdef CR_EOL
  128.   _, _, _, _, _, _, _, _, _, _, 99, _, _, 99, _, _,    /* @abcdefghijklmno */
  129. #else
  130.   _, _, _, _, _, _, _, _, _, _, 99, _, _, _, _, _,    /* @abcdefghijklmno */
  131. #endif
  132.   _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _,    /* */
  133. #ifdef TC_HPPA
  134.   _,99, _, _, _, _, _, _, _, _, _, _, _, _, _, _,    /* _!"#$%&'()*+,-./ */
  135.   _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _,    /* 0123456789:;<=>? */
  136. #else
  137.   _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _,    /* */
  138.   _, _, _, _, _, _, _, _, _, _, _, 99, _, _, _, _,    /* 0123456789:;<=>? */
  139. #endif
  140.   _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _,    /* */
  141.   _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _,    /* */
  142.   _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _,    /* */
  143.   _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _,    /* */
  144.   _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _,    /* */
  145.   _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _,    /* */
  146.   _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _,    /* */
  147.   _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _,    /* */
  148.   _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _,    /* */
  149. };
  150. #undef _
  151.  
  152. /* Functions private to this file. */
  153.  
  154. static char *buffer;    /* 1st char of each buffer of lines is here. */
  155. static char *buffer_limit;    /*->1 + last char in buffer. */
  156.  
  157. #ifdef TARGET_BYTES_BIG_ENDIAN
  158. /* Hack to deal with tc-*.h defining TARGET_BYTES_BIG_ENDIAN to empty
  159.    instead of to 0 or 1.  */
  160. #if 5 - TARGET_BYTES_BIG_ENDIAN - 5 == 10
  161. #undef  TARGET_BYTES_BIG_ENDIAN
  162. #define TARGET_BYTES_BIG_ENDIAN 1
  163. #endif
  164. int target_big_endian = TARGET_BYTES_BIG_ENDIAN;
  165. #else
  166. int target_big_endian /* = 0 */;
  167. #endif
  168.  
  169. static char *old_buffer;    /* JF a hack */
  170. static char *old_input;
  171. static char *old_limit;
  172.  
  173. /* Variables for handling include file directory list. */
  174.  
  175. char **include_dirs;    /* List of pointers to directories to
  176.                search for .include's */
  177. int include_dir_count;    /* How many are in the list */
  178. int include_dir_maxlen = 1;/* Length of longest in list */
  179.  
  180. #ifndef WORKING_DOT_WORD
  181. struct broken_word *broken_words;
  182. int new_broken_words;
  183. #endif
  184.  
  185. /* The current offset into the absolute section.  We don't try to
  186.    build frags in the absolute section, since no data can be stored
  187.    there.  We just keep track of the current offset.  */
  188. addressT abs_section_offset;
  189.  
  190. /* If this line had an MRI style label, it is stored in this variable.
  191.    This is used by some of the MRI pseudo-ops.  */
  192. symbolS *line_label;
  193.  
  194. /* This global variable is used to support MRI common sections.  We
  195.    translate such sections into a common symbol.  This variable is
  196.    non-NULL when we are in an MRI common section.  */
  197. symbolS *mri_common_symbol;
  198.  
  199. /* In MRI mode, after a dc.b pseudo-op with an odd number of bytes, we
  200.    need to align to an even byte boundary unless the next pseudo-op is
  201.    dc.b, ds.b, or dcb.b.  This variable is set to 1 if an alignment
  202.    may be needed.  */
  203. static int mri_pending_align;
  204.  
  205. static int scrub_from_string PARAMS ((char **));
  206. static void do_align PARAMS ((int, char *, int));
  207. static int hex_float PARAMS ((int, char *));
  208. static void do_org PARAMS ((segT, expressionS *, int));
  209. char *demand_copy_string PARAMS ((int *lenP));
  210. static segT get_segmented_expression PARAMS ((expressionS *expP));
  211. static segT get_known_segmented_expression PARAMS ((expressionS * expP));
  212. static void pobegin PARAMS ((void));
  213. static int get_line_sb PARAMS ((sb *));
  214.  
  215.  
  216. void
  217. read_begin ()
  218. {
  219.   const char *p;
  220.  
  221.   pobegin ();
  222.   obj_read_begin_hook ();
  223.  
  224.   /* Something close -- but not too close -- to a multiple of 1024.
  225.      The debugging malloc I'm using has 24 bytes of overhead.  */
  226.   obstack_begin (¬es, chunksize);
  227.   obstack_begin (&cond_obstack, chunksize);
  228.  
  229.   /* Use machine dependent syntax */
  230.   for (p = line_separator_chars; *p; p++)
  231.     is_end_of_line[(unsigned char) *p] = 1;
  232.   /* Use more.  FIXME-SOMEDAY. */
  233.  
  234.   if (flag_mri)
  235.     lex_type['?'] = 3;
  236. }
  237.  
  238. /* set up pseudo-op tables */
  239.  
  240. static struct hash_control *po_hash;
  241.  
  242. static const pseudo_typeS potable[] =
  243. {
  244.   {"abort", s_abort, 0},
  245.   {"align", s_align_ptwo, 0},
  246.   {"ascii", stringer, 0},
  247.   {"asciz", stringer, 1},
  248.   {"balign", s_align_bytes, 0},
  249.   {"balignw", s_align_bytes, -2},
  250.   {"balignl", s_align_bytes, -4},
  251. /* block */
  252.   {"byte", cons, 1},
  253.   {"comm", s_comm, 0},
  254.   {"common", s_mri_common, 0},
  255.   {"common.s", s_mri_common, 1},
  256.   {"data", s_data, 0},
  257.   {"dc", cons, 2},
  258.   {"dc.b", cons, 1},
  259.   {"dc.d", float_cons, 'd'},
  260.   {"dc.l", cons, 4},
  261.   {"dc.s", float_cons, 'f'},
  262.   {"dc.w", cons, 2},
  263.   {"dc.x", float_cons, 'x'},
  264.   {"dcb", s_space, 2},
  265.   {"dcb.b", s_space, 1},
  266.   {"dcb.d", s_float_space, 'd'},
  267.   {"dcb.l", s_space, 4},
  268.   {"dcb.s", s_float_space, 'f'},
  269.   {"dcb.w", s_space, 2},
  270.   {"dcb.x", s_float_space, 'x'},
  271.   {"ds", s_space, 2},
  272.   {"ds.b", s_space, 1},
  273.   {"ds.d", s_space, 8},
  274.   {"ds.l", s_space, 4},
  275.   {"ds.p", s_space, 12},
  276.   {"ds.s", s_space, 4},
  277.   {"ds.w", s_space, 2},
  278.   {"ds.x", s_space, 12},
  279.   {"debug", s_ignore, 0},
  280. #ifdef S_SET_DESC
  281.   {"desc", s_desc, 0},
  282. #endif
  283. /* dim */
  284.   {"double", float_cons, 'd'},
  285. /* dsect */
  286.   {"eject", listing_eject, 0},    /* Formfeed listing */
  287.   {"else", s_else, 0},
  288.   {"elsec", s_else, 0},
  289.   {"end", s_end, 0},
  290.   {"endc", s_endif, 0},
  291.   {"endif", s_endif, 0},
  292. /* endef */
  293.   {"equ", s_set, 0},
  294.   {"err", s_err, 0},
  295.   {"exitm", s_mexit, 0},
  296. /* extend */
  297.   {"extern", s_ignore, 0},    /* We treat all undef as ext */
  298.   {"appfile", s_app_file, 1},
  299.   {"appline", s_app_line, 0},
  300.   {"fail", s_fail, 0},
  301.   {"file", s_app_file, 0},
  302.   {"fill", s_fill, 0},
  303.   {"float", float_cons, 'f'},
  304.   {"format", s_ignore, 0},
  305.   {"global", s_globl, 0},
  306.   {"globl", s_globl, 0},
  307.   {"hword", cons, 2},
  308.   {"if", s_if, (int) O_ne},
  309.   {"ifc", s_ifc, 0},
  310.   {"ifdef", s_ifdef, 0},
  311.   {"ifeq", s_if, (int) O_eq},
  312.   {"ifeqs", s_ifeqs, 0},
  313.   {"ifge", s_if, (int) O_ge},
  314.   {"ifgt", s_if, (int) O_gt},
  315.   {"ifle", s_if, (int) O_le},
  316.   {"iflt", s_if, (int) O_lt},
  317.   {"ifnc", s_ifc, 1},
  318.   {"ifndef", s_ifdef, 1},
  319.   {"ifne", s_if, (int) O_ne},
  320.   {"ifnes", s_ifeqs, 1},
  321.   {"ifnotdef", s_ifdef, 1},
  322.   {"include", s_include, 0},
  323.   {"int", cons, 4},
  324.   {"irp", s_irp, 0},
  325.   {"irep", s_irp, 0},
  326.   {"irpc", s_irp, 1},
  327.   {"irepc", s_irp, 1},
  328.   {"lcomm", s_lcomm, 0},
  329.   {"lflags", listing_flags, 0},    /* Listing flags */
  330.   {"linkonce", s_linkonce, 0},
  331.   {"list", listing_list, 1},    /* Turn listing on */
  332.   {"llen", listing_psize, 1},
  333.   {"long", cons, 4},
  334.   {"lsym", s_lsym, 0},
  335.   {"macro", s_macro, 0},
  336.   {"mexit", s_mexit, 0},
  337.   {"mri", s_mri, 0},
  338.   {".mri", s_mri, 0},    /* Special case so .mri works in MRI mode.  */
  339.   {"name", s_ignore, 0},
  340.   {"noformat", s_ignore, 0},
  341.   {"nolist", listing_list, 0},    /* Turn listing off */
  342.   {"nopage", listing_nopage, 0},
  343.   {"octa", cons, 16},
  344.   {"offset", s_struct, 0},
  345.   {"org", s_org, 0},
  346.   {"p2align", s_align_ptwo, 0},
  347.   {"p2alignw", s_align_ptwo, -2},
  348.   {"p2alignl", s_align_ptwo, -4},
  349.   {"page", listing_eject, 0},
  350.   {"plen", listing_psize, 0},
  351.   {"print", s_print, 0},
  352.   {"psize", listing_psize, 0},    /* set paper size */
  353.   {"purgem", s_purgem, 0},
  354.   {"quad", cons, 8},
  355.   {"rep", s_rept, 0},
  356.   {"rept", s_rept, 0},
  357.   {"rva", s_rva, 4},
  358.   {"sbttl", listing_title, 1},    /* Subtitle of listing */
  359. /* scl */
  360. /* sect */
  361.   {"set", s_set, 0},
  362.   {"short", cons, 2},
  363.   {"single", float_cons, 'f'},
  364. /* size */
  365.   {"space", s_space, 0},
  366.   {"skip", s_space, 0},
  367.   {"spc", s_ignore, 0},
  368.   {"stabd", s_stab, 'd'},
  369.   {"stabn", s_stab, 'n'},
  370.   {"stabs", s_stab, 's'},
  371.   {"string", stringer, 1},
  372.   {"struct", s_struct, 0},
  373. /* tag */
  374.   {"text", s_text, 0},
  375.  
  376.   /* This is for gcc to use.  It's only just been added (2/94), so gcc
  377.      won't be able to use it for a while -- probably a year or more.
  378.      But once this has been released, check with gcc maintainers
  379.      before deleting it or even changing the spelling.  */
  380.   {"this_GCC_requires_the_GNU_assembler", s_ignore, 0},
  381.   /* If we're folding case -- done for some targets, not necessarily
  382.      all -- the above string in an input file will be converted to
  383.      this one.  Match it either way...  */
  384.   {"this_gcc_requires_the_gnu_assembler", s_ignore, 0},
  385.  
  386.   {"title", listing_title, 0},    /* Listing title */
  387.   {"ttl", listing_title, 0},
  388. /* type */
  389. /* use */
  390. /* val */
  391.   {"xcom", s_comm, 0},
  392.   {"xdef", s_globl, 0},
  393.   {"xref", s_ignore, 0},
  394.   {"xstabs", s_xstab, 's'},
  395.   {"word", cons, 2},
  396.   {"zero", s_space, 0},
  397.   {NULL}            /* end sentinel */
  398. };
  399.  
  400. static int pop_override_ok = 0;
  401. static const char *pop_table_name;
  402.  
  403. void
  404. pop_insert (table)
  405.      const pseudo_typeS *table;
  406. {
  407.   const char *errtxt;
  408.   const pseudo_typeS *pop;
  409.   for (pop = table; pop->poc_name; pop++)
  410.     {
  411.       errtxt = hash_insert (po_hash, pop->poc_name, (char *) pop);
  412.       if (errtxt && (!pop_override_ok || strcmp (errtxt, "exists")))
  413.     as_fatal ("error constructing %s pseudo-op table: %s", pop_table_name,
  414.           errtxt);
  415.     }
  416. }
  417.  
  418. #ifndef md_pop_insert
  419. #define md_pop_insert()        pop_insert(md_pseudo_table)
  420. #endif
  421.  
  422. #ifndef obj_pop_insert
  423. #define obj_pop_insert()    pop_insert(obj_pseudo_table)
  424. #endif
  425.  
  426. static void 
  427. pobegin ()
  428. {
  429.   po_hash = hash_new ();
  430.  
  431.   /* Do the target-specific pseudo ops. */
  432.   pop_table_name = "md";
  433.   md_pop_insert ();
  434.  
  435.   /* Now object specific.  Skip any that were in the target table. */
  436.   pop_table_name = "obj";
  437.   pop_override_ok = 1;
  438.   obj_pop_insert ();
  439.  
  440.   /* Now portable ones.  Skip any that we've seen already. */
  441.   pop_table_name = "standard";
  442.   pop_insert (potable);
  443. }
  444.  
  445. #define HANDLE_CONDITIONAL_ASSEMBLY()                    \
  446.   if (ignore_input ())                            \
  447.     {                                    \
  448.       while (! is_end_of_line[(unsigned char) *input_line_pointer++])    \
  449.     if (input_line_pointer == buffer_limit)                \
  450.       break;                            \
  451.       continue;                                \
  452.     }
  453.  
  454.  
  455. /* This function is used when scrubbing the characters between #APP
  456.    and #NO_APP.  */
  457.  
  458. static char *scrub_string;
  459. static char *scrub_string_end;
  460.  
  461. static int
  462. scrub_from_string (from)
  463.      char **from;
  464. {
  465.   int size;
  466.  
  467.   *from = scrub_string;
  468.   size = scrub_string_end - scrub_string;
  469.   scrub_string = scrub_string_end;
  470.   return size;
  471. }
  472.  
  473. /*    read_a_source_file()
  474.  *
  475.  * We read the file, putting things into a web that
  476.  * represents what we have been reading.
  477.  */
  478. void 
  479. read_a_source_file (name)
  480.      char *name;
  481. {
  482.   register char c;
  483.   register char *s;        /* string of symbol, '\0' appended */
  484.   register int temp;
  485.   pseudo_typeS *pop;
  486.  
  487.   buffer = input_scrub_new_file (name);
  488.  
  489.   listing_file (name);
  490.   listing_newline ("");
  491.  
  492.   while ((buffer_limit = input_scrub_next_buffer (&input_line_pointer)) != 0)
  493.     {                /* We have another line to parse. */
  494.       know (buffer_limit[-1] == '\n');    /* Must have a sentinel. */
  495.     contin:            /* JF this goto is my fault I admit it.
  496.                    Someone brave please re-write the whole
  497.                    input section here?  Pleeze???  */
  498.       while (input_line_pointer < buffer_limit)
  499.     {
  500.       /* We have more of this buffer to parse. */
  501.  
  502.       /*
  503.        * We now have input_line_pointer->1st char of next line.
  504.        * If input_line_pointer [-1] == '\n' then we just
  505.        * scanned another line: so bump line counters.
  506.        */
  507.       if (is_end_of_line[(unsigned char) input_line_pointer[-1]])
  508.         {
  509. #ifdef md_start_line_hook
  510.           md_start_line_hook ();
  511. #endif
  512.  
  513.           if (input_line_pointer[-1] == '\n')
  514.         bump_line_counters ();
  515.  
  516.           line_label = NULL;
  517.  
  518.           if (flag_m68k_mri
  519. #ifdef LABELS_WITHOUT_COLONS
  520.           || 1
  521. #endif
  522.           )
  523.         {
  524.           /* Text at the start of a line must be a label, we
  525.              run down and stick a colon in.  */
  526.           if (is_name_beginner (*input_line_pointer))
  527.             {
  528.               char *line_start = input_line_pointer;
  529.               char c;
  530.  
  531.               HANDLE_CONDITIONAL_ASSEMBLY ();
  532.  
  533.               c = get_symbol_end ();
  534.  
  535.               /* In MRI mode, the EQU pseudoop must be
  536.              handled specially.  */
  537.               if (flag_m68k_mri)
  538.             {
  539.               char *rest = input_line_pointer + 1;
  540.  
  541.               if (*rest == ':')
  542.                 ++rest;
  543.               if (*rest == ' ' || *rest == '\t')
  544.                 ++rest;
  545.               if ((strncasecmp (rest, "EQU", 3) == 0
  546.                    || strncasecmp (rest, "SET", 3) == 0)
  547.                   && (rest[3] == ' ' || rest[3] == '\t'))
  548.                 {
  549.                   input_line_pointer = rest + 3;
  550.                   equals (line_start);
  551.                   continue;
  552.                 }
  553.             }
  554.  
  555.               line_label = colon (line_start);
  556.  
  557.               *input_line_pointer = c;
  558.               if (c == ':')
  559.             input_line_pointer++;
  560.             }
  561.         }
  562.         }
  563.  
  564.       /*
  565.        * We are at the begining of a line, or similar place.
  566.        * We expect a well-formed assembler statement.
  567.        * A "symbol-name:" is a statement.
  568.        *
  569.        * Depending on what compiler is used, the order of these tests
  570.        * may vary to catch most common case 1st.
  571.        * Each test is independent of all other tests at the (top) level.
  572.        * PLEASE make a compiler that doesn't use this assembler.
  573.        * It is crufty to waste a compiler's time encoding things for this
  574.        * assembler, which then wastes more time decoding it.
  575.        * (And communicating via (linear) files is silly!
  576.        * If you must pass stuff, please pass a tree!)
  577.        */
  578.       if ((c = *input_line_pointer++) == '\t'
  579.           || c == ' '
  580.           || c == '\f'
  581.           || c == 0)
  582.         {
  583.           c = *input_line_pointer++;
  584.         }
  585.       know (c != ' ');    /* No further leading whitespace. */
  586.       LISTING_NEWLINE ();
  587.       /*
  588.        * C is the 1st significant character.
  589.        * Input_line_pointer points after that character.
  590.        */
  591.       if (is_name_beginner (c))
  592.         {
  593.           /* want user-defined label or pseudo/opcode */
  594.           HANDLE_CONDITIONAL_ASSEMBLY ();
  595.  
  596.           s = --input_line_pointer;
  597.           c = get_symbol_end ();    /* name's delimiter */
  598.           /*
  599.            * C is character after symbol.
  600.            * That character's place in the input line is now '\0'.
  601.            * S points to the beginning of the symbol.
  602.            *   [In case of pseudo-op, s->'.'.]
  603.            * Input_line_pointer->'\0' where c was.
  604.            */
  605.           if (TC_START_LABEL(c, input_line_pointer))
  606.         {
  607.           if (flag_m68k_mri)
  608.             {
  609.               char *rest = input_line_pointer + 1;
  610.  
  611.               /* In MRI mode, \tsym: set 0 is permitted.  */
  612.  
  613.               if (*rest == ':')
  614.             ++rest;
  615.               if (*rest == ' ' || *rest == '\t')
  616.             ++rest;
  617.               if ((strncasecmp (rest, "EQU", 3) == 0
  618.                || strncasecmp (rest, "SET", 3) == 0)
  619.               && (rest[3] == ' ' || rest[3] == '\t'))
  620.             {
  621.               input_line_pointer = rest + 3;
  622.               equals (s);
  623.               continue;
  624.             }
  625.             }
  626.  
  627.           line_label = colon (s);    /* user-defined label */
  628.           *input_line_pointer++ = ':';    /* Put ':' back for error messages' sake. */
  629.           /* Input_line_pointer->after ':'. */
  630.           SKIP_WHITESPACE ();
  631.  
  632.  
  633.         }
  634.           else if (c == '='
  635.                || (input_line_pointer[1] == '='
  636. #ifdef TC_EQUAL_IN_INSN
  637.                && ! TC_EQUAL_IN_INSN (c, input_line_pointer)
  638. #endif
  639.                ))
  640.         {
  641.           equals (s);
  642.           demand_empty_rest_of_line ();
  643.         }
  644.           else
  645.         {        /* expect pseudo-op or machine instruction */
  646.           pop = NULL;
  647.  
  648. #define IGNORE_OPCODE_CASE
  649. #ifdef IGNORE_OPCODE_CASE
  650.           {
  651.             char *s2 = s;
  652.             while (*s2)
  653.               {
  654.             if (isupper (*s2))
  655.               *s2 = tolower (*s2);
  656.             s2++;
  657.               }
  658.           }
  659. #endif
  660.  
  661.           if (flag_m68k_mri
  662. #ifdef NO_PSEUDO_DOT
  663.               || 1
  664. #endif
  665.               )
  666.             {
  667.               /* The MRI assembler and the m88k use pseudo-ops
  668.                          without a period.  */
  669.               pop = (pseudo_typeS *) hash_find (po_hash, s);
  670.               if (pop != NULL && pop->poc_handler == NULL)
  671.             pop = NULL;
  672.             }
  673.  
  674.           if (pop != NULL
  675.               || (! flag_m68k_mri && *s == '.'))
  676.             {
  677.               /*
  678.                * PSEUDO - OP.
  679.                *
  680.                * WARNING: c has next char, which may be end-of-line.
  681.                * We lookup the pseudo-op table with s+1 because we
  682.                * already know that the pseudo-op begins with a '.'.
  683.                */
  684.  
  685.               if (pop == NULL)
  686.             pop = (pseudo_typeS *) hash_find (po_hash, s + 1);
  687.  
  688.               /* In MRI mode, we may need to insert an
  689.                          automatic alignment directive.  What a hack
  690.                          this is.  */
  691.               if (mri_pending_align
  692.               && (pop == NULL
  693.                   || ! ((pop->poc_handler == cons
  694.                      && pop->poc_val == 1)
  695.                     || (pop->poc_handler == s_space
  696.                     && pop->poc_val == 1))))
  697.             {
  698.               do_align (1, (char *) NULL, 0);
  699.               mri_pending_align = 0;
  700.             }
  701.  
  702.               /* Print the error msg now, while we still can */
  703.               if (pop == NULL)
  704.             {
  705.               as_bad ("Unknown pseudo-op:  `%s'", s);
  706.               *input_line_pointer = c;
  707.               s_ignore (0);
  708.               continue;
  709.             }
  710.  
  711.               /* Put it back for error messages etc. */
  712.               *input_line_pointer = c;
  713.               /* The following skip of whitespace is compulsory.
  714.              A well shaped space is sometimes all that separates
  715.              keyword from operands. */
  716.               if (c == ' ' || c == '\t')
  717.             input_line_pointer++;
  718.               /*
  719.                * Input_line is restored.
  720.                * Input_line_pointer->1st non-blank char
  721.                * after pseudo-operation.
  722.                */
  723.               (*pop->poc_handler) (pop->poc_val);
  724.  
  725.               /* If that was .end, just get out now.  */
  726.               if (pop->poc_handler == s_end)
  727.             goto quit;
  728.             }
  729.           else
  730.             {        /* machine instruction */
  731.               int inquote = 0;
  732.  
  733.               if (mri_pending_align)
  734.             {
  735.               do_align (1, (char *) NULL, 0);
  736.               mri_pending_align = 0;
  737.             }
  738.  
  739.               /* WARNING: c has char, which may be end-of-line. */
  740.               /* Also: input_line_pointer->`\0` where c was. */
  741.               *input_line_pointer = c;
  742.               while (!is_end_of_line[(unsigned char) *input_line_pointer]
  743.                  || inquote
  744. #ifdef TC_EOL_IN_INSN
  745.                  || TC_EOL_IN_INSN (input_line_pointer)
  746. #endif
  747.                  )
  748.             {
  749.               if (flag_m68k_mri && *input_line_pointer == '\'')
  750.                 inquote = ! inquote;
  751.               input_line_pointer++;
  752.             }
  753.  
  754.               c = *input_line_pointer;
  755.               *input_line_pointer = '\0';
  756.  
  757. #ifdef OBJ_GENERATE_ASM_LINENO
  758.               if (generate_asm_lineno == 0)
  759.             {
  760.                   if (ecoff_no_current_file ())
  761.                 generate_asm_lineno = 1;
  762.             }
  763.               if (generate_asm_lineno == 1)
  764.                 {
  765.               unsigned int lineno;
  766.               char *s;
  767.  
  768.               as_where (&s, &lineno);
  769.               OBJ_GENERATE_ASM_LINENO (s, lineno);
  770.                 }
  771. #endif
  772.  
  773.               if (macro_defined)
  774.             {
  775.               sb out;
  776.               const char *err;
  777.  
  778.               if (check_macro (s, &out, '\0', &err))
  779.                 {
  780.                   if (err != NULL)
  781.                 as_bad (err);
  782.                   *input_line_pointer++ = c;
  783.                   input_scrub_include_sb (&out,
  784.                               input_line_pointer);
  785.                   sb_kill (&out);
  786.                   buffer_limit =
  787.                 input_scrub_next_buffer (&input_line_pointer);
  788.                   continue;
  789.                 }
  790.             }
  791.  
  792.               md_assemble (s);    /* Assemble 1 instruction. */
  793.  
  794.               *input_line_pointer++ = c;
  795.  
  796.               /* We resume loop AFTER the end-of-line from
  797.              this instruction. */
  798.             }        /* if (*s=='.') */
  799.         }        /* if c==':' */
  800.           continue;
  801.         }            /* if (is_name_beginner(c) */
  802.  
  803.  
  804.       /* Empty statement?  */
  805.       if (is_end_of_line[(unsigned char) c])
  806.         continue;
  807.  
  808.       if ((LOCAL_LABELS_DOLLAR || LOCAL_LABELS_FB)
  809.           && isdigit (c))
  810.         {
  811.           /* local label  ("4:") */
  812.           char *backup = input_line_pointer;
  813.  
  814.           HANDLE_CONDITIONAL_ASSEMBLY ();
  815.  
  816.           temp = c - '0';
  817.  
  818.           while (isdigit (*input_line_pointer))
  819.         {
  820.           temp = (temp * 10) + *input_line_pointer - '0';
  821.           ++input_line_pointer;
  822.         }        /* read the whole number */
  823.  
  824.           if (LOCAL_LABELS_DOLLAR
  825.           && *input_line_pointer == '$'
  826.           && *(input_line_pointer + 1) == ':')
  827.         {
  828.           input_line_pointer += 2;
  829.  
  830.           if (dollar_label_defined (temp))
  831.             {
  832.               as_fatal ("label \"%d$\" redefined", temp);
  833.             }
  834.  
  835.           define_dollar_label (temp);
  836.           colon (dollar_label_name (temp, 0));
  837.           continue;
  838.         }
  839.  
  840.           if (LOCAL_LABELS_FB
  841.           && *input_line_pointer++ == ':')
  842.         {
  843.           fb_label_instance_inc (temp);
  844.           colon (fb_label_name (temp, 0));
  845.           continue;
  846.         }
  847.  
  848.           input_line_pointer = backup;
  849.         }            /* local label  ("4:") */
  850.  
  851.       if (c && strchr (line_comment_chars, c))
  852.         {            /* Its a comment.  Better say APP or NO_APP */
  853.           char *ends;
  854.           char *new_buf;
  855.           char *new_tmp;
  856.           unsigned int new_length;
  857.           char *tmp_buf = 0;
  858.  
  859.           bump_line_counters ();
  860.           s = input_line_pointer;
  861.           if (strncmp (s, "APP\n", 4))
  862.         continue;    /* We ignore it */
  863.           s += 4;
  864.  
  865.           ends = strstr (s, "#NO_APP\n");
  866.  
  867.           if (!ends)
  868.         {
  869.           unsigned int tmp_len;
  870.           unsigned int num;
  871.  
  872.           /* The end of the #APP wasn't in this buffer.  We
  873.              keep reading in buffers until we find the #NO_APP
  874.              that goes with this #APP  There is one.  The specs
  875.              guarentee it. . . */
  876.           tmp_len = buffer_limit - s;
  877.           tmp_buf = xmalloc (tmp_len + 1);
  878.           memcpy (tmp_buf, s, tmp_len);
  879.           do
  880.             {
  881.               new_tmp = input_scrub_next_buffer (&buffer);
  882.               if (!new_tmp)
  883.             break;
  884.               else
  885.             buffer_limit = new_tmp;
  886.               input_line_pointer = buffer;
  887.               ends = strstr (buffer, "#NO_APP\n");
  888.               if (ends)
  889.             num = ends - buffer;
  890.               else
  891.             num = buffer_limit - buffer;
  892.  
  893.               tmp_buf = xrealloc (tmp_buf, tmp_len + num);
  894.               memcpy (tmp_buf + tmp_len, buffer, num);
  895.               tmp_len += num;
  896.             }
  897.           while (!ends);
  898.  
  899.           input_line_pointer = ends ? ends + 8 : NULL;
  900.  
  901.           s = tmp_buf;
  902.           ends = s + tmp_len;
  903.  
  904.         }
  905.           else
  906.         {
  907.           input_line_pointer = ends + 8;
  908.         }
  909.  
  910.           scrub_string = s;
  911.           scrub_string_end = ends;
  912.  
  913.           new_length = ends - s;
  914.           new_buf = (char *) xmalloc (new_length);
  915.           new_tmp = new_buf;
  916.           for (;;)
  917.         {
  918.           int space;
  919.           int size;
  920.  
  921.           space = (new_buf + new_length) - new_tmp;
  922.           size = do_scrub_chars (scrub_from_string, new_tmp, space);
  923.  
  924.           if (size < space)
  925.             {
  926.               new_tmp += size;
  927.               break;
  928.             }
  929.  
  930.           new_buf = xrealloc (new_buf, new_length + 100);
  931.           new_tmp = new_buf + new_length;
  932.           new_length += 100;
  933.         }
  934.  
  935.           if (tmp_buf)
  936.         free (tmp_buf);
  937.           old_buffer = buffer;
  938.           old_input = input_line_pointer;
  939.           old_limit = buffer_limit;
  940.           buffer = new_buf;
  941.           input_line_pointer = new_buf;
  942.           buffer_limit = new_tmp;
  943.           continue;
  944.         }
  945.  
  946.       HANDLE_CONDITIONAL_ASSEMBLY ();
  947.  
  948. #ifdef tc_unrecognized_line
  949.       if (tc_unrecognized_line (c))
  950.         continue;
  951. #endif
  952.  
  953.       /* as_warn("Junk character %d.",c);  Now done by ignore_rest */
  954.       input_line_pointer--;    /* Report unknown char as ignored. */
  955.       ignore_rest_of_line ();
  956.     }            /* while (input_line_pointer<buffer_limit) */
  957.  
  958. #ifdef md_after_pass_hook
  959.       md_after_pass_hook ();
  960. #endif
  961.  
  962.       if (old_buffer)
  963.     {
  964.       free (buffer);
  965.       bump_line_counters ();
  966.       if (old_input != 0)
  967.         {
  968.           buffer = old_buffer;
  969.           input_line_pointer = old_input;
  970.           buffer_limit = old_limit;
  971.           old_buffer = 0;
  972.           goto contin;
  973.         }
  974.     }
  975.     }                /* while (more buffers to scan) */
  976.  
  977.  quit:
  978.   input_scrub_close ();        /* Close the input file */
  979. }
  980.  
  981. /* For most MRI pseudo-ops, the line actually ends at the first
  982.    nonquoted space.  This function looks for that point, stuffs a null
  983.    in, and sets *STOPCP to the character that used to be there, and
  984.    returns the location.
  985.  
  986.    Until I hear otherwise, I am going to assume that this is only true
  987.    for the m68k MRI assembler.  */
  988.  
  989. char *
  990. mri_comment_field (stopcp)
  991.      char *stopcp;
  992. {
  993. #ifdef TC_M68K
  994.  
  995.   char *s;
  996.   int inquote = 0;
  997.  
  998.   know (flag_m68k_mri);
  999.  
  1000.   for (s = input_line_pointer;
  1001.        ((! is_end_of_line[(unsigned char) *s] && *s != ' ' && *s != '\t')
  1002.     || inquote);
  1003.        s++)
  1004.     {
  1005.       if (*s == '\'')
  1006.     inquote = ! inquote;
  1007.     }
  1008.   *stopcp = *s;
  1009.   *s = '\0';
  1010.   return s;
  1011.  
  1012. #else
  1013.  
  1014.   char *s;
  1015.  
  1016.   for (s = input_line_pointer; ! is_end_of_line[(unsigned char) *s]; s++)
  1017.     ;
  1018.   *stopcp = *s;
  1019.   *s = '\0';
  1020.   return s;
  1021.  
  1022. #endif
  1023.  
  1024. }
  1025.  
  1026. /* Skip to the end of an MRI comment field.  */
  1027.  
  1028. void
  1029. mri_comment_end (stop, stopc)
  1030.      char *stop;
  1031.      int stopc;
  1032. {
  1033.   know (flag_mri);
  1034.  
  1035.   input_line_pointer = stop;
  1036.   *stop = stopc;
  1037.   while (! is_end_of_line[(unsigned char) *input_line_pointer])
  1038.     ++input_line_pointer;
  1039. }
  1040.  
  1041. void 
  1042. s_abort (ignore)
  1043.      int ignore;
  1044. {
  1045.   as_fatal (".abort detected.  Abandoning ship.");
  1046. }
  1047.  
  1048. /* Guts of .align directive.  */
  1049. static void 
  1050. do_align (n, fill, len)
  1051.      int n;
  1052.      char *fill;
  1053.      int len;
  1054. {
  1055. #ifdef md_do_align
  1056.   md_do_align (n, fill, len, just_record_alignment);
  1057. #endif
  1058.   if (!fill)
  1059.     {
  1060.       /* @@ Fix this right for BFD!  */
  1061.       static char zero;
  1062.       static char nop_opcode = NOP_OPCODE;
  1063.  
  1064.       if (now_seg != data_section && now_seg != bss_section)
  1065.     {
  1066.       fill = &nop_opcode;
  1067.     }
  1068.       else
  1069.     {
  1070.       fill = &zero;
  1071.     }
  1072.       len = 1;
  1073.     }
  1074.  
  1075.   /* Only make a frag if we HAVE to. . . */
  1076.   if (n && !need_pass_2)
  1077.     {
  1078.       if (len <= 1)
  1079.     frag_align (n, *fill);
  1080.       else
  1081.     frag_align_pattern (n, fill, len);
  1082.     }
  1083.  
  1084. #ifdef md_do_align
  1085.  just_record_alignment:
  1086. #endif
  1087.  
  1088.   record_alignment (now_seg, n);
  1089. }
  1090.  
  1091. /* For machines where ".align 4" means align to a 4 byte boundary. */
  1092. void 
  1093. s_align_bytes (arg)
  1094.      int arg;
  1095. {
  1096.   register unsigned int temp;
  1097.   char temp_fill;
  1098.   unsigned int i = 0;
  1099.   unsigned long max_alignment = 1 << 15;
  1100.   char *stop = NULL;
  1101.   char stopc;
  1102.  
  1103.   if (flag_mri)
  1104.     stop = mri_comment_field (&stopc);
  1105.  
  1106.   if (is_end_of_line[(unsigned char) *input_line_pointer])
  1107.     {
  1108.       if (arg < 0)
  1109.     temp = 0;
  1110.       else
  1111.     temp = arg;    /* Default value from pseudo-op table */
  1112.     }
  1113.   else
  1114.     temp = get_absolute_expression ();
  1115.  
  1116.   if (temp > max_alignment)
  1117.     {
  1118.       as_bad ("Alignment too large: %d. assumed.", temp = max_alignment);
  1119.     }
  1120.  
  1121.   /* For the sparc, `.align (1<<n)' actually means `.align n' so we
  1122.      have to convert it.  */
  1123.   if (temp != 0)
  1124.     {
  1125.       for (i = 0; (temp & 1) == 0; temp >>= 1, ++i)
  1126.     ;
  1127.     }
  1128.   if (temp != 1)
  1129.     as_bad ("Alignment not a power of 2");
  1130.  
  1131.   temp = i;
  1132.   if (*input_line_pointer == ',')
  1133.     {
  1134.       offsetT fillval;
  1135.       int len;
  1136.  
  1137.       input_line_pointer++;
  1138.       fillval = get_absolute_expression ();
  1139.       if (arg >= 0)
  1140.     len = 1;
  1141.       else
  1142.     len = - arg;
  1143.       if (len <= 1)
  1144.     {
  1145.       temp_fill = fillval;
  1146.       do_align (temp, &temp_fill, len);
  1147.     }
  1148.       else
  1149.     {
  1150.       char ab[16];
  1151.  
  1152.       if (len > sizeof ab)
  1153.         abort ();
  1154.       md_number_to_chars (ab, fillval, len);
  1155.       do_align (temp, ab, len);
  1156.     }
  1157.     }
  1158.   else
  1159.     {
  1160.       if (arg < 0)
  1161.     as_warn ("expected fill pattern missing");
  1162.       do_align (temp, (char *) NULL, 0);
  1163.     }
  1164.  
  1165.   if (flag_mri)
  1166.     mri_comment_end (stop, stopc);
  1167.  
  1168.   demand_empty_rest_of_line ();
  1169. }
  1170.  
  1171. /* For machines where ".align 4" means align to 2**4 boundary. */
  1172. void 
  1173. s_align_ptwo (arg)
  1174.      int arg;
  1175. {
  1176.   register int temp;
  1177.   char temp_fill;
  1178.   long max_alignment = 15;
  1179.   char *stop = NULL;
  1180.   char stopc;
  1181.  
  1182.   if (flag_mri)
  1183.     stop = mri_comment_field (&stopc);
  1184.  
  1185.   temp = get_absolute_expression ();
  1186.   if (temp > max_alignment)
  1187.     as_bad ("Alignment too large: %d. assumed.", temp = max_alignment);
  1188.   else if (temp < 0)
  1189.     {
  1190.       as_bad ("Alignment negative. 0 assumed.");
  1191.       temp = 0;
  1192.     }
  1193.   if (*input_line_pointer == ',')
  1194.     {
  1195.       offsetT fillval;
  1196.       int len;
  1197.  
  1198.       input_line_pointer++;
  1199.       fillval = get_absolute_expression ();
  1200.       if (arg >= 0)
  1201.     len = 1;
  1202.       else
  1203.     len = - arg;
  1204.       if (len <= 1)
  1205.     {
  1206.       temp_fill = fillval;
  1207.       do_align (temp, &temp_fill, len);
  1208.     }
  1209.       else
  1210.     {
  1211.       char ab[16];
  1212.  
  1213.       if (len > sizeof ab)
  1214.         abort ();
  1215.       md_number_to_chars (ab, fillval, len);
  1216.       do_align (temp, ab, len);
  1217.     }
  1218.     }
  1219.   else
  1220.     {
  1221.       if (arg < 0)
  1222.     as_warn ("expected fill pattern missing");
  1223.       do_align (temp, (char *) NULL, 0);
  1224.     }
  1225.  
  1226.   if (flag_mri)
  1227.     mri_comment_end (stop, stopc);
  1228.  
  1229.   demand_empty_rest_of_line ();
  1230. }
  1231.  
  1232. void 
  1233. s_comm (ignore)
  1234.      int ignore;
  1235. {
  1236.   register char *name;
  1237.   register char c;
  1238.   register char *p;
  1239.   offsetT temp;
  1240.   register symbolS *symbolP;
  1241.   char *stop = NULL;
  1242.   char stopc;
  1243.  
  1244.   if (flag_mri)
  1245.     stop = mri_comment_field (&stopc);
  1246.  
  1247.   name = input_line_pointer;
  1248.   c = get_symbol_end ();
  1249.   /* just after name is now '\0' */
  1250.   p = input_line_pointer;
  1251.   *p = c;
  1252.   SKIP_WHITESPACE ();
  1253.   if (*input_line_pointer != ',')
  1254.     {
  1255.       as_bad ("Expected comma after symbol-name: rest of line ignored.");
  1256.       if (flag_mri)
  1257.     mri_comment_end (stop, stopc);
  1258.       ignore_rest_of_line ();
  1259.       return;
  1260.     }
  1261.   input_line_pointer++;        /* skip ',' */
  1262.   if ((temp = get_absolute_expression ()) < 0)
  1263.     {
  1264.       as_warn (".COMMon length (%ld.) <0! Ignored.", (long) temp);
  1265.       if (flag_mri)
  1266.     mri_comment_end (stop, stopc);
  1267.       ignore_rest_of_line ();
  1268.       return;
  1269.     }
  1270.   *p = 0;
  1271.   symbolP = symbol_find_or_make (name);
  1272.   *p = c;
  1273.   if (S_IS_DEFINED (symbolP))
  1274.     {
  1275.       as_bad ("Ignoring attempt to re-define symbol `%s'.",
  1276.           S_GET_NAME (symbolP));
  1277.       if (flag_mri)
  1278.     mri_comment_end (stop, stopc);
  1279.       ignore_rest_of_line ();
  1280.       return;
  1281.     }
  1282.   if (S_GET_VALUE (symbolP))
  1283.     {
  1284.       if (S_GET_VALUE (symbolP) != (valueT) temp)
  1285.     as_bad ("Length of .comm \"%s\" is already %ld. Not changed to %ld.",
  1286.         S_GET_NAME (symbolP),
  1287.         (long) S_GET_VALUE (symbolP),
  1288.         (long) temp);
  1289.     }
  1290.   else
  1291.     {
  1292.       S_SET_VALUE (symbolP, (valueT) temp);
  1293.       S_SET_EXTERNAL (symbolP);
  1294.     }
  1295. #ifdef OBJ_VMS
  1296.   {
  1297.     extern int flag_one;
  1298.     if ( (!temp) || !flag_one)
  1299.       S_GET_OTHER(symbolP) = const_flag;
  1300.   }
  1301. #endif /* not OBJ_VMS */
  1302.   know (symbolP->sy_frag == &zero_address_frag);
  1303.  
  1304.   if (flag_mri)
  1305.     mri_comment_end (stop, stopc);
  1306.  
  1307.   demand_empty_rest_of_line ();
  1308. }                /* s_comm() */
  1309.  
  1310. /* The MRI COMMON pseudo-op.  We handle this by creating a common
  1311.    symbol with the appropriate name.  We make s_space do the right
  1312.    thing by increasing the size.  */
  1313.  
  1314. void
  1315. s_mri_common (small)
  1316.      int small;
  1317. {
  1318.   char *name;
  1319.   char c;
  1320.   char *alc = NULL;
  1321.   symbolS *sym;
  1322.   offsetT align;
  1323.   char *stop = NULL;
  1324.   char stopc;
  1325.  
  1326.   if (! flag_mri)
  1327.     {
  1328.       s_comm (0);
  1329.       return;
  1330.     }
  1331.  
  1332.   stop = mri_comment_field (&stopc);
  1333.  
  1334.   SKIP_WHITESPACE ();
  1335.  
  1336.   name = input_line_pointer;
  1337.   if (! isdigit ((unsigned char) *name))
  1338.     c = get_symbol_end ();
  1339.   else
  1340.     {
  1341.       do
  1342.     {
  1343.       ++input_line_pointer;
  1344.     }
  1345.       while (isdigit ((unsigned char) *input_line_pointer));
  1346.       c = *input_line_pointer;
  1347.       *input_line_pointer = '\0';
  1348.  
  1349.       if (line_label != NULL)
  1350.     {
  1351.       alc = (char *) xmalloc (strlen (S_GET_NAME (line_label))
  1352.                   + (input_line_pointer - name)
  1353.                   + 1);
  1354.       sprintf (alc, "%s%s", name, S_GET_NAME (line_label));
  1355.       name = alc;
  1356.     }
  1357.     }
  1358.  
  1359.   sym = symbol_find_or_make (name);
  1360.   *input_line_pointer = c;
  1361.   if (alc != NULL)
  1362.     free (alc);
  1363.  
  1364.   if (*input_line_pointer != ',')
  1365.     align = 0;
  1366.   else
  1367.     {
  1368.       ++input_line_pointer;
  1369.       align = get_absolute_expression ();
  1370.     }
  1371.  
  1372.   if (S_IS_DEFINED (sym))
  1373.     {
  1374. #if defined (S_IS_COMMON) || defined (BFD_ASSEMBLER)
  1375.       if (! S_IS_COMMON (sym))
  1376. #endif
  1377.     {
  1378.       as_bad ("attempt to re-define symbol `%s'", S_GET_NAME (sym));
  1379.       mri_comment_end (stop, stopc);
  1380.       ignore_rest_of_line ();
  1381.       return;
  1382.     }
  1383.     }
  1384.  
  1385.   S_SET_EXTERNAL (sym);
  1386.   mri_common_symbol = sym;
  1387.  
  1388. #ifdef S_SET_ALIGN
  1389.   if (align != 0)
  1390.     S_SET_ALIGN (sym, align);
  1391. #endif
  1392.  
  1393.   if (line_label != NULL)
  1394.     {
  1395.       line_label->sy_value.X_op = O_symbol;
  1396.       line_label->sy_value.X_add_symbol = sym;
  1397.       line_label->sy_value.X_add_number = S_GET_VALUE (sym);
  1398.       line_label->sy_frag = &zero_address_frag;
  1399.       S_SET_SEGMENT (line_label, expr_section);
  1400.     }
  1401.  
  1402.   /* FIXME: We just ignore the small argument, which distinguishes
  1403.      COMMON and COMMON.S.  I don't know what we can do about it.  */
  1404.  
  1405.   /* Ignore the type and hptype.  */
  1406.   if (*input_line_pointer == ',')
  1407.     input_line_pointer += 2;
  1408.   if (*input_line_pointer == ',')
  1409.     input_line_pointer += 2;
  1410.  
  1411.   mri_comment_end (stop, stopc);
  1412.  
  1413.   demand_empty_rest_of_line ();
  1414. }
  1415.  
  1416. void
  1417. s_data (ignore)
  1418.      int ignore;
  1419. {
  1420.   segT section;
  1421.   register int temp;
  1422.  
  1423.   temp = get_absolute_expression ();
  1424.   if (flag_readonly_data_in_text)
  1425.     {
  1426.       section = text_section;
  1427.       temp += 1000;
  1428.     }
  1429.   else
  1430.     section = data_section;
  1431.  
  1432.   subseg_set (section, (subsegT) temp);
  1433.  
  1434. #ifdef OBJ_VMS
  1435.   const_flag = 0;
  1436. #endif
  1437.   demand_empty_rest_of_line ();
  1438. }
  1439.  
  1440. /* Handle the .appfile pseudo-op.  This is automatically generated by
  1441.    do_scrub_chars when a preprocessor # line comment is seen with a
  1442.    file name.  This default definition may be overridden by the object
  1443.    or CPU specific pseudo-ops.  This function is also the default
  1444.    definition for .file; the APPFILE argument is 1 for .appfile, 0 for
  1445.    .file.  */
  1446.  
  1447. void 
  1448. s_app_file (appfile)
  1449.      int appfile;
  1450. {
  1451.   register char *s;
  1452.   int length;
  1453.  
  1454.   /* Some assemblers tolerate immediately following '"' */
  1455.   if ((s = demand_copy_string (&length)) != 0)
  1456.     {
  1457.       /* If this is a fake .appfile, a fake newline was inserted into
  1458.      the buffer.  Passing -2 to new_logical_line tells it to
  1459.      account for it.  */
  1460.       new_logical_line (s, appfile ? -2 : -1);
  1461.  
  1462.       /* In MRI mode, the preprocessor may have inserted an extraneous
  1463.          backquote.  */
  1464.       if (flag_m68k_mri
  1465.       && *input_line_pointer == '\''
  1466.       && is_end_of_line[(unsigned char) input_line_pointer[1]])
  1467.     ++input_line_pointer;
  1468.  
  1469.       demand_empty_rest_of_line ();
  1470. #ifdef LISTING
  1471.       if (listing)
  1472.     listing_source_file (s);
  1473. #endif
  1474.     }
  1475. #ifdef obj_app_file
  1476.   obj_app_file (s);
  1477. #endif
  1478. }
  1479.  
  1480. /* Handle the .appline pseudo-op.  This is automatically generated by
  1481.    do_scrub_chars when a preprocessor # line comment is seen.  This
  1482.    default definition may be overridden by the object or CPU specific
  1483.    pseudo-ops.  */
  1484.  
  1485. void
  1486. s_app_line (ignore)
  1487.      int ignore;
  1488. {
  1489.   int l;
  1490.  
  1491.   /* The given number is that of the next line.  */
  1492.   l = get_absolute_expression () - 1;
  1493.   if (l < 0)
  1494.     /* Some of the back ends can't deal with non-positive line numbers.
  1495.        Besides, it's silly.  */
  1496.     as_warn ("Line numbers must be positive; line number %d rejected.", l+1);
  1497.   else
  1498.     {
  1499.       new_logical_line ((char *) NULL, l);
  1500. #ifdef LISTING
  1501.       if (listing)
  1502.     listing_source_line (l);
  1503. #endif
  1504.     }
  1505.   demand_empty_rest_of_line ();
  1506. }
  1507.  
  1508. /* Handle the .end pseudo-op.  Actually, the real work is done in
  1509.    read_a_source_file.  */
  1510.  
  1511. void
  1512. s_end (ignore)
  1513.      int ignore;
  1514. {
  1515.   if (flag_mri)
  1516.     {
  1517.       /* The MRI assembler permits the start symbol to follow .end,
  1518.          but we don't support that.  */
  1519.       SKIP_WHITESPACE ();
  1520.       if (! is_end_of_line[(unsigned char) *input_line_pointer]
  1521.       && *input_line_pointer != '*'
  1522.       && *input_line_pointer != '!')
  1523.     as_warn ("start address not supported");
  1524.     }
  1525. }
  1526.  
  1527. /* Handle the .err pseudo-op.  */
  1528.  
  1529. void
  1530. s_err (ignore)
  1531.      int ignore;
  1532. {
  1533.   as_bad (".err encountered");
  1534.   demand_empty_rest_of_line ();
  1535. }
  1536.  
  1537. /* Handle the MRI fail pseudo-op.  */
  1538.  
  1539. void
  1540. s_fail (ignore)
  1541.      int ignore;
  1542. {
  1543.   offsetT temp;
  1544.   char *stop = NULL;
  1545.   char stopc;
  1546.  
  1547.   if (flag_mri)
  1548.     stop = mri_comment_field (&stopc);
  1549.  
  1550.   temp = get_absolute_expression ();
  1551.   if (temp >= 500)
  1552.     as_warn (".fail %ld encountered", (long) temp);
  1553.   else
  1554.     as_bad (".fail %ld encountered", (long) temp);
  1555.  
  1556.   if (flag_mri)
  1557.     mri_comment_end (stop, stopc);
  1558.  
  1559.   demand_empty_rest_of_line ();
  1560. }
  1561.  
  1562. void 
  1563. s_fill (ignore)
  1564.      int ignore;
  1565. {
  1566.   long temp_repeat = 0;
  1567.   long temp_size = 1;
  1568.   register long temp_fill = 0;
  1569.   char *p;
  1570.  
  1571. #ifdef md_flush_pending_output
  1572.   md_flush_pending_output ();
  1573. #endif
  1574.  
  1575.   temp_repeat = get_absolute_expression ();
  1576.   if (*input_line_pointer == ',')
  1577.     {
  1578.       input_line_pointer++;
  1579.       temp_size = get_absolute_expression ();
  1580.       if (*input_line_pointer == ',')
  1581.     {
  1582.       input_line_pointer++;
  1583.       temp_fill = get_absolute_expression ();
  1584.     }
  1585.     }
  1586.   /* This is to be compatible with BSD 4.2 AS, not for any rational reason.  */
  1587. #define BSD_FILL_SIZE_CROCK_8 (8)
  1588.   if (temp_size > BSD_FILL_SIZE_CROCK_8)
  1589.     {
  1590.       as_warn (".fill size clamped to %d.", BSD_FILL_SIZE_CROCK_8);
  1591.       temp_size = BSD_FILL_SIZE_CROCK_8;
  1592.     }
  1593.   if (temp_size < 0)
  1594.     {
  1595.       as_warn ("Size negative: .fill ignored.");
  1596.       temp_size = 0;
  1597.     }
  1598.   else if (temp_repeat <= 0)
  1599.     {
  1600.       if (temp_repeat < 0)
  1601.     as_warn ("Repeat < 0, .fill ignored");
  1602.       temp_size = 0;
  1603.     }
  1604.  
  1605.   if (temp_size && !need_pass_2)
  1606.     {
  1607.       p = frag_var (rs_fill, (int) temp_size, (int) temp_size, (relax_substateT) 0, (symbolS *) 0, temp_repeat, (char *) 0);
  1608.       memset (p, 0, (unsigned int) temp_size);
  1609.       /* The magic number BSD_FILL_SIZE_CROCK_4 is from BSD 4.2 VAX
  1610.        * flavoured AS.  The following bizzare behaviour is to be
  1611.        * compatible with above.  I guess they tried to take up to 8
  1612.        * bytes from a 4-byte expression and they forgot to sign
  1613.        * extend. Un*x Sux. */
  1614. #define BSD_FILL_SIZE_CROCK_4 (4)
  1615.       md_number_to_chars (p, (valueT) temp_fill,
  1616.               (temp_size > BSD_FILL_SIZE_CROCK_4
  1617.                ? BSD_FILL_SIZE_CROCK_4
  1618.                : (int) temp_size));
  1619.       /* Note: .fill (),0 emits no frag (since we are asked to .fill 0 bytes)
  1620.        * but emits no error message because it seems a legal thing to do.
  1621.        * It is a degenerate case of .fill but could be emitted by a compiler.
  1622.        */
  1623.     }
  1624.   demand_empty_rest_of_line ();
  1625. }
  1626.  
  1627. void 
  1628. s_globl (ignore)
  1629.      int ignore;
  1630. {
  1631.   char *name;
  1632.   int c;
  1633.   symbolS *symbolP;
  1634.   char *stop = NULL;
  1635.   char stopc;
  1636.  
  1637.   if (flag_mri)
  1638.     stop = mri_comment_field (&stopc);
  1639.  
  1640.   do
  1641.     {
  1642.       name = input_line_pointer;
  1643.       c = get_symbol_end ();
  1644.       symbolP = symbol_find_or_make (name);
  1645.       *input_line_pointer = c;
  1646.       SKIP_WHITESPACE ();
  1647.       S_SET_EXTERNAL (symbolP);
  1648.       if (c == ',')
  1649.     {
  1650.       input_line_pointer++;
  1651.       SKIP_WHITESPACE ();
  1652.       if (*input_line_pointer == '\n')
  1653.         c = '\n';
  1654.     }
  1655.     }
  1656.   while (c == ',');
  1657.  
  1658.   if (flag_mri)
  1659.     mri_comment_end (stop, stopc);
  1660.  
  1661.   demand_empty_rest_of_line ();
  1662. }
  1663.  
  1664. /* Handle the MRI IRP and IRPC pseudo-ops.  */
  1665.  
  1666. void
  1667. s_irp (irpc)
  1668.      int irpc;
  1669. {
  1670.   char *file;
  1671.   unsigned int line;
  1672.   sb s;
  1673.   const char *err;
  1674.   sb out;
  1675.  
  1676.   as_where (&file, &line);
  1677.  
  1678.   sb_new (&s);
  1679.   while (! is_end_of_line[(unsigned char) *input_line_pointer])
  1680.     sb_add_char (&s, *input_line_pointer++);
  1681.  
  1682.   sb_new (&out);
  1683.  
  1684.   err = expand_irp (irpc, 0, &s, &out, get_line_sb, '\0');
  1685.   if (err != NULL)
  1686.     as_bad_where (file, line, "%s", err);
  1687.  
  1688.   sb_kill (&s);
  1689.  
  1690.   input_scrub_include_sb (&out, input_line_pointer);
  1691.   sb_kill (&out);
  1692.   buffer_limit = input_scrub_next_buffer (&input_line_pointer);
  1693. }
  1694.  
  1695. /* Handle the .linkonce pseudo-op.  This tells the assembler to mark
  1696.    the section to only be linked once.  However, this is not supported
  1697.    by most object file formats.  This takes an optional argument,
  1698.    which is what to do about duplicates.  */
  1699.  
  1700. void
  1701. s_linkonce (ignore)
  1702.      int ignore;
  1703. {
  1704.   enum linkonce_type type;
  1705.  
  1706.   SKIP_WHITESPACE ();
  1707.  
  1708.   type = LINKONCE_DISCARD;
  1709.  
  1710.   if (! is_end_of_line[(unsigned char) *input_line_pointer])
  1711.     {
  1712.       char *s;
  1713.       char c;
  1714.  
  1715.       s = input_line_pointer;
  1716.       c = get_symbol_end ();
  1717.       if (strcasecmp (s, "discard") == 0)
  1718.     type = LINKONCE_DISCARD;
  1719.       else if (strcasecmp (s, "one_only") == 0)
  1720.     type = LINKONCE_ONE_ONLY;
  1721.       else if (strcasecmp (s, "same_size") == 0)
  1722.     type = LINKONCE_SAME_SIZE;
  1723.       else if (strcasecmp (s, "same_contents") == 0)
  1724.     type = LINKONCE_SAME_CONTENTS;
  1725.       else
  1726.     as_warn ("unrecognized .linkonce type `%s'", s);
  1727.  
  1728.       *input_line_pointer = c;
  1729.     }
  1730.  
  1731. #ifdef obj_handle_link_once
  1732.   obj_handle_link_once (type);
  1733. #else /* ! defined (obj_handle_link_once) */
  1734. #ifdef BFD_ASSEMBLER
  1735.   {
  1736.     flagword flags;
  1737.  
  1738.     if ((bfd_applicable_section_flags (stdoutput) & SEC_LINK_ONCE) == 0)
  1739.       as_warn (".linkonce is not supported for this object file format");
  1740.  
  1741.     flags = bfd_get_section_flags (stdoutput, now_seg);
  1742.     flags |= SEC_LINK_ONCE;
  1743.     switch (type)
  1744.       {
  1745.       default:
  1746.     abort ();
  1747.       case LINKONCE_DISCARD:
  1748.     flags |= SEC_LINK_DUPLICATES_DISCARD;
  1749.     break;
  1750.       case LINKONCE_ONE_ONLY:
  1751.     flags |= SEC_LINK_DUPLICATES_ONE_ONLY;
  1752.     break;
  1753.       case LINKONCE_SAME_SIZE:
  1754.     flags |= SEC_LINK_DUPLICATES_SAME_SIZE;
  1755.     break;
  1756.       case LINKONCE_SAME_CONTENTS:
  1757.     flags |= SEC_LINK_DUPLICATES_SAME_CONTENTS;
  1758.     break;
  1759.       }
  1760.     if (! bfd_set_section_flags (stdoutput, now_seg, flags))
  1761.       as_bad ("bfd_set_section_flags: %s",
  1762.           bfd_errmsg (bfd_get_error ()));
  1763.   }
  1764. #else /* ! defined (BFD_ASSEMBLER) */
  1765.   as_warn (".linkonce is not supported for this object file format");
  1766. #endif /* ! defined (BFD_ASSEMBLER) */
  1767. #endif /* ! defined (obj_handle_link_once) */
  1768.  
  1769.   demand_empty_rest_of_line ();
  1770. }
  1771.  
  1772. void 
  1773. s_lcomm (needs_align)
  1774.      /* 1 if this was a ".bss" directive, which may require a 3rd argument
  1775.     (alignment); 0 if it was an ".lcomm" (2 args only)  */
  1776.      int needs_align;
  1777. {
  1778.   register char *name;
  1779.   register char c;
  1780.   register char *p;
  1781.   register int temp;
  1782.   register symbolS *symbolP;
  1783.   segT current_seg = now_seg;
  1784.   subsegT current_subseg = now_subseg;
  1785.   const int max_alignment = 15;
  1786.   int align = 0;
  1787.   segT bss_seg = bss_section;
  1788.  
  1789.   name = input_line_pointer;
  1790.   c = get_symbol_end ();
  1791.   p = input_line_pointer;
  1792.   *p = c;
  1793.   SKIP_WHITESPACE ();
  1794.  
  1795.   /* Accept an optional comma after the name.  The comma used to be
  1796.      required, but Irix 5 cc does not generate it.  */
  1797.   if (*input_line_pointer == ',')
  1798.     {
  1799.       ++input_line_pointer;
  1800.       SKIP_WHITESPACE ();
  1801.     }
  1802.  
  1803.   if (*input_line_pointer == '\n')
  1804.     {
  1805.       as_bad ("Missing size expression");
  1806.       return;
  1807.     }
  1808.  
  1809.   if ((temp = get_absolute_expression ()) < 0)
  1810.     {
  1811.       as_warn ("BSS length (%d.) <0! Ignored.", temp);
  1812.       ignore_rest_of_line ();
  1813.       return;
  1814.     }
  1815.  
  1816. #if defined (TC_MIPS) || defined (TC_ALPHA)
  1817.   if (OUTPUT_FLAVOR == bfd_target_ecoff_flavour
  1818.       || OUTPUT_FLAVOR == bfd_target_elf_flavour)
  1819.     {
  1820.       /* For MIPS and Alpha ECOFF or ELF, small objects are put in .sbss.  */
  1821.       if (temp <= bfd_get_gp_size (stdoutput))
  1822.     {
  1823.       bss_seg = subseg_new (".sbss", 1);
  1824.       seg_info (bss_seg)->bss = 1;
  1825. #ifdef BFD_ASSEMBLER
  1826.       if (! bfd_set_section_flags (stdoutput, bss_seg, SEC_ALLOC))
  1827.         as_warn ("error setting flags for \".sbss\": %s",
  1828.              bfd_errmsg (bfd_get_error ()));
  1829. #endif
  1830.     }
  1831.     }
  1832. #endif
  1833.    if (!needs_align)
  1834.      {
  1835.        /* FIXME. This needs to be machine independent. */
  1836.        if (temp >= 8)
  1837.      align = 3;
  1838.        else if (temp >= 4)
  1839.      align = 2;
  1840.        else if (temp >= 2)
  1841.      align = 1;
  1842.        else
  1843.      align = 0;
  1844.  
  1845.        record_alignment(bss_seg, align);
  1846.      }
  1847.  
  1848.   if (needs_align)
  1849.     {
  1850.       align = 0;
  1851.       SKIP_WHITESPACE ();
  1852.       if (*input_line_pointer != ',')
  1853.     {
  1854.       as_bad ("Expected comma after size");
  1855.       ignore_rest_of_line ();
  1856.       return;
  1857.     }
  1858.       input_line_pointer++;
  1859.       SKIP_WHITESPACE ();
  1860.       if (*input_line_pointer == '\n')
  1861.     {
  1862.       as_bad ("Missing alignment");
  1863.       return;
  1864.     }
  1865.       align = get_absolute_expression ();
  1866.       if (align > max_alignment)
  1867.     {
  1868.       align = max_alignment;
  1869.       as_warn ("Alignment too large: %d. assumed.", align);
  1870.     }
  1871.       else if (align < 0)
  1872.     {
  1873.       align = 0;
  1874.       as_warn ("Alignment negative. 0 assumed.");
  1875.     }
  1876.       record_alignment (bss_seg, align);
  1877.     }                /* if needs align */
  1878.   else
  1879.     {
  1880.       /* Assume some objects may require alignment on some systems.  */
  1881. #ifdef TC_ALPHA
  1882.       if (temp > 1)
  1883.     {
  1884.       align = ffs (temp) - 1;
  1885.       if (temp % (1 << align))
  1886.         abort ();
  1887.     }
  1888. #endif
  1889.     }
  1890.  
  1891.   *p = 0;
  1892.   symbolP = symbol_find_or_make (name);
  1893.   *p = c;
  1894.  
  1895.   if (
  1896. #if defined(OBJ_AOUT) | defined(OBJ_BOUT)
  1897.        S_GET_OTHER (symbolP) == 0 &&
  1898.        S_GET_DESC (symbolP) == 0 &&
  1899. #endif /* OBJ_AOUT or OBJ_BOUT */
  1900.        (S_GET_SEGMENT (symbolP) == bss_seg
  1901.     || (!S_IS_DEFINED (symbolP) && S_GET_VALUE (symbolP) == 0)))
  1902.     {
  1903.       char *pfrag;
  1904.  
  1905.       subseg_set (bss_seg, 1);
  1906.  
  1907.       if (align)
  1908.     frag_align (align, 0);
  1909.                     /* detach from old frag    */
  1910.       if (S_GET_SEGMENT (symbolP) == bss_seg)
  1911.     symbolP->sy_frag->fr_symbol = NULL;
  1912.  
  1913.       symbolP->sy_frag = frag_now;
  1914.       pfrag = frag_var (rs_org, 1, 1, (relax_substateT)0, symbolP,
  1915.             temp, (char *)0);
  1916.       *pfrag = 0;
  1917.  
  1918.       S_SET_SEGMENT (symbolP, bss_seg);
  1919.  
  1920. #ifdef OBJ_COFF
  1921.       /* The symbol may already have been created with a preceding
  1922.          ".globl" directive -- be careful not to step on storage class
  1923.          in that case.  Otherwise, set it to static. */
  1924.       if (S_GET_STORAGE_CLASS (symbolP) != C_EXT)
  1925.     {
  1926.       S_SET_STORAGE_CLASS (symbolP, C_STAT);
  1927.     }
  1928. #endif /* OBJ_COFF */
  1929.  
  1930. #ifdef S_SET_SIZE
  1931.       S_SET_SIZE (symbolP, temp);
  1932. #endif
  1933.     }
  1934.   else
  1935.     as_bad ("Ignoring attempt to re-define symbol `%s'.",
  1936.         S_GET_NAME (symbolP));
  1937.  
  1938.   subseg_set (current_seg, current_subseg);
  1939.  
  1940.   demand_empty_rest_of_line ();
  1941. }                /* s_lcomm() */
  1942.  
  1943. void 
  1944. s_lsym (ignore)
  1945.      int ignore;
  1946. {
  1947.   register char *name;
  1948.   register char c;
  1949.   register char *p;
  1950.   expressionS exp;
  1951.   register symbolS *symbolP;
  1952.  
  1953.   /* we permit ANY defined expression: BSD4.2 demands constants */
  1954.   name = input_line_pointer;
  1955.   c = get_symbol_end ();
  1956.   p = input_line_pointer;
  1957.   *p = c;
  1958.   SKIP_WHITESPACE ();
  1959.   if (*input_line_pointer != ',')
  1960.     {
  1961.       *p = 0;
  1962.       as_bad ("Expected comma after name \"%s\"", name);
  1963.       *p = c;
  1964.       ignore_rest_of_line ();
  1965.       return;
  1966.     }
  1967.   input_line_pointer++;
  1968.   expression (&exp);
  1969.   if (exp.X_op != O_constant
  1970.       && exp.X_op != O_register)
  1971.     {
  1972.       as_bad ("bad expression");
  1973.       ignore_rest_of_line ();
  1974.       return;
  1975.     }
  1976.   *p = 0;
  1977.   symbolP = symbol_find_or_make (name);
  1978.  
  1979.   /* FIXME-SOON I pulled a (&& symbolP->sy_other == 0 &&
  1980.      symbolP->sy_desc == 0) out of this test because coff doesn't have
  1981.      those fields, and I can't see when they'd ever be tripped.  I
  1982.      don't think I understand why they were here so I may have
  1983.      introduced a bug. As recently as 1.37 didn't have this test
  1984.      anyway.  xoxorich. */
  1985.  
  1986.   if (S_GET_SEGMENT (symbolP) == undefined_section
  1987.       && S_GET_VALUE (symbolP) == 0)
  1988.     {
  1989.       /* The name might be an undefined .global symbol; be sure to
  1990.      keep the "external" bit. */
  1991.       S_SET_SEGMENT (symbolP,
  1992.              (exp.X_op == O_constant
  1993.               ? absolute_section
  1994.               : reg_section));
  1995.       S_SET_VALUE (symbolP, (valueT) exp.X_add_number);
  1996.     }
  1997.   else
  1998.     {
  1999.       as_bad ("Symbol %s already defined", name);
  2000.     }
  2001.   *p = c;
  2002.   demand_empty_rest_of_line ();
  2003. }                /* s_lsym() */
  2004.  
  2005. /* Read a line into an sb.  */
  2006.  
  2007. static int
  2008. get_line_sb (line)
  2009.      sb *line;
  2010. {
  2011.   if (input_line_pointer[-1] == '\n')
  2012.     bump_line_counters ();
  2013.  
  2014.   if (input_line_pointer >= buffer_limit)
  2015.     {
  2016.       buffer_limit = input_scrub_next_buffer (&input_line_pointer);
  2017.       if (buffer_limit == 0)
  2018.     return 0;
  2019.     }
  2020.  
  2021.   while (! is_end_of_line[(unsigned char) *input_line_pointer])
  2022.     sb_add_char (line, *input_line_pointer++);
  2023.   while (input_line_pointer < buffer_limit
  2024.      && is_end_of_line[(unsigned char) *input_line_pointer])
  2025.     {
  2026.       if (input_line_pointer[-1] == '\n')
  2027.     bump_line_counters ();
  2028.       ++input_line_pointer;
  2029.     }
  2030.   return 1;
  2031. }
  2032.  
  2033. /* Define a macro.  This is an interface to macro.c, which is shared
  2034.    between gas and gasp.  */
  2035.  
  2036. void
  2037. s_macro (ignore)
  2038.      int ignore;
  2039. {
  2040.   char *file;
  2041.   unsigned int line;
  2042.   sb s;
  2043.   sb label;
  2044.   const char *err;
  2045.  
  2046.   as_where (&file, &line);
  2047.  
  2048.   sb_new (&s);
  2049.   while (! is_end_of_line[(unsigned char) *input_line_pointer])
  2050.     sb_add_char (&s, *input_line_pointer++);
  2051.  
  2052.   sb_new (&label);
  2053.   if (line_label != NULL)
  2054.     sb_add_string (&label, S_GET_NAME (line_label));
  2055.  
  2056.   err = define_macro (0, &s, &label, get_line_sb);
  2057.   if (err != NULL)
  2058.     as_bad_where (file, line, "%s", err);
  2059.   else
  2060.     {
  2061.       if (line_label != NULL)
  2062.     {
  2063.       S_SET_SEGMENT (line_label, undefined_section);
  2064.       S_SET_VALUE (line_label, 0);
  2065.       line_label->sy_frag = &zero_address_frag;
  2066.     }
  2067.     }
  2068.  
  2069.   sb_kill (&s);
  2070. }
  2071.  
  2072. /* Handle the .mexit pseudo-op, which immediately exits a macro
  2073.    expansion.  */
  2074.  
  2075. void
  2076. s_mexit (ignore)
  2077.      int ignore;
  2078. {
  2079.   buffer_limit = input_scrub_next_buffer (&input_line_pointer);
  2080. }
  2081.  
  2082. /* Switch in and out of MRI mode.  */
  2083.  
  2084. void
  2085. s_mri (ignore)
  2086.      int ignore;
  2087. {
  2088.   int on, old_flag;
  2089.  
  2090.   on = get_absolute_expression ();
  2091.   old_flag = flag_mri;
  2092.   if (on != 0)
  2093.     {
  2094.       flag_mri = 1;
  2095. #ifdef TC_M68K
  2096.       flag_m68k_mri = 1;
  2097. #endif
  2098.     }
  2099.   else
  2100.     {
  2101.       flag_mri = 0;
  2102.       flag_m68k_mri = 0;
  2103.     }
  2104.  
  2105. #ifdef MRI_MODE_CHANGE
  2106.   if (on != old_flag)
  2107.     MRI_MODE_CHANGE (on);
  2108. #endif
  2109.  
  2110.   demand_empty_rest_of_line ();
  2111. }
  2112.  
  2113. /* Handle changing the location counter.  */
  2114.  
  2115. static void
  2116. do_org (segment, exp, fill)
  2117.      segT segment;
  2118.      expressionS *exp;
  2119.      int fill;
  2120. {
  2121.   if (segment != now_seg && segment != absolute_section)
  2122.     as_bad ("invalid segment \"%s\"; segment \"%s\" assumed",
  2123.         segment_name (segment), segment_name (now_seg));
  2124.  
  2125.   if (now_seg == absolute_section)
  2126.     {
  2127.       if (fill != 0)
  2128.     as_warn ("ignoring fill value in absolute section");
  2129.       if (exp->X_op != O_constant)
  2130.     {
  2131.       as_bad ("only constant offsets supported in absolute section");
  2132.       exp->X_add_number = 0;
  2133.     }
  2134.       abs_section_offset = exp->X_add_number;
  2135.     }
  2136.   else
  2137.     {
  2138.       char *p;
  2139.  
  2140.       p = frag_var (rs_org, 1, 1, (relax_substateT) 0, exp->X_add_symbol,
  2141.             exp->X_add_number, (char *) NULL);
  2142.       *p = fill;
  2143.     }
  2144. }
  2145.  
  2146. void 
  2147. s_org (ignore)
  2148.      int ignore;
  2149. {
  2150.   register segT segment;
  2151.   expressionS exp;
  2152.   register long temp_fill;
  2153.  
  2154.   /* The m68k MRI assembler has a different meaning for .org.  It
  2155.      means to create an absolute section at a given address.  We can't
  2156.      support that--use a linker script instead.  */
  2157.   if (flag_m68k_mri)
  2158.     {
  2159.       as_bad ("MRI style ORG pseudo-op not supported");
  2160.       ignore_rest_of_line ();
  2161.       return;
  2162.     }
  2163.  
  2164.   /* Don't believe the documentation of BSD 4.2 AS.  There is no such
  2165.      thing as a sub-segment-relative origin.  Any absolute origin is
  2166.      given a warning, then assumed to be segment-relative.  Any
  2167.      segmented origin expression ("foo+42") had better be in the right
  2168.      segment or the .org is ignored.
  2169.  
  2170.      BSD 4.2 AS warns if you try to .org backwards. We cannot because
  2171.      we never know sub-segment sizes when we are reading code.  BSD
  2172.      will crash trying to emit negative numbers of filler bytes in
  2173.      certain .orgs. We don't crash, but see as-write for that code.
  2174.  
  2175.      Don't make frag if need_pass_2==1.  */
  2176.   segment = get_known_segmented_expression (&exp);
  2177.   if (*input_line_pointer == ',')
  2178.     {
  2179.       input_line_pointer++;
  2180.       temp_fill = get_absolute_expression ();
  2181.     }
  2182.   else
  2183.     temp_fill = 0;
  2184.  
  2185.   if (!need_pass_2)
  2186.     do_org (segment, &exp, temp_fill);
  2187.  
  2188.   demand_empty_rest_of_line ();
  2189. }                /* s_org() */
  2190.  
  2191. /* Handle parsing for the MRI SECT/SECTION pseudo-op.  This should be
  2192.    called by the obj-format routine which handles section changing
  2193.    when in MRI mode.  It will create a new section, and return it.  It
  2194.    will set *TYPE to the section type: one of 'C' (code), 'D' (data),
  2195.    'M' (mixed), or 'R' (romable).  If BFD_ASSEMBLER is defined, the
  2196.    flags will be set in the section.  */
  2197.  
  2198. void
  2199. s_mri_sect (type)
  2200.      char *type;
  2201. {
  2202. #ifdef TC_M68K
  2203.  
  2204.   char *name;
  2205.   char c;
  2206.   segT seg;
  2207.  
  2208.   SKIP_WHITESPACE ();
  2209.   
  2210.   name = input_line_pointer;
  2211.   if (! isdigit ((unsigned char) *name))
  2212.     c = get_symbol_end ();
  2213.   else
  2214.     {
  2215.       do
  2216.     {
  2217.       ++input_line_pointer;
  2218.     }
  2219.       while (isdigit ((unsigned char) *input_line_pointer));
  2220.       c = *input_line_pointer;
  2221.       *input_line_pointer = '\0';
  2222.     }
  2223.  
  2224.   name = xstrdup (name);
  2225.  
  2226.   *input_line_pointer = c;
  2227.  
  2228.   seg = subseg_new (name, 0);
  2229.  
  2230.   if (*input_line_pointer == ',')
  2231.     {
  2232.       int align;
  2233.  
  2234.       ++input_line_pointer;
  2235.       align = get_absolute_expression ();
  2236.       record_alignment (seg, align);
  2237.     }
  2238.  
  2239.   *type = 'C';
  2240.   if (*input_line_pointer == ',')
  2241.     {
  2242.       c = *++input_line_pointer;
  2243.       c = toupper ((unsigned char) c);
  2244.       if (c == 'C' || c == 'D' || c == 'M' || c == 'R')
  2245.     *type = c;
  2246.       else
  2247.     as_bad ("unrecognized section type");
  2248.       ++input_line_pointer;
  2249.  
  2250. #ifdef BFD_ASSEMBLER
  2251.       {
  2252.     flagword flags;
  2253.  
  2254.     flags = SEC_NO_FLAGS;
  2255.     if (*type == 'C')
  2256.       flags = SEC_ALLOC | SEC_LOAD | SEC_READONLY | SEC_CODE;
  2257.     else if (*type == 'D' || *type == 'M')
  2258.       flags = SEC_ALLOC | SEC_LOAD | SEC_DATA;
  2259.     else if (*type == 'R')
  2260.       flags = SEC_ALLOC | SEC_LOAD | SEC_DATA | SEC_READONLY | SEC_ROM;
  2261.     if (flags != SEC_NO_FLAGS)
  2262.       {
  2263.         if (! bfd_set_section_flags (stdoutput, seg, flags))
  2264.           as_warn ("error setting flags for \"%s\": %s",
  2265.                bfd_section_name (stdoutput, seg),
  2266.                bfd_errmsg (bfd_get_error ()));
  2267.       }
  2268.       }
  2269. #endif
  2270.     }
  2271.  
  2272.   /* Ignore the HP type.  */
  2273.   if (*input_line_pointer == ',')
  2274.     input_line_pointer += 2;
  2275.  
  2276.   demand_empty_rest_of_line ();
  2277.  
  2278. #else /* ! TC_M68K */
  2279. #ifdef TC_I960
  2280.  
  2281.   char *name;
  2282.   char c;
  2283.   segT seg;
  2284.  
  2285.   SKIP_WHITESPACE ();
  2286.  
  2287.   name = input_line_pointer;
  2288.   c = get_symbol_end ();
  2289.  
  2290.   name = xstrdup (name);
  2291.  
  2292.   *input_line_pointer = c;
  2293.  
  2294.   seg = subseg_new (name, 0);
  2295.  
  2296.   if (*input_line_pointer != ',')
  2297.     *type = 'C';
  2298.   else
  2299.     {
  2300.       char *sectype;
  2301.  
  2302.       ++input_line_pointer;
  2303.       SKIP_WHITESPACE ();
  2304.       sectype = input_line_pointer;
  2305.       c = get_symbol_end ();
  2306.       if (*sectype == '\0')
  2307.     *type = 'C';
  2308.       else if (strcasecmp (sectype, "text") == 0)
  2309.     *type = 'C';
  2310.       else if (strcasecmp (sectype, "data") == 0)
  2311.     *type = 'D';
  2312.       else if (strcasecmp (sectype, "romdata") == 0)
  2313.     *type = 'R';
  2314.       else
  2315.     as_warn ("unrecognized section type `%s'", sectype);
  2316.       *input_line_pointer = c;
  2317.     }
  2318.  
  2319.   if (*input_line_pointer == ',')
  2320.     {
  2321.       char *seccmd;
  2322.  
  2323.       ++input_line_pointer;
  2324.       SKIP_WHITESPACE ();
  2325.       seccmd = input_line_pointer;
  2326.       c = get_symbol_end ();
  2327.       if (strcasecmp (seccmd, "absolute") == 0)
  2328.     {
  2329.       as_bad ("absolute sections are not supported");
  2330.       *input_line_pointer = c;
  2331.       ignore_rest_of_line ();
  2332.       return;
  2333.     }
  2334.       else if (strcasecmp (seccmd, "align") == 0)
  2335.     {
  2336.       int align;
  2337.  
  2338.       *input_line_pointer = c;
  2339.       align = get_absolute_expression ();
  2340.       record_alignment (seg, align);
  2341.     }
  2342.       else
  2343.     {
  2344.       as_warn ("unrecognized section command `%s'", seccmd);
  2345.       *input_line_pointer = c;
  2346.     }
  2347.     }
  2348.  
  2349.   demand_empty_rest_of_line ();      
  2350.  
  2351. #else /* ! TC_I960 */
  2352.   /* The MRI assembler seems to use different forms of .sect for
  2353.      different targets.  */
  2354.   abort ();
  2355. #endif /* ! TC_I960 */
  2356. #endif /* ! TC_M68K */
  2357. }
  2358.  
  2359. /* Handle the .print pseudo-op.  */
  2360.  
  2361. void
  2362. s_print (ignore)
  2363.      int ignore;
  2364. {
  2365.   char *s;
  2366.   int len;
  2367.  
  2368.   s = demand_copy_C_string (&len);
  2369.   printf ("%s\n", s);
  2370.   demand_empty_rest_of_line ();
  2371. }
  2372.  
  2373. /* Handle the .purgem pseudo-op.  */
  2374.  
  2375. void
  2376. s_purgem (ignore)
  2377.      int ignore;
  2378. {
  2379.   if (is_it_end_of_statement ())
  2380.     {
  2381.       demand_empty_rest_of_line ();
  2382.       return;
  2383.     }
  2384.  
  2385.   do
  2386.     {
  2387.       char *name;
  2388.       char c;
  2389.  
  2390.       SKIP_WHITESPACE ();
  2391.       name = input_line_pointer;
  2392.       c = get_symbol_end ();
  2393.       delete_macro (name);
  2394.       *input_line_pointer = c;
  2395.       SKIP_WHITESPACE ();
  2396.     }
  2397.   while (*input_line_pointer++ == ',');
  2398.  
  2399.   --input_line_pointer;
  2400.   demand_empty_rest_of_line ();
  2401. }
  2402.  
  2403. /* Handle the .rept pseudo-op.  */
  2404.  
  2405. void
  2406. s_rept (ignore)
  2407.      int ignore;
  2408. {
  2409.   int count;
  2410.   sb one;
  2411.   sb many;
  2412.  
  2413.   count = get_absolute_expression ();
  2414.  
  2415.   sb_new (&one);
  2416.   if (! buffer_and_nest ("REPT", "ENDR", &one, get_line_sb))
  2417.     {
  2418.       as_bad ("rept without endr");
  2419.       return;
  2420.     }
  2421.  
  2422.   sb_new (&many);
  2423.   while (count-- > 0)
  2424.     sb_add_sb (&many, &one);
  2425.  
  2426.   sb_kill (&one);
  2427.  
  2428.   input_scrub_include_sb (&many, input_line_pointer);
  2429.   sb_kill (&many);
  2430.   buffer_limit = input_scrub_next_buffer (&input_line_pointer);
  2431. }
  2432.  
  2433. void 
  2434. s_set (ignore)
  2435.      int ignore;
  2436. {
  2437.   register char *name;
  2438.   register char delim;
  2439.   register char *end_name;
  2440.   register symbolS *symbolP;
  2441.  
  2442.   /*
  2443.    * Especial apologies for the random logic:
  2444.    * this just grew, and could be parsed much more simply!
  2445.    * Dean in haste.
  2446.    */
  2447.   name = input_line_pointer;
  2448.   delim = get_symbol_end ();
  2449.   end_name = input_line_pointer;
  2450.   *end_name = delim;
  2451.   SKIP_WHITESPACE ();
  2452.  
  2453.   if (*input_line_pointer != ',')
  2454.     {
  2455.       *end_name = 0;
  2456.       as_bad ("Expected comma after name \"%s\"", name);
  2457.       *end_name = delim;
  2458.       ignore_rest_of_line ();
  2459.       return;
  2460.     }
  2461.  
  2462.   input_line_pointer++;
  2463.   *end_name = 0;
  2464.  
  2465.   if (name[0] == '.' && name[1] == '\0')
  2466.     {
  2467.       /* Turn '. = mumble' into a .org mumble */
  2468.       register segT segment;
  2469.       expressionS exp;
  2470.  
  2471.       segment = get_known_segmented_expression (&exp);
  2472.  
  2473.       if (!need_pass_2)
  2474.     do_org (segment, &exp, 0);
  2475.  
  2476.       *end_name = delim;
  2477.       return;
  2478.     }
  2479.  
  2480.   if ((symbolP = symbol_find (name)) == NULL
  2481.       && (symbolP = md_undefined_symbol (name)) == NULL)
  2482.     {
  2483.       symbolP = symbol_new (name, undefined_section, 0, &zero_address_frag);
  2484. #ifdef OBJ_COFF
  2485.       /* "set" symbols are local unless otherwise specified. */
  2486.       SF_SET_LOCAL (symbolP);
  2487. #endif /* OBJ_COFF */
  2488.  
  2489.     }                /* make a new symbol */
  2490.  
  2491.   symbol_table_insert (symbolP);
  2492.  
  2493.   *end_name = delim;
  2494.   pseudo_set (symbolP);
  2495.   demand_empty_rest_of_line ();
  2496. }                /* s_set() */
  2497.  
  2498. void 
  2499. s_space (mult)
  2500.      int mult;
  2501. {
  2502.   expressionS exp;
  2503.   expressionS val;
  2504.   char *p = 0;
  2505.   char *stop = NULL;
  2506.   char stopc;
  2507.  
  2508. #ifdef md_flush_pending_output
  2509.   md_flush_pending_output ();
  2510. #endif
  2511.  
  2512.   if (flag_mri)
  2513.     stop = mri_comment_field (&stopc);
  2514.  
  2515.   expression (&exp);
  2516.  
  2517.   SKIP_WHITESPACE ();
  2518.   if (*input_line_pointer == ',')
  2519.     {
  2520.       ++input_line_pointer;
  2521.       expression (&val);
  2522.     }
  2523.   else
  2524.     {
  2525.       val.X_op = O_constant;
  2526.       val.X_add_number = 0;
  2527.     }
  2528.  
  2529.   if (val.X_op != O_constant
  2530.       || val.X_add_number < - 0x80
  2531.       || val.X_add_number > 0xff
  2532.       || (mult != 0 && mult != 1 && val.X_add_number != 0))
  2533.     {
  2534.       if (exp.X_op != O_constant)
  2535.     as_bad ("Unsupported variable size or fill value");
  2536.       else
  2537.     {
  2538.       offsetT i;
  2539.  
  2540.       if (mult == 0)
  2541.         mult = 1;
  2542.       for (i = 0; i < exp.X_add_number; i++)
  2543.         emit_expr (&val, mult);
  2544.     }
  2545.     }
  2546.   else
  2547.     {
  2548.       if (exp.X_op == O_constant)
  2549.     {
  2550.       long repeat;
  2551.  
  2552.       repeat = exp.X_add_number;
  2553.       if (mult)
  2554.         repeat *= mult;
  2555.       if (repeat <= 0)
  2556.         {
  2557.           if (! flag_mri || repeat < 0)
  2558.         as_warn (".space repeat count is %s, ignored",
  2559.              repeat ? "negative" : "zero");
  2560.           goto getout;
  2561.         }
  2562.  
  2563.       /* If we are in the absolute section, just bump the offset.  */
  2564.       if (now_seg == absolute_section)
  2565.         {
  2566.           abs_section_offset += repeat;
  2567.           goto getout;
  2568.         }
  2569.  
  2570.       /* If we are secretly in an MRI common section, then
  2571.          creating space just increases the size of the common
  2572.          symbol.  */
  2573.       if (mri_common_symbol != NULL)
  2574.         {
  2575.           S_SET_VALUE (mri_common_symbol,
  2576.                S_GET_VALUE (mri_common_symbol) + repeat);
  2577.           goto getout;
  2578.         }
  2579.  
  2580.       if (!need_pass_2)
  2581.         p = frag_var (rs_fill, 1, 1, (relax_substateT) 0, (symbolS *) 0,
  2582.               repeat, (char *) 0);
  2583.     }
  2584.       else
  2585.     {
  2586.       if (now_seg == absolute_section)
  2587.         {
  2588.           as_bad ("space allocation too complex in absolute section");
  2589.           subseg_set (text_section, 0);
  2590.         }
  2591.       if (mri_common_symbol != NULL)
  2592.         {
  2593.           as_bad ("space allocation too complex in common section");
  2594.           mri_common_symbol = NULL;
  2595.         }
  2596.       if (!need_pass_2)
  2597.         p = frag_var (rs_space, 1, 1, (relax_substateT) 0,
  2598.               make_expr_symbol (&exp), 0L, (char *) 0);
  2599.     }
  2600.  
  2601.       if (p)
  2602.     *p = val.X_add_number;
  2603.     }
  2604.  
  2605.  getout:
  2606.   if (flag_mri)
  2607.     mri_comment_end (stop, stopc);
  2608.  
  2609.   demand_empty_rest_of_line ();
  2610. }
  2611.  
  2612. /* This is like s_space, but the value is a floating point number with
  2613.    the given precision.  This is for the MRI dcb.s pseudo-op and
  2614.    friends.  */
  2615.  
  2616. void
  2617. s_float_space (float_type)
  2618.      int float_type;
  2619. {
  2620.   offsetT count;
  2621.   int flen;
  2622.   char temp[MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT];
  2623.   char *stop = NULL;
  2624.   char stopc;
  2625.  
  2626.   if (flag_mri)
  2627.     stop = mri_comment_field (&stopc);
  2628.  
  2629.   count = get_absolute_expression ();
  2630.  
  2631.   SKIP_WHITESPACE ();
  2632.   if (*input_line_pointer != ',')
  2633.     {
  2634.       as_bad ("missing value");
  2635.       if (flag_mri)
  2636.     mri_comment_end (stop, stopc);
  2637.       ignore_rest_of_line ();
  2638.       return;
  2639.     }
  2640.  
  2641.   ++input_line_pointer;
  2642.  
  2643.   SKIP_WHITESPACE ();
  2644.  
  2645.   /* Skip any 0{letter} that may be present.  Don't even check if the
  2646.    * letter is legal.  */
  2647.   if (input_line_pointer[0] == '0' && isalpha (input_line_pointer[1]))
  2648.     input_line_pointer += 2;
  2649.  
  2650.   /* Accept :xxxx, where the x's are hex digits, for a floating point
  2651.      with the exact digits specified.  */
  2652.   if (input_line_pointer[0] == ':')
  2653.     {
  2654.       flen = hex_float (float_type, temp);
  2655.       if (flen < 0)
  2656.     {
  2657.       if (flag_mri)
  2658.         mri_comment_end (stop, stopc);
  2659.       ignore_rest_of_line ();
  2660.       return;
  2661.     }
  2662.     }
  2663.   else
  2664.     {
  2665.       char *err;
  2666.  
  2667.       err = md_atof (float_type, temp, &flen);
  2668.       know (flen <= MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT);
  2669.       know (flen > 0);
  2670.       if (err)
  2671.     {
  2672.       as_bad ("Bad floating literal: %s", err);
  2673.       if (flag_mri)
  2674.         mri_comment_end (stop, stopc);
  2675.       ignore_rest_of_line ();
  2676.       return;
  2677.     }
  2678.     }
  2679.  
  2680.   while (--count >= 0)
  2681.     {
  2682.       char *p;
  2683.  
  2684.       p = frag_more (flen);
  2685.       memcpy (p, temp, (unsigned int) flen);
  2686.     }
  2687.  
  2688.   if (flag_mri)
  2689.     mri_comment_end (stop, stopc);
  2690.  
  2691.   demand_empty_rest_of_line ();
  2692. }
  2693.  
  2694. /* Handle the .struct pseudo-op, as found in MIPS assemblers.  */
  2695.  
  2696. void
  2697. s_struct (ignore)
  2698.      int ignore;
  2699. {
  2700.   char *stop = NULL;
  2701.   char stopc;
  2702.  
  2703.   if (flag_mri)
  2704.     stop = mri_comment_field (&stopc);
  2705.   abs_section_offset = get_absolute_expression ();
  2706.   subseg_set (absolute_section, 0);
  2707.   if (flag_mri)
  2708.     mri_comment_end (stop, stopc);
  2709.   demand_empty_rest_of_line ();
  2710. }
  2711.  
  2712. void
  2713. s_text (ignore)
  2714.      int ignore;
  2715. {
  2716.   register int temp;
  2717.  
  2718.   temp = get_absolute_expression ();
  2719.   subseg_set (text_section, (subsegT) temp);
  2720.   demand_empty_rest_of_line ();
  2721. #ifdef OBJ_VMS
  2722.   const_flag &= ~IN_DEFAULT_SECTION;
  2723. #endif
  2724. }                /* s_text() */
  2725.  
  2726.  
  2727. void 
  2728. demand_empty_rest_of_line ()
  2729. {
  2730.   SKIP_WHITESPACE ();
  2731.   if (is_end_of_line[(unsigned char) *input_line_pointer])
  2732.     {
  2733.       input_line_pointer++;
  2734.     }
  2735.   else
  2736.     {
  2737.       ignore_rest_of_line ();
  2738.     }
  2739.   /* Return having already swallowed end-of-line. */
  2740. }                /* Return pointing just after end-of-line. */
  2741.  
  2742. void
  2743. ignore_rest_of_line ()        /* For suspect lines: gives warning. */
  2744. {
  2745.   if (!is_end_of_line[(unsigned char) *input_line_pointer])
  2746.     {
  2747.       if (isprint (*input_line_pointer))
  2748.     as_bad ("Rest of line ignored. First ignored character is `%c'.",
  2749.         *input_line_pointer);
  2750.       else
  2751.     as_bad ("Rest of line ignored. First ignored character valued 0x%x.",
  2752.         *input_line_pointer);
  2753.       while (input_line_pointer < buffer_limit
  2754.          && !is_end_of_line[(unsigned char) *input_line_pointer])
  2755.     {
  2756.       input_line_pointer++;
  2757.     }
  2758.     }
  2759.   input_line_pointer++;        /* Return pointing just after end-of-line. */
  2760.   know (is_end_of_line[(unsigned char) input_line_pointer[-1]]);
  2761. }
  2762.  
  2763. /*
  2764.  *            pseudo_set()
  2765.  *
  2766.  * In:    Pointer to a symbol.
  2767.  *    Input_line_pointer->expression.
  2768.  *
  2769.  * Out:    Input_line_pointer->just after any whitespace after expression.
  2770.  *    Tried to set symbol to value of expression.
  2771.  *    Will change symbols type, value, and frag;
  2772.  */
  2773. void
  2774. pseudo_set (symbolP)
  2775.      symbolS *symbolP;
  2776. {
  2777.   expressionS exp;
  2778. #if (defined (OBJ_AOUT) || defined (OBJ_BOUT)) && ! defined (BFD_ASSEMBLER)
  2779.   int ext;
  2780. #endif /* OBJ_AOUT or OBJ_BOUT */
  2781.  
  2782.   know (symbolP);        /* NULL pointer is logic error. */
  2783. #if (defined (OBJ_AOUT) || defined (OBJ_BOUT)) && ! defined (BFD_ASSEMBLER)
  2784.   ext = S_IS_EXTERNAL (symbolP);
  2785. #endif /* OBJ_AOUT or OBJ_BOUT */
  2786.  
  2787.   (void) expression (&exp);
  2788.  
  2789.   if (exp.X_op == O_illegal)
  2790.     as_bad ("illegal expression; zero assumed");
  2791.   else if (exp.X_op == O_absent)
  2792.     as_bad ("missing expression; zero assumed");
  2793.   else if (exp.X_op == O_big)
  2794.     as_bad ("%s number invalid; zero assumed",
  2795.         exp.X_add_number > 0 ? "bignum" : "floating point");
  2796.   else if (exp.X_op == O_subtract
  2797.        && (S_GET_SEGMENT (exp.X_add_symbol)
  2798.            == S_GET_SEGMENT (exp.X_op_symbol))
  2799.        && SEG_NORMAL (S_GET_SEGMENT (exp.X_add_symbol))
  2800.        && exp.X_add_symbol->sy_frag == exp.X_op_symbol->sy_frag)
  2801.     {
  2802.       exp.X_op = O_constant;
  2803.       exp.X_add_number = (S_GET_VALUE (exp.X_add_symbol)
  2804.               - S_GET_VALUE (exp.X_op_symbol));
  2805.     }
  2806.  
  2807.   switch (exp.X_op)
  2808.     {
  2809.     case O_illegal:
  2810.     case O_absent:
  2811.     case O_big:
  2812.       exp.X_add_number = 0;
  2813.       /* Fall through.  */
  2814.     case O_constant:
  2815.       S_SET_SEGMENT (symbolP, absolute_section);
  2816. #if (defined (OBJ_AOUT) || defined (OBJ_BOUT)) && ! defined (BFD_ASSEMBLER)
  2817.       if (ext)
  2818.     S_SET_EXTERNAL (symbolP);
  2819.       else
  2820.     S_CLEAR_EXTERNAL (symbolP);
  2821. #endif /* OBJ_AOUT or OBJ_BOUT */
  2822.       S_SET_VALUE (symbolP, (valueT) exp.X_add_number);
  2823.       symbolP->sy_frag = &zero_address_frag;
  2824.       break;
  2825.  
  2826.     case O_register:
  2827.       S_SET_SEGMENT (symbolP, reg_section);
  2828.       S_SET_VALUE (symbolP, (valueT) exp.X_add_number);
  2829.       symbolP->sy_frag = &zero_address_frag;
  2830.       break;
  2831.  
  2832.     case O_symbol:
  2833.       if (S_GET_SEGMENT (exp.X_add_symbol) == undefined_section
  2834.       || exp.X_add_number != 0)
  2835.     symbolP->sy_value = exp;
  2836.       else
  2837.     {
  2838.       symbolS *s = exp.X_add_symbol;
  2839.  
  2840.       S_SET_SEGMENT (symbolP, S_GET_SEGMENT (s));
  2841. #if (defined (OBJ_AOUT) || defined (OBJ_BOUT)) && ! defined (BFD_ASSEMBLER)
  2842.       if (ext)
  2843.         S_SET_EXTERNAL (symbolP);
  2844.       else
  2845.         S_CLEAR_EXTERNAL (symbolP);
  2846. #endif /* OBJ_AOUT or OBJ_BOUT */
  2847.       S_SET_VALUE (symbolP,
  2848.                exp.X_add_number + S_GET_VALUE (s));
  2849.       symbolP->sy_frag = s->sy_frag;
  2850.       copy_symbol_attributes (symbolP, s);
  2851.     }
  2852.       break;
  2853.  
  2854.     default:
  2855.       /* The value is some complex expression.
  2856.      FIXME: Should we set the segment to anything?  */
  2857.       symbolP->sy_value = exp;
  2858.       break;
  2859.     }
  2860. }
  2861.  
  2862. /*
  2863.  *            cons()
  2864.  *
  2865.  * CONStruct more frag of .bytes, or .words etc.
  2866.  * Should need_pass_2 be 1 then emit no frag(s).
  2867.  * This understands EXPRESSIONS.
  2868.  *
  2869.  * Bug (?)
  2870.  *
  2871.  * This has a split personality. We use expression() to read the
  2872.  * value. We can detect if the value won't fit in a byte or word.
  2873.  * But we can't detect if expression() discarded significant digits
  2874.  * in the case of a long. Not worth the crocks required to fix it.
  2875.  */
  2876.  
  2877. /* Select a parser for cons expressions.  */
  2878.  
  2879. /* Some targets need to parse the expression in various fancy ways.
  2880.    You can define TC_PARSE_CONS_EXPRESSION to do whatever you like
  2881.    (for example, the HPPA does this).  Otherwise, you can define
  2882.    BITFIELD_CONS_EXPRESSIONS to permit bitfields to be specified, or
  2883.    REPEAT_CONS_EXPRESSIONS to permit repeat counts.  If none of these
  2884.    are defined, which is the normal case, then only simple expressions
  2885.    are permitted.  */
  2886.  
  2887. static void
  2888. parse_mri_cons PARAMS ((expressionS *exp, unsigned int nbytes));
  2889.  
  2890. #ifndef TC_PARSE_CONS_EXPRESSION
  2891. #ifdef BITFIELD_CONS_EXPRESSIONS
  2892. #define TC_PARSE_CONS_EXPRESSION(EXP, NBYTES) parse_bitfield_cons (EXP, NBYTES)
  2893. static void 
  2894. parse_bitfield_cons PARAMS ((expressionS *exp, unsigned int nbytes));
  2895. #endif
  2896. #ifdef REPEAT_CONS_EXPRESSIONS
  2897. #define TC_PARSE_CONS_EXPRESSION(EXP, NBYTES) parse_repeat_cons (EXP, NBYTES)
  2898. static void
  2899. parse_repeat_cons PARAMS ((expressionS *exp, unsigned int nbytes));
  2900. #endif
  2901.  
  2902. /* If we haven't gotten one yet, just call expression.  */
  2903. #ifndef TC_PARSE_CONS_EXPRESSION
  2904. #define TC_PARSE_CONS_EXPRESSION(EXP, NBYTES) expression (EXP)
  2905. #endif
  2906. #endif
  2907.  
  2908. /* worker to do .byte etc statements */
  2909. /* clobbers input_line_pointer, checks */
  2910. /* end-of-line. */
  2911. static void 
  2912. cons_worker (nbytes, rva)
  2913.      register int nbytes;    /* 1=.byte, 2=.word, 4=.long */
  2914.      int rva;
  2915. {
  2916.   int c;
  2917.   expressionS exp;
  2918.   char *stop = NULL;
  2919.   char stopc;
  2920.  
  2921. #ifdef md_flush_pending_output
  2922.   md_flush_pending_output ();
  2923. #endif
  2924.  
  2925.   if (flag_mri)
  2926.     stop = mri_comment_field (&stopc);
  2927.  
  2928.   if (is_it_end_of_statement ())
  2929.     {
  2930.       if (flag_mri)
  2931.     mri_comment_end (stop, stopc);
  2932.       demand_empty_rest_of_line ();
  2933.       return;
  2934.     }
  2935.  
  2936. #ifdef md_cons_align
  2937.   md_cons_align (nbytes);
  2938. #endif
  2939.  
  2940.   c = 0;
  2941.   do
  2942.     {
  2943.       if (flag_m68k_mri)
  2944.     parse_mri_cons (&exp, (unsigned int) nbytes);
  2945.       else
  2946.     TC_PARSE_CONS_EXPRESSION (&exp, (unsigned int) nbytes);
  2947.  
  2948.       if (rva)
  2949.     {
  2950.       if (exp.X_op == O_symbol)
  2951.         exp.X_op = O_symbol_rva;
  2952.       else
  2953.         as_fatal ("rva without symbol");
  2954.     }
  2955.       emit_expr (&exp, (unsigned int) nbytes);
  2956.       ++c;
  2957.     }
  2958.   while (*input_line_pointer++ == ',');
  2959.  
  2960.   /* In MRI mode, after an odd number of bytes, we must align to an
  2961.      even word boundary, unless the next instruction is a dc.b, ds.b
  2962.      or dcb.b.  */
  2963.   if (flag_mri && nbytes == 1 && (c & 1) != 0)
  2964.     mri_pending_align = 1;
  2965.  
  2966.   input_line_pointer--;        /* Put terminator back into stream. */
  2967.  
  2968.   if (flag_mri)
  2969.     mri_comment_end (stop, stopc);
  2970.  
  2971.   demand_empty_rest_of_line ();
  2972. }
  2973.  
  2974.  
  2975. void
  2976. cons (size)
  2977.      int size;
  2978. {
  2979.   cons_worker (size, 0);
  2980. }
  2981.  
  2982. void 
  2983. s_rva (size)
  2984.      int size;
  2985. {
  2986.   cons_worker (size, 1);
  2987. }
  2988.  
  2989.  
  2990. /* Put the contents of expression EXP into the object file using
  2991.    NBYTES bytes.  If need_pass_2 is 1, this does nothing.  */
  2992.  
  2993. void
  2994. emit_expr (exp, nbytes)
  2995.      expressionS *exp;
  2996.      unsigned int nbytes;
  2997. {
  2998.   operatorT op;
  2999.   register char *p;
  3000.   valueT extra_digit = 0;
  3001.  
  3002.   /* Don't do anything if we are going to make another pass.  */
  3003.   if (need_pass_2)
  3004.     return;
  3005.  
  3006.   op = exp->X_op;
  3007.  
  3008.   /* Allow `.word 0' in the absolute section.  */
  3009.   if (now_seg == absolute_section)
  3010.     {
  3011.       if (op != O_constant || exp->X_add_number != 0)
  3012.     as_bad ("attempt to store value in absolute section");
  3013.       abs_section_offset += nbytes;
  3014.       return;
  3015.     }
  3016.  
  3017.   /* Handle a negative bignum.  */
  3018.   if (op == O_uminus
  3019.       && exp->X_add_number == 0
  3020.       && exp->X_add_symbol->sy_value.X_op == O_big
  3021.       && exp->X_add_symbol->sy_value.X_add_number > 0)
  3022.     {
  3023.       int i;
  3024.       unsigned long carry;
  3025.  
  3026.       exp = &exp->X_add_symbol->sy_value;
  3027.  
  3028.       /* Negate the bignum: one's complement each digit and add 1.  */
  3029.       carry = 1;
  3030.       for (i = 0; i < exp->X_add_number; i++)
  3031.     {
  3032.       unsigned long next;
  3033.  
  3034.       next = (((~ (generic_bignum[i] & LITTLENUM_MASK))
  3035.            & LITTLENUM_MASK)
  3036.           + carry);
  3037.       generic_bignum[i] = next & LITTLENUM_MASK;
  3038.       carry = next >> LITTLENUM_NUMBER_OF_BITS;
  3039.     }
  3040.  
  3041.       /* We can ignore any carry out, because it will be handled by
  3042.      extra_digit if it is needed.  */
  3043.  
  3044.       extra_digit = (valueT) -1;
  3045.       op = O_big;
  3046.     }
  3047.  
  3048.   if (op == O_absent || op == O_illegal)
  3049.     {
  3050.       as_warn ("zero assumed for missing expression");
  3051.       exp->X_add_number = 0;
  3052.       op = O_constant;
  3053.     }
  3054.   else if (op == O_big && exp->X_add_number <= 0)
  3055.     {
  3056.       as_bad ("floating point number invalid; zero assumed");
  3057.       exp->X_add_number = 0;
  3058.       op = O_constant;
  3059.     }
  3060.   else if (op == O_register)
  3061.     {
  3062.       as_warn ("register value used as expression");
  3063.       op = O_constant;
  3064.     }
  3065.  
  3066.   p = frag_more ((int) nbytes);
  3067.  
  3068. #ifndef WORKING_DOT_WORD
  3069.   /* If we have the difference of two symbols in a word, save it on
  3070.      the broken_words list.  See the code in write.c.  */
  3071.   if (op == O_subtract && nbytes == 2)
  3072.     {
  3073.       struct broken_word *x;
  3074.  
  3075.       x = (struct broken_word *) xmalloc (sizeof (struct broken_word));
  3076.       x->next_broken_word = broken_words;
  3077.       broken_words = x;
  3078.       x->frag = frag_now;
  3079.       x->word_goes_here = p;
  3080.       x->dispfrag = 0;
  3081.       x->add = exp->X_add_symbol;
  3082.       x->sub = exp->X_op_symbol;
  3083.       x->addnum = exp->X_add_number;
  3084.       x->added = 0;
  3085.       new_broken_words++;
  3086.       return;
  3087.     }
  3088. #endif
  3089.  
  3090.   /* If we have an integer, but the number of bytes is too large to
  3091.      pass to md_number_to_chars, handle it as a bignum.  */
  3092.   if (op == O_constant && nbytes > sizeof (valueT))
  3093.     {
  3094.       valueT val;
  3095.       int gencnt;
  3096.  
  3097.       if (! exp->X_unsigned && exp->X_add_number < 0)
  3098.     extra_digit = (valueT) -1;
  3099.       val = (valueT) exp->X_add_number;
  3100.       gencnt = 0;
  3101.       do
  3102.     {
  3103.       generic_bignum[gencnt] = val & LITTLENUM_MASK;
  3104.       val >>= LITTLENUM_NUMBER_OF_BITS;
  3105.       ++gencnt;
  3106.     }
  3107.       while (val != 0);
  3108.       op = exp->X_op = O_big;
  3109.       exp->X_add_number = gencnt;
  3110.     }
  3111.  
  3112.   if (op == O_constant)
  3113.     {
  3114.       register valueT get;
  3115.       register valueT use;
  3116.       register valueT mask;
  3117.       register valueT unmask;
  3118.  
  3119.       /* JF << of >= number of bits in the object is undefined.  In
  3120.      particular SPARC (Sun 4) has problems */
  3121.       if (nbytes >= sizeof (valueT))
  3122.     mask = 0;
  3123.       else
  3124.     mask = ~(valueT) 0 << (BITS_PER_CHAR * nbytes);    /* Don't store these bits. */
  3125.  
  3126.       unmask = ~mask;        /* Do store these bits. */
  3127.  
  3128. #ifdef NEVER
  3129.       "Do this mod if you want every overflow check to assume SIGNED 2's complement data.";
  3130.       mask = ~(unmask >> 1);    /* Includes sign bit now. */
  3131. #endif
  3132.  
  3133.       get = exp->X_add_number;
  3134.       use = get & unmask;
  3135.       if ((get & mask) != 0 && (get & mask) != mask)
  3136.     {        /* Leading bits contain both 0s & 1s. */
  3137.       as_warn ("Value 0x%lx truncated to 0x%lx.",
  3138.            (unsigned long) get, (unsigned long) use);
  3139.     }
  3140.       /* put bytes in right order. */
  3141.       md_number_to_chars (p, use, (int) nbytes);
  3142.     }
  3143.   else if (op == O_big)
  3144.     {
  3145.       int size;
  3146.       LITTLENUM_TYPE *nums;
  3147.  
  3148.       know (nbytes % CHARS_PER_LITTLENUM == 0);
  3149.  
  3150.       size = exp->X_add_number * CHARS_PER_LITTLENUM;
  3151.       if (nbytes < size)
  3152.     {
  3153.       as_warn ("Bignum truncated to %d bytes", nbytes);
  3154.       size = nbytes;
  3155.     }
  3156.  
  3157.       if (target_big_endian)
  3158.     {
  3159.       while (nbytes > size)
  3160.         {
  3161.           md_number_to_chars (p, extra_digit, CHARS_PER_LITTLENUM);
  3162.           nbytes -= CHARS_PER_LITTLENUM;
  3163.           p += CHARS_PER_LITTLENUM;
  3164.         }
  3165.  
  3166.       nums = generic_bignum + size / CHARS_PER_LITTLENUM;
  3167.       while (size > 0)
  3168.         {
  3169.           --nums;
  3170.           md_number_to_chars (p, (valueT) *nums, CHARS_PER_LITTLENUM);
  3171.           size -= CHARS_PER_LITTLENUM;
  3172.           p += CHARS_PER_LITTLENUM;
  3173.         }
  3174.     }
  3175.       else
  3176.     {
  3177.       nums = generic_bignum;
  3178.       while (size > 0)
  3179.         {
  3180.           md_number_to_chars (p, (valueT) *nums, CHARS_PER_LITTLENUM);
  3181.           ++nums;
  3182.           size -= CHARS_PER_LITTLENUM;
  3183.           p += CHARS_PER_LITTLENUM;
  3184.           nbytes -= CHARS_PER_LITTLENUM;
  3185.         }
  3186.  
  3187.       while (nbytes > 0)
  3188.         {
  3189.           md_number_to_chars (p, extra_digit, CHARS_PER_LITTLENUM);
  3190.           nbytes -= CHARS_PER_LITTLENUM;
  3191.           p += CHARS_PER_LITTLENUM;
  3192.         }
  3193.     }
  3194.     }
  3195.   else
  3196.     {
  3197.       memset (p, 0, nbytes);
  3198.  
  3199.       /* Now we need to generate a fixS to record the symbol value.
  3200.      This is easy for BFD.  For other targets it can be more
  3201.      complex.  For very complex cases (currently, the HPPA and
  3202.      NS32K), you can define TC_CONS_FIX_NEW to do whatever you
  3203.      want.  For simpler cases, you can define TC_CONS_RELOC to be
  3204.      the name of the reloc code that should be stored in the fixS.
  3205.      If neither is defined, the code uses NO_RELOC if it is
  3206.      defined, and otherwise uses 0.  */
  3207.  
  3208. #ifdef BFD_ASSEMBLER
  3209. #ifdef TC_CONS_FIX_NEW
  3210.       TC_CONS_FIX_NEW (frag_now, p - frag_now->fr_literal, nbytes, exp, 0);
  3211. #else
  3212.       fix_new_exp (frag_now, p - frag_now->fr_literal, (int) nbytes, exp, 0,
  3213.            /* @@ Should look at CPU word size.  */
  3214.            nbytes == 2 ? BFD_RELOC_16
  3215.               : nbytes == 8 ? BFD_RELOC_64
  3216.               : BFD_RELOC_32, 0);
  3217. #endif
  3218. #else
  3219. #ifdef TC_CONS_FIX_NEW
  3220.       TC_CONS_FIX_NEW (frag_now, p - frag_now->fr_literal, nbytes, exp, 0);
  3221. #else
  3222.       /* Figure out which reloc number to use.  Use TC_CONS_RELOC if
  3223.      it is defined, otherwise use NO_RELOC if it is defined,
  3224.      otherwise use 0.  */
  3225. #ifndef TC_CONS_RELOC
  3226. #ifdef NO_RELOC
  3227. #define TC_CONS_RELOC NO_RELOC
  3228. #else
  3229. #define TC_CONS_RELOC 0
  3230. #endif
  3231. #endif
  3232.       fix_new_exp (frag_now, p - frag_now->fr_literal, (int) nbytes, exp, 0,
  3233.            TC_CONS_RELOC, 0);
  3234. #endif /* TC_CONS_FIX_NEW */
  3235. #endif /* BFD_ASSEMBLER */
  3236.     }
  3237. }
  3238.  
  3239. #ifdef BITFIELD_CONS_EXPRESSIONS
  3240.  
  3241. /* i960 assemblers, (eg, asm960), allow bitfields after ".byte" as
  3242.    w:x,y:z, where w and y are bitwidths and x and y are values.  They
  3243.    then pack them all together. We do a little better in that we allow
  3244.    them in words, longs, etc. and we'll pack them in target byte order
  3245.    for you.
  3246.  
  3247.    The rules are: pack least significat bit first, if a field doesn't
  3248.    entirely fit, put it in the next unit.  Overflowing the bitfield is
  3249.    explicitly *not* even a warning.  The bitwidth should be considered
  3250.    a "mask".
  3251.  
  3252.    To use this function the tc-XXX.h file should define
  3253.    BITFIELD_CONS_EXPRESSIONS.  */
  3254.  
  3255. static void 
  3256. parse_bitfield_cons (exp, nbytes)
  3257.      expressionS *exp;
  3258.      unsigned int nbytes;
  3259. {
  3260.   unsigned int bits_available = BITS_PER_CHAR * nbytes;
  3261.   char *hold = input_line_pointer;
  3262.  
  3263.   (void) expression (exp);
  3264.  
  3265.   if (*input_line_pointer == ':')
  3266.     {            /* bitfields */
  3267.       long value = 0;
  3268.  
  3269.       for (;;)
  3270.     {
  3271.       unsigned long width;
  3272.  
  3273.       if (*input_line_pointer != ':')
  3274.         {
  3275.           input_line_pointer = hold;
  3276.           break;
  3277.         }            /* next piece is not a bitfield */
  3278.  
  3279.       /* In the general case, we can't allow
  3280.          full expressions with symbol
  3281.          differences and such.  The relocation
  3282.          entries for symbols not defined in this
  3283.          assembly would require arbitrary field
  3284.          widths, positions, and masks which most
  3285.          of our current object formats don't
  3286.          support.
  3287.  
  3288.          In the specific case where a symbol
  3289.          *is* defined in this assembly, we
  3290.          *could* build fixups and track it, but
  3291.          this could lead to confusion for the
  3292.          backends.  I'm lazy. I'll take any
  3293.          SEG_ABSOLUTE. I think that means that
  3294.          you can use a previous .set or
  3295.          .equ type symbol.  xoxorich. */
  3296.  
  3297.       if (exp->X_op == O_absent)
  3298.         {
  3299.           as_warn ("using a bit field width of zero");
  3300.           exp->X_add_number = 0;
  3301.           exp->X_op = O_constant;
  3302.         }            /* implied zero width bitfield */
  3303.  
  3304.       if (exp->X_op != O_constant)
  3305.         {
  3306.           *input_line_pointer = '\0';
  3307.           as_bad ("field width \"%s\" too complex for a bitfield", hold);
  3308.           *input_line_pointer = ':';
  3309.           demand_empty_rest_of_line ();
  3310.           return;
  3311.         }            /* too complex */
  3312.  
  3313.       if ((width = exp->X_add_number) > (BITS_PER_CHAR * nbytes))
  3314.         {
  3315.           as_warn ("field width %lu too big to fit in %d bytes: truncated to %d bits",
  3316.                width, nbytes, (BITS_PER_CHAR * nbytes));
  3317.           width = BITS_PER_CHAR * nbytes;
  3318.         }            /* too big */
  3319.  
  3320.       if (width > bits_available)
  3321.         {
  3322.           /* FIXME-SOMEDAY: backing up and reparsing is wasteful.  */
  3323.           input_line_pointer = hold;
  3324.           exp->X_add_number = value;
  3325.           break;
  3326.         }            /* won't fit */
  3327.  
  3328.       hold = ++input_line_pointer; /* skip ':' */
  3329.  
  3330.       (void) expression (exp);
  3331.       if (exp->X_op != O_constant)
  3332.         {
  3333.           char cache = *input_line_pointer;
  3334.  
  3335.           *input_line_pointer = '\0';
  3336.           as_bad ("field value \"%s\" too complex for a bitfield", hold);
  3337.           *input_line_pointer = cache;
  3338.           demand_empty_rest_of_line ();
  3339.           return;
  3340.         }            /* too complex */
  3341.  
  3342.       value |= ((~(-1 << width) & exp->X_add_number)
  3343.             << ((BITS_PER_CHAR * nbytes) - bits_available));
  3344.  
  3345.       if ((bits_available -= width) == 0
  3346.           || is_it_end_of_statement ()
  3347.           || *input_line_pointer != ',')
  3348.         {
  3349.           break;
  3350.         }            /* all the bitfields we're gonna get */
  3351.  
  3352.       hold = ++input_line_pointer;
  3353.       (void) expression (exp);
  3354.     }            /* forever loop */
  3355.  
  3356.       exp->X_add_number = value;
  3357.       exp->X_op = O_constant;
  3358.       exp->X_unsigned = 1;
  3359.     }                /* if looks like a bitfield */
  3360. }                /* parse_bitfield_cons() */
  3361.  
  3362. #endif /* BITFIELD_CONS_EXPRESSIONS */
  3363.  
  3364. /* Handle an MRI style string expression.  */
  3365.  
  3366. static void
  3367. parse_mri_cons (exp, nbytes)
  3368.      expressionS *exp;
  3369.      unsigned int nbytes;
  3370. {
  3371.   if (*input_line_pointer != '\''
  3372.       && (input_line_pointer[1] != '\''
  3373.       || (*input_line_pointer != 'A'
  3374.           && *input_line_pointer != 'E')))
  3375.     TC_PARSE_CONS_EXPRESSION (exp, nbytes);
  3376.   else
  3377.     {
  3378.       int scan = 0;
  3379.       unsigned int result = 0;
  3380.  
  3381.       /* An MRI style string.  Cut into as many bytes as will fit into
  3382.      a nbyte chunk, left justify if necessary, and separate with
  3383.      commas so we can try again later.  */
  3384.       if (*input_line_pointer == 'A')
  3385.     ++input_line_pointer;
  3386.       else if (*input_line_pointer == 'E')
  3387.     {
  3388.       as_bad ("EBCDIC constants are not supported");
  3389.       ++input_line_pointer;
  3390.     }
  3391.  
  3392.       input_line_pointer++;
  3393.       for (scan = 0; scan < nbytes; scan++)
  3394.     {
  3395.       if (*input_line_pointer == '\'')
  3396.         {
  3397.           if (input_line_pointer[1] == '\'')
  3398.         {
  3399.           input_line_pointer++;
  3400.         }
  3401.           else
  3402.         break;
  3403.         }
  3404.       result = (result << 8) | (*input_line_pointer++);
  3405.     }
  3406.  
  3407.       /* Left justify */
  3408.       while (scan < nbytes)
  3409.     {
  3410.       result <<= 8;
  3411.       scan++;
  3412.     }
  3413.       /* Create correct expression */
  3414.       exp->X_op = O_constant;
  3415.       exp->X_add_number = result;
  3416.       /* Fake it so that we can read the next char too */
  3417.       if (input_line_pointer[0] != '\'' ||
  3418.       (input_line_pointer[0] == '\'' && input_line_pointer[1] == '\''))
  3419.     {
  3420.       input_line_pointer -= 2;
  3421.       input_line_pointer[0] = ',';
  3422.       input_line_pointer[1] = '\'';
  3423.     }
  3424.       else
  3425.     input_line_pointer++;
  3426.     }
  3427. }
  3428.  
  3429. #ifdef REPEAT_CONS_EXPRESSIONS
  3430.  
  3431. /* Parse a repeat expression for cons.  This is used by the MIPS
  3432.    assembler.  The format is NUMBER:COUNT; NUMBER appears in the
  3433.    object file COUNT times.
  3434.  
  3435.    To use this for a target, define REPEAT_CONS_EXPRESSIONS.  */
  3436.  
  3437. static void
  3438. parse_repeat_cons (exp, nbytes)
  3439.      expressionS *exp;
  3440.      unsigned int nbytes;
  3441. {
  3442.   expressionS count;
  3443.   register int i;
  3444.  
  3445.   expression (exp);
  3446.  
  3447.   if (*input_line_pointer != ':')
  3448.     {
  3449.       /* No repeat count.  */
  3450.       return;
  3451.     }
  3452.  
  3453.   ++input_line_pointer;
  3454.   expression (&count);
  3455.   if (count.X_op != O_constant
  3456.       || count.X_add_number <= 0)
  3457.     {
  3458.       as_warn ("Unresolvable or nonpositive repeat count; using 1");
  3459.       return;
  3460.     }
  3461.  
  3462.   /* The cons function is going to output this expression once.  So we
  3463.      output it count - 1 times.  */
  3464.   for (i = count.X_add_number - 1; i > 0; i--)
  3465.     emit_expr (exp, nbytes);
  3466. }
  3467.  
  3468. #endif /* REPEAT_CONS_EXPRESSIONS */
  3469.  
  3470. /* Parse a floating point number represented as a hex constant.  This
  3471.    permits users to specify the exact bits they want in the floating
  3472.    point number.  */
  3473.  
  3474. static int
  3475. hex_float (float_type, bytes)
  3476.      int float_type;
  3477.      char *bytes;
  3478. {
  3479.   int length;
  3480.   int i;
  3481.  
  3482.   switch (float_type)
  3483.     {
  3484.     case 'f':
  3485.     case 'F':
  3486.     case 's':
  3487.     case 'S':
  3488.       length = 4;
  3489.       break;
  3490.  
  3491.     case 'd':
  3492.     case 'D':
  3493.     case 'r':
  3494.     case 'R':
  3495.       length = 8;
  3496.       break;
  3497.  
  3498.     case 'x':
  3499.     case 'X':
  3500.       length = 12;
  3501.       break;
  3502.  
  3503.     case 'p':
  3504.     case 'P':
  3505.       length = 12;
  3506.       break;
  3507.  
  3508.     default:
  3509.       as_bad ("Unknown floating type type '%c'", float_type);
  3510.       return -1;
  3511.     }
  3512.  
  3513.   /* It would be nice if we could go through expression to parse the
  3514.      hex constant, but if we get a bignum it's a pain to sort it into
  3515.      the buffer correctly.  */
  3516.   i = 0;
  3517.   while (hex_p (*input_line_pointer) || *input_line_pointer == '_')
  3518.     {
  3519.       int d;
  3520.  
  3521.       /* The MRI assembler accepts arbitrary underscores strewn about
  3522.      through the hex constant, so we ignore them as well. */
  3523.       if (*input_line_pointer == '_')
  3524.     {
  3525.       ++input_line_pointer;
  3526.       continue;
  3527.     }
  3528.  
  3529.       if (i >= length)
  3530.     {
  3531.       as_warn ("Floating point constant too large");
  3532.       return -1;
  3533.     }
  3534.       d = hex_value (*input_line_pointer) << 4;
  3535.       ++input_line_pointer;
  3536.       while (*input_line_pointer == '_')
  3537.     ++input_line_pointer;
  3538.       if (hex_p (*input_line_pointer))
  3539.     {
  3540.       d += hex_value (*input_line_pointer);
  3541.       ++input_line_pointer;
  3542.     }
  3543.       if (target_big_endian)
  3544.     bytes[i] = d;
  3545.       else
  3546.     bytes[length - i - 1] = d;
  3547.       ++i;
  3548.     }
  3549.  
  3550.   if (i < length)
  3551.     {
  3552.       if (target_big_endian)
  3553.     memset (bytes + i, 0, length - i);
  3554.       else
  3555.     memset (bytes, 0, length - i);
  3556.     }
  3557.  
  3558.   return length;
  3559. }
  3560.  
  3561. /*
  3562.  *            float_cons()
  3563.  *
  3564.  * CONStruct some more frag chars of .floats .ffloats etc.
  3565.  * Makes 0 or more new frags.
  3566.  * If need_pass_2 == 1, no frags are emitted.
  3567.  * This understands only floating literals, not expressions. Sorry.
  3568.  *
  3569.  * A floating constant is defined by atof_generic(), except it is preceded
  3570.  * by 0d 0f 0g or 0h. After observing the STRANGE way my BSD AS does its
  3571.  * reading, I decided to be incompatible. This always tries to give you
  3572.  * rounded bits to the precision of the pseudo-op. Former AS did premature
  3573.  * truncatation, restored noisy bits instead of trailing 0s AND gave you
  3574.  * a choice of 2 flavours of noise according to which of 2 floating-point
  3575.  * scanners you directed AS to use.
  3576.  *
  3577.  * In:    input_line_pointer->whitespace before, or '0' of flonum.
  3578.  *
  3579.  */
  3580.  
  3581. void
  3582. float_cons (float_type)
  3583.      /* Clobbers input_line-pointer, checks end-of-line. */
  3584.      register int float_type;    /* 'f':.ffloat ... 'F':.float ... */
  3585. {
  3586.   register char *p;
  3587.   int length;            /* Number of chars in an object. */
  3588.   register char *err;        /* Error from scanning floating literal. */
  3589.   char temp[MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT];
  3590.  
  3591.   if (is_it_end_of_statement ())
  3592.     {
  3593.       demand_empty_rest_of_line ();
  3594.       return;
  3595.     }
  3596.  
  3597.   do
  3598.     {
  3599.       /* input_line_pointer->1st char of a flonum (we hope!). */
  3600.       SKIP_WHITESPACE ();
  3601.  
  3602.       /* Skip any 0{letter} that may be present. Don't even check if the
  3603.        * letter is legal. Someone may invent a "z" format and this routine
  3604.        * has no use for such information. Lusers beware: you get
  3605.        * diagnostics if your input is ill-conditioned.
  3606.        */
  3607.       if (input_line_pointer[0] == '0' && isalpha (input_line_pointer[1]))
  3608.     input_line_pointer += 2;
  3609.  
  3610.       /* Accept :xxxx, where the x's are hex digits, for a floating
  3611.          point with the exact digits specified.  */
  3612.       if (input_line_pointer[0] == ':')
  3613.     {
  3614.       ++input_line_pointer;
  3615.       length = hex_float (float_type, temp);
  3616.       if (length < 0)
  3617.         {
  3618.           ignore_rest_of_line ();
  3619.           return;
  3620.         }
  3621.     }
  3622.       else
  3623.     {
  3624.       err = md_atof (float_type, temp, &length);
  3625.       know (length <= MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT);
  3626.       know (length > 0);
  3627.       if (err)
  3628.         {
  3629.           as_bad ("Bad floating literal: %s", err);
  3630.           ignore_rest_of_line ();
  3631.           return;
  3632.         }
  3633.     }
  3634.  
  3635.       if (!need_pass_2)
  3636.     {
  3637.       int count;
  3638.  
  3639.       count = 1;
  3640.  
  3641. #ifdef REPEAT_CONS_EXPRESSIONS
  3642.       if (*input_line_pointer == ':')
  3643.         {
  3644.           expressionS count_exp;
  3645.  
  3646.           ++input_line_pointer;
  3647.           expression (&count_exp);
  3648.           if (count_exp.X_op != O_constant
  3649.           || count_exp.X_add_number <= 0)
  3650.         {
  3651.           as_warn ("unresolvable or nonpositive repeat count; using 1");
  3652.         }
  3653.           else
  3654.         count = count_exp.X_add_number;
  3655.         }
  3656. #endif
  3657.  
  3658.       while (--count >= 0)
  3659.         {
  3660.           p = frag_more (length);
  3661.           memcpy (p, temp, (unsigned int) length);
  3662.         }
  3663.     }
  3664.       SKIP_WHITESPACE ();
  3665.     }
  3666.   while (*input_line_pointer++ == ',');
  3667.  
  3668.   --input_line_pointer;        /* Put terminator back into stream.  */
  3669.   demand_empty_rest_of_line ();
  3670. }                /* float_cons() */
  3671.  
  3672. /*
  3673.  *            stringer()
  3674.  *
  3675.  * We read 0 or more ',' seperated, double-quoted strings.
  3676.  *
  3677.  * Caller should have checked need_pass_2 is FALSE because we don't check it.
  3678.  */
  3679.  
  3680.  
  3681. void 
  3682. stringer (append_zero)        /* Worker to do .ascii etc statements. */
  3683.      /* Checks end-of-line. */
  3684.      register int append_zero;    /* 0: don't append '\0', else 1 */
  3685. {
  3686.   register unsigned int c;
  3687.  
  3688. #ifdef md_flush_pending_output
  3689.   md_flush_pending_output ();
  3690. #endif
  3691.  
  3692.   /*
  3693.    * The following awkward logic is to parse ZERO or more strings,
  3694.    * comma seperated. Recall a string expression includes spaces
  3695.    * before the opening '\"' and spaces after the closing '\"'.
  3696.    * We fake a leading ',' if there is (supposed to be)
  3697.    * a 1st, expression. We keep demanding expressions for each
  3698.    * ','.
  3699.    */
  3700.   if (is_it_end_of_statement ())
  3701.     {
  3702.       c = 0;            /* Skip loop. */
  3703.       ++input_line_pointer;    /* Compensate for end of loop. */
  3704.     }
  3705.   else
  3706.     {
  3707.       c = ',';            /* Do loop. */
  3708.     }
  3709.   while (c == ',' || c == '<' || c == '"')
  3710.     {
  3711.       SKIP_WHITESPACE ();
  3712.       switch (*input_line_pointer)
  3713.     {
  3714.     case '\"':
  3715.       ++input_line_pointer;    /*->1st char of string. */
  3716.       while (is_a_char (c = next_char_of_string ()))
  3717.         {
  3718.           FRAG_APPEND_1_CHAR (c);
  3719.         }
  3720.       if (append_zero)
  3721.         {
  3722.           FRAG_APPEND_1_CHAR (0);
  3723.         }
  3724.       know (input_line_pointer[-1] == '\"');
  3725.       break;
  3726.     case '<':
  3727.       input_line_pointer++;
  3728.       c = get_single_number ();
  3729.       FRAG_APPEND_1_CHAR (c);
  3730.       if (*input_line_pointer != '>')
  3731.         {
  3732.           as_bad ("Expected <nn>");
  3733.         }
  3734.       input_line_pointer++;
  3735.       break;
  3736.     case ',':
  3737.       input_line_pointer++;
  3738.       break;
  3739.     }
  3740.       SKIP_WHITESPACE ();
  3741.       c = *input_line_pointer;
  3742.     }
  3743.  
  3744.   demand_empty_rest_of_line ();
  3745. }                /* stringer() */
  3746.  
  3747. /* FIXME-SOMEDAY: I had trouble here on characters with the
  3748.     high bits set.  We'll probably also have trouble with
  3749.     multibyte chars, wide chars, etc.  Also be careful about
  3750.     returning values bigger than 1 byte.  xoxorich. */
  3751.  
  3752. unsigned int 
  3753. next_char_of_string ()
  3754. {
  3755.   register unsigned int c;
  3756.  
  3757.   c = *input_line_pointer++ & CHAR_MASK;
  3758.   switch (c)
  3759.     {
  3760.     case '\"':
  3761.       c = NOT_A_CHAR;
  3762.       break;
  3763.  
  3764.     case '\n':
  3765.       as_warn ("Unterminated string: Newline inserted.");
  3766.       bump_line_counters ();
  3767.       break;
  3768.  
  3769. #ifndef NO_STRING_ESCAPES
  3770.     case '\\':
  3771.       switch (c = *input_line_pointer++)
  3772.     {
  3773.     case 'b':
  3774.       c = '\b';
  3775.       break;
  3776.  
  3777.     case 'f':
  3778.       c = '\f';
  3779.       break;
  3780.  
  3781.     case 'n':
  3782.       c = '\n';
  3783.       break;
  3784.  
  3785.     case 'r':
  3786.       c = '\r';
  3787.       break;
  3788.  
  3789.     case 't':
  3790.       c = '\t';
  3791.       break;
  3792.  
  3793.     case 'v':
  3794.       c = '\013';
  3795.       break;
  3796.  
  3797.     case '\\':
  3798.     case '"':
  3799.       break;        /* As itself. */
  3800.  
  3801.     case '0':
  3802.     case '1':
  3803.     case '2':
  3804.     case '3':
  3805.     case '4':
  3806.     case '5':
  3807.     case '6':
  3808.     case '7':
  3809.     case '8':
  3810.     case '9':
  3811.       {
  3812.         long number;
  3813.         int i;
  3814.  
  3815.         for (i = 0, number = 0; isdigit (c) && i < 3; c = *input_line_pointer++, i++)
  3816.           {
  3817.         number = number * 8 + c - '0';
  3818.           }
  3819.         c = number & 0xff;
  3820.       }
  3821.       --input_line_pointer;
  3822.       break;
  3823.  
  3824.     case 'x':
  3825.     case 'X':
  3826.       {
  3827.         long number;
  3828.  
  3829.         number = 0;
  3830.         c = *input_line_pointer++;
  3831.         while (isxdigit (c))
  3832.           {
  3833.         if (isdigit (c))
  3834.           number = number * 16 + c - '0';
  3835.         else if (isupper (c))
  3836.           number = number * 16 + c - 'A' + 10;
  3837.         else
  3838.           number = number * 16 + c - 'a' + 10;
  3839.         c = *input_line_pointer++;
  3840.           }
  3841.         c = number & 0xff;
  3842.         --input_line_pointer;
  3843.       }
  3844.       break;
  3845.  
  3846.     case '\n':
  3847.       /* To be compatible with BSD 4.2 as: give the luser a linefeed!! */
  3848.       as_warn ("Unterminated string: Newline inserted.");
  3849.       c = '\n';
  3850.       bump_line_counters ();
  3851.       break;
  3852.  
  3853.     default:
  3854.  
  3855. #ifdef ONLY_STANDARD_ESCAPES
  3856.       as_bad ("Bad escaped character in string, '?' assumed");
  3857.       c = '?';
  3858. #endif /* ONLY_STANDARD_ESCAPES */
  3859.  
  3860.       break;
  3861.     }            /* switch on escaped char */
  3862.       break;
  3863. #endif /* ! defined (NO_STRING_ESCAPES) */
  3864.  
  3865.     default:
  3866.       break;
  3867.     }                /* switch on char */
  3868.   return (c);
  3869. }                /* next_char_of_string() */
  3870.  
  3871. static segT
  3872. get_segmented_expression (expP)
  3873.      register expressionS *expP;
  3874. {
  3875.   register segT retval;
  3876.  
  3877.   retval = expression (expP);
  3878.   if (expP->X_op == O_illegal
  3879.       || expP->X_op == O_absent
  3880.       || expP->X_op == O_big)
  3881.     {
  3882.       as_bad ("expected address expression; zero assumed");
  3883.       expP->X_op = O_constant;
  3884.       expP->X_add_number = 0;
  3885.       retval = absolute_section;
  3886.     }
  3887.   return retval;
  3888. }
  3889.  
  3890. static segT 
  3891. get_known_segmented_expression (expP)
  3892.      register expressionS *expP;
  3893. {
  3894.   register segT retval;
  3895.  
  3896.   if ((retval = get_segmented_expression (expP)) == undefined_section)
  3897.     {
  3898.       /* There is no easy way to extract the undefined symbol from the
  3899.      expression.  */
  3900.       if (expP->X_add_symbol != NULL
  3901.       && S_GET_SEGMENT (expP->X_add_symbol) != expr_section)
  3902.     as_warn ("symbol \"%s\" undefined; zero assumed",
  3903.          S_GET_NAME (expP->X_add_symbol));
  3904.       else
  3905.     as_warn ("some symbol undefined; zero assumed");
  3906.       retval = absolute_section;
  3907.       expP->X_op = O_constant;
  3908.       expP->X_add_number = 0;
  3909.     }
  3910.   know (retval == absolute_section || SEG_NORMAL (retval));
  3911.   return (retval);
  3912. }                /* get_known_segmented_expression() */
  3913.  
  3914. offsetT
  3915. get_absolute_expression ()
  3916. {
  3917.   expressionS exp;
  3918.  
  3919.   expression (&exp);
  3920.   if (exp.X_op != O_constant)
  3921.     {
  3922.       if (exp.X_op != O_absent)
  3923.     as_bad ("bad or irreducible absolute expression; zero assumed");
  3924.       exp.X_add_number = 0;
  3925.     }
  3926.   return exp.X_add_number;
  3927. }
  3928.  
  3929. char                /* return terminator */
  3930. get_absolute_expression_and_terminator (val_pointer)
  3931.      long *val_pointer;        /* return value of expression */
  3932. {
  3933.   /* FIXME: val_pointer should probably be offsetT *.  */
  3934.   *val_pointer = (long) get_absolute_expression ();
  3935.   return (*input_line_pointer++);
  3936. }
  3937.  
  3938. /*
  3939.  *            demand_copy_C_string()
  3940.  *
  3941.  * Like demand_copy_string, but return NULL if the string contains any '\0's.
  3942.  * Give a warning if that happens.
  3943.  */
  3944. char *
  3945. demand_copy_C_string (len_pointer)
  3946.      int *len_pointer;
  3947. {
  3948.   register char *s;
  3949.  
  3950.   if ((s = demand_copy_string (len_pointer)) != 0)
  3951.     {
  3952.       register int len;
  3953.  
  3954.       for (len = *len_pointer; len > 0; len--)
  3955.     {
  3956.       if (*s == 0)
  3957.         {
  3958.           s = 0;
  3959.           len = 1;
  3960.           *len_pointer = 0;
  3961.           as_bad ("This string may not contain \'\\0\'");
  3962.         }
  3963.     }
  3964.     }
  3965.   return s;
  3966. }
  3967.  
  3968. /*
  3969.  *            demand_copy_string()
  3970.  *
  3971.  * Demand string, but return a safe (=private) copy of the string.
  3972.  * Return NULL if we can't read a string here.
  3973.  */
  3974. char *
  3975. demand_copy_string (lenP)
  3976.      int *lenP;
  3977. {
  3978.   register unsigned int c;
  3979.   register int len;
  3980.   char *retval;
  3981.  
  3982.   len = 0;
  3983.   SKIP_WHITESPACE ();
  3984.   if (*input_line_pointer == '\"')
  3985.     {
  3986.       input_line_pointer++;    /* Skip opening quote. */
  3987.  
  3988.       while (is_a_char (c = next_char_of_string ()))
  3989.     {
  3990.       obstack_1grow (¬es, c);
  3991.       len++;
  3992.     }
  3993.       /* JF this next line is so demand_copy_C_string will return a
  3994.      null terminated string. */
  3995.       obstack_1grow (¬es, '\0');
  3996.       retval = obstack_finish (¬es);
  3997.     }
  3998.   else
  3999.     {
  4000.       as_warn ("Missing string");
  4001.       retval = NULL;
  4002.       ignore_rest_of_line ();
  4003.     }
  4004.   *lenP = len;
  4005.   return (retval);
  4006. }                /* demand_copy_string() */
  4007.  
  4008. /*
  4009.  *        is_it_end_of_statement()
  4010.  *
  4011.  * In:    Input_line_pointer->next character.
  4012.  *
  4013.  * Do:    Skip input_line_pointer over all whitespace.
  4014.  *
  4015.  * Out:    1 if input_line_pointer->end-of-line.
  4016. */
  4017. int 
  4018. is_it_end_of_statement ()
  4019. {
  4020.   SKIP_WHITESPACE ();
  4021.   return (is_end_of_line[(unsigned char) *input_line_pointer]);
  4022. }                /* is_it_end_of_statement() */
  4023.  
  4024. void 
  4025. equals (sym_name)
  4026.      char *sym_name;
  4027. {
  4028.   register symbolS *symbolP;    /* symbol we are working with */
  4029.   char *stop;
  4030.   char stopc;
  4031.  
  4032.   input_line_pointer++;
  4033.   if (*input_line_pointer == '=')
  4034.     input_line_pointer++;
  4035.  
  4036.   while (*input_line_pointer == ' ' || *input_line_pointer == '\t')
  4037.     input_line_pointer++;
  4038.  
  4039.   if (flag_mri)
  4040.     stop = mri_comment_field (&stopc);
  4041.  
  4042.   if (sym_name[0] == '.' && sym_name[1] == '\0')
  4043.     {
  4044.       /* Turn '. = mumble' into a .org mumble */
  4045.       register segT segment;
  4046.       expressionS exp;
  4047.  
  4048.       segment = get_known_segmented_expression (&exp);
  4049.       if (!need_pass_2)
  4050.     do_org (segment, &exp, 0);
  4051.     }
  4052.   else
  4053.     {
  4054.       symbolP = symbol_find_or_make (sym_name);
  4055.       pseudo_set (symbolP);
  4056.     }
  4057.  
  4058.   if (flag_mri)
  4059.     mri_comment_end (stop, stopc);
  4060. }                /* equals() */
  4061.  
  4062. /* .include -- include a file at this point. */
  4063.  
  4064. /* ARGSUSED */
  4065. void 
  4066. s_include (arg)
  4067.      int arg;
  4068. {
  4069.   char *newbuf;
  4070.   char *filename;
  4071.   int i;
  4072.   FILE *try;
  4073.   char *path;
  4074.  
  4075.   if (! flag_m68k_mri)
  4076.     filename = demand_copy_string (&i);
  4077.   else
  4078.     {
  4079.       SKIP_WHITESPACE ();
  4080.       i = 0;
  4081.       while (! is_end_of_line[(unsigned char) *input_line_pointer]
  4082.          && *input_line_pointer != ' '
  4083.          && *input_line_pointer != '\t')
  4084.     {
  4085.       obstack_1grow (¬es, *input_line_pointer);
  4086.       ++input_line_pointer;
  4087.       ++i;
  4088.     }
  4089.       obstack_1grow (¬es, '\0');
  4090.       filename = obstack_finish (¬es);
  4091.       while (! is_end_of_line[(unsigned char) *input_line_pointer])
  4092.     ++input_line_pointer;
  4093.     }
  4094.   demand_empty_rest_of_line ();
  4095.   path = xmalloc ((unsigned long) i + include_dir_maxlen + 5 /* slop */ );
  4096.   for (i = 0; i < include_dir_count; i++)
  4097.     {
  4098.       strcpy (path, include_dirs[i]);
  4099.       strcat (path, "/");
  4100.       strcat (path, filename);
  4101.       if (0 != (try = fopen (path, "r")))
  4102.     {
  4103.       fclose (try);
  4104.       goto gotit;
  4105.     }
  4106.     }
  4107.   free (path);
  4108.   path = filename;
  4109. gotit:
  4110.   /* malloc Storage leak when file is found on path.  FIXME-SOMEDAY. */
  4111.   newbuf = input_scrub_include_file (path, input_line_pointer);
  4112.   buffer_limit = input_scrub_next_buffer (&input_line_pointer);
  4113. }                /* s_include() */
  4114.  
  4115. void 
  4116. add_include_dir (path)
  4117.      char *path;
  4118. {
  4119.   int i;
  4120.  
  4121.   if (include_dir_count == 0)
  4122.     {
  4123.       include_dirs = (char **) xmalloc (2 * sizeof (*include_dirs));
  4124.       include_dirs[0] = ".";    /* Current dir */
  4125.       include_dir_count = 2;
  4126.     }
  4127.   else
  4128.     {
  4129.       include_dir_count++;
  4130.       include_dirs = (char **) realloc (include_dirs,
  4131.                 include_dir_count * sizeof (*include_dirs));
  4132.     }
  4133.  
  4134.   include_dirs[include_dir_count - 1] = path;    /* New one */
  4135.  
  4136.   i = strlen (path);
  4137.   if (i > include_dir_maxlen)
  4138.     include_dir_maxlen = i;
  4139. }                /* add_include_dir() */
  4140.  
  4141. void 
  4142. s_ignore (arg)
  4143.      int arg;
  4144. {
  4145.   while (!is_end_of_line[(unsigned char) *input_line_pointer])
  4146.     {
  4147.       ++input_line_pointer;
  4148.     }
  4149.   ++input_line_pointer;
  4150. }
  4151.  
  4152.  
  4153. void
  4154. read_print_statistics (file)
  4155.      FILE *file;
  4156. {
  4157.   hash_print_statistics (file, "pseudo-op table", po_hash);
  4158. }
  4159.  
  4160. /* end of read.c */
  4161.