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