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 the Free
19 Software Foundation, 59 Temple Place - Suite 330, Boston, MA
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.)
29 #define MASK_CHAR ((int)(unsigned char)-1)
33 /* This is the largest known floating point format (for now). It will
34 grow when we do 4361 style flonums. */
36 #define MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT (16)
38 /* Routines that read assembler source text to build spagetti in memory.
39 Another group of these functions is in the expr.c module. */
52 #ifndef TC_START_LABEL
53 #define TC_START_LABEL(x,y) (x==':')
56 /* The NOP_OPCODE is for the alignment fill value.
57 * fill it a nop instruction so that the disassembler does not choke
61 #define NOP_OPCODE 0x00
64 char *input_line_pointer
; /*->next char of source file to parse. */
66 int generate_asm_lineno
= 0; /* flag to generate line stab for .s file */
68 #if BITS_PER_CHAR != 8
69 /* The following table is indexed by[(char)] and will break if
70 a char does not have exactly 256 states (hopefully 0:255!)! */
75 /* The m88k unfortunately uses @ as a label beginner. */
80 /* The RS/6000 assembler uses {,},[,] as parts of symbol names. */
85 /* The Delta 68k assembler permits % inside label names. */
90 /* The PowerPC Windows NT assemblers permits ? inside label names. */
95 /* The a29k assembler does not permits labels to start with $. */
99 /* used by is_... macros. our ctype[] */
102 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* @ABCDEFGHIJKLMNO */
103 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* PQRSTUVWXYZ[\]^_ */
104 0, 0, 0, 0, LEX_DOLLAR
, LEX_PCT
, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, /* _!"#$%&'()*+,-./ */
105 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, LEX_QM
, /* 0123456789:;<=>? */
106 LEX_AT
, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, /* @ABCDEFGHIJKLMNO */
107 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, LEX_BR
, 0, LEX_BR
, 0, 3, /* PQRSTUVWXYZ[\]^_ */
108 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, /* `abcdefghijklmno */
109 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, LEX_BR
, 0, LEX_BR
, 0, 0, /* pqrstuvwxyz{|}~. */
110 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
111 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
112 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
113 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
114 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
115 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
116 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
122 * Out: 1 if this character ends a line.
125 char is_end_of_line
[256] =
128 _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, 99, _
, _
, 99, _
, _
, /* @abcdefghijklmno */
130 _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, 99, _
, _
, _
, _
, _
, /* @abcdefghijklmno */
132 _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, /* */
134 _
,99, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, /* _!"#$%&'()*+,-./ */
135 _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, /* 0123456789:;<=>? */
137 _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, /* */
138 _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, 99, _
, _
, _
, _
, /* 0123456789:;<=>? */
140 _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, /* */
141 _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, /* */
142 _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, /* */
143 _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, /* */
144 _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, /* */
145 _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, /* */
146 _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, /* */
147 _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, /* */
148 _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, /* */
152 /* Functions private to this file. */
154 static char *buffer
; /* 1st char of each buffer of lines is here. */
155 static char *buffer_limit
; /*->1 + last char in buffer. */
157 #ifdef TARGET_BYTES_BIG_ENDIAN
158 /* Hack to deal with tc-*.h defining TARGET_BYTES_BIG_ENDIAN to empty
159 instead of to 0 or 1. */
160 #if 5 - TARGET_BYTES_BIG_ENDIAN - 5 == 10
161 #undef TARGET_BYTES_BIG_ENDIAN
162 #define TARGET_BYTES_BIG_ENDIAN 1
164 int target_big_endian
= TARGET_BYTES_BIG_ENDIAN
;
166 int target_big_endian
/* = 0 */;
169 static char *old_buffer
; /* JF a hack */
170 static char *old_input
;
171 static char *old_limit
;
173 /* Variables for handling include file directory list. */
175 char **include_dirs
; /* List of pointers to directories to
176 search for .include's */
177 int include_dir_count
; /* How many are in the list */
178 int include_dir_maxlen
= 1;/* Length of longest in list */
180 #ifndef WORKING_DOT_WORD
181 struct broken_word
*broken_words
;
182 int new_broken_words
;
185 /* The current offset into the absolute section. We don't try to
186 build frags in the absolute section, since no data can be stored
187 there. We just keep track of the current offset. */
188 addressT abs_section_offset
;
190 /* If this line had an MRI style label, it is stored in this variable.
191 This is used by some of the MRI pseudo-ops. */
194 /* This global variable is used to support MRI common sections. We
195 translate such sections into a common symbol. This variable is
196 non-NULL when we are in an MRI common section. */
197 symbolS
*mri_common_symbol
;
199 /* In MRI mode, after a dc.b pseudo-op with an odd number of bytes, we
200 need to align to an even byte boundary unless the next pseudo-op is
201 dc.b, ds.b, or dcb.b. This variable is set to 1 if an alignment
203 static int mri_pending_align
;
205 static int scrub_from_string
PARAMS ((char **));
206 static void do_align
PARAMS ((int, char *, int));
207 static int hex_float
PARAMS ((int, char *));
208 static void do_org
PARAMS ((segT
, expressionS
*, int));
209 char *demand_copy_string
PARAMS ((int *lenP
));
210 static segT get_segmented_expression
PARAMS ((expressionS
*expP
));
211 static segT get_known_segmented_expression
PARAMS ((expressionS
* expP
));
212 static void pobegin
PARAMS ((void));
213 static int get_line_sb
PARAMS ((sb
*));
222 obj_read_begin_hook ();
224 /* Something close -- but not too close -- to a multiple of 1024.
225 The debugging malloc I'm using has 24 bytes of overhead. */
226 obstack_begin (¬es
, chunksize
);
227 obstack_begin (&cond_obstack
, chunksize
);
229 /* Use machine dependent syntax */
230 for (p
= line_separator_chars
; *p
; p
++)
231 is_end_of_line
[(unsigned char) *p
] = 1;
232 /* Use more. FIXME-SOMEDAY. */
238 /* set up pseudo-op tables */
240 static struct hash_control
*po_hash
;
242 static const pseudo_typeS potable
[] =
244 {"abort", s_abort
, 0},
245 {"align", s_align_ptwo
, 0},
246 {"ascii", stringer
, 0},
247 {"asciz", stringer
, 1},
248 {"balign", s_align_bytes
, 0},
249 {"balignw", s_align_bytes
, -2},
250 {"balignl", s_align_bytes
, -4},
254 {"common", s_mri_common
, 0},
255 {"common.s", s_mri_common
, 1},
259 {"dc.d", float_cons
, 'd'},
261 {"dc.s", float_cons
, 'f'},
263 {"dc.x", float_cons
, 'x'},
265 {"dcb.b", s_space
, 1},
266 {"dcb.d", s_float_space
, 'd'},
267 {"dcb.l", s_space
, 4},
268 {"dcb.s", s_float_space
, 'f'},
269 {"dcb.w", s_space
, 2},
270 {"dcb.x", s_float_space
, 'x'},
272 {"ds.b", s_space
, 1},
273 {"ds.d", s_space
, 8},
274 {"ds.l", s_space
, 4},
275 {"ds.p", s_space
, 12},
276 {"ds.s", s_space
, 4},
277 {"ds.w", s_space
, 2},
278 {"ds.x", s_space
, 12},
279 {"debug", s_ignore
, 0},
284 {"double", float_cons
, 'd'},
286 {"eject", listing_eject
, 0}, /* Formfeed listing */
288 {"elsec", s_else
, 0},
290 {"endc", s_endif
, 0},
291 {"endif", s_endif
, 0},
295 {"exitm", s_mexit
, 0},
297 {"extern", s_ignore
, 0}, /* We treat all undef as ext */
298 {"appfile", s_app_file
, 1},
299 {"appline", s_app_line
, 0},
301 {"file", s_app_file
, 0},
303 {"float", float_cons
, 'f'},
304 {"format", s_ignore
, 0},
305 {"global", s_globl
, 0},
306 {"globl", s_globl
, 0},
308 {"if", s_if
, (int) O_ne
},
310 {"ifdef", s_ifdef
, 0},
311 {"ifeq", s_if
, (int) O_eq
},
312 {"ifeqs", s_ifeqs
, 0},
313 {"ifge", s_if
, (int) O_ge
},
314 {"ifgt", s_if
, (int) O_gt
},
315 {"ifle", s_if
, (int) O_le
},
316 {"iflt", s_if
, (int) O_lt
},
318 {"ifndef", s_ifdef
, 1},
319 {"ifne", s_if
, (int) O_ne
},
320 {"ifnes", s_ifeqs
, 1},
321 {"ifnotdef", s_ifdef
, 1},
322 {"include", s_include
, 0},
328 {"lcomm", s_lcomm
, 0},
329 {"lflags", listing_flags
, 0}, /* Listing flags */
330 {"linkonce", s_linkonce
, 0},
331 {"list", listing_list
, 1}, /* Turn listing on */
332 {"llen", listing_psize
, 1},
335 {"macro", s_macro
, 0},
336 {"mexit", s_mexit
, 0},
338 {".mri", s_mri
, 0}, /* Special case so .mri works in MRI mode. */
339 {"name", s_ignore
, 0},
340 {"noformat", s_ignore
, 0},
341 {"nolist", listing_list
, 0}, /* Turn listing off */
342 {"nopage", listing_nopage
, 0},
344 {"offset", s_struct
, 0},
346 {"p2align", s_align_ptwo
, 0},
347 {"p2alignw", s_align_ptwo
, -2},
348 {"p2alignl", s_align_ptwo
, -4},
349 {"page", listing_eject
, 0},
350 {"plen", listing_psize
, 0},
351 {"print", s_print
, 0},
352 {"psize", listing_psize
, 0}, /* set paper size */
353 {"purgem", s_purgem
, 0},
358 {"sbttl", listing_title
, 1}, /* Subtitle of listing */
363 {"single", float_cons
, 'f'},
365 {"space", s_space
, 0},
366 {"skip", s_space
, 0},
367 {"spc", s_ignore
, 0},
368 {"stabd", s_stab
, 'd'},
369 {"stabn", s_stab
, 'n'},
370 {"stabs", s_stab
, 's'},
371 {"string", stringer
, 1},
372 {"struct", s_struct
, 0},
376 /* This is for gcc to use. It's only just been added (2/94), so gcc
377 won't be able to use it for a while -- probably a year or more.
378 But once this has been released, check with gcc maintainers
379 before deleting it or even changing the spelling. */
380 {"this_GCC_requires_the_GNU_assembler", s_ignore
, 0},
381 /* If we're folding case -- done for some targets, not necessarily
382 all -- the above string in an input file will be converted to
383 this one. Match it either way... */
384 {"this_gcc_requires_the_gnu_assembler", s_ignore
, 0},
386 {"title", listing_title
, 0}, /* Listing title */
387 {"ttl", listing_title
, 0},
392 {"xdef", s_globl
, 0},
393 {"xref", s_ignore
, 0},
394 {"xstabs", s_xstab
, 's'},
396 {"zero", s_space
, 0},
397 {NULL
} /* end sentinel */
400 static int pop_override_ok
= 0;
401 static const char *pop_table_name
;
405 const pseudo_typeS
*table
;
408 const pseudo_typeS
*pop
;
409 for (pop
= table
; pop
->poc_name
; pop
++)
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
,
418 #ifndef md_pop_insert
419 #define md_pop_insert() pop_insert(md_pseudo_table)
422 #ifndef obj_pop_insert
423 #define obj_pop_insert() pop_insert(obj_pseudo_table)
429 po_hash
= hash_new ();
431 /* Do the target-specific pseudo ops. */
432 pop_table_name
= "md";
435 /* Now object specific. Skip any that were in the target table. */
436 pop_table_name
= "obj";
440 /* Now portable ones. Skip any that we've seen already. */
441 pop_table_name
= "standard";
442 pop_insert (potable
);
445 #define HANDLE_CONDITIONAL_ASSEMBLY() \
446 if (ignore_input ()) \
448 while (! is_end_of_line[(unsigned char) *input_line_pointer++]) \
449 if (input_line_pointer == buffer_limit) \
455 /* This function is used when scrubbing the characters between #APP
458 static char *scrub_string
;
459 static char *scrub_string_end
;
462 scrub_from_string (from
)
467 *from
= scrub_string
;
468 size
= scrub_string_end
- scrub_string
;
469 scrub_string
= scrub_string_end
;
473 /* read_a_source_file()
475 * We read the file, putting things into a web that
476 * represents what we have been reading.
479 read_a_source_file (name
)
483 register char *s
; /* string of symbol, '\0' appended */
487 buffer
= input_scrub_new_file (name
);
490 listing_newline ("");
492 while ((buffer_limit
= input_scrub_next_buffer (&input_line_pointer
)) != 0)
493 { /* We have another line to parse. */
494 know (buffer_limit
[-1] == '\n'); /* Must have a sentinel. */
495 contin
: /* JF this goto is my fault I admit it.
496 Someone brave please re-write the whole
497 input section here? Pleeze??? */
498 while (input_line_pointer
< buffer_limit
)
500 /* We have more of this buffer to parse. */
503 * We now have input_line_pointer->1st char of next line.
504 * If input_line_pointer [-1] == '\n' then we just
505 * scanned another line: so bump line counters.
507 if (is_end_of_line
[(unsigned char) input_line_pointer
[-1]])
509 #ifdef md_start_line_hook
510 md_start_line_hook ();
513 if (input_line_pointer
[-1] == '\n')
514 bump_line_counters ();
519 #ifdef LABELS_WITHOUT_COLONS
524 /* Text at the start of a line must be a label, we
525 run down and stick a colon in. */
526 if (is_name_beginner (*input_line_pointer
))
528 char *line_start
= input_line_pointer
;
532 HANDLE_CONDITIONAL_ASSEMBLY ();
534 c
= get_symbol_end ();
536 /* In MRI mode, the EQU and MACRO pseudoops must
537 be handled specially. */
541 char *rest
= input_line_pointer
+ 1;
545 if (*rest
== ' ' || *rest
== '\t')
547 if ((strncasecmp (rest
, "EQU", 3) == 0
548 || strncasecmp (rest
, "SET", 3) == 0)
549 && (rest
[3] == ' ' || rest
[3] == '\t'))
551 input_line_pointer
= rest
+ 3;
555 if (strncasecmp (rest
, "MACRO", 5) == 0
558 || is_end_of_line
[(unsigned char) rest
[5]]))
562 /* In MRI mode, we need to handle the MACRO
563 pseudo-op specially: we don't want to put the
564 symbol in the symbol table. */
565 if (! mri_line_macro
)
566 line_label
= colon (line_start
);
568 line_label
= symbol_create (line_start
,
573 *input_line_pointer
= c
;
575 input_line_pointer
++;
581 * We are at the begining of a line, or similar place.
582 * We expect a well-formed assembler statement.
583 * A "symbol-name:" is a statement.
585 * Depending on what compiler is used, the order of these tests
586 * may vary to catch most common case 1st.
587 * Each test is independent of all other tests at the (top) level.
588 * PLEASE make a compiler that doesn't use this assembler.
589 * It is crufty to waste a compiler's time encoding things for this
590 * assembler, which then wastes more time decoding it.
591 * (And communicating via (linear) files is silly!
592 * If you must pass stuff, please pass a tree!)
594 if ((c
= *input_line_pointer
++) == '\t'
599 c
= *input_line_pointer
++;
601 know (c
!= ' '); /* No further leading whitespace. */
604 * C is the 1st significant character.
605 * Input_line_pointer points after that character.
607 if (is_name_beginner (c
))
609 /* want user-defined label or pseudo/opcode */
610 HANDLE_CONDITIONAL_ASSEMBLY ();
612 s
= --input_line_pointer
;
613 c
= get_symbol_end (); /* name's delimiter */
615 * C is character after symbol.
616 * That character's place in the input line is now '\0'.
617 * S points to the beginning of the symbol.
618 * [In case of pseudo-op, s->'.'.]
619 * Input_line_pointer->'\0' where c was.
621 if (TC_START_LABEL(c
, input_line_pointer
))
625 char *rest
= input_line_pointer
+ 1;
627 /* In MRI mode, \tsym: set 0 is permitted. */
631 if (*rest
== ' ' || *rest
== '\t')
633 if ((strncasecmp (rest
, "EQU", 3) == 0
634 || strncasecmp (rest
, "SET", 3) == 0)
635 && (rest
[3] == ' ' || rest
[3] == '\t'))
637 input_line_pointer
= rest
+ 3;
643 line_label
= colon (s
); /* user-defined label */
644 *input_line_pointer
++ = ':'; /* Put ':' back for error messages' sake. */
645 /* Input_line_pointer->after ':'. */
651 || (input_line_pointer
[1] == '='
652 #ifdef TC_EQUAL_IN_INSN
653 && ! TC_EQUAL_IN_INSN (c
, input_line_pointer
)
658 demand_empty_rest_of_line ();
661 { /* expect pseudo-op or machine instruction */
664 #define IGNORE_OPCODE_CASE
665 #ifdef IGNORE_OPCODE_CASE
683 /* The MRI assembler and the m88k use pseudo-ops
685 pop
= (pseudo_typeS
*) hash_find (po_hash
, s
);
686 if (pop
!= NULL
&& pop
->poc_handler
== NULL
)
691 || (! flag_m68k_mri
&& *s
== '.'))
696 * WARNING: c has next char, which may be end-of-line.
697 * We lookup the pseudo-op table with s+1 because we
698 * already know that the pseudo-op begins with a '.'.
702 pop
= (pseudo_typeS
*) hash_find (po_hash
, s
+ 1);
704 /* In MRI mode, we may need to insert an
705 automatic alignment directive. What a hack
707 if (mri_pending_align
709 || ! ((pop
->poc_handler
== cons
710 && pop
->poc_val
== 1)
711 || (pop
->poc_handler
== s_space
712 && pop
->poc_val
== 1)
713 #ifdef tc_conditional_pseudoop
714 || tc_conditional_pseudoop (pop
)
716 || pop
->poc_handler
== s_if
717 || pop
->poc_handler
== s_ifdef
718 || pop
->poc_handler
== s_ifc
719 || pop
->poc_handler
== s_ifeqs
720 || pop
->poc_handler
== s_else
721 || pop
->poc_handler
== s_endif
)))
723 do_align (1, (char *) NULL
, 0);
724 mri_pending_align
= 0;
727 /* Print the error msg now, while we still can */
730 as_bad ("Unknown pseudo-op: `%s'", s
);
731 *input_line_pointer
= c
;
736 /* Put it back for error messages etc. */
737 *input_line_pointer
= c
;
738 /* The following skip of whitespace is compulsory.
739 A well shaped space is sometimes all that separates
740 keyword from operands. */
741 if (c
== ' ' || c
== '\t')
742 input_line_pointer
++;
744 * Input_line is restored.
745 * Input_line_pointer->1st non-blank char
746 * after pseudo-operation.
748 (*pop
->poc_handler
) (pop
->poc_val
);
750 /* If that was .end, just get out now. */
751 if (pop
->poc_handler
== s_end
)
758 /* WARNING: c has char, which may be end-of-line. */
759 /* Also: input_line_pointer->`\0` where c was. */
760 *input_line_pointer
= c
;
761 while (!is_end_of_line
[(unsigned char) *input_line_pointer
]
763 #ifdef TC_EOL_IN_INSN
764 || TC_EOL_IN_INSN (input_line_pointer
)
768 if (flag_m68k_mri
&& *input_line_pointer
== '\'')
770 input_line_pointer
++;
773 c
= *input_line_pointer
;
774 *input_line_pointer
= '\0';
776 #ifdef OBJ_GENERATE_ASM_LINENO
777 if (generate_asm_lineno
== 0)
779 if (ecoff_no_current_file ())
780 generate_asm_lineno
= 1;
782 if (generate_asm_lineno
== 1)
787 as_where (&s
, &lineno
);
788 OBJ_GENERATE_ASM_LINENO (s
, lineno
);
797 if (check_macro (s
, &out
, '\0', &err
))
801 *input_line_pointer
++ = c
;
802 input_scrub_include_sb (&out
,
806 input_scrub_next_buffer (&input_line_pointer
);
811 if (mri_pending_align
)
813 do_align (1, (char *) NULL
, 0);
814 mri_pending_align
= 0;
817 md_assemble (s
); /* Assemble 1 instruction. */
819 *input_line_pointer
++ = c
;
821 /* We resume loop AFTER the end-of-line from
826 } /* if (is_name_beginner(c) */
829 /* Empty statement? */
830 if (is_end_of_line
[(unsigned char) c
])
833 if ((LOCAL_LABELS_DOLLAR
|| LOCAL_LABELS_FB
)
836 /* local label ("4:") */
837 char *backup
= input_line_pointer
;
839 HANDLE_CONDITIONAL_ASSEMBLY ();
843 while (isdigit (*input_line_pointer
))
845 temp
= (temp
* 10) + *input_line_pointer
- '0';
846 ++input_line_pointer
;
847 } /* read the whole number */
849 if (LOCAL_LABELS_DOLLAR
850 && *input_line_pointer
== '$'
851 && *(input_line_pointer
+ 1) == ':')
853 input_line_pointer
+= 2;
855 if (dollar_label_defined (temp
))
857 as_fatal ("label \"%d$\" redefined", temp
);
860 define_dollar_label (temp
);
861 colon (dollar_label_name (temp
, 0));
866 && *input_line_pointer
++ == ':')
868 fb_label_instance_inc (temp
);
869 colon (fb_label_name (temp
, 0));
873 input_line_pointer
= backup
;
874 } /* local label ("4:") */
876 if (c
&& strchr (line_comment_chars
, c
))
877 { /* Its a comment. Better say APP or NO_APP */
881 unsigned int new_length
;
884 bump_line_counters ();
885 s
= input_line_pointer
;
886 if (strncmp (s
, "APP\n", 4))
887 continue; /* We ignore it */
890 ends
= strstr (s
, "#NO_APP\n");
894 unsigned int tmp_len
;
897 /* The end of the #APP wasn't in this buffer. We
898 keep reading in buffers until we find the #NO_APP
899 that goes with this #APP There is one. The specs
901 tmp_len
= buffer_limit
- s
;
902 tmp_buf
= xmalloc (tmp_len
+ 1);
903 memcpy (tmp_buf
, s
, tmp_len
);
906 new_tmp
= input_scrub_next_buffer (&buffer
);
910 buffer_limit
= new_tmp
;
911 input_line_pointer
= buffer
;
912 ends
= strstr (buffer
, "#NO_APP\n");
916 num
= buffer_limit
- buffer
;
918 tmp_buf
= xrealloc (tmp_buf
, tmp_len
+ num
);
919 memcpy (tmp_buf
+ tmp_len
, buffer
, num
);
924 input_line_pointer
= ends
? ends
+ 8 : NULL
;
932 input_line_pointer
= ends
+ 8;
936 scrub_string_end
= ends
;
938 new_length
= ends
- s
;
939 new_buf
= (char *) xmalloc (new_length
);
946 space
= (new_buf
+ new_length
) - new_tmp
;
947 size
= do_scrub_chars (scrub_from_string
, new_tmp
, space
);
955 new_buf
= xrealloc (new_buf
, new_length
+ 100);
956 new_tmp
= new_buf
+ new_length
;
963 old_input
= input_line_pointer
;
964 old_limit
= buffer_limit
;
966 input_line_pointer
= new_buf
;
967 buffer_limit
= new_tmp
;
971 HANDLE_CONDITIONAL_ASSEMBLY ();
973 #ifdef tc_unrecognized_line
974 if (tc_unrecognized_line (c
))
978 /* as_warn("Junk character %d.",c); Now done by ignore_rest */
979 input_line_pointer
--; /* Report unknown char as ignored. */
980 ignore_rest_of_line ();
981 } /* while (input_line_pointer<buffer_limit) */
983 #ifdef md_after_pass_hook
984 md_after_pass_hook ();
990 bump_line_counters ();
994 input_line_pointer
= old_input
;
995 buffer_limit
= old_limit
;
1000 } /* while (more buffers to scan) */
1007 input_scrub_close (); /* Close the input file */
1010 /* For most MRI pseudo-ops, the line actually ends at the first
1011 nonquoted space. This function looks for that point, stuffs a null
1012 in, and sets *STOPCP to the character that used to be there, and
1013 returns the location.
1015 Until I hear otherwise, I am going to assume that this is only true
1016 for the m68k MRI assembler. */
1019 mri_comment_field (stopcp
)
1027 know (flag_m68k_mri
);
1029 for (s
= input_line_pointer
;
1030 ((! is_end_of_line
[(unsigned char) *s
] && *s
!= ' ' && *s
!= '\t')
1035 inquote
= ! inquote
;
1045 for (s
= input_line_pointer
; ! is_end_of_line
[(unsigned char) *s
]; s
++)
1055 /* Skip to the end of an MRI comment field. */
1058 mri_comment_end (stop
, stopc
)
1064 input_line_pointer
= stop
;
1066 while (! is_end_of_line
[(unsigned char) *input_line_pointer
])
1067 ++input_line_pointer
;
1074 as_fatal (".abort detected. Abandoning ship.");
1077 /* Guts of .align directive. */
1079 do_align (n
, fill
, len
)
1085 md_do_align (n
, fill
, len
, just_record_alignment
);
1089 /* @@ Fix this right for BFD! */
1091 static char nop_opcode
= NOP_OPCODE
;
1093 if (now_seg
!= data_section
&& now_seg
!= bss_section
)
1104 /* Only make a frag if we HAVE to. . . */
1105 if (n
&& !need_pass_2
)
1108 frag_align (n
, *fill
);
1110 frag_align_pattern (n
, fill
, len
);
1114 just_record_alignment
:
1117 record_alignment (now_seg
, n
);
1120 /* For machines where ".align 4" means align to a 4 byte boundary. */
1125 register unsigned int temp
;
1128 unsigned long max_alignment
= 1 << 15;
1133 stop
= mri_comment_field (&stopc
);
1135 if (is_end_of_line
[(unsigned char) *input_line_pointer
])
1140 temp
= arg
; /* Default value from pseudo-op table */
1143 temp
= get_absolute_expression ();
1145 if (temp
> max_alignment
)
1147 as_bad ("Alignment too large: %d. assumed.", temp
= max_alignment
);
1150 /* For the sparc, `.align (1<<n)' actually means `.align n' so we
1151 have to convert it. */
1154 for (i
= 0; (temp
& 1) == 0; temp
>>= 1, ++i
)
1158 as_bad ("Alignment not a power of 2");
1161 if (*input_line_pointer
== ',')
1166 input_line_pointer
++;
1167 fillval
= get_absolute_expression ();
1174 temp_fill
= fillval
;
1175 do_align (temp
, &temp_fill
, len
);
1181 if (len
> sizeof ab
)
1183 md_number_to_chars (ab
, fillval
, len
);
1184 do_align (temp
, ab
, len
);
1190 as_warn ("expected fill pattern missing");
1191 do_align (temp
, (char *) NULL
, 0);
1195 mri_comment_end (stop
, stopc
);
1197 demand_empty_rest_of_line ();
1200 /* For machines where ".align 4" means align to 2**4 boundary. */
1207 long max_alignment
= 15;
1212 stop
= mri_comment_field (&stopc
);
1214 temp
= get_absolute_expression ();
1215 if (temp
> max_alignment
)
1216 as_bad ("Alignment too large: %d. assumed.", temp
= max_alignment
);
1219 as_bad ("Alignment negative. 0 assumed.");
1222 if (*input_line_pointer
== ',')
1227 input_line_pointer
++;
1228 fillval
= get_absolute_expression ();
1235 temp_fill
= fillval
;
1236 do_align (temp
, &temp_fill
, len
);
1242 if (len
> sizeof ab
)
1244 md_number_to_chars (ab
, fillval
, len
);
1245 do_align (temp
, ab
, len
);
1251 as_warn ("expected fill pattern missing");
1252 do_align (temp
, (char *) NULL
, 0);
1256 mri_comment_end (stop
, stopc
);
1258 demand_empty_rest_of_line ();
1265 register char *name
;
1269 register symbolS
*symbolP
;
1274 stop
= mri_comment_field (&stopc
);
1276 name
= input_line_pointer
;
1277 c
= get_symbol_end ();
1278 /* just after name is now '\0' */
1279 p
= input_line_pointer
;
1282 if (*input_line_pointer
!= ',')
1284 as_bad ("Expected comma after symbol-name: rest of line ignored.");
1286 mri_comment_end (stop
, stopc
);
1287 ignore_rest_of_line ();
1290 input_line_pointer
++; /* skip ',' */
1291 if ((temp
= get_absolute_expression ()) < 0)
1293 as_warn (".COMMon length (%ld.) <0! Ignored.", (long) temp
);
1295 mri_comment_end (stop
, stopc
);
1296 ignore_rest_of_line ();
1300 symbolP
= symbol_find_or_make (name
);
1302 if (S_IS_DEFINED (symbolP
))
1304 as_bad ("Ignoring attempt to re-define symbol `%s'.",
1305 S_GET_NAME (symbolP
));
1307 mri_comment_end (stop
, stopc
);
1308 ignore_rest_of_line ();
1311 if (S_GET_VALUE (symbolP
))
1313 if (S_GET_VALUE (symbolP
) != (valueT
) temp
)
1314 as_bad ("Length of .comm \"%s\" is already %ld. Not changed to %ld.",
1315 S_GET_NAME (symbolP
),
1316 (long) S_GET_VALUE (symbolP
),
1321 S_SET_VALUE (symbolP
, (valueT
) temp
);
1322 S_SET_EXTERNAL (symbolP
);
1326 extern int flag_one
;
1327 if ( (!temp
) || !flag_one
)
1328 S_GET_OTHER(symbolP
) = const_flag
;
1330 #endif /* not OBJ_VMS */
1331 know (symbolP
->sy_frag
== &zero_address_frag
);
1334 mri_comment_end (stop
, stopc
);
1336 demand_empty_rest_of_line ();
1339 /* The MRI COMMON pseudo-op. We handle this by creating a common
1340 symbol with the appropriate name. We make s_space do the right
1341 thing by increasing the size. */
1344 s_mri_common (small
)
1361 stop
= mri_comment_field (&stopc
);
1365 name
= input_line_pointer
;
1366 if (! isdigit ((unsigned char) *name
))
1367 c
= get_symbol_end ();
1372 ++input_line_pointer
;
1374 while (isdigit ((unsigned char) *input_line_pointer
));
1375 c
= *input_line_pointer
;
1376 *input_line_pointer
= '\0';
1378 if (line_label
!= NULL
)
1380 alc
= (char *) xmalloc (strlen (S_GET_NAME (line_label
))
1381 + (input_line_pointer
- name
)
1383 sprintf (alc
, "%s%s", name
, S_GET_NAME (line_label
));
1388 sym
= symbol_find_or_make (name
);
1389 *input_line_pointer
= c
;
1393 if (*input_line_pointer
!= ',')
1397 ++input_line_pointer
;
1398 align
= get_absolute_expression ();
1401 if (S_IS_DEFINED (sym
))
1403 #if defined (S_IS_COMMON) || defined (BFD_ASSEMBLER)
1404 if (! S_IS_COMMON (sym
))
1407 as_bad ("attempt to re-define symbol `%s'", S_GET_NAME (sym
));
1408 mri_comment_end (stop
, stopc
);
1409 ignore_rest_of_line ();
1414 S_SET_EXTERNAL (sym
);
1415 mri_common_symbol
= sym
;
1419 S_SET_ALIGN (sym
, align
);
1422 if (line_label
!= NULL
)
1424 line_label
->sy_value
.X_op
= O_symbol
;
1425 line_label
->sy_value
.X_add_symbol
= sym
;
1426 line_label
->sy_value
.X_add_number
= S_GET_VALUE (sym
);
1427 line_label
->sy_frag
= &zero_address_frag
;
1428 S_SET_SEGMENT (line_label
, expr_section
);
1431 /* FIXME: We just ignore the small argument, which distinguishes
1432 COMMON and COMMON.S. I don't know what we can do about it. */
1434 /* Ignore the type and hptype. */
1435 if (*input_line_pointer
== ',')
1436 input_line_pointer
+= 2;
1437 if (*input_line_pointer
== ',')
1438 input_line_pointer
+= 2;
1440 mri_comment_end (stop
, stopc
);
1442 demand_empty_rest_of_line ();
1452 temp
= get_absolute_expression ();
1453 if (flag_readonly_data_in_text
)
1455 section
= text_section
;
1459 section
= data_section
;
1461 subseg_set (section
, (subsegT
) temp
);
1466 demand_empty_rest_of_line ();
1469 /* Handle the .appfile pseudo-op. This is automatically generated by
1470 do_scrub_chars when a preprocessor # line comment is seen with a
1471 file name. This default definition may be overridden by the object
1472 or CPU specific pseudo-ops. This function is also the default
1473 definition for .file; the APPFILE argument is 1 for .appfile, 0 for
1477 s_app_file (appfile
)
1483 /* Some assemblers tolerate immediately following '"' */
1484 if ((s
= demand_copy_string (&length
)) != 0)
1486 /* If this is a fake .appfile, a fake newline was inserted into
1487 the buffer. Passing -2 to new_logical_line tells it to
1489 new_logical_line (s
, appfile
? -2 : -1);
1491 /* In MRI mode, the preprocessor may have inserted an extraneous
1494 && *input_line_pointer
== '\''
1495 && is_end_of_line
[(unsigned char) input_line_pointer
[1]])
1496 ++input_line_pointer
;
1498 demand_empty_rest_of_line ();
1501 listing_source_file (s
);
1509 /* Handle the .appline pseudo-op. This is automatically generated by
1510 do_scrub_chars when a preprocessor # line comment is seen. This
1511 default definition may be overridden by the object or CPU specific
1520 /* The given number is that of the next line. */
1521 l
= get_absolute_expression () - 1;
1523 /* Some of the back ends can't deal with non-positive line numbers.
1524 Besides, it's silly. */
1525 as_warn ("Line numbers must be positive; line number %d rejected.", l
+1);
1528 new_logical_line ((char *) NULL
, l
);
1531 listing_source_line (l
);
1534 demand_empty_rest_of_line ();
1537 /* Handle the .end pseudo-op. Actually, the real work is done in
1538 read_a_source_file. */
1546 /* The MRI assembler permits the start symbol to follow .end,
1547 but we don't support that. */
1549 if (! is_end_of_line
[(unsigned char) *input_line_pointer
]
1550 && *input_line_pointer
!= '*'
1551 && *input_line_pointer
!= '!')
1552 as_warn ("start address not supported");
1556 /* Handle the .err pseudo-op. */
1562 as_bad (".err encountered");
1563 demand_empty_rest_of_line ();
1566 /* Handle the MRI fail pseudo-op. */
1577 stop
= mri_comment_field (&stopc
);
1579 temp
= get_absolute_expression ();
1581 as_warn (".fail %ld encountered", (long) temp
);
1583 as_bad (".fail %ld encountered", (long) temp
);
1586 mri_comment_end (stop
, stopc
);
1588 demand_empty_rest_of_line ();
1595 long temp_repeat
= 0;
1597 register long temp_fill
= 0;
1600 #ifdef md_flush_pending_output
1601 md_flush_pending_output ();
1604 temp_repeat
= get_absolute_expression ();
1605 if (*input_line_pointer
== ',')
1607 input_line_pointer
++;
1608 temp_size
= get_absolute_expression ();
1609 if (*input_line_pointer
== ',')
1611 input_line_pointer
++;
1612 temp_fill
= get_absolute_expression ();
1615 /* This is to be compatible with BSD 4.2 AS, not for any rational reason. */
1616 #define BSD_FILL_SIZE_CROCK_8 (8)
1617 if (temp_size
> BSD_FILL_SIZE_CROCK_8
)
1619 as_warn (".fill size clamped to %d.", BSD_FILL_SIZE_CROCK_8
);
1620 temp_size
= BSD_FILL_SIZE_CROCK_8
;
1624 as_warn ("Size negative: .fill ignored.");
1627 else if (temp_repeat
<= 0)
1629 if (temp_repeat
< 0)
1630 as_warn ("Repeat < 0, .fill ignored");
1634 if (temp_size
&& !need_pass_2
)
1636 p
= frag_var (rs_fill
, (int) temp_size
, (int) temp_size
, (relax_substateT
) 0, (symbolS
*) 0, temp_repeat
, (char *) 0);
1637 memset (p
, 0, (unsigned int) temp_size
);
1638 /* The magic number BSD_FILL_SIZE_CROCK_4 is from BSD 4.2 VAX
1639 * flavoured AS. The following bizzare behaviour is to be
1640 * compatible with above. I guess they tried to take up to 8
1641 * bytes from a 4-byte expression and they forgot to sign
1642 * extend. Un*x Sux. */
1643 #define BSD_FILL_SIZE_CROCK_4 (4)
1644 md_number_to_chars (p
, (valueT
) temp_fill
,
1645 (temp_size
> BSD_FILL_SIZE_CROCK_4
1646 ? BSD_FILL_SIZE_CROCK_4
1647 : (int) temp_size
));
1648 /* Note: .fill (),0 emits no frag (since we are asked to .fill 0 bytes)
1649 * but emits no error message because it seems a legal thing to do.
1650 * It is a degenerate case of .fill but could be emitted by a compiler.
1653 demand_empty_rest_of_line ();
1667 stop
= mri_comment_field (&stopc
);
1671 name
= input_line_pointer
;
1672 c
= get_symbol_end ();
1673 symbolP
= symbol_find_or_make (name
);
1674 *input_line_pointer
= c
;
1676 S_SET_EXTERNAL (symbolP
);
1679 input_line_pointer
++;
1681 if (*input_line_pointer
== '\n')
1688 mri_comment_end (stop
, stopc
);
1690 demand_empty_rest_of_line ();
1693 /* Handle the MRI IRP and IRPC pseudo-ops. */
1705 as_where (&file
, &line
);
1708 while (! is_end_of_line
[(unsigned char) *input_line_pointer
])
1709 sb_add_char (&s
, *input_line_pointer
++);
1713 err
= expand_irp (irpc
, 0, &s
, &out
, get_line_sb
, '\0');
1715 as_bad_where (file
, line
, "%s", err
);
1719 input_scrub_include_sb (&out
, input_line_pointer
);
1721 buffer_limit
= input_scrub_next_buffer (&input_line_pointer
);
1724 /* Handle the .linkonce pseudo-op. This tells the assembler to mark
1725 the section to only be linked once. However, this is not supported
1726 by most object file formats. This takes an optional argument,
1727 which is what to do about duplicates. */
1733 enum linkonce_type type
;
1737 type
= LINKONCE_DISCARD
;
1739 if (! is_end_of_line
[(unsigned char) *input_line_pointer
])
1744 s
= input_line_pointer
;
1745 c
= get_symbol_end ();
1746 if (strcasecmp (s
, "discard") == 0)
1747 type
= LINKONCE_DISCARD
;
1748 else if (strcasecmp (s
, "one_only") == 0)
1749 type
= LINKONCE_ONE_ONLY
;
1750 else if (strcasecmp (s
, "same_size") == 0)
1751 type
= LINKONCE_SAME_SIZE
;
1752 else if (strcasecmp (s
, "same_contents") == 0)
1753 type
= LINKONCE_SAME_CONTENTS
;
1755 as_warn ("unrecognized .linkonce type `%s'", s
);
1757 *input_line_pointer
= c
;
1760 #ifdef obj_handle_link_once
1761 obj_handle_link_once (type
);
1762 #else /* ! defined (obj_handle_link_once) */
1763 #ifdef BFD_ASSEMBLER
1767 if ((bfd_applicable_section_flags (stdoutput
) & SEC_LINK_ONCE
) == 0)
1768 as_warn (".linkonce is not supported for this object file format");
1770 flags
= bfd_get_section_flags (stdoutput
, now_seg
);
1771 flags
|= SEC_LINK_ONCE
;
1776 case LINKONCE_DISCARD
:
1777 flags
|= SEC_LINK_DUPLICATES_DISCARD
;
1779 case LINKONCE_ONE_ONLY
:
1780 flags
|= SEC_LINK_DUPLICATES_ONE_ONLY
;
1782 case LINKONCE_SAME_SIZE
:
1783 flags
|= SEC_LINK_DUPLICATES_SAME_SIZE
;
1785 case LINKONCE_SAME_CONTENTS
:
1786 flags
|= SEC_LINK_DUPLICATES_SAME_CONTENTS
;
1789 if (! bfd_set_section_flags (stdoutput
, now_seg
, flags
))
1790 as_bad ("bfd_set_section_flags: %s",
1791 bfd_errmsg (bfd_get_error ()));
1793 #else /* ! defined (BFD_ASSEMBLER) */
1794 as_warn (".linkonce is not supported for this object file format");
1795 #endif /* ! defined (BFD_ASSEMBLER) */
1796 #endif /* ! defined (obj_handle_link_once) */
1798 demand_empty_rest_of_line ();
1802 s_lcomm (needs_align
)
1803 /* 1 if this was a ".bss" directive, which may require a 3rd argument
1804 (alignment); 0 if it was an ".lcomm" (2 args only) */
1807 register char *name
;
1811 register symbolS
*symbolP
;
1812 segT current_seg
= now_seg
;
1813 subsegT current_subseg
= now_subseg
;
1814 const int max_alignment
= 15;
1816 segT bss_seg
= bss_section
;
1818 name
= input_line_pointer
;
1819 c
= get_symbol_end ();
1820 p
= input_line_pointer
;
1824 /* Accept an optional comma after the name. The comma used to be
1825 required, but Irix 5 cc does not generate it. */
1826 if (*input_line_pointer
== ',')
1828 ++input_line_pointer
;
1832 if (*input_line_pointer
== '\n')
1834 as_bad ("Missing size expression");
1838 if ((temp
= get_absolute_expression ()) < 0)
1840 as_warn ("BSS length (%d.) <0! Ignored.", temp
);
1841 ignore_rest_of_line ();
1845 #if defined (TC_MIPS) || defined (TC_ALPHA)
1846 if (OUTPUT_FLAVOR
== bfd_target_ecoff_flavour
1847 || OUTPUT_FLAVOR
== bfd_target_elf_flavour
)
1849 /* For MIPS and Alpha ECOFF or ELF, small objects are put in .sbss. */
1850 if (temp
<= bfd_get_gp_size (stdoutput
))
1852 bss_seg
= subseg_new (".sbss", 1);
1853 seg_info (bss_seg
)->bss
= 1;
1854 #ifdef BFD_ASSEMBLER
1855 if (! bfd_set_section_flags (stdoutput
, bss_seg
, SEC_ALLOC
))
1856 as_warn ("error setting flags for \".sbss\": %s",
1857 bfd_errmsg (bfd_get_error ()));
1864 /* FIXME. This needs to be machine independent. */
1875 /* FIXME: This needs to be done in a more general fashion. */
1879 record_alignment(bss_seg
, align
);
1886 if (*input_line_pointer
!= ',')
1888 as_bad ("Expected comma after size");
1889 ignore_rest_of_line ();
1892 input_line_pointer
++;
1894 if (*input_line_pointer
== '\n')
1896 as_bad ("Missing alignment");
1899 align
= get_absolute_expression ();
1900 if (align
> max_alignment
)
1902 align
= max_alignment
;
1903 as_warn ("Alignment too large: %d. assumed.", align
);
1908 as_warn ("Alignment negative. 0 assumed.");
1910 record_alignment (bss_seg
, align
);
1911 } /* if needs align */
1914 /* Assume some objects may require alignment on some systems. */
1915 #if defined (TC_ALPHA) && ! defined (VMS)
1918 align
= ffs (temp
) - 1;
1919 if (temp
% (1 << align
))
1926 symbolP
= symbol_find_or_make (name
);
1930 #if defined(OBJ_AOUT) | defined(OBJ_BOUT)
1931 S_GET_OTHER (symbolP
) == 0 &&
1932 S_GET_DESC (symbolP
) == 0 &&
1933 #endif /* OBJ_AOUT or OBJ_BOUT */
1934 (S_GET_SEGMENT (symbolP
) == bss_seg
1935 || (!S_IS_DEFINED (symbolP
) && S_GET_VALUE (symbolP
) == 0)))
1939 subseg_set (bss_seg
, 1);
1942 frag_align (align
, 0);
1943 /* detach from old frag */
1944 if (S_GET_SEGMENT (symbolP
) == bss_seg
)
1945 symbolP
->sy_frag
->fr_symbol
= NULL
;
1947 symbolP
->sy_frag
= frag_now
;
1948 pfrag
= frag_var (rs_org
, 1, 1, (relax_substateT
)0, symbolP
,
1952 S_SET_SEGMENT (symbolP
, bss_seg
);
1955 /* The symbol may already have been created with a preceding
1956 ".globl" directive -- be careful not to step on storage class
1957 in that case. Otherwise, set it to static. */
1958 if (S_GET_STORAGE_CLASS (symbolP
) != C_EXT
)
1960 S_SET_STORAGE_CLASS (symbolP
, C_STAT
);
1962 #endif /* OBJ_COFF */
1965 S_SET_SIZE (symbolP
, temp
);
1969 as_bad ("Ignoring attempt to re-define symbol `%s'.",
1970 S_GET_NAME (symbolP
));
1972 subseg_set (current_seg
, current_subseg
);
1974 demand_empty_rest_of_line ();
1981 register char *name
;
1985 register symbolS
*symbolP
;
1987 /* we permit ANY defined expression: BSD4.2 demands constants */
1988 name
= input_line_pointer
;
1989 c
= get_symbol_end ();
1990 p
= input_line_pointer
;
1993 if (*input_line_pointer
!= ',')
1996 as_bad ("Expected comma after name \"%s\"", name
);
1998 ignore_rest_of_line ();
2001 input_line_pointer
++;
2003 if (exp
.X_op
!= O_constant
2004 && exp
.X_op
!= O_register
)
2006 as_bad ("bad expression");
2007 ignore_rest_of_line ();
2011 symbolP
= symbol_find_or_make (name
);
2013 /* FIXME-SOON I pulled a (&& symbolP->sy_other == 0 &&
2014 symbolP->sy_desc == 0) out of this test because coff doesn't have
2015 those fields, and I can't see when they'd ever be tripped. I
2016 don't think I understand why they were here so I may have
2017 introduced a bug. As recently as 1.37 didn't have this test
2018 anyway. xoxorich. */
2020 if (S_GET_SEGMENT (symbolP
) == undefined_section
2021 && S_GET_VALUE (symbolP
) == 0)
2023 /* The name might be an undefined .global symbol; be sure to
2024 keep the "external" bit. */
2025 S_SET_SEGMENT (symbolP
,
2026 (exp
.X_op
== O_constant
2029 S_SET_VALUE (symbolP
, (valueT
) exp
.X_add_number
);
2033 as_bad ("Symbol %s already defined", name
);
2036 demand_empty_rest_of_line ();
2039 /* Read a line into an sb. */
2045 if (input_line_pointer
[-1] == '\n')
2046 bump_line_counters ();
2048 if (input_line_pointer
>= buffer_limit
)
2050 buffer_limit
= input_scrub_next_buffer (&input_line_pointer
);
2051 if (buffer_limit
== 0)
2055 while (! is_end_of_line
[(unsigned char) *input_line_pointer
])
2056 sb_add_char (line
, *input_line_pointer
++);
2057 while (input_line_pointer
< buffer_limit
2058 && is_end_of_line
[(unsigned char) *input_line_pointer
])
2060 if (input_line_pointer
[-1] == '\n')
2061 bump_line_counters ();
2062 ++input_line_pointer
;
2067 /* Define a macro. This is an interface to macro.c, which is shared
2068 between gas and gasp. */
2081 as_where (&file
, &line
);
2084 while (! is_end_of_line
[(unsigned char) *input_line_pointer
])
2085 sb_add_char (&s
, *input_line_pointer
++);
2088 if (line_label
!= NULL
)
2089 sb_add_string (&label
, S_GET_NAME (line_label
));
2091 err
= define_macro (0, &s
, &label
, get_line_sb
, &name
);
2093 as_bad_where (file
, line
, "%s", err
);
2096 if (line_label
!= NULL
)
2098 S_SET_SEGMENT (line_label
, undefined_section
);
2099 S_SET_VALUE (line_label
, 0);
2100 line_label
->sy_frag
= &zero_address_frag
;
2104 #ifdef NO_PSEUDO_DOT
2108 && hash_find (po_hash
, name
) != NULL
)
2111 && hash_find (po_hash
, name
+ 1) != NULL
))
2112 as_warn ("attempt to redefine pseudo-op `%s' ignored",
2119 /* Handle the .mexit pseudo-op, which immediately exits a macro
2126 buffer_limit
= input_scrub_next_buffer (&input_line_pointer
);
2129 /* Switch in and out of MRI mode. */
2137 on
= get_absolute_expression ();
2138 old_flag
= flag_mri
;
2152 #ifdef MRI_MODE_CHANGE
2154 MRI_MODE_CHANGE (on
);
2157 demand_empty_rest_of_line ();
2160 /* Handle changing the location counter. */
2163 do_org (segment
, exp
, fill
)
2168 if (segment
!= now_seg
&& segment
!= absolute_section
)
2169 as_bad ("invalid segment \"%s\"; segment \"%s\" assumed",
2170 segment_name (segment
), segment_name (now_seg
));
2172 if (now_seg
== absolute_section
)
2175 as_warn ("ignoring fill value in absolute section");
2176 if (exp
->X_op
!= O_constant
)
2178 as_bad ("only constant offsets supported in absolute section");
2179 exp
->X_add_number
= 0;
2181 abs_section_offset
= exp
->X_add_number
;
2187 p
= frag_var (rs_org
, 1, 1, (relax_substateT
) 0, exp
->X_add_symbol
,
2188 exp
->X_add_number
, (char *) NULL
);
2197 register segT segment
;
2199 register long temp_fill
;
2201 /* The m68k MRI assembler has a different meaning for .org. It
2202 means to create an absolute section at a given address. We can't
2203 support that--use a linker script instead. */
2206 as_bad ("MRI style ORG pseudo-op not supported");
2207 ignore_rest_of_line ();
2211 /* Don't believe the documentation of BSD 4.2 AS. There is no such
2212 thing as a sub-segment-relative origin. Any absolute origin is
2213 given a warning, then assumed to be segment-relative. Any
2214 segmented origin expression ("foo+42") had better be in the right
2215 segment or the .org is ignored.
2217 BSD 4.2 AS warns if you try to .org backwards. We cannot because
2218 we never know sub-segment sizes when we are reading code. BSD
2219 will crash trying to emit negative numbers of filler bytes in
2220 certain .orgs. We don't crash, but see as-write for that code.
2222 Don't make frag if need_pass_2==1. */
2223 segment
= get_known_segmented_expression (&exp
);
2224 if (*input_line_pointer
== ',')
2226 input_line_pointer
++;
2227 temp_fill
= get_absolute_expression ();
2233 do_org (segment
, &exp
, temp_fill
);
2235 demand_empty_rest_of_line ();
2238 /* Handle parsing for the MRI SECT/SECTION pseudo-op. This should be
2239 called by the obj-format routine which handles section changing
2240 when in MRI mode. It will create a new section, and return it. It
2241 will set *TYPE to the section type: one of 'C' (code), 'D' (data),
2242 'M' (mixed), or 'R' (romable). If BFD_ASSEMBLER is defined, the
2243 flags will be set in the section. */
2257 name
= input_line_pointer
;
2258 if (! isdigit ((unsigned char) *name
))
2259 c
= get_symbol_end ();
2264 ++input_line_pointer
;
2266 while (isdigit ((unsigned char) *input_line_pointer
));
2267 c
= *input_line_pointer
;
2268 *input_line_pointer
= '\0';
2271 name
= xstrdup (name
);
2273 *input_line_pointer
= c
;
2275 seg
= subseg_new (name
, 0);
2277 if (*input_line_pointer
== ',')
2281 ++input_line_pointer
;
2282 align
= get_absolute_expression ();
2283 record_alignment (seg
, align
);
2287 if (*input_line_pointer
== ',')
2289 c
= *++input_line_pointer
;
2290 c
= toupper ((unsigned char) c
);
2291 if (c
== 'C' || c
== 'D' || c
== 'M' || c
== 'R')
2294 as_bad ("unrecognized section type");
2295 ++input_line_pointer
;
2297 #ifdef BFD_ASSEMBLER
2301 flags
= SEC_NO_FLAGS
;
2303 flags
= SEC_ALLOC
| SEC_LOAD
| SEC_READONLY
| SEC_CODE
;
2304 else if (*type
== 'D' || *type
== 'M')
2305 flags
= SEC_ALLOC
| SEC_LOAD
| SEC_DATA
;
2306 else if (*type
== 'R')
2307 flags
= SEC_ALLOC
| SEC_LOAD
| SEC_DATA
| SEC_READONLY
| SEC_ROM
;
2308 if (flags
!= SEC_NO_FLAGS
)
2310 if (! bfd_set_section_flags (stdoutput
, seg
, flags
))
2311 as_warn ("error setting flags for \"%s\": %s",
2312 bfd_section_name (stdoutput
, seg
),
2313 bfd_errmsg (bfd_get_error ()));
2319 /* Ignore the HP type. */
2320 if (*input_line_pointer
== ',')
2321 input_line_pointer
+= 2;
2323 demand_empty_rest_of_line ();
2325 #else /* ! TC_M68K */
2334 name
= input_line_pointer
;
2335 c
= get_symbol_end ();
2337 name
= xstrdup (name
);
2339 *input_line_pointer
= c
;
2341 seg
= subseg_new (name
, 0);
2343 if (*input_line_pointer
!= ',')
2349 ++input_line_pointer
;
2351 sectype
= input_line_pointer
;
2352 c
= get_symbol_end ();
2353 if (*sectype
== '\0')
2355 else if (strcasecmp (sectype
, "text") == 0)
2357 else if (strcasecmp (sectype
, "data") == 0)
2359 else if (strcasecmp (sectype
, "romdata") == 0)
2362 as_warn ("unrecognized section type `%s'", sectype
);
2363 *input_line_pointer
= c
;
2366 if (*input_line_pointer
== ',')
2370 ++input_line_pointer
;
2372 seccmd
= input_line_pointer
;
2373 c
= get_symbol_end ();
2374 if (strcasecmp (seccmd
, "absolute") == 0)
2376 as_bad ("absolute sections are not supported");
2377 *input_line_pointer
= c
;
2378 ignore_rest_of_line ();
2381 else if (strcasecmp (seccmd
, "align") == 0)
2385 *input_line_pointer
= c
;
2386 align
= get_absolute_expression ();
2387 record_alignment (seg
, align
);
2391 as_warn ("unrecognized section command `%s'", seccmd
);
2392 *input_line_pointer
= c
;
2396 demand_empty_rest_of_line ();
2398 #else /* ! TC_I960 */
2399 /* The MRI assembler seems to use different forms of .sect for
2400 different targets. */
2402 #endif /* ! TC_I960 */
2403 #endif /* ! TC_M68K */
2406 /* Handle the .print pseudo-op. */
2415 s
= demand_copy_C_string (&len
);
2417 demand_empty_rest_of_line ();
2420 /* Handle the .purgem pseudo-op. */
2426 if (is_it_end_of_statement ())
2428 demand_empty_rest_of_line ();
2438 name
= input_line_pointer
;
2439 c
= get_symbol_end ();
2440 delete_macro (name
);
2441 *input_line_pointer
= c
;
2444 while (*input_line_pointer
++ == ',');
2446 --input_line_pointer
;
2447 demand_empty_rest_of_line ();
2450 /* Handle the .rept pseudo-op. */
2460 count
= get_absolute_expression ();
2463 if (! buffer_and_nest ("REPT", "ENDR", &one
, get_line_sb
))
2465 as_bad ("rept without endr");
2471 sb_add_sb (&many
, &one
);
2475 input_scrub_include_sb (&many
, input_line_pointer
);
2477 buffer_limit
= input_scrub_next_buffer (&input_line_pointer
);
2484 register char *name
;
2485 register char delim
;
2486 register char *end_name
;
2487 register symbolS
*symbolP
;
2490 * Especial apologies for the random logic:
2491 * this just grew, and could be parsed much more simply!
2494 name
= input_line_pointer
;
2495 delim
= get_symbol_end ();
2496 end_name
= input_line_pointer
;
2500 if (*input_line_pointer
!= ',')
2503 as_bad ("Expected comma after name \"%s\"", name
);
2505 ignore_rest_of_line ();
2509 input_line_pointer
++;
2512 if (name
[0] == '.' && name
[1] == '\0')
2514 /* Turn '. = mumble' into a .org mumble */
2515 register segT segment
;
2518 segment
= get_known_segmented_expression (&exp
);
2521 do_org (segment
, &exp
, 0);
2527 if ((symbolP
= symbol_find (name
)) == NULL
2528 && (symbolP
= md_undefined_symbol (name
)) == NULL
)
2530 symbolP
= symbol_new (name
, undefined_section
, 0, &zero_address_frag
);
2532 /* "set" symbols are local unless otherwise specified. */
2533 SF_SET_LOCAL (symbolP
);
2534 #endif /* OBJ_COFF */
2536 } /* make a new symbol */
2538 symbol_table_insert (symbolP
);
2541 pseudo_set (symbolP
);
2542 demand_empty_rest_of_line ();
2555 #ifdef md_flush_pending_output
2556 md_flush_pending_output ();
2560 stop
= mri_comment_field (&stopc
);
2562 /* In m68k MRI mode, we need to align to a word boundary, unless
2564 if (flag_m68k_mri
&& mult
> 1)
2566 if (now_seg
== absolute_section
)
2568 abs_section_offset
+= abs_section_offset
& 1;
2569 if (line_label
!= NULL
)
2570 S_SET_VALUE (line_label
, abs_section_offset
);
2572 else if (mri_common_symbol
!= NULL
)
2576 val
= S_GET_VALUE (mri_common_symbol
);
2579 S_SET_VALUE (mri_common_symbol
, val
+ 1);
2580 if (line_label
!= NULL
)
2582 know (line_label
->sy_value
.X_op
== O_symbol
);
2583 know (line_label
->sy_value
.X_add_symbol
== mri_common_symbol
);
2584 line_label
->sy_value
.X_add_number
+= 1;
2590 do_align (1, (char *) NULL
, 0);
2591 if (line_label
!= NULL
)
2593 line_label
->sy_frag
= frag_now
;
2594 S_SET_VALUE (line_label
, frag_now_fix ());
2602 if (*input_line_pointer
== ',')
2604 ++input_line_pointer
;
2609 val
.X_op
= O_constant
;
2610 val
.X_add_number
= 0;
2613 if (val
.X_op
!= O_constant
2614 || val
.X_add_number
< - 0x80
2615 || val
.X_add_number
> 0xff
2616 || (mult
!= 0 && mult
!= 1 && val
.X_add_number
!= 0))
2618 if (exp
.X_op
!= O_constant
)
2619 as_bad ("Unsupported variable size or fill value");
2626 for (i
= 0; i
< exp
.X_add_number
; i
++)
2627 emit_expr (&val
, mult
);
2632 if (exp
.X_op
== O_constant
)
2636 repeat
= exp
.X_add_number
;
2641 if (! flag_mri
|| repeat
< 0)
2642 as_warn (".space repeat count is %s, ignored",
2643 repeat
? "negative" : "zero");
2647 /* If we are in the absolute section, just bump the offset. */
2648 if (now_seg
== absolute_section
)
2650 abs_section_offset
+= repeat
;
2654 /* If we are secretly in an MRI common section, then
2655 creating space just increases the size of the common
2657 if (mri_common_symbol
!= NULL
)
2659 S_SET_VALUE (mri_common_symbol
,
2660 S_GET_VALUE (mri_common_symbol
) + repeat
);
2665 p
= frag_var (rs_fill
, 1, 1, (relax_substateT
) 0, (symbolS
*) 0,
2666 repeat
, (char *) 0);
2670 if (now_seg
== absolute_section
)
2672 as_bad ("space allocation too complex in absolute section");
2673 subseg_set (text_section
, 0);
2675 if (mri_common_symbol
!= NULL
)
2677 as_bad ("space allocation too complex in common section");
2678 mri_common_symbol
= NULL
;
2681 p
= frag_var (rs_space
, 1, 1, (relax_substateT
) 0,
2682 make_expr_symbol (&exp
), 0L, (char *) 0);
2686 *p
= val
.X_add_number
;
2691 mri_comment_end (stop
, stopc
);
2693 demand_empty_rest_of_line ();
2696 /* This is like s_space, but the value is a floating point number with
2697 the given precision. This is for the MRI dcb.s pseudo-op and
2701 s_float_space (float_type
)
2706 char temp
[MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT
];
2711 stop
= mri_comment_field (&stopc
);
2713 count
= get_absolute_expression ();
2716 if (*input_line_pointer
!= ',')
2718 as_bad ("missing value");
2720 mri_comment_end (stop
, stopc
);
2721 ignore_rest_of_line ();
2725 ++input_line_pointer
;
2729 /* Skip any 0{letter} that may be present. Don't even check if the
2730 * letter is legal. */
2731 if (input_line_pointer
[0] == '0' && isalpha (input_line_pointer
[1]))
2732 input_line_pointer
+= 2;
2734 /* Accept :xxxx, where the x's are hex digits, for a floating point
2735 with the exact digits specified. */
2736 if (input_line_pointer
[0] == ':')
2738 flen
= hex_float (float_type
, temp
);
2742 mri_comment_end (stop
, stopc
);
2743 ignore_rest_of_line ();
2751 err
= md_atof (float_type
, temp
, &flen
);
2752 know (flen
<= MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT
);
2756 as_bad ("Bad floating literal: %s", err
);
2758 mri_comment_end (stop
, stopc
);
2759 ignore_rest_of_line ();
2764 while (--count
>= 0)
2768 p
= frag_more (flen
);
2769 memcpy (p
, temp
, (unsigned int) flen
);
2773 mri_comment_end (stop
, stopc
);
2775 demand_empty_rest_of_line ();
2778 /* Handle the .struct pseudo-op, as found in MIPS assemblers. */
2788 stop
= mri_comment_field (&stopc
);
2789 abs_section_offset
= get_absolute_expression ();
2790 subseg_set (absolute_section
, 0);
2792 mri_comment_end (stop
, stopc
);
2793 demand_empty_rest_of_line ();
2802 temp
= get_absolute_expression ();
2803 subseg_set (text_section
, (subsegT
) temp
);
2804 demand_empty_rest_of_line ();
2806 const_flag
&= ~IN_DEFAULT_SECTION
;
2812 demand_empty_rest_of_line ()
2815 if (is_end_of_line
[(unsigned char) *input_line_pointer
])
2817 input_line_pointer
++;
2821 ignore_rest_of_line ();
2823 /* Return having already swallowed end-of-line. */
2824 } /* Return pointing just after end-of-line. */
2827 ignore_rest_of_line () /* For suspect lines: gives warning. */
2829 if (!is_end_of_line
[(unsigned char) *input_line_pointer
])
2831 if (isprint (*input_line_pointer
))
2832 as_bad ("Rest of line ignored. First ignored character is `%c'.",
2833 *input_line_pointer
);
2835 as_bad ("Rest of line ignored. First ignored character valued 0x%x.",
2836 *input_line_pointer
);
2837 while (input_line_pointer
< buffer_limit
2838 && !is_end_of_line
[(unsigned char) *input_line_pointer
])
2840 input_line_pointer
++;
2843 input_line_pointer
++; /* Return pointing just after end-of-line. */
2844 know (is_end_of_line
[(unsigned char) input_line_pointer
[-1]]);
2850 * In: Pointer to a symbol.
2851 * Input_line_pointer->expression.
2853 * Out: Input_line_pointer->just after any whitespace after expression.
2854 * Tried to set symbol to value of expression.
2855 * Will change symbols type, value, and frag;
2858 pseudo_set (symbolP
)
2862 #if (defined (OBJ_AOUT) || defined (OBJ_BOUT)) && ! defined (BFD_ASSEMBLER)
2864 #endif /* OBJ_AOUT or OBJ_BOUT */
2866 know (symbolP
); /* NULL pointer is logic error. */
2867 #if (defined (OBJ_AOUT) || defined (OBJ_BOUT)) && ! defined (BFD_ASSEMBLER)
2868 ext
= S_IS_EXTERNAL (symbolP
);
2869 #endif /* OBJ_AOUT or OBJ_BOUT */
2871 (void) expression (&exp
);
2873 if (exp
.X_op
== O_illegal
)
2874 as_bad ("illegal expression; zero assumed");
2875 else if (exp
.X_op
== O_absent
)
2876 as_bad ("missing expression; zero assumed");
2877 else if (exp
.X_op
== O_big
)
2878 as_bad ("%s number invalid; zero assumed",
2879 exp
.X_add_number
> 0 ? "bignum" : "floating point");
2880 else if (exp
.X_op
== O_subtract
2881 && (S_GET_SEGMENT (exp
.X_add_symbol
)
2882 == S_GET_SEGMENT (exp
.X_op_symbol
))
2883 && SEG_NORMAL (S_GET_SEGMENT (exp
.X_add_symbol
))
2884 && exp
.X_add_symbol
->sy_frag
== exp
.X_op_symbol
->sy_frag
)
2886 exp
.X_op
= O_constant
;
2887 exp
.X_add_number
= (S_GET_VALUE (exp
.X_add_symbol
)
2888 - S_GET_VALUE (exp
.X_op_symbol
));
2896 exp
.X_add_number
= 0;
2899 S_SET_SEGMENT (symbolP
, absolute_section
);
2900 #if (defined (OBJ_AOUT) || defined (OBJ_BOUT)) && ! defined (BFD_ASSEMBLER)
2902 S_SET_EXTERNAL (symbolP
);
2904 S_CLEAR_EXTERNAL (symbolP
);
2905 #endif /* OBJ_AOUT or OBJ_BOUT */
2906 S_SET_VALUE (symbolP
, (valueT
) exp
.X_add_number
);
2907 symbolP
->sy_frag
= &zero_address_frag
;
2911 S_SET_SEGMENT (symbolP
, reg_section
);
2912 S_SET_VALUE (symbolP
, (valueT
) exp
.X_add_number
);
2913 symbolP
->sy_frag
= &zero_address_frag
;
2917 if (S_GET_SEGMENT (exp
.X_add_symbol
) == undefined_section
2918 || exp
.X_add_number
!= 0)
2919 symbolP
->sy_value
= exp
;
2922 symbolS
*s
= exp
.X_add_symbol
;
2924 S_SET_SEGMENT (symbolP
, S_GET_SEGMENT (s
));
2925 #if (defined (OBJ_AOUT) || defined (OBJ_BOUT)) && ! defined (BFD_ASSEMBLER)
2927 S_SET_EXTERNAL (symbolP
);
2929 S_CLEAR_EXTERNAL (symbolP
);
2930 #endif /* OBJ_AOUT or OBJ_BOUT */
2931 S_SET_VALUE (symbolP
,
2932 exp
.X_add_number
+ S_GET_VALUE (s
));
2933 symbolP
->sy_frag
= s
->sy_frag
;
2934 copy_symbol_attributes (symbolP
, s
);
2939 /* The value is some complex expression.
2940 FIXME: Should we set the segment to anything? */
2941 symbolP
->sy_value
= exp
;
2949 * CONStruct more frag of .bytes, or .words etc.
2950 * Should need_pass_2 be 1 then emit no frag(s).
2951 * This understands EXPRESSIONS.
2955 * This has a split personality. We use expression() to read the
2956 * value. We can detect if the value won't fit in a byte or word.
2957 * But we can't detect if expression() discarded significant digits
2958 * in the case of a long. Not worth the crocks required to fix it.
2961 /* Select a parser for cons expressions. */
2963 /* Some targets need to parse the expression in various fancy ways.
2964 You can define TC_PARSE_CONS_EXPRESSION to do whatever you like
2965 (for example, the HPPA does this). Otherwise, you can define
2966 BITFIELD_CONS_EXPRESSIONS to permit bitfields to be specified, or
2967 REPEAT_CONS_EXPRESSIONS to permit repeat counts. If none of these
2968 are defined, which is the normal case, then only simple expressions
2972 parse_mri_cons
PARAMS ((expressionS
*exp
, unsigned int nbytes
));
2974 #ifndef TC_PARSE_CONS_EXPRESSION
2975 #ifdef BITFIELD_CONS_EXPRESSIONS
2976 #define TC_PARSE_CONS_EXPRESSION(EXP, NBYTES) parse_bitfield_cons (EXP, NBYTES)
2978 parse_bitfield_cons
PARAMS ((expressionS
*exp
, unsigned int nbytes
));
2980 #ifdef REPEAT_CONS_EXPRESSIONS
2981 #define TC_PARSE_CONS_EXPRESSION(EXP, NBYTES) parse_repeat_cons (EXP, NBYTES)
2983 parse_repeat_cons
PARAMS ((expressionS
*exp
, unsigned int nbytes
));
2986 /* If we haven't gotten one yet, just call expression. */
2987 #ifndef TC_PARSE_CONS_EXPRESSION
2988 #define TC_PARSE_CONS_EXPRESSION(EXP, NBYTES) expression (EXP)
2992 /* worker to do .byte etc statements */
2993 /* clobbers input_line_pointer, checks */
2996 cons_worker (nbytes
, rva
)
2997 register int nbytes
; /* 1=.byte, 2=.word, 4=.long */
3005 #ifdef md_flush_pending_output
3006 md_flush_pending_output ();
3010 stop
= mri_comment_field (&stopc
);
3012 if (is_it_end_of_statement ())
3015 mri_comment_end (stop
, stopc
);
3016 demand_empty_rest_of_line ();
3020 #ifdef md_cons_align
3021 md_cons_align (nbytes
);
3028 parse_mri_cons (&exp
, (unsigned int) nbytes
);
3030 TC_PARSE_CONS_EXPRESSION (&exp
, (unsigned int) nbytes
);
3034 if (exp
.X_op
== O_symbol
)
3035 exp
.X_op
= O_symbol_rva
;
3037 as_fatal ("rva without symbol");
3039 emit_expr (&exp
, (unsigned int) nbytes
);
3042 while (*input_line_pointer
++ == ',');
3044 /* In MRI mode, after an odd number of bytes, we must align to an
3045 even word boundary, unless the next instruction is a dc.b, ds.b
3047 if (flag_mri
&& nbytes
== 1 && (c
& 1) != 0)
3048 mri_pending_align
= 1;
3050 input_line_pointer
--; /* Put terminator back into stream. */
3053 mri_comment_end (stop
, stopc
);
3055 demand_empty_rest_of_line ();
3063 cons_worker (size
, 0);
3070 cons_worker (size
, 1);
3074 /* Put the contents of expression EXP into the object file using
3075 NBYTES bytes. If need_pass_2 is 1, this does nothing. */
3078 emit_expr (exp
, nbytes
)
3080 unsigned int nbytes
;
3084 valueT extra_digit
= 0;
3086 /* Don't do anything if we are going to make another pass. */
3092 /* Allow `.word 0' in the absolute section. */
3093 if (now_seg
== absolute_section
)
3095 if (op
!= O_constant
|| exp
->X_add_number
!= 0)
3096 as_bad ("attempt to store value in absolute section");
3097 abs_section_offset
+= nbytes
;
3101 /* Handle a negative bignum. */
3103 && exp
->X_add_number
== 0
3104 && exp
->X_add_symbol
->sy_value
.X_op
== O_big
3105 && exp
->X_add_symbol
->sy_value
.X_add_number
> 0)
3108 unsigned long carry
;
3110 exp
= &exp
->X_add_symbol
->sy_value
;
3112 /* Negate the bignum: one's complement each digit and add 1. */
3114 for (i
= 0; i
< exp
->X_add_number
; i
++)
3118 next
= (((~ (generic_bignum
[i
] & LITTLENUM_MASK
))
3121 generic_bignum
[i
] = next
& LITTLENUM_MASK
;
3122 carry
= next
>> LITTLENUM_NUMBER_OF_BITS
;
3125 /* We can ignore any carry out, because it will be handled by
3126 extra_digit if it is needed. */
3128 extra_digit
= (valueT
) -1;
3132 if (op
== O_absent
|| op
== O_illegal
)
3134 as_warn ("zero assumed for missing expression");
3135 exp
->X_add_number
= 0;
3138 else if (op
== O_big
&& exp
->X_add_number
<= 0)
3140 as_bad ("floating point number invalid; zero assumed");
3141 exp
->X_add_number
= 0;
3144 else if (op
== O_register
)
3146 as_warn ("register value used as expression");
3150 p
= frag_more ((int) nbytes
);
3152 #ifndef WORKING_DOT_WORD
3153 /* If we have the difference of two symbols in a word, save it on
3154 the broken_words list. See the code in write.c. */
3155 if (op
== O_subtract
&& nbytes
== 2)
3157 struct broken_word
*x
;
3159 x
= (struct broken_word
*) xmalloc (sizeof (struct broken_word
));
3160 x
->next_broken_word
= broken_words
;
3163 x
->word_goes_here
= p
;
3165 x
->add
= exp
->X_add_symbol
;
3166 x
->sub
= exp
->X_op_symbol
;
3167 x
->addnum
= exp
->X_add_number
;
3174 /* If we have an integer, but the number of bytes is too large to
3175 pass to md_number_to_chars, handle it as a bignum. */
3176 if (op
== O_constant
&& nbytes
> sizeof (valueT
))
3181 if (! exp
->X_unsigned
&& exp
->X_add_number
< 0)
3182 extra_digit
= (valueT
) -1;
3183 val
= (valueT
) exp
->X_add_number
;
3187 generic_bignum
[gencnt
] = val
& LITTLENUM_MASK
;
3188 val
>>= LITTLENUM_NUMBER_OF_BITS
;
3192 op
= exp
->X_op
= O_big
;
3193 exp
->X_add_number
= gencnt
;
3196 if (op
== O_constant
)
3198 register valueT get
;
3199 register valueT use
;
3200 register valueT mask
;
3202 register valueT unmask
;
3204 /* JF << of >= number of bits in the object is undefined. In
3205 particular SPARC (Sun 4) has problems */
3206 if (nbytes
>= sizeof (valueT
))
3209 if (nbytes
> sizeof (valueT
))
3212 hibit
= (valueT
) 1 << (nbytes
* BITS_PER_CHAR
- 1);
3216 /* Don't store these bits. */
3217 mask
= ~(valueT
) 0 << (BITS_PER_CHAR
* nbytes
);
3218 hibit
= (valueT
) 1 << (nbytes
* BITS_PER_CHAR
- 1);
3221 unmask
= ~mask
; /* Do store these bits. */
3224 "Do this mod if you want every overflow check to assume SIGNED 2's complement data.";
3225 mask
= ~(unmask
>> 1); /* Includes sign bit now. */
3228 get
= exp
->X_add_number
;
3230 if ((get
& mask
) != 0
3231 && ((get
& mask
) != mask
3232 || (get
& hibit
) == 0))
3233 { /* Leading bits contain both 0s & 1s. */
3234 as_warn ("Value 0x%lx truncated to 0x%lx.",
3235 (unsigned long) get
, (unsigned long) use
);
3237 /* put bytes in right order. */
3238 md_number_to_chars (p
, use
, (int) nbytes
);
3240 else if (op
== O_big
)
3243 LITTLENUM_TYPE
*nums
;
3245 know (nbytes
% CHARS_PER_LITTLENUM
== 0);
3247 size
= exp
->X_add_number
* CHARS_PER_LITTLENUM
;
3250 as_warn ("Bignum truncated to %d bytes", nbytes
);
3254 if (target_big_endian
)
3256 while (nbytes
> size
)
3258 md_number_to_chars (p
, extra_digit
, CHARS_PER_LITTLENUM
);
3259 nbytes
-= CHARS_PER_LITTLENUM
;
3260 p
+= CHARS_PER_LITTLENUM
;
3263 nums
= generic_bignum
+ size
/ CHARS_PER_LITTLENUM
;
3267 md_number_to_chars (p
, (valueT
) *nums
, CHARS_PER_LITTLENUM
);
3268 size
-= CHARS_PER_LITTLENUM
;
3269 p
+= CHARS_PER_LITTLENUM
;
3274 nums
= generic_bignum
;
3277 md_number_to_chars (p
, (valueT
) *nums
, CHARS_PER_LITTLENUM
);
3279 size
-= CHARS_PER_LITTLENUM
;
3280 p
+= CHARS_PER_LITTLENUM
;
3281 nbytes
-= CHARS_PER_LITTLENUM
;
3286 md_number_to_chars (p
, extra_digit
, CHARS_PER_LITTLENUM
);
3287 nbytes
-= CHARS_PER_LITTLENUM
;
3288 p
+= CHARS_PER_LITTLENUM
;
3294 memset (p
, 0, nbytes
);
3296 /* Now we need to generate a fixS to record the symbol value.
3297 This is easy for BFD. For other targets it can be more
3298 complex. For very complex cases (currently, the HPPA and
3299 NS32K), you can define TC_CONS_FIX_NEW to do whatever you
3300 want. For simpler cases, you can define TC_CONS_RELOC to be
3301 the name of the reloc code that should be stored in the fixS.
3302 If neither is defined, the code uses NO_RELOC if it is
3303 defined, and otherwise uses 0. */
3305 #ifdef BFD_ASSEMBLER
3306 #ifdef TC_CONS_FIX_NEW
3307 TC_CONS_FIX_NEW (frag_now
, p
- frag_now
->fr_literal
, nbytes
, exp
);
3310 bfd_reloc_code_real_type r
;
3327 as_bad ("unsupported BFD relocation size %u", nbytes
);
3331 fix_new_exp (frag_now
, p
- frag_now
->fr_literal
, (int) nbytes
, exp
,
3336 #ifdef TC_CONS_FIX_NEW
3337 TC_CONS_FIX_NEW (frag_now
, p
- frag_now
->fr_literal
, nbytes
, exp
);
3339 /* Figure out which reloc number to use. Use TC_CONS_RELOC if
3340 it is defined, otherwise use NO_RELOC if it is defined,
3342 #ifndef TC_CONS_RELOC
3344 #define TC_CONS_RELOC NO_RELOC
3346 #define TC_CONS_RELOC 0
3349 fix_new_exp (frag_now
, p
- frag_now
->fr_literal
, (int) nbytes
, exp
, 0,
3351 #endif /* TC_CONS_FIX_NEW */
3352 #endif /* BFD_ASSEMBLER */
3356 #ifdef BITFIELD_CONS_EXPRESSIONS
3358 /* i960 assemblers, (eg, asm960), allow bitfields after ".byte" as
3359 w:x,y:z, where w and y are bitwidths and x and y are values. They
3360 then pack them all together. We do a little better in that we allow
3361 them in words, longs, etc. and we'll pack them in target byte order
3364 The rules are: pack least significat bit first, if a field doesn't
3365 entirely fit, put it in the next unit. Overflowing the bitfield is
3366 explicitly *not* even a warning. The bitwidth should be considered
3369 To use this function the tc-XXX.h file should define
3370 BITFIELD_CONS_EXPRESSIONS. */
3373 parse_bitfield_cons (exp
, nbytes
)
3375 unsigned int nbytes
;
3377 unsigned int bits_available
= BITS_PER_CHAR
* nbytes
;
3378 char *hold
= input_line_pointer
;
3380 (void) expression (exp
);
3382 if (*input_line_pointer
== ':')
3388 unsigned long width
;
3390 if (*input_line_pointer
!= ':')
3392 input_line_pointer
= hold
;
3394 } /* next piece is not a bitfield */
3396 /* In the general case, we can't allow
3397 full expressions with symbol
3398 differences and such. The relocation
3399 entries for symbols not defined in this
3400 assembly would require arbitrary field
3401 widths, positions, and masks which most
3402 of our current object formats don't
3405 In the specific case where a symbol
3406 *is* defined in this assembly, we
3407 *could* build fixups and track it, but
3408 this could lead to confusion for the
3409 backends. I'm lazy. I'll take any
3410 SEG_ABSOLUTE. I think that means that
3411 you can use a previous .set or
3412 .equ type symbol. xoxorich. */
3414 if (exp
->X_op
== O_absent
)
3416 as_warn ("using a bit field width of zero");
3417 exp
->X_add_number
= 0;
3418 exp
->X_op
= O_constant
;
3419 } /* implied zero width bitfield */
3421 if (exp
->X_op
!= O_constant
)
3423 *input_line_pointer
= '\0';
3424 as_bad ("field width \"%s\" too complex for a bitfield", hold
);
3425 *input_line_pointer
= ':';
3426 demand_empty_rest_of_line ();
3430 if ((width
= exp
->X_add_number
) > (BITS_PER_CHAR
* nbytes
))
3432 as_warn ("field width %lu too big to fit in %d bytes: truncated to %d bits",
3433 width
, nbytes
, (BITS_PER_CHAR
* nbytes
));
3434 width
= BITS_PER_CHAR
* nbytes
;
3437 if (width
> bits_available
)
3439 /* FIXME-SOMEDAY: backing up and reparsing is wasteful. */
3440 input_line_pointer
= hold
;
3441 exp
->X_add_number
= value
;
3445 hold
= ++input_line_pointer
; /* skip ':' */
3447 (void) expression (exp
);
3448 if (exp
->X_op
!= O_constant
)
3450 char cache
= *input_line_pointer
;
3452 *input_line_pointer
= '\0';
3453 as_bad ("field value \"%s\" too complex for a bitfield", hold
);
3454 *input_line_pointer
= cache
;
3455 demand_empty_rest_of_line ();
3459 value
|= ((~(-1 << width
) & exp
->X_add_number
)
3460 << ((BITS_PER_CHAR
* nbytes
) - bits_available
));
3462 if ((bits_available
-= width
) == 0
3463 || is_it_end_of_statement ()
3464 || *input_line_pointer
!= ',')
3467 } /* all the bitfields we're gonna get */
3469 hold
= ++input_line_pointer
;
3470 (void) expression (exp
);
3471 } /* forever loop */
3473 exp
->X_add_number
= value
;
3474 exp
->X_op
= O_constant
;
3475 exp
->X_unsigned
= 1;
3476 } /* if looks like a bitfield */
3477 } /* parse_bitfield_cons() */
3479 #endif /* BITFIELD_CONS_EXPRESSIONS */
3481 /* Handle an MRI style string expression. */
3484 parse_mri_cons (exp
, nbytes
)
3486 unsigned int nbytes
;
3488 if (*input_line_pointer
!= '\''
3489 && (input_line_pointer
[1] != '\''
3490 || (*input_line_pointer
!= 'A'
3491 && *input_line_pointer
!= 'E')))
3492 TC_PARSE_CONS_EXPRESSION (exp
, nbytes
);
3496 unsigned int result
= 0;
3498 /* An MRI style string. Cut into as many bytes as will fit into
3499 a nbyte chunk, left justify if necessary, and separate with
3500 commas so we can try again later. */
3501 if (*input_line_pointer
== 'A')
3502 ++input_line_pointer
;
3503 else if (*input_line_pointer
== 'E')
3505 as_bad ("EBCDIC constants are not supported");
3506 ++input_line_pointer
;
3509 input_line_pointer
++;
3510 for (scan
= 0; scan
< nbytes
; scan
++)
3512 if (*input_line_pointer
== '\'')
3514 if (input_line_pointer
[1] == '\'')
3516 input_line_pointer
++;
3521 result
= (result
<< 8) | (*input_line_pointer
++);
3525 while (scan
< nbytes
)
3530 /* Create correct expression */
3531 exp
->X_op
= O_constant
;
3532 exp
->X_add_number
= result
;
3533 /* Fake it so that we can read the next char too */
3534 if (input_line_pointer
[0] != '\'' ||
3535 (input_line_pointer
[0] == '\'' && input_line_pointer
[1] == '\''))
3537 input_line_pointer
-= 2;
3538 input_line_pointer
[0] = ',';
3539 input_line_pointer
[1] = '\'';
3542 input_line_pointer
++;
3546 #ifdef REPEAT_CONS_EXPRESSIONS
3548 /* Parse a repeat expression for cons. This is used by the MIPS
3549 assembler. The format is NUMBER:COUNT; NUMBER appears in the
3550 object file COUNT times.
3552 To use this for a target, define REPEAT_CONS_EXPRESSIONS. */
3555 parse_repeat_cons (exp
, nbytes
)
3557 unsigned int nbytes
;
3564 if (*input_line_pointer
!= ':')
3566 /* No repeat count. */
3570 ++input_line_pointer
;
3571 expression (&count
);
3572 if (count
.X_op
!= O_constant
3573 || count
.X_add_number
<= 0)
3575 as_warn ("Unresolvable or nonpositive repeat count; using 1");
3579 /* The cons function is going to output this expression once. So we
3580 output it count - 1 times. */
3581 for (i
= count
.X_add_number
- 1; i
> 0; i
--)
3582 emit_expr (exp
, nbytes
);
3585 #endif /* REPEAT_CONS_EXPRESSIONS */
3587 /* Parse a floating point number represented as a hex constant. This
3588 permits users to specify the exact bits they want in the floating
3592 hex_float (float_type
, bytes
)
3626 as_bad ("Unknown floating type type '%c'", float_type
);
3630 /* It would be nice if we could go through expression to parse the
3631 hex constant, but if we get a bignum it's a pain to sort it into
3632 the buffer correctly. */
3634 while (hex_p (*input_line_pointer
) || *input_line_pointer
== '_')
3638 /* The MRI assembler accepts arbitrary underscores strewn about
3639 through the hex constant, so we ignore them as well. */
3640 if (*input_line_pointer
== '_')
3642 ++input_line_pointer
;
3648 as_warn ("Floating point constant too large");
3651 d
= hex_value (*input_line_pointer
) << 4;
3652 ++input_line_pointer
;
3653 while (*input_line_pointer
== '_')
3654 ++input_line_pointer
;
3655 if (hex_p (*input_line_pointer
))
3657 d
+= hex_value (*input_line_pointer
);
3658 ++input_line_pointer
;
3660 if (target_big_endian
)
3663 bytes
[length
- i
- 1] = d
;
3669 if (target_big_endian
)
3670 memset (bytes
+ i
, 0, length
- i
);
3672 memset (bytes
, 0, length
- i
);
3681 * CONStruct some more frag chars of .floats .ffloats etc.
3682 * Makes 0 or more new frags.
3683 * If need_pass_2 == 1, no frags are emitted.
3684 * This understands only floating literals, not expressions. Sorry.
3686 * A floating constant is defined by atof_generic(), except it is preceded
3687 * by 0d 0f 0g or 0h. After observing the STRANGE way my BSD AS does its
3688 * reading, I decided to be incompatible. This always tries to give you
3689 * rounded bits to the precision of the pseudo-op. Former AS did premature
3690 * truncatation, restored noisy bits instead of trailing 0s AND gave you
3691 * a choice of 2 flavours of noise according to which of 2 floating-point
3692 * scanners you directed AS to use.
3694 * In: input_line_pointer->whitespace before, or '0' of flonum.
3699 float_cons (float_type
)
3700 /* Clobbers input_line-pointer, checks end-of-line. */
3701 register int float_type
; /* 'f':.ffloat ... 'F':.float ... */
3704 int length
; /* Number of chars in an object. */
3705 register char *err
; /* Error from scanning floating literal. */
3706 char temp
[MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT
];
3708 if (is_it_end_of_statement ())
3710 demand_empty_rest_of_line ();
3714 #ifdef md_flush_pending_output
3715 md_flush_pending_output ();
3720 /* input_line_pointer->1st char of a flonum (we hope!). */
3723 /* Skip any 0{letter} that may be present. Don't even check if the
3724 * letter is legal. Someone may invent a "z" format and this routine
3725 * has no use for such information. Lusers beware: you get
3726 * diagnostics if your input is ill-conditioned.
3728 if (input_line_pointer
[0] == '0' && isalpha (input_line_pointer
[1]))
3729 input_line_pointer
+= 2;
3731 /* Accept :xxxx, where the x's are hex digits, for a floating
3732 point with the exact digits specified. */
3733 if (input_line_pointer
[0] == ':')
3735 ++input_line_pointer
;
3736 length
= hex_float (float_type
, temp
);
3739 ignore_rest_of_line ();
3745 err
= md_atof (float_type
, temp
, &length
);
3746 know (length
<= MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT
);
3750 as_bad ("Bad floating literal: %s", err
);
3751 ignore_rest_of_line ();
3762 #ifdef REPEAT_CONS_EXPRESSIONS
3763 if (*input_line_pointer
== ':')
3765 expressionS count_exp
;
3767 ++input_line_pointer
;
3768 expression (&count_exp
);
3769 if (count_exp
.X_op
!= O_constant
3770 || count_exp
.X_add_number
<= 0)
3772 as_warn ("unresolvable or nonpositive repeat count; using 1");
3775 count
= count_exp
.X_add_number
;
3779 while (--count
>= 0)
3781 p
= frag_more (length
);
3782 memcpy (p
, temp
, (unsigned int) length
);
3787 while (*input_line_pointer
++ == ',');
3789 --input_line_pointer
; /* Put terminator back into stream. */
3790 demand_empty_rest_of_line ();
3791 } /* float_cons() */
3796 * We read 0 or more ',' seperated, double-quoted strings.
3798 * Caller should have checked need_pass_2 is FALSE because we don't check it.
3803 stringer (append_zero
) /* Worker to do .ascii etc statements. */
3804 /* Checks end-of-line. */
3805 register int append_zero
; /* 0: don't append '\0', else 1 */
3807 register unsigned int c
;
3809 #ifdef md_flush_pending_output
3810 md_flush_pending_output ();
3814 * The following awkward logic is to parse ZERO or more strings,
3815 * comma seperated. Recall a string expression includes spaces
3816 * before the opening '\"' and spaces after the closing '\"'.
3817 * We fake a leading ',' if there is (supposed to be)
3818 * a 1st, expression. We keep demanding expressions for each
3821 if (is_it_end_of_statement ())
3823 c
= 0; /* Skip loop. */
3824 ++input_line_pointer
; /* Compensate for end of loop. */
3828 c
= ','; /* Do loop. */
3830 while (c
== ',' || c
== '<' || c
== '"')
3833 switch (*input_line_pointer
)
3836 ++input_line_pointer
; /*->1st char of string. */
3837 while (is_a_char (c
= next_char_of_string ()))
3839 FRAG_APPEND_1_CHAR (c
);
3843 FRAG_APPEND_1_CHAR (0);
3845 know (input_line_pointer
[-1] == '\"');
3848 input_line_pointer
++;
3849 c
= get_single_number ();
3850 FRAG_APPEND_1_CHAR (c
);
3851 if (*input_line_pointer
!= '>')
3853 as_bad ("Expected <nn>");
3855 input_line_pointer
++;
3858 input_line_pointer
++;
3862 c
= *input_line_pointer
;
3865 demand_empty_rest_of_line ();
3868 /* FIXME-SOMEDAY: I had trouble here on characters with the
3869 high bits set. We'll probably also have trouble with
3870 multibyte chars, wide chars, etc. Also be careful about
3871 returning values bigger than 1 byte. xoxorich. */
3874 next_char_of_string ()
3876 register unsigned int c
;
3878 c
= *input_line_pointer
++ & CHAR_MASK
;
3886 as_warn ("Unterminated string: Newline inserted.");
3887 bump_line_counters ();
3890 #ifndef NO_STRING_ESCAPES
3892 switch (c
= *input_line_pointer
++)
3920 break; /* As itself. */
3936 for (i
= 0, number
= 0; isdigit (c
) && i
< 3; c
= *input_line_pointer
++, i
++)
3938 number
= number
* 8 + c
- '0';
3942 --input_line_pointer
;
3951 c
= *input_line_pointer
++;
3952 while (isxdigit (c
))
3955 number
= number
* 16 + c
- '0';
3956 else if (isupper (c
))
3957 number
= number
* 16 + c
- 'A' + 10;
3959 number
= number
* 16 + c
- 'a' + 10;
3960 c
= *input_line_pointer
++;
3963 --input_line_pointer
;
3968 /* To be compatible with BSD 4.2 as: give the luser a linefeed!! */
3969 as_warn ("Unterminated string: Newline inserted.");
3971 bump_line_counters ();
3976 #ifdef ONLY_STANDARD_ESCAPES
3977 as_bad ("Bad escaped character in string, '?' assumed");
3979 #endif /* ONLY_STANDARD_ESCAPES */
3982 } /* switch on escaped char */
3984 #endif /* ! defined (NO_STRING_ESCAPES) */
3988 } /* switch on char */
3990 } /* next_char_of_string() */
3993 get_segmented_expression (expP
)
3994 register expressionS
*expP
;
3996 register segT retval
;
3998 retval
= expression (expP
);
3999 if (expP
->X_op
== O_illegal
4000 || expP
->X_op
== O_absent
4001 || expP
->X_op
== O_big
)
4003 as_bad ("expected address expression; zero assumed");
4004 expP
->X_op
= O_constant
;
4005 expP
->X_add_number
= 0;
4006 retval
= absolute_section
;
4012 get_known_segmented_expression (expP
)
4013 register expressionS
*expP
;
4015 register segT retval
;
4017 if ((retval
= get_segmented_expression (expP
)) == undefined_section
)
4019 /* There is no easy way to extract the undefined symbol from the
4021 if (expP
->X_add_symbol
!= NULL
4022 && S_GET_SEGMENT (expP
->X_add_symbol
) != expr_section
)
4023 as_warn ("symbol \"%s\" undefined; zero assumed",
4024 S_GET_NAME (expP
->X_add_symbol
));
4026 as_warn ("some symbol undefined; zero assumed");
4027 retval
= absolute_section
;
4028 expP
->X_op
= O_constant
;
4029 expP
->X_add_number
= 0;
4031 know (retval
== absolute_section
|| SEG_NORMAL (retval
));
4033 } /* get_known_segmented_expression() */
4036 get_absolute_expression ()
4041 if (exp
.X_op
!= O_constant
)
4043 if (exp
.X_op
!= O_absent
)
4044 as_bad ("bad or irreducible absolute expression; zero assumed");
4045 exp
.X_add_number
= 0;
4047 return exp
.X_add_number
;
4050 char /* return terminator */
4051 get_absolute_expression_and_terminator (val_pointer
)
4052 long *val_pointer
; /* return value of expression */
4054 /* FIXME: val_pointer should probably be offsetT *. */
4055 *val_pointer
= (long) get_absolute_expression ();
4056 return (*input_line_pointer
++);
4060 * demand_copy_C_string()
4062 * Like demand_copy_string, but return NULL if the string contains any '\0's.
4063 * Give a warning if that happens.
4066 demand_copy_C_string (len_pointer
)
4071 if ((s
= demand_copy_string (len_pointer
)) != 0)
4075 for (len
= *len_pointer
; len
> 0; len
--)
4082 as_bad ("This string may not contain \'\\0\'");
4090 * demand_copy_string()
4092 * Demand string, but return a safe (=private) copy of the string.
4093 * Return NULL if we can't read a string here.
4096 demand_copy_string (lenP
)
4099 register unsigned int c
;
4105 if (*input_line_pointer
== '\"')
4107 input_line_pointer
++; /* Skip opening quote. */
4109 while (is_a_char (c
= next_char_of_string ()))
4111 obstack_1grow (¬es
, c
);
4114 /* JF this next line is so demand_copy_C_string will return a
4115 null terminated string. */
4116 obstack_1grow (¬es
, '\0');
4117 retval
= obstack_finish (¬es
);
4121 as_warn ("Missing string");
4123 ignore_rest_of_line ();
4127 } /* demand_copy_string() */
4130 * is_it_end_of_statement()
4132 * In: Input_line_pointer->next character.
4134 * Do: Skip input_line_pointer over all whitespace.
4136 * Out: 1 if input_line_pointer->end-of-line.
4139 is_it_end_of_statement ()
4142 return (is_end_of_line
[(unsigned char) *input_line_pointer
]);
4143 } /* is_it_end_of_statement() */
4149 register symbolS
*symbolP
; /* symbol we are working with */
4153 input_line_pointer
++;
4154 if (*input_line_pointer
== '=')
4155 input_line_pointer
++;
4157 while (*input_line_pointer
== ' ' || *input_line_pointer
== '\t')
4158 input_line_pointer
++;
4161 stop
= mri_comment_field (&stopc
);
4163 if (sym_name
[0] == '.' && sym_name
[1] == '\0')
4165 /* Turn '. = mumble' into a .org mumble */
4166 register segT segment
;
4169 segment
= get_known_segmented_expression (&exp
);
4171 do_org (segment
, &exp
, 0);
4175 symbolP
= symbol_find_or_make (sym_name
);
4176 pseudo_set (symbolP
);
4180 mri_comment_end (stop
, stopc
);
4183 /* .include -- include a file at this point. */
4196 if (! flag_m68k_mri
)
4197 filename
= demand_copy_string (&i
);
4202 while (! is_end_of_line
[(unsigned char) *input_line_pointer
]
4203 && *input_line_pointer
!= ' '
4204 && *input_line_pointer
!= '\t')
4206 obstack_1grow (¬es
, *input_line_pointer
);
4207 ++input_line_pointer
;
4210 obstack_1grow (¬es
, '\0');
4211 filename
= obstack_finish (¬es
);
4212 while (! is_end_of_line
[(unsigned char) *input_line_pointer
])
4213 ++input_line_pointer
;
4215 demand_empty_rest_of_line ();
4216 path
= xmalloc ((unsigned long) i
+ include_dir_maxlen
+ 5 /* slop */ );
4217 for (i
= 0; i
< include_dir_count
; i
++)
4219 strcpy (path
, include_dirs
[i
]);
4221 strcat (path
, filename
);
4222 if (0 != (try = fopen (path
, "r")))
4231 /* malloc Storage leak when file is found on path. FIXME-SOMEDAY. */
4232 newbuf
= input_scrub_include_file (path
, input_line_pointer
);
4233 buffer_limit
= input_scrub_next_buffer (&input_line_pointer
);
4237 add_include_dir (path
)
4242 if (include_dir_count
== 0)
4244 include_dirs
= (char **) xmalloc (2 * sizeof (*include_dirs
));
4245 include_dirs
[0] = "."; /* Current dir */
4246 include_dir_count
= 2;
4250 include_dir_count
++;
4251 include_dirs
= (char **) realloc (include_dirs
,
4252 include_dir_count
* sizeof (*include_dirs
));
4255 include_dirs
[include_dir_count
- 1] = path
; /* New one */
4258 if (i
> include_dir_maxlen
)
4259 include_dir_maxlen
= i
;
4260 } /* add_include_dir() */
4266 while (!is_end_of_line
[(unsigned char) *input_line_pointer
])
4268 ++input_line_pointer
;
4270 ++input_line_pointer
;
4275 read_print_statistics (file
)
4278 hash_print_statistics (file
, "pseudo-op table", po_hash
);