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.
5 This file is part of GAS, the GNU Assembler.
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)
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.
17 You should have received a copy of the GNU General Public License
18 along with GAS; see the file COPYING. If not, write to
19 the Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
22 #define MASK_CHAR (0xFF) /* If your chars aren't 8 bits, you will
23 change this a bit. But then, GNU isn't
24 spozed to run on your machine anyway.
25 (RMS is so shortsighted sometimes.)
28 #define MASK_CHAR ((int)(unsigned char)-1)
32 /* This is the largest known floating point format (for now). It will
33 grow when we do 4361 style flonums. */
35 #define MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT (16)
37 /* Routines that read assembler source text to build spagetti in memory.
38 Another group of these functions is in the expr.c module. */
51 #ifndef TC_START_LABEL
52 #define TC_START_LABEL(x,y) (x==':')
55 /* The NOP_OPCODE is for the alignment fill value.
56 * fill it a nop instruction so that the disassembler does not choke
60 #define NOP_OPCODE 0x00
63 char *input_line_pointer
; /*->next char of source file to parse. */
65 int generate_asm_lineno
= 0; /* flag to generate line stab for .s file */
67 #if BITS_PER_CHAR != 8
68 /* The following table is indexed by[(char)] and will break if
69 a char does not have exactly 256 states (hopefully 0:255!)! */
74 /* The m88k unfortunately uses @ as a label beginner. */
79 /* The RS/6000 assembler uses {,},[,] as parts of symbol names. */
84 /* The Delta 68k assembler permits % inside label names. */
89 /* The PowerPC Windows NT assemblers permits ? inside label names. */
94 /* The a29k assembler does not permits labels to start with $. */
98 /* used by is_... macros. our ctype[] */
101 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* @ABCDEFGHIJKLMNO */
102 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* PQRSTUVWXYZ[\]^_ */
103 0, 0, 0, 0, LEX_DOLLAR
, LEX_PCT
, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, /* _!"#$%&'()*+,-./ */
104 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, LEX_QM
, /* 0123456789:;<=>? */
105 LEX_AT
, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, /* @ABCDEFGHIJKLMNO */
106 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, LEX_BR
, 0, LEX_BR
, 0, 3, /* PQRSTUVWXYZ[\]^_ */
107 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, /* `abcdefghijklmno */
108 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, LEX_BR
, 0, LEX_BR
, 0, 0, /* pqrstuvwxyz{|}~. */
109 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
110 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
111 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
112 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
113 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
114 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
115 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
121 * Out: 1 if this character ends a line.
124 char is_end_of_line
[256] =
127 _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, 99, _
, _
, 99, _
, _
, /* @abcdefghijklmno */
129 _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, 99, _
, _
, _
, _
, _
, /* @abcdefghijklmno */
131 _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, /* */
133 _
,99, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, /* _!"#$%&'()*+,-./ */
134 _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, /* 0123456789:;<=>? */
136 _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, /* */
137 _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, 99, _
, _
, _
, _
, /* 0123456789:;<=>? */
139 _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, /* */
140 _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, /* */
141 _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, /* */
142 _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, /* */
143 _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, /* */
144 _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, /* */
145 _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, /* */
146 _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, /* */
147 _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, /* */
151 /* Functions private to this file. */
153 static char *buffer
; /* 1st char of each buffer of lines is here. */
154 static char *buffer_limit
; /*->1 + last char in buffer. */
156 #ifdef TARGET_BYTES_BIG_ENDIAN
157 /* Hack to deal with tc-*.h defining TARGET_BYTES_BIG_ENDIAN to empty
158 instead of to 0 or 1. */
159 #if 5 - TARGET_BYTES_BIG_ENDIAN - 5 == 10
160 #undef TARGET_BYTES_BIG_ENDIAN
161 #define TARGET_BYTES_BIG_ENDIAN 1
163 int target_big_endian
= TARGET_BYTES_BIG_ENDIAN
;
165 int target_big_endian
/* = 0 */;
168 static char *old_buffer
; /* JF a hack */
169 static char *old_input
;
170 static char *old_limit
;
172 /* Variables for handling include file directory list. */
174 char **include_dirs
; /* List of pointers to directories to
175 search for .include's */
176 int include_dir_count
; /* How many are in the list */
177 int include_dir_maxlen
= 1;/* Length of longest in list */
179 #ifndef WORKING_DOT_WORD
180 struct broken_word
*broken_words
;
181 int new_broken_words
;
184 /* The current offset into the absolute section. We don't try to
185 build frags in the absolute section, since no data can be stored
186 there. We just keep track of the current offset. */
187 addressT abs_section_offset
;
189 /* If this line had an MRI style label, it is stored in this variable.
190 This is used by some of the MRI pseudo-ops. */
193 /* This global variable is used to support MRI common sections. We
194 translate such sections into a common symbol. This variable is
195 non-NULL when we are in an MRI common section. */
196 symbolS
*mri_common_symbol
;
198 /* In MRI mode, after a dc.b pseudo-op with an odd number of bytes, we
199 need to align to an even byte boundary unless the next pseudo-op is
200 dc.b, ds.b, or dcb.b. This variable is set to 1 if an alignment
202 static int mri_pending_align
;
204 static int scrub_from_string
PARAMS ((char **));
205 static void do_align
PARAMS ((int, char *, int));
206 static int hex_float
PARAMS ((int, char *));
207 static void do_org
PARAMS ((segT
, expressionS
*, int));
208 char *demand_copy_string
PARAMS ((int *lenP
));
209 static segT get_segmented_expression
PARAMS ((expressionS
*expP
));
210 static segT get_known_segmented_expression
PARAMS ((expressionS
* expP
));
211 static void pobegin
PARAMS ((void));
212 static int get_line_sb
PARAMS ((sb
*));
221 obj_read_begin_hook ();
223 /* Something close -- but not too close -- to a multiple of 1024.
224 The debugging malloc I'm using has 24 bytes of overhead. */
225 obstack_begin (¬es
, chunksize
);
226 obstack_begin (&cond_obstack
, chunksize
);
228 /* Use machine dependent syntax */
229 for (p
= line_separator_chars
; *p
; p
++)
230 is_end_of_line
[(unsigned char) *p
] = 1;
231 /* Use more. FIXME-SOMEDAY. */
237 /* set up pseudo-op tables */
239 static struct hash_control
*po_hash
;
241 static const pseudo_typeS potable
[] =
243 {"abort", s_abort
, 0},
244 {"align", s_align_ptwo
, 0},
245 {"ascii", stringer
, 0},
246 {"asciz", stringer
, 1},
247 {"balign", s_align_bytes
, 0},
248 {"balignw", s_align_bytes
, -2},
249 {"balignl", s_align_bytes
, -4},
253 {"common", s_mri_common
, 0},
254 {"common.s", s_mri_common
, 1},
258 {"dc.d", float_cons
, 'd'},
260 {"dc.s", float_cons
, 'f'},
262 {"dc.x", float_cons
, 'x'},
264 {"dcb.b", s_space
, 1},
265 {"dcb.d", s_float_space
, 'd'},
266 {"dcb.l", s_space
, 4},
267 {"dcb.s", s_float_space
, 'f'},
268 {"dcb.w", s_space
, 2},
269 {"dcb.x", s_float_space
, 'x'},
271 {"ds.b", s_space
, 1},
272 {"ds.d", s_space
, 8},
273 {"ds.l", s_space
, 4},
274 {"ds.p", s_space
, 12},
275 {"ds.s", s_space
, 4},
276 {"ds.w", s_space
, 2},
277 {"ds.x", s_space
, 12},
278 {"debug", s_ignore
, 0},
283 {"double", float_cons
, 'd'},
285 {"eject", listing_eject
, 0}, /* Formfeed listing */
287 {"elsec", s_else
, 0},
289 {"endc", s_endif
, 0},
290 {"endif", s_endif
, 0},
294 {"exitm", s_mexit
, 0},
296 {"extern", s_ignore
, 0}, /* We treat all undef as ext */
297 {"appfile", s_app_file
, 1},
298 {"appline", s_app_line
, 0},
300 {"file", s_app_file
, 0},
302 {"float", float_cons
, 'f'},
303 {"format", s_ignore
, 0},
304 {"global", s_globl
, 0},
305 {"globl", s_globl
, 0},
307 {"if", s_if
, (int) O_ne
},
309 {"ifdef", s_ifdef
, 0},
310 {"ifeq", s_if
, (int) O_eq
},
311 {"ifeqs", s_ifeqs
, 0},
312 {"ifge", s_if
, (int) O_ge
},
313 {"ifgt", s_if
, (int) O_gt
},
314 {"ifle", s_if
, (int) O_le
},
315 {"iflt", s_if
, (int) O_lt
},
317 {"ifndef", s_ifdef
, 1},
318 {"ifne", s_if
, (int) O_ne
},
319 {"ifnes", s_ifeqs
, 1},
320 {"ifnotdef", s_ifdef
, 1},
321 {"include", s_include
, 0},
327 {"lcomm", s_lcomm
, 0},
328 {"lflags", listing_flags
, 0}, /* Listing flags */
329 {"linkonce", s_linkonce
, 0},
330 {"list", listing_list
, 1}, /* Turn listing on */
331 {"llen", listing_psize
, 1},
334 {"macro", s_macro
, 0},
335 {"mexit", s_mexit
, 0},
337 {".mri", s_mri
, 0}, /* Special case so .mri works in MRI mode. */
338 {"name", s_ignore
, 0},
339 {"noformat", s_ignore
, 0},
340 {"nolist", listing_list
, 0}, /* Turn listing off */
341 {"nopage", listing_nopage
, 0},
343 {"offset", s_struct
, 0},
345 {"p2align", s_align_ptwo
, 0},
346 {"p2alignw", s_align_ptwo
, -2},
347 {"p2alignl", s_align_ptwo
, -4},
348 {"page", listing_eject
, 0},
349 {"plen", listing_psize
, 0},
350 {"print", s_print
, 0},
351 {"psize", listing_psize
, 0}, /* set paper size */
352 {"purgem", s_purgem
, 0},
357 {"sbttl", listing_title
, 1}, /* Subtitle of listing */
362 {"single", float_cons
, 'f'},
364 {"space", s_space
, 0},
365 {"skip", s_space
, 0},
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},
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},
385 {"title", listing_title
, 0}, /* Listing title */
386 {"ttl", listing_title
, 0},
391 {"xdef", s_globl
, 0},
392 {"xref", s_ignore
, 0},
393 {"xstabs", s_xstab
, 's'},
395 {"zero", s_space
, 0},
396 {NULL
} /* end sentinel */
399 static int pop_override_ok
= 0;
400 static const char *pop_table_name
;
404 const pseudo_typeS
*table
;
407 const pseudo_typeS
*pop
;
408 for (pop
= table
; pop
->poc_name
; pop
++)
410 errtxt
= hash_insert (po_hash
, pop
->poc_name
, (char *) pop
);
411 if (errtxt
&& (!pop_override_ok
|| strcmp (errtxt
, "exists")))
412 as_fatal ("error constructing %s pseudo-op table: %s", pop_table_name
,
417 #ifndef md_pop_insert
418 #define md_pop_insert() pop_insert(md_pseudo_table)
421 #ifndef obj_pop_insert
422 #define obj_pop_insert() pop_insert(obj_pseudo_table)
428 po_hash
= hash_new ();
430 /* Do the target-specific pseudo ops. */
431 pop_table_name
= "md";
434 /* Now object specific. Skip any that were in the target table. */
435 pop_table_name
= "obj";
439 /* Now portable ones. Skip any that we've seen already. */
440 pop_table_name
= "standard";
441 pop_insert (potable
);
444 #define HANDLE_CONDITIONAL_ASSEMBLY() \
445 if (ignore_input ()) \
447 while (! is_end_of_line[(unsigned char) *input_line_pointer++]) \
448 if (input_line_pointer == buffer_limit) \
454 /* This function is used when scrubbing the characters between #APP
457 static char *scrub_string
;
458 static char *scrub_string_end
;
461 scrub_from_string (from
)
466 *from
= scrub_string
;
467 size
= scrub_string_end
- scrub_string
;
468 scrub_string
= scrub_string_end
;
472 /* read_a_source_file()
474 * We read the file, putting things into a web that
475 * represents what we have been reading.
478 read_a_source_file (name
)
482 register char *s
; /* string of symbol, '\0' appended */
486 buffer
= input_scrub_new_file (name
);
489 listing_newline ("");
491 while ((buffer_limit
= input_scrub_next_buffer (&input_line_pointer
)) != 0)
492 { /* We have another line to parse. */
493 know (buffer_limit
[-1] == '\n'); /* Must have a sentinel. */
494 contin
: /* JF this goto is my fault I admit it.
495 Someone brave please re-write the whole
496 input section here? Pleeze??? */
497 while (input_line_pointer
< buffer_limit
)
499 /* We have more of this buffer to parse. */
502 * We now have input_line_pointer->1st char of next line.
503 * If input_line_pointer [-1] == '\n' then we just
504 * scanned another line: so bump line counters.
506 if (is_end_of_line
[(unsigned char) input_line_pointer
[-1]])
508 #ifdef md_start_line_hook
509 md_start_line_hook ();
512 if (input_line_pointer
[-1] == '\n')
513 bump_line_counters ();
518 #ifdef LABELS_WITHOUT_COLONS
523 /* Text at the start of a line must be a label, we
524 run down and stick a colon in. */
525 if (is_name_beginner (*input_line_pointer
))
527 char *line_start
= input_line_pointer
;
530 HANDLE_CONDITIONAL_ASSEMBLY ();
532 c
= get_symbol_end ();
534 /* In MRI mode, the EQU pseudoop must be
535 handled specially. */
538 char *rest
= input_line_pointer
+ 1;
542 if (*rest
== ' ' || *rest
== '\t')
544 if ((strncasecmp (rest
, "EQU", 3) == 0
545 || strncasecmp (rest
, "SET", 3) == 0)
546 && (rest
[3] == ' ' || rest
[3] == '\t'))
548 input_line_pointer
= rest
+ 3;
554 line_label
= colon (line_start
);
556 *input_line_pointer
= c
;
558 input_line_pointer
++;
564 * We are at the begining of a line, or similar place.
565 * We expect a well-formed assembler statement.
566 * A "symbol-name:" is a statement.
568 * Depending on what compiler is used, the order of these tests
569 * may vary to catch most common case 1st.
570 * Each test is independent of all other tests at the (top) level.
571 * PLEASE make a compiler that doesn't use this assembler.
572 * It is crufty to waste a compiler's time encoding things for this
573 * assembler, which then wastes more time decoding it.
574 * (And communicating via (linear) files is silly!
575 * If you must pass stuff, please pass a tree!)
577 if ((c
= *input_line_pointer
++) == '\t'
582 c
= *input_line_pointer
++;
584 know (c
!= ' '); /* No further leading whitespace. */
587 * C is the 1st significant character.
588 * Input_line_pointer points after that character.
590 if (is_name_beginner (c
))
592 /* want user-defined label or pseudo/opcode */
593 HANDLE_CONDITIONAL_ASSEMBLY ();
595 s
= --input_line_pointer
;
596 c
= get_symbol_end (); /* name's delimiter */
598 * C is character after symbol.
599 * That character's place in the input line is now '\0'.
600 * S points to the beginning of the symbol.
601 * [In case of pseudo-op, s->'.'.]
602 * Input_line_pointer->'\0' where c was.
604 if (TC_START_LABEL(c
, input_line_pointer
))
608 char *rest
= input_line_pointer
+ 1;
610 /* In MRI mode, \tsym: set 0 is permitted. */
614 if (*rest
== ' ' || *rest
== '\t')
616 if ((strncasecmp (rest
, "EQU", 3) == 0
617 || strncasecmp (rest
, "SET", 3) == 0)
618 && (rest
[3] == ' ' || rest
[3] == '\t'))
620 input_line_pointer
= rest
+ 3;
626 line_label
= colon (s
); /* user-defined label */
627 *input_line_pointer
++ = ':'; /* Put ':' back for error messages' sake. */
628 /* Input_line_pointer->after ':'. */
634 || (input_line_pointer
[1] == '='
635 #ifdef TC_EQUAL_IN_INSN
636 && ! TC_EQUAL_IN_INSN (c
, input_line_pointer
)
641 demand_empty_rest_of_line ();
644 { /* expect pseudo-op or machine instruction */
647 #define IGNORE_OPCODE_CASE
648 #ifdef IGNORE_OPCODE_CASE
666 /* The MRI assembler and the m88k use pseudo-ops
668 pop
= (pseudo_typeS
*) hash_find (po_hash
, s
);
669 if (pop
!= NULL
&& pop
->poc_handler
== NULL
)
674 || (! flag_m68k_mri
&& *s
== '.'))
679 * WARNING: c has next char, which may be end-of-line.
680 * We lookup the pseudo-op table with s+1 because we
681 * already know that the pseudo-op begins with a '.'.
685 pop
= (pseudo_typeS
*) hash_find (po_hash
, s
+ 1);
687 /* In MRI mode, we may need to insert an
688 automatic alignment directive. What a hack
690 if (mri_pending_align
692 || ! ((pop
->poc_handler
== cons
693 && pop
->poc_val
== 1)
694 || (pop
->poc_handler
== s_space
695 && pop
->poc_val
== 1)
696 #ifdef tc_conditional_pseudoop
697 || tc_conditional_pseudoop (pop
)
699 || pop
->poc_handler
== s_if
700 || pop
->poc_handler
== s_ifdef
701 || pop
->poc_handler
== s_ifc
702 || pop
->poc_handler
== s_ifeqs
703 || pop
->poc_handler
== s_else
704 || pop
->poc_handler
== s_endif
)))
706 do_align (1, (char *) NULL
, 0);
707 mri_pending_align
= 0;
710 /* Print the error msg now, while we still can */
713 as_bad ("Unknown pseudo-op: `%s'", s
);
714 *input_line_pointer
= c
;
719 /* Put it back for error messages etc. */
720 *input_line_pointer
= c
;
721 /* The following skip of whitespace is compulsory.
722 A well shaped space is sometimes all that separates
723 keyword from operands. */
724 if (c
== ' ' || c
== '\t')
725 input_line_pointer
++;
727 * Input_line is restored.
728 * Input_line_pointer->1st non-blank char
729 * after pseudo-operation.
731 (*pop
->poc_handler
) (pop
->poc_val
);
733 /* If that was .end, just get out now. */
734 if (pop
->poc_handler
== s_end
)
741 /* WARNING: c has char, which may be end-of-line. */
742 /* Also: input_line_pointer->`\0` where c was. */
743 *input_line_pointer
= c
;
744 while (!is_end_of_line
[(unsigned char) *input_line_pointer
]
746 #ifdef TC_EOL_IN_INSN
747 || TC_EOL_IN_INSN (input_line_pointer
)
751 if (flag_m68k_mri
&& *input_line_pointer
== '\'')
753 input_line_pointer
++;
756 c
= *input_line_pointer
;
757 *input_line_pointer
= '\0';
759 #ifdef OBJ_GENERATE_ASM_LINENO
760 if (generate_asm_lineno
== 0)
762 if (ecoff_no_current_file ())
763 generate_asm_lineno
= 1;
765 if (generate_asm_lineno
== 1)
770 as_where (&s
, &lineno
);
771 OBJ_GENERATE_ASM_LINENO (s
, lineno
);
780 if (check_macro (s
, &out
, '\0', &err
))
784 *input_line_pointer
++ = c
;
785 input_scrub_include_sb (&out
,
789 input_scrub_next_buffer (&input_line_pointer
);
794 if (mri_pending_align
)
796 do_align (1, (char *) NULL
, 0);
797 mri_pending_align
= 0;
800 md_assemble (s
); /* Assemble 1 instruction. */
802 *input_line_pointer
++ = c
;
804 /* We resume loop AFTER the end-of-line from
809 } /* if (is_name_beginner(c) */
812 /* Empty statement? */
813 if (is_end_of_line
[(unsigned char) c
])
816 if ((LOCAL_LABELS_DOLLAR
|| LOCAL_LABELS_FB
)
819 /* local label ("4:") */
820 char *backup
= input_line_pointer
;
822 HANDLE_CONDITIONAL_ASSEMBLY ();
826 while (isdigit (*input_line_pointer
))
828 temp
= (temp
* 10) + *input_line_pointer
- '0';
829 ++input_line_pointer
;
830 } /* read the whole number */
832 if (LOCAL_LABELS_DOLLAR
833 && *input_line_pointer
== '$'
834 && *(input_line_pointer
+ 1) == ':')
836 input_line_pointer
+= 2;
838 if (dollar_label_defined (temp
))
840 as_fatal ("label \"%d$\" redefined", temp
);
843 define_dollar_label (temp
);
844 colon (dollar_label_name (temp
, 0));
849 && *input_line_pointer
++ == ':')
851 fb_label_instance_inc (temp
);
852 colon (fb_label_name (temp
, 0));
856 input_line_pointer
= backup
;
857 } /* local label ("4:") */
859 if (c
&& strchr (line_comment_chars
, c
))
860 { /* Its a comment. Better say APP or NO_APP */
864 unsigned int new_length
;
867 bump_line_counters ();
868 s
= input_line_pointer
;
869 if (strncmp (s
, "APP\n", 4))
870 continue; /* We ignore it */
873 ends
= strstr (s
, "#NO_APP\n");
877 unsigned int tmp_len
;
880 /* The end of the #APP wasn't in this buffer. We
881 keep reading in buffers until we find the #NO_APP
882 that goes with this #APP There is one. The specs
884 tmp_len
= buffer_limit
- s
;
885 tmp_buf
= xmalloc (tmp_len
+ 1);
886 memcpy (tmp_buf
, s
, tmp_len
);
889 new_tmp
= input_scrub_next_buffer (&buffer
);
893 buffer_limit
= new_tmp
;
894 input_line_pointer
= buffer
;
895 ends
= strstr (buffer
, "#NO_APP\n");
899 num
= buffer_limit
- buffer
;
901 tmp_buf
= xrealloc (tmp_buf
, tmp_len
+ num
);
902 memcpy (tmp_buf
+ tmp_len
, buffer
, num
);
907 input_line_pointer
= ends
? ends
+ 8 : NULL
;
915 input_line_pointer
= ends
+ 8;
919 scrub_string_end
= ends
;
921 new_length
= ends
- s
;
922 new_buf
= (char *) xmalloc (new_length
);
929 space
= (new_buf
+ new_length
) - new_tmp
;
930 size
= do_scrub_chars (scrub_from_string
, new_tmp
, space
);
938 new_buf
= xrealloc (new_buf
, new_length
+ 100);
939 new_tmp
= new_buf
+ new_length
;
946 old_input
= input_line_pointer
;
947 old_limit
= buffer_limit
;
949 input_line_pointer
= new_buf
;
950 buffer_limit
= new_tmp
;
954 HANDLE_CONDITIONAL_ASSEMBLY ();
956 #ifdef tc_unrecognized_line
957 if (tc_unrecognized_line (c
))
961 /* as_warn("Junk character %d.",c); Now done by ignore_rest */
962 input_line_pointer
--; /* Report unknown char as ignored. */
963 ignore_rest_of_line ();
964 } /* while (input_line_pointer<buffer_limit) */
966 #ifdef md_after_pass_hook
967 md_after_pass_hook ();
973 bump_line_counters ();
977 input_line_pointer
= old_input
;
978 buffer_limit
= old_limit
;
983 } /* while (more buffers to scan) */
990 input_scrub_close (); /* Close the input file */
993 /* For most MRI pseudo-ops, the line actually ends at the first
994 nonquoted space. This function looks for that point, stuffs a null
995 in, and sets *STOPCP to the character that used to be there, and
996 returns the location.
998 Until I hear otherwise, I am going to assume that this is only true
999 for the m68k MRI assembler. */
1002 mri_comment_field (stopcp
)
1010 know (flag_m68k_mri
);
1012 for (s
= input_line_pointer
;
1013 ((! is_end_of_line
[(unsigned char) *s
] && *s
!= ' ' && *s
!= '\t')
1018 inquote
= ! inquote
;
1028 for (s
= input_line_pointer
; ! is_end_of_line
[(unsigned char) *s
]; s
++)
1038 /* Skip to the end of an MRI comment field. */
1041 mri_comment_end (stop
, stopc
)
1047 input_line_pointer
= stop
;
1049 while (! is_end_of_line
[(unsigned char) *input_line_pointer
])
1050 ++input_line_pointer
;
1057 as_fatal (".abort detected. Abandoning ship.");
1060 /* Guts of .align directive. */
1062 do_align (n
, fill
, len
)
1068 md_do_align (n
, fill
, len
, just_record_alignment
);
1072 /* @@ Fix this right for BFD! */
1074 static char nop_opcode
= NOP_OPCODE
;
1076 if (now_seg
!= data_section
&& now_seg
!= bss_section
)
1087 /* Only make a frag if we HAVE to. . . */
1088 if (n
&& !need_pass_2
)
1091 frag_align (n
, *fill
);
1093 frag_align_pattern (n
, fill
, len
);
1097 just_record_alignment
:
1100 record_alignment (now_seg
, n
);
1103 /* For machines where ".align 4" means align to a 4 byte boundary. */
1108 register unsigned int temp
;
1111 unsigned long max_alignment
= 1 << 15;
1116 stop
= mri_comment_field (&stopc
);
1118 if (is_end_of_line
[(unsigned char) *input_line_pointer
])
1123 temp
= arg
; /* Default value from pseudo-op table */
1126 temp
= get_absolute_expression ();
1128 if (temp
> max_alignment
)
1130 as_bad ("Alignment too large: %d. assumed.", temp
= max_alignment
);
1133 /* For the sparc, `.align (1<<n)' actually means `.align n' so we
1134 have to convert it. */
1137 for (i
= 0; (temp
& 1) == 0; temp
>>= 1, ++i
)
1141 as_bad ("Alignment not a power of 2");
1144 if (*input_line_pointer
== ',')
1149 input_line_pointer
++;
1150 fillval
= get_absolute_expression ();
1157 temp_fill
= fillval
;
1158 do_align (temp
, &temp_fill
, len
);
1164 if (len
> sizeof ab
)
1166 md_number_to_chars (ab
, fillval
, len
);
1167 do_align (temp
, ab
, len
);
1173 as_warn ("expected fill pattern missing");
1174 do_align (temp
, (char *) NULL
, 0);
1178 mri_comment_end (stop
, stopc
);
1180 demand_empty_rest_of_line ();
1183 /* For machines where ".align 4" means align to 2**4 boundary. */
1190 long max_alignment
= 15;
1195 stop
= mri_comment_field (&stopc
);
1197 temp
= get_absolute_expression ();
1198 if (temp
> max_alignment
)
1199 as_bad ("Alignment too large: %d. assumed.", temp
= max_alignment
);
1202 as_bad ("Alignment negative. 0 assumed.");
1205 if (*input_line_pointer
== ',')
1210 input_line_pointer
++;
1211 fillval
= get_absolute_expression ();
1218 temp_fill
= fillval
;
1219 do_align (temp
, &temp_fill
, len
);
1225 if (len
> sizeof ab
)
1227 md_number_to_chars (ab
, fillval
, len
);
1228 do_align (temp
, ab
, len
);
1234 as_warn ("expected fill pattern missing");
1235 do_align (temp
, (char *) NULL
, 0);
1239 mri_comment_end (stop
, stopc
);
1241 demand_empty_rest_of_line ();
1248 register char *name
;
1252 register symbolS
*symbolP
;
1257 stop
= mri_comment_field (&stopc
);
1259 name
= input_line_pointer
;
1260 c
= get_symbol_end ();
1261 /* just after name is now '\0' */
1262 p
= input_line_pointer
;
1265 if (*input_line_pointer
!= ',')
1267 as_bad ("Expected comma after symbol-name: rest of line ignored.");
1269 mri_comment_end (stop
, stopc
);
1270 ignore_rest_of_line ();
1273 input_line_pointer
++; /* skip ',' */
1274 if ((temp
= get_absolute_expression ()) < 0)
1276 as_warn (".COMMon length (%ld.) <0! Ignored.", (long) temp
);
1278 mri_comment_end (stop
, stopc
);
1279 ignore_rest_of_line ();
1283 symbolP
= symbol_find_or_make (name
);
1285 if (S_IS_DEFINED (symbolP
))
1287 as_bad ("Ignoring attempt to re-define symbol `%s'.",
1288 S_GET_NAME (symbolP
));
1290 mri_comment_end (stop
, stopc
);
1291 ignore_rest_of_line ();
1294 if (S_GET_VALUE (symbolP
))
1296 if (S_GET_VALUE (symbolP
) != (valueT
) temp
)
1297 as_bad ("Length of .comm \"%s\" is already %ld. Not changed to %ld.",
1298 S_GET_NAME (symbolP
),
1299 (long) S_GET_VALUE (symbolP
),
1304 S_SET_VALUE (symbolP
, (valueT
) temp
);
1305 S_SET_EXTERNAL (symbolP
);
1309 extern int flag_one
;
1310 if ( (!temp
) || !flag_one
)
1311 S_GET_OTHER(symbolP
) = const_flag
;
1313 #endif /* not OBJ_VMS */
1314 know (symbolP
->sy_frag
== &zero_address_frag
);
1317 mri_comment_end (stop
, stopc
);
1319 demand_empty_rest_of_line ();
1322 /* The MRI COMMON pseudo-op. We handle this by creating a common
1323 symbol with the appropriate name. We make s_space do the right
1324 thing by increasing the size. */
1327 s_mri_common (small
)
1344 stop
= mri_comment_field (&stopc
);
1348 name
= input_line_pointer
;
1349 if (! isdigit ((unsigned char) *name
))
1350 c
= get_symbol_end ();
1355 ++input_line_pointer
;
1357 while (isdigit ((unsigned char) *input_line_pointer
));
1358 c
= *input_line_pointer
;
1359 *input_line_pointer
= '\0';
1361 if (line_label
!= NULL
)
1363 alc
= (char *) xmalloc (strlen (S_GET_NAME (line_label
))
1364 + (input_line_pointer
- name
)
1366 sprintf (alc
, "%s%s", name
, S_GET_NAME (line_label
));
1371 sym
= symbol_find_or_make (name
);
1372 *input_line_pointer
= c
;
1376 if (*input_line_pointer
!= ',')
1380 ++input_line_pointer
;
1381 align
= get_absolute_expression ();
1384 if (S_IS_DEFINED (sym
))
1386 #if defined (S_IS_COMMON) || defined (BFD_ASSEMBLER)
1387 if (! S_IS_COMMON (sym
))
1390 as_bad ("attempt to re-define symbol `%s'", S_GET_NAME (sym
));
1391 mri_comment_end (stop
, stopc
);
1392 ignore_rest_of_line ();
1397 S_SET_EXTERNAL (sym
);
1398 mri_common_symbol
= sym
;
1402 S_SET_ALIGN (sym
, align
);
1405 if (line_label
!= NULL
)
1407 line_label
->sy_value
.X_op
= O_symbol
;
1408 line_label
->sy_value
.X_add_symbol
= sym
;
1409 line_label
->sy_value
.X_add_number
= S_GET_VALUE (sym
);
1410 line_label
->sy_frag
= &zero_address_frag
;
1411 S_SET_SEGMENT (line_label
, expr_section
);
1414 /* FIXME: We just ignore the small argument, which distinguishes
1415 COMMON and COMMON.S. I don't know what we can do about it. */
1417 /* Ignore the type and hptype. */
1418 if (*input_line_pointer
== ',')
1419 input_line_pointer
+= 2;
1420 if (*input_line_pointer
== ',')
1421 input_line_pointer
+= 2;
1423 mri_comment_end (stop
, stopc
);
1425 demand_empty_rest_of_line ();
1435 temp
= get_absolute_expression ();
1436 if (flag_readonly_data_in_text
)
1438 section
= text_section
;
1442 section
= data_section
;
1444 subseg_set (section
, (subsegT
) temp
);
1449 demand_empty_rest_of_line ();
1452 /* Handle the .appfile pseudo-op. This is automatically generated by
1453 do_scrub_chars when a preprocessor # line comment is seen with a
1454 file name. This default definition may be overridden by the object
1455 or CPU specific pseudo-ops. This function is also the default
1456 definition for .file; the APPFILE argument is 1 for .appfile, 0 for
1460 s_app_file (appfile
)
1466 /* Some assemblers tolerate immediately following '"' */
1467 if ((s
= demand_copy_string (&length
)) != 0)
1469 /* If this is a fake .appfile, a fake newline was inserted into
1470 the buffer. Passing -2 to new_logical_line tells it to
1472 new_logical_line (s
, appfile
? -2 : -1);
1474 /* In MRI mode, the preprocessor may have inserted an extraneous
1477 && *input_line_pointer
== '\''
1478 && is_end_of_line
[(unsigned char) input_line_pointer
[1]])
1479 ++input_line_pointer
;
1481 demand_empty_rest_of_line ();
1484 listing_source_file (s
);
1492 /* Handle the .appline pseudo-op. This is automatically generated by
1493 do_scrub_chars when a preprocessor # line comment is seen. This
1494 default definition may be overridden by the object or CPU specific
1503 /* The given number is that of the next line. */
1504 l
= get_absolute_expression () - 1;
1506 /* Some of the back ends can't deal with non-positive line numbers.
1507 Besides, it's silly. */
1508 as_warn ("Line numbers must be positive; line number %d rejected.", l
+1);
1511 new_logical_line ((char *) NULL
, l
);
1514 listing_source_line (l
);
1517 demand_empty_rest_of_line ();
1520 /* Handle the .end pseudo-op. Actually, the real work is done in
1521 read_a_source_file. */
1529 /* The MRI assembler permits the start symbol to follow .end,
1530 but we don't support that. */
1532 if (! is_end_of_line
[(unsigned char) *input_line_pointer
]
1533 && *input_line_pointer
!= '*'
1534 && *input_line_pointer
!= '!')
1535 as_warn ("start address not supported");
1539 /* Handle the .err pseudo-op. */
1545 as_bad (".err encountered");
1546 demand_empty_rest_of_line ();
1549 /* Handle the MRI fail pseudo-op. */
1560 stop
= mri_comment_field (&stopc
);
1562 temp
= get_absolute_expression ();
1564 as_warn (".fail %ld encountered", (long) temp
);
1566 as_bad (".fail %ld encountered", (long) temp
);
1569 mri_comment_end (stop
, stopc
);
1571 demand_empty_rest_of_line ();
1578 long temp_repeat
= 0;
1580 register long temp_fill
= 0;
1583 #ifdef md_flush_pending_output
1584 md_flush_pending_output ();
1587 temp_repeat
= get_absolute_expression ();
1588 if (*input_line_pointer
== ',')
1590 input_line_pointer
++;
1591 temp_size
= get_absolute_expression ();
1592 if (*input_line_pointer
== ',')
1594 input_line_pointer
++;
1595 temp_fill
= get_absolute_expression ();
1598 /* This is to be compatible with BSD 4.2 AS, not for any rational reason. */
1599 #define BSD_FILL_SIZE_CROCK_8 (8)
1600 if (temp_size
> BSD_FILL_SIZE_CROCK_8
)
1602 as_warn (".fill size clamped to %d.", BSD_FILL_SIZE_CROCK_8
);
1603 temp_size
= BSD_FILL_SIZE_CROCK_8
;
1607 as_warn ("Size negative: .fill ignored.");
1610 else if (temp_repeat
<= 0)
1612 if (temp_repeat
< 0)
1613 as_warn ("Repeat < 0, .fill ignored");
1617 if (temp_size
&& !need_pass_2
)
1619 p
= frag_var (rs_fill
, (int) temp_size
, (int) temp_size
, (relax_substateT
) 0, (symbolS
*) 0, temp_repeat
, (char *) 0);
1620 memset (p
, 0, (unsigned int) temp_size
);
1621 /* The magic number BSD_FILL_SIZE_CROCK_4 is from BSD 4.2 VAX
1622 * flavoured AS. The following bizzare behaviour is to be
1623 * compatible with above. I guess they tried to take up to 8
1624 * bytes from a 4-byte expression and they forgot to sign
1625 * extend. Un*x Sux. */
1626 #define BSD_FILL_SIZE_CROCK_4 (4)
1627 md_number_to_chars (p
, (valueT
) temp_fill
,
1628 (temp_size
> BSD_FILL_SIZE_CROCK_4
1629 ? BSD_FILL_SIZE_CROCK_4
1630 : (int) temp_size
));
1631 /* Note: .fill (),0 emits no frag (since we are asked to .fill 0 bytes)
1632 * but emits no error message because it seems a legal thing to do.
1633 * It is a degenerate case of .fill but could be emitted by a compiler.
1636 demand_empty_rest_of_line ();
1650 stop
= mri_comment_field (&stopc
);
1654 name
= input_line_pointer
;
1655 c
= get_symbol_end ();
1656 symbolP
= symbol_find_or_make (name
);
1657 *input_line_pointer
= c
;
1659 S_SET_EXTERNAL (symbolP
);
1662 input_line_pointer
++;
1664 if (*input_line_pointer
== '\n')
1671 mri_comment_end (stop
, stopc
);
1673 demand_empty_rest_of_line ();
1676 /* Handle the MRI IRP and IRPC pseudo-ops. */
1688 as_where (&file
, &line
);
1691 while (! is_end_of_line
[(unsigned char) *input_line_pointer
])
1692 sb_add_char (&s
, *input_line_pointer
++);
1696 err
= expand_irp (irpc
, 0, &s
, &out
, get_line_sb
, '\0');
1698 as_bad_where (file
, line
, "%s", err
);
1702 input_scrub_include_sb (&out
, input_line_pointer
);
1704 buffer_limit
= input_scrub_next_buffer (&input_line_pointer
);
1707 /* Handle the .linkonce pseudo-op. This tells the assembler to mark
1708 the section to only be linked once. However, this is not supported
1709 by most object file formats. This takes an optional argument,
1710 which is what to do about duplicates. */
1716 enum linkonce_type type
;
1720 type
= LINKONCE_DISCARD
;
1722 if (! is_end_of_line
[(unsigned char) *input_line_pointer
])
1727 s
= input_line_pointer
;
1728 c
= get_symbol_end ();
1729 if (strcasecmp (s
, "discard") == 0)
1730 type
= LINKONCE_DISCARD
;
1731 else if (strcasecmp (s
, "one_only") == 0)
1732 type
= LINKONCE_ONE_ONLY
;
1733 else if (strcasecmp (s
, "same_size") == 0)
1734 type
= LINKONCE_SAME_SIZE
;
1735 else if (strcasecmp (s
, "same_contents") == 0)
1736 type
= LINKONCE_SAME_CONTENTS
;
1738 as_warn ("unrecognized .linkonce type `%s'", s
);
1740 *input_line_pointer
= c
;
1743 #ifdef obj_handle_link_once
1744 obj_handle_link_once (type
);
1745 #else /* ! defined (obj_handle_link_once) */
1746 #ifdef BFD_ASSEMBLER
1750 if ((bfd_applicable_section_flags (stdoutput
) & SEC_LINK_ONCE
) == 0)
1751 as_warn (".linkonce is not supported for this object file format");
1753 flags
= bfd_get_section_flags (stdoutput
, now_seg
);
1754 flags
|= SEC_LINK_ONCE
;
1759 case LINKONCE_DISCARD
:
1760 flags
|= SEC_LINK_DUPLICATES_DISCARD
;
1762 case LINKONCE_ONE_ONLY
:
1763 flags
|= SEC_LINK_DUPLICATES_ONE_ONLY
;
1765 case LINKONCE_SAME_SIZE
:
1766 flags
|= SEC_LINK_DUPLICATES_SAME_SIZE
;
1768 case LINKONCE_SAME_CONTENTS
:
1769 flags
|= SEC_LINK_DUPLICATES_SAME_CONTENTS
;
1772 if (! bfd_set_section_flags (stdoutput
, now_seg
, flags
))
1773 as_bad ("bfd_set_section_flags: %s",
1774 bfd_errmsg (bfd_get_error ()));
1776 #else /* ! defined (BFD_ASSEMBLER) */
1777 as_warn (".linkonce is not supported for this object file format");
1778 #endif /* ! defined (BFD_ASSEMBLER) */
1779 #endif /* ! defined (obj_handle_link_once) */
1781 demand_empty_rest_of_line ();
1785 s_lcomm (needs_align
)
1786 /* 1 if this was a ".bss" directive, which may require a 3rd argument
1787 (alignment); 0 if it was an ".lcomm" (2 args only) */
1790 register char *name
;
1794 register symbolS
*symbolP
;
1795 segT current_seg
= now_seg
;
1796 subsegT current_subseg
= now_subseg
;
1797 const int max_alignment
= 15;
1799 segT bss_seg
= bss_section
;
1801 name
= input_line_pointer
;
1802 c
= get_symbol_end ();
1803 p
= input_line_pointer
;
1807 /* Accept an optional comma after the name. The comma used to be
1808 required, but Irix 5 cc does not generate it. */
1809 if (*input_line_pointer
== ',')
1811 ++input_line_pointer
;
1815 if (*input_line_pointer
== '\n')
1817 as_bad ("Missing size expression");
1821 if ((temp
= get_absolute_expression ()) < 0)
1823 as_warn ("BSS length (%d.) <0! Ignored.", temp
);
1824 ignore_rest_of_line ();
1828 #if defined (TC_MIPS) || defined (TC_ALPHA)
1829 if (OUTPUT_FLAVOR
== bfd_target_ecoff_flavour
1830 || OUTPUT_FLAVOR
== bfd_target_elf_flavour
)
1832 /* For MIPS and Alpha ECOFF or ELF, small objects are put in .sbss. */
1833 if (temp
<= bfd_get_gp_size (stdoutput
))
1835 bss_seg
= subseg_new (".sbss", 1);
1836 seg_info (bss_seg
)->bss
= 1;
1837 #ifdef BFD_ASSEMBLER
1838 if (! bfd_set_section_flags (stdoutput
, bss_seg
, SEC_ALLOC
))
1839 as_warn ("error setting flags for \".sbss\": %s",
1840 bfd_errmsg (bfd_get_error ()));
1847 /* FIXME. This needs to be machine independent. */
1858 /* FIXME: This needs to be done in a more general fashion. */
1862 record_alignment(bss_seg
, align
);
1869 if (*input_line_pointer
!= ',')
1871 as_bad ("Expected comma after size");
1872 ignore_rest_of_line ();
1875 input_line_pointer
++;
1877 if (*input_line_pointer
== '\n')
1879 as_bad ("Missing alignment");
1882 align
= get_absolute_expression ();
1883 if (align
> max_alignment
)
1885 align
= max_alignment
;
1886 as_warn ("Alignment too large: %d. assumed.", align
);
1891 as_warn ("Alignment negative. 0 assumed.");
1893 record_alignment (bss_seg
, align
);
1894 } /* if needs align */
1897 /* Assume some objects may require alignment on some systems. */
1898 #if defined (TC_ALPHA) && ! defined (VMS)
1901 align
= ffs (temp
) - 1;
1902 if (temp
% (1 << align
))
1909 symbolP
= symbol_find_or_make (name
);
1913 #if defined(OBJ_AOUT) | defined(OBJ_BOUT)
1914 S_GET_OTHER (symbolP
) == 0 &&
1915 S_GET_DESC (symbolP
) == 0 &&
1916 #endif /* OBJ_AOUT or OBJ_BOUT */
1917 (S_GET_SEGMENT (symbolP
) == bss_seg
1918 || (!S_IS_DEFINED (symbolP
) && S_GET_VALUE (symbolP
) == 0)))
1922 subseg_set (bss_seg
, 1);
1925 frag_align (align
, 0);
1926 /* detach from old frag */
1927 if (S_GET_SEGMENT (symbolP
) == bss_seg
)
1928 symbolP
->sy_frag
->fr_symbol
= NULL
;
1930 symbolP
->sy_frag
= frag_now
;
1931 pfrag
= frag_var (rs_org
, 1, 1, (relax_substateT
)0, symbolP
,
1935 S_SET_SEGMENT (symbolP
, bss_seg
);
1938 /* The symbol may already have been created with a preceding
1939 ".globl" directive -- be careful not to step on storage class
1940 in that case. Otherwise, set it to static. */
1941 if (S_GET_STORAGE_CLASS (symbolP
) != C_EXT
)
1943 S_SET_STORAGE_CLASS (symbolP
, C_STAT
);
1945 #endif /* OBJ_COFF */
1948 S_SET_SIZE (symbolP
, temp
);
1952 as_bad ("Ignoring attempt to re-define symbol `%s'.",
1953 S_GET_NAME (symbolP
));
1955 subseg_set (current_seg
, current_subseg
);
1957 demand_empty_rest_of_line ();
1964 register char *name
;
1968 register symbolS
*symbolP
;
1970 /* we permit ANY defined expression: BSD4.2 demands constants */
1971 name
= input_line_pointer
;
1972 c
= get_symbol_end ();
1973 p
= input_line_pointer
;
1976 if (*input_line_pointer
!= ',')
1979 as_bad ("Expected comma after name \"%s\"", name
);
1981 ignore_rest_of_line ();
1984 input_line_pointer
++;
1986 if (exp
.X_op
!= O_constant
1987 && exp
.X_op
!= O_register
)
1989 as_bad ("bad expression");
1990 ignore_rest_of_line ();
1994 symbolP
= symbol_find_or_make (name
);
1996 /* FIXME-SOON I pulled a (&& symbolP->sy_other == 0 &&
1997 symbolP->sy_desc == 0) out of this test because coff doesn't have
1998 those fields, and I can't see when they'd ever be tripped. I
1999 don't think I understand why they were here so I may have
2000 introduced a bug. As recently as 1.37 didn't have this test
2001 anyway. xoxorich. */
2003 if (S_GET_SEGMENT (symbolP
) == undefined_section
2004 && S_GET_VALUE (symbolP
) == 0)
2006 /* The name might be an undefined .global symbol; be sure to
2007 keep the "external" bit. */
2008 S_SET_SEGMENT (symbolP
,
2009 (exp
.X_op
== O_constant
2012 S_SET_VALUE (symbolP
, (valueT
) exp
.X_add_number
);
2016 as_bad ("Symbol %s already defined", name
);
2019 demand_empty_rest_of_line ();
2022 /* Read a line into an sb. */
2028 if (input_line_pointer
[-1] == '\n')
2029 bump_line_counters ();
2031 if (input_line_pointer
>= buffer_limit
)
2033 buffer_limit
= input_scrub_next_buffer (&input_line_pointer
);
2034 if (buffer_limit
== 0)
2038 while (! is_end_of_line
[(unsigned char) *input_line_pointer
])
2039 sb_add_char (line
, *input_line_pointer
++);
2040 while (input_line_pointer
< buffer_limit
2041 && is_end_of_line
[(unsigned char) *input_line_pointer
])
2043 if (input_line_pointer
[-1] == '\n')
2044 bump_line_counters ();
2045 ++input_line_pointer
;
2050 /* Define a macro. This is an interface to macro.c, which is shared
2051 between gas and gasp. */
2064 as_where (&file
, &line
);
2067 while (! is_end_of_line
[(unsigned char) *input_line_pointer
])
2068 sb_add_char (&s
, *input_line_pointer
++);
2071 if (line_label
!= NULL
)
2072 sb_add_string (&label
, S_GET_NAME (line_label
));
2074 err
= define_macro (0, &s
, &label
, get_line_sb
, &name
);
2076 as_bad_where (file
, line
, "%s", err
);
2079 if (line_label
!= NULL
)
2081 S_SET_SEGMENT (line_label
, undefined_section
);
2082 S_SET_VALUE (line_label
, 0);
2083 line_label
->sy_frag
= &zero_address_frag
;
2087 #ifdef NO_PSEUDO_DOT
2091 && hash_find (po_hash
, name
) != NULL
)
2094 && hash_find (po_hash
, name
+ 1) != NULL
))
2095 as_warn ("attempt to redefine pseudo-op `%s' ignored",
2102 /* Handle the .mexit pseudo-op, which immediately exits a macro
2109 buffer_limit
= input_scrub_next_buffer (&input_line_pointer
);
2112 /* Switch in and out of MRI mode. */
2120 on
= get_absolute_expression ();
2121 old_flag
= flag_mri
;
2135 #ifdef MRI_MODE_CHANGE
2137 MRI_MODE_CHANGE (on
);
2140 demand_empty_rest_of_line ();
2143 /* Handle changing the location counter. */
2146 do_org (segment
, exp
, fill
)
2151 if (segment
!= now_seg
&& segment
!= absolute_section
)
2152 as_bad ("invalid segment \"%s\"; segment \"%s\" assumed",
2153 segment_name (segment
), segment_name (now_seg
));
2155 if (now_seg
== absolute_section
)
2158 as_warn ("ignoring fill value in absolute section");
2159 if (exp
->X_op
!= O_constant
)
2161 as_bad ("only constant offsets supported in absolute section");
2162 exp
->X_add_number
= 0;
2164 abs_section_offset
= exp
->X_add_number
;
2170 p
= frag_var (rs_org
, 1, 1, (relax_substateT
) 0, exp
->X_add_symbol
,
2171 exp
->X_add_number
, (char *) NULL
);
2180 register segT segment
;
2182 register long temp_fill
;
2184 /* The m68k MRI assembler has a different meaning for .org. It
2185 means to create an absolute section at a given address. We can't
2186 support that--use a linker script instead. */
2189 as_bad ("MRI style ORG pseudo-op not supported");
2190 ignore_rest_of_line ();
2194 /* Don't believe the documentation of BSD 4.2 AS. There is no such
2195 thing as a sub-segment-relative origin. Any absolute origin is
2196 given a warning, then assumed to be segment-relative. Any
2197 segmented origin expression ("foo+42") had better be in the right
2198 segment or the .org is ignored.
2200 BSD 4.2 AS warns if you try to .org backwards. We cannot because
2201 we never know sub-segment sizes when we are reading code. BSD
2202 will crash trying to emit negative numbers of filler bytes in
2203 certain .orgs. We don't crash, but see as-write for that code.
2205 Don't make frag if need_pass_2==1. */
2206 segment
= get_known_segmented_expression (&exp
);
2207 if (*input_line_pointer
== ',')
2209 input_line_pointer
++;
2210 temp_fill
= get_absolute_expression ();
2216 do_org (segment
, &exp
, temp_fill
);
2218 demand_empty_rest_of_line ();
2221 /* Handle parsing for the MRI SECT/SECTION pseudo-op. This should be
2222 called by the obj-format routine which handles section changing
2223 when in MRI mode. It will create a new section, and return it. It
2224 will set *TYPE to the section type: one of 'C' (code), 'D' (data),
2225 'M' (mixed), or 'R' (romable). If BFD_ASSEMBLER is defined, the
2226 flags will be set in the section. */
2240 name
= input_line_pointer
;
2241 if (! isdigit ((unsigned char) *name
))
2242 c
= get_symbol_end ();
2247 ++input_line_pointer
;
2249 while (isdigit ((unsigned char) *input_line_pointer
));
2250 c
= *input_line_pointer
;
2251 *input_line_pointer
= '\0';
2254 name
= xstrdup (name
);
2256 *input_line_pointer
= c
;
2258 seg
= subseg_new (name
, 0);
2260 if (*input_line_pointer
== ',')
2264 ++input_line_pointer
;
2265 align
= get_absolute_expression ();
2266 record_alignment (seg
, align
);
2270 if (*input_line_pointer
== ',')
2272 c
= *++input_line_pointer
;
2273 c
= toupper ((unsigned char) c
);
2274 if (c
== 'C' || c
== 'D' || c
== 'M' || c
== 'R')
2277 as_bad ("unrecognized section type");
2278 ++input_line_pointer
;
2280 #ifdef BFD_ASSEMBLER
2284 flags
= SEC_NO_FLAGS
;
2286 flags
= SEC_ALLOC
| SEC_LOAD
| SEC_READONLY
| SEC_CODE
;
2287 else if (*type
== 'D' || *type
== 'M')
2288 flags
= SEC_ALLOC
| SEC_LOAD
| SEC_DATA
;
2289 else if (*type
== 'R')
2290 flags
= SEC_ALLOC
| SEC_LOAD
| SEC_DATA
| SEC_READONLY
| SEC_ROM
;
2291 if (flags
!= SEC_NO_FLAGS
)
2293 if (! bfd_set_section_flags (stdoutput
, seg
, flags
))
2294 as_warn ("error setting flags for \"%s\": %s",
2295 bfd_section_name (stdoutput
, seg
),
2296 bfd_errmsg (bfd_get_error ()));
2302 /* Ignore the HP type. */
2303 if (*input_line_pointer
== ',')
2304 input_line_pointer
+= 2;
2306 demand_empty_rest_of_line ();
2308 #else /* ! TC_M68K */
2317 name
= input_line_pointer
;
2318 c
= get_symbol_end ();
2320 name
= xstrdup (name
);
2322 *input_line_pointer
= c
;
2324 seg
= subseg_new (name
, 0);
2326 if (*input_line_pointer
!= ',')
2332 ++input_line_pointer
;
2334 sectype
= input_line_pointer
;
2335 c
= get_symbol_end ();
2336 if (*sectype
== '\0')
2338 else if (strcasecmp (sectype
, "text") == 0)
2340 else if (strcasecmp (sectype
, "data") == 0)
2342 else if (strcasecmp (sectype
, "romdata") == 0)
2345 as_warn ("unrecognized section type `%s'", sectype
);
2346 *input_line_pointer
= c
;
2349 if (*input_line_pointer
== ',')
2353 ++input_line_pointer
;
2355 seccmd
= input_line_pointer
;
2356 c
= get_symbol_end ();
2357 if (strcasecmp (seccmd
, "absolute") == 0)
2359 as_bad ("absolute sections are not supported");
2360 *input_line_pointer
= c
;
2361 ignore_rest_of_line ();
2364 else if (strcasecmp (seccmd
, "align") == 0)
2368 *input_line_pointer
= c
;
2369 align
= get_absolute_expression ();
2370 record_alignment (seg
, align
);
2374 as_warn ("unrecognized section command `%s'", seccmd
);
2375 *input_line_pointer
= c
;
2379 demand_empty_rest_of_line ();
2381 #else /* ! TC_I960 */
2382 /* The MRI assembler seems to use different forms of .sect for
2383 different targets. */
2385 #endif /* ! TC_I960 */
2386 #endif /* ! TC_M68K */
2389 /* Handle the .print pseudo-op. */
2398 s
= demand_copy_C_string (&len
);
2400 demand_empty_rest_of_line ();
2403 /* Handle the .purgem pseudo-op. */
2409 if (is_it_end_of_statement ())
2411 demand_empty_rest_of_line ();
2421 name
= input_line_pointer
;
2422 c
= get_symbol_end ();
2423 delete_macro (name
);
2424 *input_line_pointer
= c
;
2427 while (*input_line_pointer
++ == ',');
2429 --input_line_pointer
;
2430 demand_empty_rest_of_line ();
2433 /* Handle the .rept pseudo-op. */
2443 count
= get_absolute_expression ();
2446 if (! buffer_and_nest ("REPT", "ENDR", &one
, get_line_sb
))
2448 as_bad ("rept without endr");
2454 sb_add_sb (&many
, &one
);
2458 input_scrub_include_sb (&many
, input_line_pointer
);
2460 buffer_limit
= input_scrub_next_buffer (&input_line_pointer
);
2467 register char *name
;
2468 register char delim
;
2469 register char *end_name
;
2470 register symbolS
*symbolP
;
2473 * Especial apologies for the random logic:
2474 * this just grew, and could be parsed much more simply!
2477 name
= input_line_pointer
;
2478 delim
= get_symbol_end ();
2479 end_name
= input_line_pointer
;
2483 if (*input_line_pointer
!= ',')
2486 as_bad ("Expected comma after name \"%s\"", name
);
2488 ignore_rest_of_line ();
2492 input_line_pointer
++;
2495 if (name
[0] == '.' && name
[1] == '\0')
2497 /* Turn '. = mumble' into a .org mumble */
2498 register segT segment
;
2501 segment
= get_known_segmented_expression (&exp
);
2504 do_org (segment
, &exp
, 0);
2510 if ((symbolP
= symbol_find (name
)) == NULL
2511 && (symbolP
= md_undefined_symbol (name
)) == NULL
)
2513 symbolP
= symbol_new (name
, undefined_section
, 0, &zero_address_frag
);
2515 /* "set" symbols are local unless otherwise specified. */
2516 SF_SET_LOCAL (symbolP
);
2517 #endif /* OBJ_COFF */
2519 } /* make a new symbol */
2521 symbol_table_insert (symbolP
);
2524 pseudo_set (symbolP
);
2525 demand_empty_rest_of_line ();
2538 #ifdef md_flush_pending_output
2539 md_flush_pending_output ();
2543 stop
= mri_comment_field (&stopc
);
2545 /* In m68k MRI mode, we need to align to a word boundary, unless
2547 if (flag_m68k_mri
&& mult
> 1)
2549 if (now_seg
== absolute_section
)
2551 abs_section_offset
+= abs_section_offset
& 1;
2552 if (line_label
!= NULL
)
2553 S_SET_VALUE (line_label
, abs_section_offset
);
2555 else if (mri_common_symbol
!= NULL
)
2559 val
= S_GET_VALUE (mri_common_symbol
);
2562 S_SET_VALUE (mri_common_symbol
, val
+ 1);
2563 if (line_label
!= NULL
)
2565 know (line_label
->sy_value
.X_op
== O_symbol
);
2566 know (line_label
->sy_value
.X_add_symbol
== mri_common_symbol
);
2567 line_label
->sy_value
.X_add_number
+= 1;
2573 do_align (1, (char *) NULL
, 0);
2574 if (line_label
!= NULL
)
2576 line_label
->sy_frag
= frag_now
;
2577 S_SET_VALUE (line_label
, frag_now_fix ());
2585 if (*input_line_pointer
== ',')
2587 ++input_line_pointer
;
2592 val
.X_op
= O_constant
;
2593 val
.X_add_number
= 0;
2596 if (val
.X_op
!= O_constant
2597 || val
.X_add_number
< - 0x80
2598 || val
.X_add_number
> 0xff
2599 || (mult
!= 0 && mult
!= 1 && val
.X_add_number
!= 0))
2601 if (exp
.X_op
!= O_constant
)
2602 as_bad ("Unsupported variable size or fill value");
2609 for (i
= 0; i
< exp
.X_add_number
; i
++)
2610 emit_expr (&val
, mult
);
2615 if (exp
.X_op
== O_constant
)
2619 repeat
= exp
.X_add_number
;
2624 if (! flag_mri
|| repeat
< 0)
2625 as_warn (".space repeat count is %s, ignored",
2626 repeat
? "negative" : "zero");
2630 /* If we are in the absolute section, just bump the offset. */
2631 if (now_seg
== absolute_section
)
2633 abs_section_offset
+= repeat
;
2637 /* If we are secretly in an MRI common section, then
2638 creating space just increases the size of the common
2640 if (mri_common_symbol
!= NULL
)
2642 S_SET_VALUE (mri_common_symbol
,
2643 S_GET_VALUE (mri_common_symbol
) + repeat
);
2648 p
= frag_var (rs_fill
, 1, 1, (relax_substateT
) 0, (symbolS
*) 0,
2649 repeat
, (char *) 0);
2653 if (now_seg
== absolute_section
)
2655 as_bad ("space allocation too complex in absolute section");
2656 subseg_set (text_section
, 0);
2658 if (mri_common_symbol
!= NULL
)
2660 as_bad ("space allocation too complex in common section");
2661 mri_common_symbol
= NULL
;
2664 p
= frag_var (rs_space
, 1, 1, (relax_substateT
) 0,
2665 make_expr_symbol (&exp
), 0L, (char *) 0);
2669 *p
= val
.X_add_number
;
2674 mri_comment_end (stop
, stopc
);
2676 demand_empty_rest_of_line ();
2679 /* This is like s_space, but the value is a floating point number with
2680 the given precision. This is for the MRI dcb.s pseudo-op and
2684 s_float_space (float_type
)
2689 char temp
[MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT
];
2694 stop
= mri_comment_field (&stopc
);
2696 count
= get_absolute_expression ();
2699 if (*input_line_pointer
!= ',')
2701 as_bad ("missing value");
2703 mri_comment_end (stop
, stopc
);
2704 ignore_rest_of_line ();
2708 ++input_line_pointer
;
2712 /* Skip any 0{letter} that may be present. Don't even check if the
2713 * letter is legal. */
2714 if (input_line_pointer
[0] == '0' && isalpha (input_line_pointer
[1]))
2715 input_line_pointer
+= 2;
2717 /* Accept :xxxx, where the x's are hex digits, for a floating point
2718 with the exact digits specified. */
2719 if (input_line_pointer
[0] == ':')
2721 flen
= hex_float (float_type
, temp
);
2725 mri_comment_end (stop
, stopc
);
2726 ignore_rest_of_line ();
2734 err
= md_atof (float_type
, temp
, &flen
);
2735 know (flen
<= MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT
);
2739 as_bad ("Bad floating literal: %s", err
);
2741 mri_comment_end (stop
, stopc
);
2742 ignore_rest_of_line ();
2747 while (--count
>= 0)
2751 p
= frag_more (flen
);
2752 memcpy (p
, temp
, (unsigned int) flen
);
2756 mri_comment_end (stop
, stopc
);
2758 demand_empty_rest_of_line ();
2761 /* Handle the .struct pseudo-op, as found in MIPS assemblers. */
2771 stop
= mri_comment_field (&stopc
);
2772 abs_section_offset
= get_absolute_expression ();
2773 subseg_set (absolute_section
, 0);
2775 mri_comment_end (stop
, stopc
);
2776 demand_empty_rest_of_line ();
2785 temp
= get_absolute_expression ();
2786 subseg_set (text_section
, (subsegT
) temp
);
2787 demand_empty_rest_of_line ();
2789 const_flag
&= ~IN_DEFAULT_SECTION
;
2795 demand_empty_rest_of_line ()
2798 if (is_end_of_line
[(unsigned char) *input_line_pointer
])
2800 input_line_pointer
++;
2804 ignore_rest_of_line ();
2806 /* Return having already swallowed end-of-line. */
2807 } /* Return pointing just after end-of-line. */
2810 ignore_rest_of_line () /* For suspect lines: gives warning. */
2812 if (!is_end_of_line
[(unsigned char) *input_line_pointer
])
2814 if (isprint (*input_line_pointer
))
2815 as_bad ("Rest of line ignored. First ignored character is `%c'.",
2816 *input_line_pointer
);
2818 as_bad ("Rest of line ignored. First ignored character valued 0x%x.",
2819 *input_line_pointer
);
2820 while (input_line_pointer
< buffer_limit
2821 && !is_end_of_line
[(unsigned char) *input_line_pointer
])
2823 input_line_pointer
++;
2826 input_line_pointer
++; /* Return pointing just after end-of-line. */
2827 know (is_end_of_line
[(unsigned char) input_line_pointer
[-1]]);
2833 * In: Pointer to a symbol.
2834 * Input_line_pointer->expression.
2836 * Out: Input_line_pointer->just after any whitespace after expression.
2837 * Tried to set symbol to value of expression.
2838 * Will change symbols type, value, and frag;
2841 pseudo_set (symbolP
)
2845 #if (defined (OBJ_AOUT) || defined (OBJ_BOUT)) && ! defined (BFD_ASSEMBLER)
2847 #endif /* OBJ_AOUT or OBJ_BOUT */
2849 know (symbolP
); /* NULL pointer is logic error. */
2850 #if (defined (OBJ_AOUT) || defined (OBJ_BOUT)) && ! defined (BFD_ASSEMBLER)
2851 ext
= S_IS_EXTERNAL (symbolP
);
2852 #endif /* OBJ_AOUT or OBJ_BOUT */
2854 (void) expression (&exp
);
2856 if (exp
.X_op
== O_illegal
)
2857 as_bad ("illegal expression; zero assumed");
2858 else if (exp
.X_op
== O_absent
)
2859 as_bad ("missing expression; zero assumed");
2860 else if (exp
.X_op
== O_big
)
2861 as_bad ("%s number invalid; zero assumed",
2862 exp
.X_add_number
> 0 ? "bignum" : "floating point");
2863 else if (exp
.X_op
== O_subtract
2864 && (S_GET_SEGMENT (exp
.X_add_symbol
)
2865 == S_GET_SEGMENT (exp
.X_op_symbol
))
2866 && SEG_NORMAL (S_GET_SEGMENT (exp
.X_add_symbol
))
2867 && exp
.X_add_symbol
->sy_frag
== exp
.X_op_symbol
->sy_frag
)
2869 exp
.X_op
= O_constant
;
2870 exp
.X_add_number
= (S_GET_VALUE (exp
.X_add_symbol
)
2871 - S_GET_VALUE (exp
.X_op_symbol
));
2879 exp
.X_add_number
= 0;
2882 S_SET_SEGMENT (symbolP
, absolute_section
);
2883 #if (defined (OBJ_AOUT) || defined (OBJ_BOUT)) && ! defined (BFD_ASSEMBLER)
2885 S_SET_EXTERNAL (symbolP
);
2887 S_CLEAR_EXTERNAL (symbolP
);
2888 #endif /* OBJ_AOUT or OBJ_BOUT */
2889 S_SET_VALUE (symbolP
, (valueT
) exp
.X_add_number
);
2890 symbolP
->sy_frag
= &zero_address_frag
;
2894 S_SET_SEGMENT (symbolP
, reg_section
);
2895 S_SET_VALUE (symbolP
, (valueT
) exp
.X_add_number
);
2896 symbolP
->sy_frag
= &zero_address_frag
;
2900 if (S_GET_SEGMENT (exp
.X_add_symbol
) == undefined_section
2901 || exp
.X_add_number
!= 0)
2902 symbolP
->sy_value
= exp
;
2905 symbolS
*s
= exp
.X_add_symbol
;
2907 S_SET_SEGMENT (symbolP
, S_GET_SEGMENT (s
));
2908 #if (defined (OBJ_AOUT) || defined (OBJ_BOUT)) && ! defined (BFD_ASSEMBLER)
2910 S_SET_EXTERNAL (symbolP
);
2912 S_CLEAR_EXTERNAL (symbolP
);
2913 #endif /* OBJ_AOUT or OBJ_BOUT */
2914 S_SET_VALUE (symbolP
,
2915 exp
.X_add_number
+ S_GET_VALUE (s
));
2916 symbolP
->sy_frag
= s
->sy_frag
;
2917 copy_symbol_attributes (symbolP
, s
);
2922 /* The value is some complex expression.
2923 FIXME: Should we set the segment to anything? */
2924 symbolP
->sy_value
= exp
;
2932 * CONStruct more frag of .bytes, or .words etc.
2933 * Should need_pass_2 be 1 then emit no frag(s).
2934 * This understands EXPRESSIONS.
2938 * This has a split personality. We use expression() to read the
2939 * value. We can detect if the value won't fit in a byte or word.
2940 * But we can't detect if expression() discarded significant digits
2941 * in the case of a long. Not worth the crocks required to fix it.
2944 /* Select a parser for cons expressions. */
2946 /* Some targets need to parse the expression in various fancy ways.
2947 You can define TC_PARSE_CONS_EXPRESSION to do whatever you like
2948 (for example, the HPPA does this). Otherwise, you can define
2949 BITFIELD_CONS_EXPRESSIONS to permit bitfields to be specified, or
2950 REPEAT_CONS_EXPRESSIONS to permit repeat counts. If none of these
2951 are defined, which is the normal case, then only simple expressions
2955 parse_mri_cons
PARAMS ((expressionS
*exp
, unsigned int nbytes
));
2957 #ifndef TC_PARSE_CONS_EXPRESSION
2958 #ifdef BITFIELD_CONS_EXPRESSIONS
2959 #define TC_PARSE_CONS_EXPRESSION(EXP, NBYTES) parse_bitfield_cons (EXP, NBYTES)
2961 parse_bitfield_cons
PARAMS ((expressionS
*exp
, unsigned int nbytes
));
2963 #ifdef REPEAT_CONS_EXPRESSIONS
2964 #define TC_PARSE_CONS_EXPRESSION(EXP, NBYTES) parse_repeat_cons (EXP, NBYTES)
2966 parse_repeat_cons
PARAMS ((expressionS
*exp
, unsigned int nbytes
));
2969 /* If we haven't gotten one yet, just call expression. */
2970 #ifndef TC_PARSE_CONS_EXPRESSION
2971 #define TC_PARSE_CONS_EXPRESSION(EXP, NBYTES) expression (EXP)
2975 /* worker to do .byte etc statements */
2976 /* clobbers input_line_pointer, checks */
2979 cons_worker (nbytes
, rva
)
2980 register int nbytes
; /* 1=.byte, 2=.word, 4=.long */
2988 #ifdef md_flush_pending_output
2989 md_flush_pending_output ();
2993 stop
= mri_comment_field (&stopc
);
2995 if (is_it_end_of_statement ())
2998 mri_comment_end (stop
, stopc
);
2999 demand_empty_rest_of_line ();
3003 #ifdef md_cons_align
3004 md_cons_align (nbytes
);
3011 parse_mri_cons (&exp
, (unsigned int) nbytes
);
3013 TC_PARSE_CONS_EXPRESSION (&exp
, (unsigned int) nbytes
);
3017 if (exp
.X_op
== O_symbol
)
3018 exp
.X_op
= O_symbol_rva
;
3020 as_fatal ("rva without symbol");
3022 emit_expr (&exp
, (unsigned int) nbytes
);
3025 while (*input_line_pointer
++ == ',');
3027 /* In MRI mode, after an odd number of bytes, we must align to an
3028 even word boundary, unless the next instruction is a dc.b, ds.b
3030 if (flag_mri
&& nbytes
== 1 && (c
& 1) != 0)
3031 mri_pending_align
= 1;
3033 input_line_pointer
--; /* Put terminator back into stream. */
3036 mri_comment_end (stop
, stopc
);
3038 demand_empty_rest_of_line ();
3046 cons_worker (size
, 0);
3053 cons_worker (size
, 1);
3057 /* Put the contents of expression EXP into the object file using
3058 NBYTES bytes. If need_pass_2 is 1, this does nothing. */
3061 emit_expr (exp
, nbytes
)
3063 unsigned int nbytes
;
3067 valueT extra_digit
= 0;
3069 /* Don't do anything if we are going to make another pass. */
3075 /* Allow `.word 0' in the absolute section. */
3076 if (now_seg
== absolute_section
)
3078 if (op
!= O_constant
|| exp
->X_add_number
!= 0)
3079 as_bad ("attempt to store value in absolute section");
3080 abs_section_offset
+= nbytes
;
3084 /* Handle a negative bignum. */
3086 && exp
->X_add_number
== 0
3087 && exp
->X_add_symbol
->sy_value
.X_op
== O_big
3088 && exp
->X_add_symbol
->sy_value
.X_add_number
> 0)
3091 unsigned long carry
;
3093 exp
= &exp
->X_add_symbol
->sy_value
;
3095 /* Negate the bignum: one's complement each digit and add 1. */
3097 for (i
= 0; i
< exp
->X_add_number
; i
++)
3101 next
= (((~ (generic_bignum
[i
] & LITTLENUM_MASK
))
3104 generic_bignum
[i
] = next
& LITTLENUM_MASK
;
3105 carry
= next
>> LITTLENUM_NUMBER_OF_BITS
;
3108 /* We can ignore any carry out, because it will be handled by
3109 extra_digit if it is needed. */
3111 extra_digit
= (valueT
) -1;
3115 if (op
== O_absent
|| op
== O_illegal
)
3117 as_warn ("zero assumed for missing expression");
3118 exp
->X_add_number
= 0;
3121 else if (op
== O_big
&& exp
->X_add_number
<= 0)
3123 as_bad ("floating point number invalid; zero assumed");
3124 exp
->X_add_number
= 0;
3127 else if (op
== O_register
)
3129 as_warn ("register value used as expression");
3133 p
= frag_more ((int) nbytes
);
3135 #ifndef WORKING_DOT_WORD
3136 /* If we have the difference of two symbols in a word, save it on
3137 the broken_words list. See the code in write.c. */
3138 if (op
== O_subtract
&& nbytes
== 2)
3140 struct broken_word
*x
;
3142 x
= (struct broken_word
*) xmalloc (sizeof (struct broken_word
));
3143 x
->next_broken_word
= broken_words
;
3146 x
->word_goes_here
= p
;
3148 x
->add
= exp
->X_add_symbol
;
3149 x
->sub
= exp
->X_op_symbol
;
3150 x
->addnum
= exp
->X_add_number
;
3157 /* If we have an integer, but the number of bytes is too large to
3158 pass to md_number_to_chars, handle it as a bignum. */
3159 if (op
== O_constant
&& nbytes
> sizeof (valueT
))
3164 if (! exp
->X_unsigned
&& exp
->X_add_number
< 0)
3165 extra_digit
= (valueT
) -1;
3166 val
= (valueT
) exp
->X_add_number
;
3170 generic_bignum
[gencnt
] = val
& LITTLENUM_MASK
;
3171 val
>>= LITTLENUM_NUMBER_OF_BITS
;
3175 op
= exp
->X_op
= O_big
;
3176 exp
->X_add_number
= gencnt
;
3179 if (op
== O_constant
)
3181 register valueT get
;
3182 register valueT use
;
3183 register valueT mask
;
3184 register valueT unmask
;
3186 /* JF << of >= number of bits in the object is undefined. In
3187 particular SPARC (Sun 4) has problems */
3188 if (nbytes
>= sizeof (valueT
))
3191 mask
= ~(valueT
) 0 << (BITS_PER_CHAR
* nbytes
); /* Don't store these bits. */
3193 unmask
= ~mask
; /* Do store these bits. */
3196 "Do this mod if you want every overflow check to assume SIGNED 2's complement data.";
3197 mask
= ~(unmask
>> 1); /* Includes sign bit now. */
3200 get
= exp
->X_add_number
;
3202 if ((get
& mask
) != 0 && (get
& mask
) != mask
)
3203 { /* Leading bits contain both 0s & 1s. */
3204 as_warn ("Value 0x%lx truncated to 0x%lx.",
3205 (unsigned long) get
, (unsigned long) use
);
3207 /* put bytes in right order. */
3208 md_number_to_chars (p
, use
, (int) nbytes
);
3210 else if (op
== O_big
)
3213 LITTLENUM_TYPE
*nums
;
3215 know (nbytes
% CHARS_PER_LITTLENUM
== 0);
3217 size
= exp
->X_add_number
* CHARS_PER_LITTLENUM
;
3220 as_warn ("Bignum truncated to %d bytes", nbytes
);
3224 if (target_big_endian
)
3226 while (nbytes
> size
)
3228 md_number_to_chars (p
, extra_digit
, CHARS_PER_LITTLENUM
);
3229 nbytes
-= CHARS_PER_LITTLENUM
;
3230 p
+= CHARS_PER_LITTLENUM
;
3233 nums
= generic_bignum
+ size
/ CHARS_PER_LITTLENUM
;
3237 md_number_to_chars (p
, (valueT
) *nums
, CHARS_PER_LITTLENUM
);
3238 size
-= CHARS_PER_LITTLENUM
;
3239 p
+= CHARS_PER_LITTLENUM
;
3244 nums
= generic_bignum
;
3247 md_number_to_chars (p
, (valueT
) *nums
, CHARS_PER_LITTLENUM
);
3249 size
-= CHARS_PER_LITTLENUM
;
3250 p
+= CHARS_PER_LITTLENUM
;
3251 nbytes
-= CHARS_PER_LITTLENUM
;
3256 md_number_to_chars (p
, extra_digit
, CHARS_PER_LITTLENUM
);
3257 nbytes
-= CHARS_PER_LITTLENUM
;
3258 p
+= CHARS_PER_LITTLENUM
;
3264 memset (p
, 0, nbytes
);
3266 /* Now we need to generate a fixS to record the symbol value.
3267 This is easy for BFD. For other targets it can be more
3268 complex. For very complex cases (currently, the HPPA and
3269 NS32K), you can define TC_CONS_FIX_NEW to do whatever you
3270 want. For simpler cases, you can define TC_CONS_RELOC to be
3271 the name of the reloc code that should be stored in the fixS.
3272 If neither is defined, the code uses NO_RELOC if it is
3273 defined, and otherwise uses 0. */
3275 #ifdef BFD_ASSEMBLER
3276 #ifdef TC_CONS_FIX_NEW
3277 TC_CONS_FIX_NEW (frag_now
, p
- frag_now
->fr_literal
, nbytes
, exp
);
3280 bfd_reloc_code_real_type r
;
3297 as_bad ("unsupported BFD relocation size %u", nbytes
);
3301 fix_new_exp (frag_now
, p
- frag_now
->fr_literal
, (int) nbytes
, exp
,
3306 #ifdef TC_CONS_FIX_NEW
3307 TC_CONS_FIX_NEW (frag_now
, p
- frag_now
->fr_literal
, nbytes
, exp
);
3309 /* Figure out which reloc number to use. Use TC_CONS_RELOC if
3310 it is defined, otherwise use NO_RELOC if it is defined,
3312 #ifndef TC_CONS_RELOC
3314 #define TC_CONS_RELOC NO_RELOC
3316 #define TC_CONS_RELOC 0
3319 fix_new_exp (frag_now
, p
- frag_now
->fr_literal
, (int) nbytes
, exp
, 0,
3321 #endif /* TC_CONS_FIX_NEW */
3322 #endif /* BFD_ASSEMBLER */
3326 #ifdef BITFIELD_CONS_EXPRESSIONS
3328 /* i960 assemblers, (eg, asm960), allow bitfields after ".byte" as
3329 w:x,y:z, where w and y are bitwidths and x and y are values. They
3330 then pack them all together. We do a little better in that we allow
3331 them in words, longs, etc. and we'll pack them in target byte order
3334 The rules are: pack least significat bit first, if a field doesn't
3335 entirely fit, put it in the next unit. Overflowing the bitfield is
3336 explicitly *not* even a warning. The bitwidth should be considered
3339 To use this function the tc-XXX.h file should define
3340 BITFIELD_CONS_EXPRESSIONS. */
3343 parse_bitfield_cons (exp
, nbytes
)
3345 unsigned int nbytes
;
3347 unsigned int bits_available
= BITS_PER_CHAR
* nbytes
;
3348 char *hold
= input_line_pointer
;
3350 (void) expression (exp
);
3352 if (*input_line_pointer
== ':')
3358 unsigned long width
;
3360 if (*input_line_pointer
!= ':')
3362 input_line_pointer
= hold
;
3364 } /* next piece is not a bitfield */
3366 /* In the general case, we can't allow
3367 full expressions with symbol
3368 differences and such. The relocation
3369 entries for symbols not defined in this
3370 assembly would require arbitrary field
3371 widths, positions, and masks which most
3372 of our current object formats don't
3375 In the specific case where a symbol
3376 *is* defined in this assembly, we
3377 *could* build fixups and track it, but
3378 this could lead to confusion for the
3379 backends. I'm lazy. I'll take any
3380 SEG_ABSOLUTE. I think that means that
3381 you can use a previous .set or
3382 .equ type symbol. xoxorich. */
3384 if (exp
->X_op
== O_absent
)
3386 as_warn ("using a bit field width of zero");
3387 exp
->X_add_number
= 0;
3388 exp
->X_op
= O_constant
;
3389 } /* implied zero width bitfield */
3391 if (exp
->X_op
!= O_constant
)
3393 *input_line_pointer
= '\0';
3394 as_bad ("field width \"%s\" too complex for a bitfield", hold
);
3395 *input_line_pointer
= ':';
3396 demand_empty_rest_of_line ();
3400 if ((width
= exp
->X_add_number
) > (BITS_PER_CHAR
* nbytes
))
3402 as_warn ("field width %lu too big to fit in %d bytes: truncated to %d bits",
3403 width
, nbytes
, (BITS_PER_CHAR
* nbytes
));
3404 width
= BITS_PER_CHAR
* nbytes
;
3407 if (width
> bits_available
)
3409 /* FIXME-SOMEDAY: backing up and reparsing is wasteful. */
3410 input_line_pointer
= hold
;
3411 exp
->X_add_number
= value
;
3415 hold
= ++input_line_pointer
; /* skip ':' */
3417 (void) expression (exp
);
3418 if (exp
->X_op
!= O_constant
)
3420 char cache
= *input_line_pointer
;
3422 *input_line_pointer
= '\0';
3423 as_bad ("field value \"%s\" too complex for a bitfield", hold
);
3424 *input_line_pointer
= cache
;
3425 demand_empty_rest_of_line ();
3429 value
|= ((~(-1 << width
) & exp
->X_add_number
)
3430 << ((BITS_PER_CHAR
* nbytes
) - bits_available
));
3432 if ((bits_available
-= width
) == 0
3433 || is_it_end_of_statement ()
3434 || *input_line_pointer
!= ',')
3437 } /* all the bitfields we're gonna get */
3439 hold
= ++input_line_pointer
;
3440 (void) expression (exp
);
3441 } /* forever loop */
3443 exp
->X_add_number
= value
;
3444 exp
->X_op
= O_constant
;
3445 exp
->X_unsigned
= 1;
3446 } /* if looks like a bitfield */
3447 } /* parse_bitfield_cons() */
3449 #endif /* BITFIELD_CONS_EXPRESSIONS */
3451 /* Handle an MRI style string expression. */
3454 parse_mri_cons (exp
, nbytes
)
3456 unsigned int nbytes
;
3458 if (*input_line_pointer
!= '\''
3459 && (input_line_pointer
[1] != '\''
3460 || (*input_line_pointer
!= 'A'
3461 && *input_line_pointer
!= 'E')))
3462 TC_PARSE_CONS_EXPRESSION (exp
, nbytes
);
3466 unsigned int result
= 0;
3468 /* An MRI style string. Cut into as many bytes as will fit into
3469 a nbyte chunk, left justify if necessary, and separate with
3470 commas so we can try again later. */
3471 if (*input_line_pointer
== 'A')
3472 ++input_line_pointer
;
3473 else if (*input_line_pointer
== 'E')
3475 as_bad ("EBCDIC constants are not supported");
3476 ++input_line_pointer
;
3479 input_line_pointer
++;
3480 for (scan
= 0; scan
< nbytes
; scan
++)
3482 if (*input_line_pointer
== '\'')
3484 if (input_line_pointer
[1] == '\'')
3486 input_line_pointer
++;
3491 result
= (result
<< 8) | (*input_line_pointer
++);
3495 while (scan
< nbytes
)
3500 /* Create correct expression */
3501 exp
->X_op
= O_constant
;
3502 exp
->X_add_number
= result
;
3503 /* Fake it so that we can read the next char too */
3504 if (input_line_pointer
[0] != '\'' ||
3505 (input_line_pointer
[0] == '\'' && input_line_pointer
[1] == '\''))
3507 input_line_pointer
-= 2;
3508 input_line_pointer
[0] = ',';
3509 input_line_pointer
[1] = '\'';
3512 input_line_pointer
++;
3516 #ifdef REPEAT_CONS_EXPRESSIONS
3518 /* Parse a repeat expression for cons. This is used by the MIPS
3519 assembler. The format is NUMBER:COUNT; NUMBER appears in the
3520 object file COUNT times.
3522 To use this for a target, define REPEAT_CONS_EXPRESSIONS. */
3525 parse_repeat_cons (exp
, nbytes
)
3527 unsigned int nbytes
;
3534 if (*input_line_pointer
!= ':')
3536 /* No repeat count. */
3540 ++input_line_pointer
;
3541 expression (&count
);
3542 if (count
.X_op
!= O_constant
3543 || count
.X_add_number
<= 0)
3545 as_warn ("Unresolvable or nonpositive repeat count; using 1");
3549 /* The cons function is going to output this expression once. So we
3550 output it count - 1 times. */
3551 for (i
= count
.X_add_number
- 1; i
> 0; i
--)
3552 emit_expr (exp
, nbytes
);
3555 #endif /* REPEAT_CONS_EXPRESSIONS */
3557 /* Parse a floating point number represented as a hex constant. This
3558 permits users to specify the exact bits they want in the floating
3562 hex_float (float_type
, bytes
)
3596 as_bad ("Unknown floating type type '%c'", float_type
);
3600 /* It would be nice if we could go through expression to parse the
3601 hex constant, but if we get a bignum it's a pain to sort it into
3602 the buffer correctly. */
3604 while (hex_p (*input_line_pointer
) || *input_line_pointer
== '_')
3608 /* The MRI assembler accepts arbitrary underscores strewn about
3609 through the hex constant, so we ignore them as well. */
3610 if (*input_line_pointer
== '_')
3612 ++input_line_pointer
;
3618 as_warn ("Floating point constant too large");
3621 d
= hex_value (*input_line_pointer
) << 4;
3622 ++input_line_pointer
;
3623 while (*input_line_pointer
== '_')
3624 ++input_line_pointer
;
3625 if (hex_p (*input_line_pointer
))
3627 d
+= hex_value (*input_line_pointer
);
3628 ++input_line_pointer
;
3630 if (target_big_endian
)
3633 bytes
[length
- i
- 1] = d
;
3639 if (target_big_endian
)
3640 memset (bytes
+ i
, 0, length
- i
);
3642 memset (bytes
, 0, length
- i
);
3651 * CONStruct some more frag chars of .floats .ffloats etc.
3652 * Makes 0 or more new frags.
3653 * If need_pass_2 == 1, no frags are emitted.
3654 * This understands only floating literals, not expressions. Sorry.
3656 * A floating constant is defined by atof_generic(), except it is preceded
3657 * by 0d 0f 0g or 0h. After observing the STRANGE way my BSD AS does its
3658 * reading, I decided to be incompatible. This always tries to give you
3659 * rounded bits to the precision of the pseudo-op. Former AS did premature
3660 * truncatation, restored noisy bits instead of trailing 0s AND gave you
3661 * a choice of 2 flavours of noise according to which of 2 floating-point
3662 * scanners you directed AS to use.
3664 * In: input_line_pointer->whitespace before, or '0' of flonum.
3669 float_cons (float_type
)
3670 /* Clobbers input_line-pointer, checks end-of-line. */
3671 register int float_type
; /* 'f':.ffloat ... 'F':.float ... */
3674 int length
; /* Number of chars in an object. */
3675 register char *err
; /* Error from scanning floating literal. */
3676 char temp
[MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT
];
3678 if (is_it_end_of_statement ())
3680 demand_empty_rest_of_line ();
3684 #ifdef md_flush_pending_output
3685 md_flush_pending_output ();
3690 /* input_line_pointer->1st char of a flonum (we hope!). */
3693 /* Skip any 0{letter} that may be present. Don't even check if the
3694 * letter is legal. Someone may invent a "z" format and this routine
3695 * has no use for such information. Lusers beware: you get
3696 * diagnostics if your input is ill-conditioned.
3698 if (input_line_pointer
[0] == '0' && isalpha (input_line_pointer
[1]))
3699 input_line_pointer
+= 2;
3701 /* Accept :xxxx, where the x's are hex digits, for a floating
3702 point with the exact digits specified. */
3703 if (input_line_pointer
[0] == ':')
3705 ++input_line_pointer
;
3706 length
= hex_float (float_type
, temp
);
3709 ignore_rest_of_line ();
3715 err
= md_atof (float_type
, temp
, &length
);
3716 know (length
<= MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT
);
3720 as_bad ("Bad floating literal: %s", err
);
3721 ignore_rest_of_line ();
3732 #ifdef REPEAT_CONS_EXPRESSIONS
3733 if (*input_line_pointer
== ':')
3735 expressionS count_exp
;
3737 ++input_line_pointer
;
3738 expression (&count_exp
);
3739 if (count_exp
.X_op
!= O_constant
3740 || count_exp
.X_add_number
<= 0)
3742 as_warn ("unresolvable or nonpositive repeat count; using 1");
3745 count
= count_exp
.X_add_number
;
3749 while (--count
>= 0)
3751 p
= frag_more (length
);
3752 memcpy (p
, temp
, (unsigned int) length
);
3757 while (*input_line_pointer
++ == ',');
3759 --input_line_pointer
; /* Put terminator back into stream. */
3760 demand_empty_rest_of_line ();
3761 } /* float_cons() */
3766 * We read 0 or more ',' seperated, double-quoted strings.
3768 * Caller should have checked need_pass_2 is FALSE because we don't check it.
3773 stringer (append_zero
) /* Worker to do .ascii etc statements. */
3774 /* Checks end-of-line. */
3775 register int append_zero
; /* 0: don't append '\0', else 1 */
3777 register unsigned int c
;
3779 #ifdef md_flush_pending_output
3780 md_flush_pending_output ();
3784 * The following awkward logic is to parse ZERO or more strings,
3785 * comma seperated. Recall a string expression includes spaces
3786 * before the opening '\"' and spaces after the closing '\"'.
3787 * We fake a leading ',' if there is (supposed to be)
3788 * a 1st, expression. We keep demanding expressions for each
3791 if (is_it_end_of_statement ())
3793 c
= 0; /* Skip loop. */
3794 ++input_line_pointer
; /* Compensate for end of loop. */
3798 c
= ','; /* Do loop. */
3800 while (c
== ',' || c
== '<' || c
== '"')
3803 switch (*input_line_pointer
)
3806 ++input_line_pointer
; /*->1st char of string. */
3807 while (is_a_char (c
= next_char_of_string ()))
3809 FRAG_APPEND_1_CHAR (c
);
3813 FRAG_APPEND_1_CHAR (0);
3815 know (input_line_pointer
[-1] == '\"');
3818 input_line_pointer
++;
3819 c
= get_single_number ();
3820 FRAG_APPEND_1_CHAR (c
);
3821 if (*input_line_pointer
!= '>')
3823 as_bad ("Expected <nn>");
3825 input_line_pointer
++;
3828 input_line_pointer
++;
3832 c
= *input_line_pointer
;
3835 demand_empty_rest_of_line ();
3838 /* FIXME-SOMEDAY: I had trouble here on characters with the
3839 high bits set. We'll probably also have trouble with
3840 multibyte chars, wide chars, etc. Also be careful about
3841 returning values bigger than 1 byte. xoxorich. */
3844 next_char_of_string ()
3846 register unsigned int c
;
3848 c
= *input_line_pointer
++ & CHAR_MASK
;
3856 as_warn ("Unterminated string: Newline inserted.");
3857 bump_line_counters ();
3860 #ifndef NO_STRING_ESCAPES
3862 switch (c
= *input_line_pointer
++)
3890 break; /* As itself. */
3906 for (i
= 0, number
= 0; isdigit (c
) && i
< 3; c
= *input_line_pointer
++, i
++)
3908 number
= number
* 8 + c
- '0';
3912 --input_line_pointer
;
3921 c
= *input_line_pointer
++;
3922 while (isxdigit (c
))
3925 number
= number
* 16 + c
- '0';
3926 else if (isupper (c
))
3927 number
= number
* 16 + c
- 'A' + 10;
3929 number
= number
* 16 + c
- 'a' + 10;
3930 c
= *input_line_pointer
++;
3933 --input_line_pointer
;
3938 /* To be compatible with BSD 4.2 as: give the luser a linefeed!! */
3939 as_warn ("Unterminated string: Newline inserted.");
3941 bump_line_counters ();
3946 #ifdef ONLY_STANDARD_ESCAPES
3947 as_bad ("Bad escaped character in string, '?' assumed");
3949 #endif /* ONLY_STANDARD_ESCAPES */
3952 } /* switch on escaped char */
3954 #endif /* ! defined (NO_STRING_ESCAPES) */
3958 } /* switch on char */
3960 } /* next_char_of_string() */
3963 get_segmented_expression (expP
)
3964 register expressionS
*expP
;
3966 register segT retval
;
3968 retval
= expression (expP
);
3969 if (expP
->X_op
== O_illegal
3970 || expP
->X_op
== O_absent
3971 || expP
->X_op
== O_big
)
3973 as_bad ("expected address expression; zero assumed");
3974 expP
->X_op
= O_constant
;
3975 expP
->X_add_number
= 0;
3976 retval
= absolute_section
;
3982 get_known_segmented_expression (expP
)
3983 register expressionS
*expP
;
3985 register segT retval
;
3987 if ((retval
= get_segmented_expression (expP
)) == undefined_section
)
3989 /* There is no easy way to extract the undefined symbol from the
3991 if (expP
->X_add_symbol
!= NULL
3992 && S_GET_SEGMENT (expP
->X_add_symbol
) != expr_section
)
3993 as_warn ("symbol \"%s\" undefined; zero assumed",
3994 S_GET_NAME (expP
->X_add_symbol
));
3996 as_warn ("some symbol undefined; zero assumed");
3997 retval
= absolute_section
;
3998 expP
->X_op
= O_constant
;
3999 expP
->X_add_number
= 0;
4001 know (retval
== absolute_section
|| SEG_NORMAL (retval
));
4003 } /* get_known_segmented_expression() */
4006 get_absolute_expression ()
4011 if (exp
.X_op
!= O_constant
)
4013 if (exp
.X_op
!= O_absent
)
4014 as_bad ("bad or irreducible absolute expression; zero assumed");
4015 exp
.X_add_number
= 0;
4017 return exp
.X_add_number
;
4020 char /* return terminator */
4021 get_absolute_expression_and_terminator (val_pointer
)
4022 long *val_pointer
; /* return value of expression */
4024 /* FIXME: val_pointer should probably be offsetT *. */
4025 *val_pointer
= (long) get_absolute_expression ();
4026 return (*input_line_pointer
++);
4030 * demand_copy_C_string()
4032 * Like demand_copy_string, but return NULL if the string contains any '\0's.
4033 * Give a warning if that happens.
4036 demand_copy_C_string (len_pointer
)
4041 if ((s
= demand_copy_string (len_pointer
)) != 0)
4045 for (len
= *len_pointer
; len
> 0; len
--)
4052 as_bad ("This string may not contain \'\\0\'");
4060 * demand_copy_string()
4062 * Demand string, but return a safe (=private) copy of the string.
4063 * Return NULL if we can't read a string here.
4066 demand_copy_string (lenP
)
4069 register unsigned int c
;
4075 if (*input_line_pointer
== '\"')
4077 input_line_pointer
++; /* Skip opening quote. */
4079 while (is_a_char (c
= next_char_of_string ()))
4081 obstack_1grow (¬es
, c
);
4084 /* JF this next line is so demand_copy_C_string will return a
4085 null terminated string. */
4086 obstack_1grow (¬es
, '\0');
4087 retval
= obstack_finish (¬es
);
4091 as_warn ("Missing string");
4093 ignore_rest_of_line ();
4097 } /* demand_copy_string() */
4100 * is_it_end_of_statement()
4102 * In: Input_line_pointer->next character.
4104 * Do: Skip input_line_pointer over all whitespace.
4106 * Out: 1 if input_line_pointer->end-of-line.
4109 is_it_end_of_statement ()
4112 return (is_end_of_line
[(unsigned char) *input_line_pointer
]);
4113 } /* is_it_end_of_statement() */
4119 register symbolS
*symbolP
; /* symbol we are working with */
4123 input_line_pointer
++;
4124 if (*input_line_pointer
== '=')
4125 input_line_pointer
++;
4127 while (*input_line_pointer
== ' ' || *input_line_pointer
== '\t')
4128 input_line_pointer
++;
4131 stop
= mri_comment_field (&stopc
);
4133 if (sym_name
[0] == '.' && sym_name
[1] == '\0')
4135 /* Turn '. = mumble' into a .org mumble */
4136 register segT segment
;
4139 segment
= get_known_segmented_expression (&exp
);
4141 do_org (segment
, &exp
, 0);
4145 symbolP
= symbol_find_or_make (sym_name
);
4146 pseudo_set (symbolP
);
4150 mri_comment_end (stop
, stopc
);
4153 /* .include -- include a file at this point. */
4166 if (! flag_m68k_mri
)
4167 filename
= demand_copy_string (&i
);
4172 while (! is_end_of_line
[(unsigned char) *input_line_pointer
]
4173 && *input_line_pointer
!= ' '
4174 && *input_line_pointer
!= '\t')
4176 obstack_1grow (¬es
, *input_line_pointer
);
4177 ++input_line_pointer
;
4180 obstack_1grow (¬es
, '\0');
4181 filename
= obstack_finish (¬es
);
4182 while (! is_end_of_line
[(unsigned char) *input_line_pointer
])
4183 ++input_line_pointer
;
4185 demand_empty_rest_of_line ();
4186 path
= xmalloc ((unsigned long) i
+ include_dir_maxlen
+ 5 /* slop */ );
4187 for (i
= 0; i
< include_dir_count
; i
++)
4189 strcpy (path
, include_dirs
[i
]);
4191 strcat (path
, filename
);
4192 if (0 != (try = fopen (path
, "r")))
4201 /* malloc Storage leak when file is found on path. FIXME-SOMEDAY. */
4202 newbuf
= input_scrub_include_file (path
, input_line_pointer
);
4203 buffer_limit
= input_scrub_next_buffer (&input_line_pointer
);
4207 add_include_dir (path
)
4212 if (include_dir_count
== 0)
4214 include_dirs
= (char **) xmalloc (2 * sizeof (*include_dirs
));
4215 include_dirs
[0] = "."; /* Current dir */
4216 include_dir_count
= 2;
4220 include_dir_count
++;
4221 include_dirs
= (char **) realloc (include_dirs
,
4222 include_dir_count
* sizeof (*include_dirs
));
4225 include_dirs
[include_dir_count
- 1] = path
; /* New one */
4228 if (i
> include_dir_maxlen
)
4229 include_dir_maxlen
= i
;
4230 } /* add_include_dir() */
4236 while (!is_end_of_line
[(unsigned char) *input_line_pointer
])
4238 ++input_line_pointer
;
4240 ++input_line_pointer
;
4245 read_print_statistics (file
)
4248 hash_print_statistics (file
, "pseudo-op table", po_hash
);