1 /* read.c - read a source file -
2 Copyright (C) 1986, 87, 90, 91, 92, 93, 94, 95, 1996
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))))
697 do_align (1, (char *) NULL
, 0);
698 mri_pending_align
= 0;
701 /* Print the error msg now, while we still can */
704 as_bad ("Unknown pseudo-op: `%s'", s
);
705 *input_line_pointer
= c
;
710 /* Put it back for error messages etc. */
711 *input_line_pointer
= c
;
712 /* The following skip of whitespace is compulsory.
713 A well shaped space is sometimes all that separates
714 keyword from operands. */
715 if (c
== ' ' || c
== '\t')
716 input_line_pointer
++;
718 * Input_line is restored.
719 * Input_line_pointer->1st non-blank char
720 * after pseudo-operation.
722 (*pop
->poc_handler
) (pop
->poc_val
);
724 /* If that was .end, just get out now. */
725 if (pop
->poc_handler
== s_end
)
732 /* WARNING: c has char, which may be end-of-line. */
733 /* Also: input_line_pointer->`\0` where c was. */
734 *input_line_pointer
= c
;
735 while (!is_end_of_line
[(unsigned char) *input_line_pointer
]
737 #ifdef TC_EOL_IN_INSN
738 || TC_EOL_IN_INSN (input_line_pointer
)
742 if (flag_m68k_mri
&& *input_line_pointer
== '\'')
744 input_line_pointer
++;
747 c
= *input_line_pointer
;
748 *input_line_pointer
= '\0';
750 #ifdef OBJ_GENERATE_ASM_LINENO
751 if (generate_asm_lineno
== 0)
753 if (ecoff_no_current_file ())
754 generate_asm_lineno
= 1;
756 if (generate_asm_lineno
== 1)
761 as_where (&s
, &lineno
);
762 OBJ_GENERATE_ASM_LINENO (s
, lineno
);
771 if (check_macro (s
, &out
, '\0', &err
))
775 *input_line_pointer
++ = c
;
776 input_scrub_include_sb (&out
,
780 input_scrub_next_buffer (&input_line_pointer
);
785 if (mri_pending_align
)
787 do_align (1, (char *) NULL
, 0);
788 mri_pending_align
= 0;
791 md_assemble (s
); /* Assemble 1 instruction. */
793 *input_line_pointer
++ = c
;
795 /* We resume loop AFTER the end-of-line from
800 } /* if (is_name_beginner(c) */
803 /* Empty statement? */
804 if (is_end_of_line
[(unsigned char) c
])
807 if ((LOCAL_LABELS_DOLLAR
|| LOCAL_LABELS_FB
)
810 /* local label ("4:") */
811 char *backup
= input_line_pointer
;
813 HANDLE_CONDITIONAL_ASSEMBLY ();
817 while (isdigit (*input_line_pointer
))
819 temp
= (temp
* 10) + *input_line_pointer
- '0';
820 ++input_line_pointer
;
821 } /* read the whole number */
823 if (LOCAL_LABELS_DOLLAR
824 && *input_line_pointer
== '$'
825 && *(input_line_pointer
+ 1) == ':')
827 input_line_pointer
+= 2;
829 if (dollar_label_defined (temp
))
831 as_fatal ("label \"%d$\" redefined", temp
);
834 define_dollar_label (temp
);
835 colon (dollar_label_name (temp
, 0));
840 && *input_line_pointer
++ == ':')
842 fb_label_instance_inc (temp
);
843 colon (fb_label_name (temp
, 0));
847 input_line_pointer
= backup
;
848 } /* local label ("4:") */
850 if (c
&& strchr (line_comment_chars
, c
))
851 { /* Its a comment. Better say APP or NO_APP */
855 unsigned int new_length
;
858 bump_line_counters ();
859 s
= input_line_pointer
;
860 if (strncmp (s
, "APP\n", 4))
861 continue; /* We ignore it */
864 ends
= strstr (s
, "#NO_APP\n");
868 unsigned int tmp_len
;
871 /* The end of the #APP wasn't in this buffer. We
872 keep reading in buffers until we find the #NO_APP
873 that goes with this #APP There is one. The specs
875 tmp_len
= buffer_limit
- s
;
876 tmp_buf
= xmalloc (tmp_len
+ 1);
877 memcpy (tmp_buf
, s
, tmp_len
);
880 new_tmp
= input_scrub_next_buffer (&buffer
);
884 buffer_limit
= new_tmp
;
885 input_line_pointer
= buffer
;
886 ends
= strstr (buffer
, "#NO_APP\n");
890 num
= buffer_limit
- buffer
;
892 tmp_buf
= xrealloc (tmp_buf
, tmp_len
+ num
);
893 memcpy (tmp_buf
+ tmp_len
, buffer
, num
);
898 input_line_pointer
= ends
? ends
+ 8 : NULL
;
906 input_line_pointer
= ends
+ 8;
910 scrub_string_end
= ends
;
912 new_length
= ends
- s
;
913 new_buf
= (char *) xmalloc (new_length
);
920 space
= (new_buf
+ new_length
) - new_tmp
;
921 size
= do_scrub_chars (scrub_from_string
, new_tmp
, space
);
929 new_buf
= xrealloc (new_buf
, new_length
+ 100);
930 new_tmp
= new_buf
+ new_length
;
937 old_input
= input_line_pointer
;
938 old_limit
= buffer_limit
;
940 input_line_pointer
= new_buf
;
941 buffer_limit
= new_tmp
;
945 HANDLE_CONDITIONAL_ASSEMBLY ();
947 #ifdef tc_unrecognized_line
948 if (tc_unrecognized_line (c
))
952 /* as_warn("Junk character %d.",c); Now done by ignore_rest */
953 input_line_pointer
--; /* Report unknown char as ignored. */
954 ignore_rest_of_line ();
955 } /* while (input_line_pointer<buffer_limit) */
957 #ifdef md_after_pass_hook
958 md_after_pass_hook ();
964 bump_line_counters ();
968 input_line_pointer
= old_input
;
969 buffer_limit
= old_limit
;
974 } /* while (more buffers to scan) */
981 input_scrub_close (); /* Close the input file */
984 /* For most MRI pseudo-ops, the line actually ends at the first
985 nonquoted space. This function looks for that point, stuffs a null
986 in, and sets *STOPCP to the character that used to be there, and
987 returns the location.
989 Until I hear otherwise, I am going to assume that this is only true
990 for the m68k MRI assembler. */
993 mri_comment_field (stopcp
)
1001 know (flag_m68k_mri
);
1003 for (s
= input_line_pointer
;
1004 ((! is_end_of_line
[(unsigned char) *s
] && *s
!= ' ' && *s
!= '\t')
1009 inquote
= ! inquote
;
1019 for (s
= input_line_pointer
; ! is_end_of_line
[(unsigned char) *s
]; s
++)
1029 /* Skip to the end of an MRI comment field. */
1032 mri_comment_end (stop
, stopc
)
1038 input_line_pointer
= stop
;
1040 while (! is_end_of_line
[(unsigned char) *input_line_pointer
])
1041 ++input_line_pointer
;
1048 as_fatal (".abort detected. Abandoning ship.");
1051 /* Guts of .align directive. */
1053 do_align (n
, fill
, len
)
1059 md_do_align (n
, fill
, len
, just_record_alignment
);
1063 /* @@ Fix this right for BFD! */
1065 static char nop_opcode
= NOP_OPCODE
;
1067 if (now_seg
!= data_section
&& now_seg
!= bss_section
)
1078 /* Only make a frag if we HAVE to. . . */
1079 if (n
&& !need_pass_2
)
1082 frag_align (n
, *fill
);
1084 frag_align_pattern (n
, fill
, len
);
1088 just_record_alignment
:
1091 record_alignment (now_seg
, n
);
1094 /* For machines where ".align 4" means align to a 4 byte boundary. */
1099 register unsigned int temp
;
1102 unsigned long max_alignment
= 1 << 15;
1107 stop
= mri_comment_field (&stopc
);
1109 if (is_end_of_line
[(unsigned char) *input_line_pointer
])
1114 temp
= arg
; /* Default value from pseudo-op table */
1117 temp
= get_absolute_expression ();
1119 if (temp
> max_alignment
)
1121 as_bad ("Alignment too large: %d. assumed.", temp
= max_alignment
);
1124 /* For the sparc, `.align (1<<n)' actually means `.align n' so we
1125 have to convert it. */
1128 for (i
= 0; (temp
& 1) == 0; temp
>>= 1, ++i
)
1132 as_bad ("Alignment not a power of 2");
1135 if (*input_line_pointer
== ',')
1140 input_line_pointer
++;
1141 fillval
= get_absolute_expression ();
1148 temp_fill
= fillval
;
1149 do_align (temp
, &temp_fill
, len
);
1155 if (len
> sizeof ab
)
1157 md_number_to_chars (ab
, fillval
, len
);
1158 do_align (temp
, ab
, len
);
1164 as_warn ("expected fill pattern missing");
1165 do_align (temp
, (char *) NULL
, 0);
1169 mri_comment_end (stop
, stopc
);
1171 demand_empty_rest_of_line ();
1174 /* For machines where ".align 4" means align to 2**4 boundary. */
1181 long max_alignment
= 15;
1186 stop
= mri_comment_field (&stopc
);
1188 temp
= get_absolute_expression ();
1189 if (temp
> max_alignment
)
1190 as_bad ("Alignment too large: %d. assumed.", temp
= max_alignment
);
1193 as_bad ("Alignment negative. 0 assumed.");
1196 if (*input_line_pointer
== ',')
1201 input_line_pointer
++;
1202 fillval
= get_absolute_expression ();
1209 temp_fill
= fillval
;
1210 do_align (temp
, &temp_fill
, len
);
1216 if (len
> sizeof ab
)
1218 md_number_to_chars (ab
, fillval
, len
);
1219 do_align (temp
, ab
, len
);
1225 as_warn ("expected fill pattern missing");
1226 do_align (temp
, (char *) NULL
, 0);
1230 mri_comment_end (stop
, stopc
);
1232 demand_empty_rest_of_line ();
1239 register char *name
;
1243 register symbolS
*symbolP
;
1248 stop
= mri_comment_field (&stopc
);
1250 name
= input_line_pointer
;
1251 c
= get_symbol_end ();
1252 /* just after name is now '\0' */
1253 p
= input_line_pointer
;
1256 if (*input_line_pointer
!= ',')
1258 as_bad ("Expected comma after symbol-name: rest of line ignored.");
1260 mri_comment_end (stop
, stopc
);
1261 ignore_rest_of_line ();
1264 input_line_pointer
++; /* skip ',' */
1265 if ((temp
= get_absolute_expression ()) < 0)
1267 as_warn (".COMMon length (%ld.) <0! Ignored.", (long) temp
);
1269 mri_comment_end (stop
, stopc
);
1270 ignore_rest_of_line ();
1274 symbolP
= symbol_find_or_make (name
);
1276 if (S_IS_DEFINED (symbolP
))
1278 as_bad ("Ignoring attempt to re-define symbol `%s'.",
1279 S_GET_NAME (symbolP
));
1281 mri_comment_end (stop
, stopc
);
1282 ignore_rest_of_line ();
1285 if (S_GET_VALUE (symbolP
))
1287 if (S_GET_VALUE (symbolP
) != (valueT
) temp
)
1288 as_bad ("Length of .comm \"%s\" is already %ld. Not changed to %ld.",
1289 S_GET_NAME (symbolP
),
1290 (long) S_GET_VALUE (symbolP
),
1295 S_SET_VALUE (symbolP
, (valueT
) temp
);
1296 S_SET_EXTERNAL (symbolP
);
1300 extern int flag_one
;
1301 if ( (!temp
) || !flag_one
)
1302 S_GET_OTHER(symbolP
) = const_flag
;
1304 #endif /* not OBJ_VMS */
1305 know (symbolP
->sy_frag
== &zero_address_frag
);
1308 mri_comment_end (stop
, stopc
);
1310 demand_empty_rest_of_line ();
1313 /* The MRI COMMON pseudo-op. We handle this by creating a common
1314 symbol with the appropriate name. We make s_space do the right
1315 thing by increasing the size. */
1318 s_mri_common (small
)
1335 stop
= mri_comment_field (&stopc
);
1339 name
= input_line_pointer
;
1340 if (! isdigit ((unsigned char) *name
))
1341 c
= get_symbol_end ();
1346 ++input_line_pointer
;
1348 while (isdigit ((unsigned char) *input_line_pointer
));
1349 c
= *input_line_pointer
;
1350 *input_line_pointer
= '\0';
1352 if (line_label
!= NULL
)
1354 alc
= (char *) xmalloc (strlen (S_GET_NAME (line_label
))
1355 + (input_line_pointer
- name
)
1357 sprintf (alc
, "%s%s", name
, S_GET_NAME (line_label
));
1362 sym
= symbol_find_or_make (name
);
1363 *input_line_pointer
= c
;
1367 if (*input_line_pointer
!= ',')
1371 ++input_line_pointer
;
1372 align
= get_absolute_expression ();
1375 if (S_IS_DEFINED (sym
))
1377 #if defined (S_IS_COMMON) || defined (BFD_ASSEMBLER)
1378 if (! S_IS_COMMON (sym
))
1381 as_bad ("attempt to re-define symbol `%s'", S_GET_NAME (sym
));
1382 mri_comment_end (stop
, stopc
);
1383 ignore_rest_of_line ();
1388 S_SET_EXTERNAL (sym
);
1389 mri_common_symbol
= sym
;
1393 S_SET_ALIGN (sym
, align
);
1396 if (line_label
!= NULL
)
1398 line_label
->sy_value
.X_op
= O_symbol
;
1399 line_label
->sy_value
.X_add_symbol
= sym
;
1400 line_label
->sy_value
.X_add_number
= S_GET_VALUE (sym
);
1401 line_label
->sy_frag
= &zero_address_frag
;
1402 S_SET_SEGMENT (line_label
, expr_section
);
1405 /* FIXME: We just ignore the small argument, which distinguishes
1406 COMMON and COMMON.S. I don't know what we can do about it. */
1408 /* Ignore the type and hptype. */
1409 if (*input_line_pointer
== ',')
1410 input_line_pointer
+= 2;
1411 if (*input_line_pointer
== ',')
1412 input_line_pointer
+= 2;
1414 mri_comment_end (stop
, stopc
);
1416 demand_empty_rest_of_line ();
1426 temp
= get_absolute_expression ();
1427 if (flag_readonly_data_in_text
)
1429 section
= text_section
;
1433 section
= data_section
;
1435 subseg_set (section
, (subsegT
) temp
);
1440 demand_empty_rest_of_line ();
1443 /* Handle the .appfile pseudo-op. This is automatically generated by
1444 do_scrub_chars when a preprocessor # line comment is seen with a
1445 file name. This default definition may be overridden by the object
1446 or CPU specific pseudo-ops. This function is also the default
1447 definition for .file; the APPFILE argument is 1 for .appfile, 0 for
1451 s_app_file (appfile
)
1457 /* Some assemblers tolerate immediately following '"' */
1458 if ((s
= demand_copy_string (&length
)) != 0)
1460 /* If this is a fake .appfile, a fake newline was inserted into
1461 the buffer. Passing -2 to new_logical_line tells it to
1463 new_logical_line (s
, appfile
? -2 : -1);
1465 /* In MRI mode, the preprocessor may have inserted an extraneous
1468 && *input_line_pointer
== '\''
1469 && is_end_of_line
[(unsigned char) input_line_pointer
[1]])
1470 ++input_line_pointer
;
1472 demand_empty_rest_of_line ();
1475 listing_source_file (s
);
1483 /* Handle the .appline pseudo-op. This is automatically generated by
1484 do_scrub_chars when a preprocessor # line comment is seen. This
1485 default definition may be overridden by the object or CPU specific
1494 /* The given number is that of the next line. */
1495 l
= get_absolute_expression () - 1;
1497 /* Some of the back ends can't deal with non-positive line numbers.
1498 Besides, it's silly. */
1499 as_warn ("Line numbers must be positive; line number %d rejected.", l
+1);
1502 new_logical_line ((char *) NULL
, l
);
1505 listing_source_line (l
);
1508 demand_empty_rest_of_line ();
1511 /* Handle the .end pseudo-op. Actually, the real work is done in
1512 read_a_source_file. */
1520 /* The MRI assembler permits the start symbol to follow .end,
1521 but we don't support that. */
1523 if (! is_end_of_line
[(unsigned char) *input_line_pointer
]
1524 && *input_line_pointer
!= '*'
1525 && *input_line_pointer
!= '!')
1526 as_warn ("start address not supported");
1530 /* Handle the .err pseudo-op. */
1536 as_bad (".err encountered");
1537 demand_empty_rest_of_line ();
1540 /* Handle the MRI fail pseudo-op. */
1551 stop
= mri_comment_field (&stopc
);
1553 temp
= get_absolute_expression ();
1555 as_warn (".fail %ld encountered", (long) temp
);
1557 as_bad (".fail %ld encountered", (long) temp
);
1560 mri_comment_end (stop
, stopc
);
1562 demand_empty_rest_of_line ();
1569 long temp_repeat
= 0;
1571 register long temp_fill
= 0;
1574 #ifdef md_flush_pending_output
1575 md_flush_pending_output ();
1578 temp_repeat
= get_absolute_expression ();
1579 if (*input_line_pointer
== ',')
1581 input_line_pointer
++;
1582 temp_size
= get_absolute_expression ();
1583 if (*input_line_pointer
== ',')
1585 input_line_pointer
++;
1586 temp_fill
= get_absolute_expression ();
1589 /* This is to be compatible with BSD 4.2 AS, not for any rational reason. */
1590 #define BSD_FILL_SIZE_CROCK_8 (8)
1591 if (temp_size
> BSD_FILL_SIZE_CROCK_8
)
1593 as_warn (".fill size clamped to %d.", BSD_FILL_SIZE_CROCK_8
);
1594 temp_size
= BSD_FILL_SIZE_CROCK_8
;
1598 as_warn ("Size negative: .fill ignored.");
1601 else if (temp_repeat
<= 0)
1603 if (temp_repeat
< 0)
1604 as_warn ("Repeat < 0, .fill ignored");
1608 if (temp_size
&& !need_pass_2
)
1610 p
= frag_var (rs_fill
, (int) temp_size
, (int) temp_size
, (relax_substateT
) 0, (symbolS
*) 0, temp_repeat
, (char *) 0);
1611 memset (p
, 0, (unsigned int) temp_size
);
1612 /* The magic number BSD_FILL_SIZE_CROCK_4 is from BSD 4.2 VAX
1613 * flavoured AS. The following bizzare behaviour is to be
1614 * compatible with above. I guess they tried to take up to 8
1615 * bytes from a 4-byte expression and they forgot to sign
1616 * extend. Un*x Sux. */
1617 #define BSD_FILL_SIZE_CROCK_4 (4)
1618 md_number_to_chars (p
, (valueT
) temp_fill
,
1619 (temp_size
> BSD_FILL_SIZE_CROCK_4
1620 ? BSD_FILL_SIZE_CROCK_4
1621 : (int) temp_size
));
1622 /* Note: .fill (),0 emits no frag (since we are asked to .fill 0 bytes)
1623 * but emits no error message because it seems a legal thing to do.
1624 * It is a degenerate case of .fill but could be emitted by a compiler.
1627 demand_empty_rest_of_line ();
1641 stop
= mri_comment_field (&stopc
);
1645 name
= input_line_pointer
;
1646 c
= get_symbol_end ();
1647 symbolP
= symbol_find_or_make (name
);
1648 *input_line_pointer
= c
;
1650 S_SET_EXTERNAL (symbolP
);
1653 input_line_pointer
++;
1655 if (*input_line_pointer
== '\n')
1662 mri_comment_end (stop
, stopc
);
1664 demand_empty_rest_of_line ();
1667 /* Handle the MRI IRP and IRPC pseudo-ops. */
1679 as_where (&file
, &line
);
1682 while (! is_end_of_line
[(unsigned char) *input_line_pointer
])
1683 sb_add_char (&s
, *input_line_pointer
++);
1687 err
= expand_irp (irpc
, 0, &s
, &out
, get_line_sb
, '\0');
1689 as_bad_where (file
, line
, "%s", err
);
1693 input_scrub_include_sb (&out
, input_line_pointer
);
1695 buffer_limit
= input_scrub_next_buffer (&input_line_pointer
);
1698 /* Handle the .linkonce pseudo-op. This tells the assembler to mark
1699 the section to only be linked once. However, this is not supported
1700 by most object file formats. This takes an optional argument,
1701 which is what to do about duplicates. */
1707 enum linkonce_type type
;
1711 type
= LINKONCE_DISCARD
;
1713 if (! is_end_of_line
[(unsigned char) *input_line_pointer
])
1718 s
= input_line_pointer
;
1719 c
= get_symbol_end ();
1720 if (strcasecmp (s
, "discard") == 0)
1721 type
= LINKONCE_DISCARD
;
1722 else if (strcasecmp (s
, "one_only") == 0)
1723 type
= LINKONCE_ONE_ONLY
;
1724 else if (strcasecmp (s
, "same_size") == 0)
1725 type
= LINKONCE_SAME_SIZE
;
1726 else if (strcasecmp (s
, "same_contents") == 0)
1727 type
= LINKONCE_SAME_CONTENTS
;
1729 as_warn ("unrecognized .linkonce type `%s'", s
);
1731 *input_line_pointer
= c
;
1734 #ifdef obj_handle_link_once
1735 obj_handle_link_once (type
);
1736 #else /* ! defined (obj_handle_link_once) */
1737 #ifdef BFD_ASSEMBLER
1741 if ((bfd_applicable_section_flags (stdoutput
) & SEC_LINK_ONCE
) == 0)
1742 as_warn (".linkonce is not supported for this object file format");
1744 flags
= bfd_get_section_flags (stdoutput
, now_seg
);
1745 flags
|= SEC_LINK_ONCE
;
1750 case LINKONCE_DISCARD
:
1751 flags
|= SEC_LINK_DUPLICATES_DISCARD
;
1753 case LINKONCE_ONE_ONLY
:
1754 flags
|= SEC_LINK_DUPLICATES_ONE_ONLY
;
1756 case LINKONCE_SAME_SIZE
:
1757 flags
|= SEC_LINK_DUPLICATES_SAME_SIZE
;
1759 case LINKONCE_SAME_CONTENTS
:
1760 flags
|= SEC_LINK_DUPLICATES_SAME_CONTENTS
;
1763 if (! bfd_set_section_flags (stdoutput
, now_seg
, flags
))
1764 as_bad ("bfd_set_section_flags: %s",
1765 bfd_errmsg (bfd_get_error ()));
1767 #else /* ! defined (BFD_ASSEMBLER) */
1768 as_warn (".linkonce is not supported for this object file format");
1769 #endif /* ! defined (BFD_ASSEMBLER) */
1770 #endif /* ! defined (obj_handle_link_once) */
1772 demand_empty_rest_of_line ();
1776 s_lcomm (needs_align
)
1777 /* 1 if this was a ".bss" directive, which may require a 3rd argument
1778 (alignment); 0 if it was an ".lcomm" (2 args only) */
1781 register char *name
;
1785 register symbolS
*symbolP
;
1786 segT current_seg
= now_seg
;
1787 subsegT current_subseg
= now_subseg
;
1788 const int max_alignment
= 15;
1790 segT bss_seg
= bss_section
;
1792 name
= input_line_pointer
;
1793 c
= get_symbol_end ();
1794 p
= input_line_pointer
;
1798 /* Accept an optional comma after the name. The comma used to be
1799 required, but Irix 5 cc does not generate it. */
1800 if (*input_line_pointer
== ',')
1802 ++input_line_pointer
;
1806 if (*input_line_pointer
== '\n')
1808 as_bad ("Missing size expression");
1812 if ((temp
= get_absolute_expression ()) < 0)
1814 as_warn ("BSS length (%d.) <0! Ignored.", temp
);
1815 ignore_rest_of_line ();
1819 #if defined (TC_MIPS) || defined (TC_ALPHA)
1820 if (OUTPUT_FLAVOR
== bfd_target_ecoff_flavour
1821 || OUTPUT_FLAVOR
== bfd_target_elf_flavour
)
1823 /* For MIPS and Alpha ECOFF or ELF, small objects are put in .sbss. */
1824 if (temp
<= bfd_get_gp_size (stdoutput
))
1826 bss_seg
= subseg_new (".sbss", 1);
1827 seg_info (bss_seg
)->bss
= 1;
1828 #ifdef BFD_ASSEMBLER
1829 if (! bfd_set_section_flags (stdoutput
, bss_seg
, SEC_ALLOC
))
1830 as_warn ("error setting flags for \".sbss\": %s",
1831 bfd_errmsg (bfd_get_error ()));
1838 /* FIXME. This needs to be machine independent. */
1849 /* FIXME: This needs to be done in a more general fashion. */
1853 record_alignment(bss_seg
, align
);
1860 if (*input_line_pointer
!= ',')
1862 as_bad ("Expected comma after size");
1863 ignore_rest_of_line ();
1866 input_line_pointer
++;
1868 if (*input_line_pointer
== '\n')
1870 as_bad ("Missing alignment");
1873 align
= get_absolute_expression ();
1874 if (align
> max_alignment
)
1876 align
= max_alignment
;
1877 as_warn ("Alignment too large: %d. assumed.", align
);
1882 as_warn ("Alignment negative. 0 assumed.");
1884 record_alignment (bss_seg
, align
);
1885 } /* if needs align */
1888 /* Assume some objects may require alignment on some systems. */
1889 #if defined (TC_ALPHA) && ! defined (VMS)
1892 align
= ffs (temp
) - 1;
1893 if (temp
% (1 << align
))
1900 symbolP
= symbol_find_or_make (name
);
1904 #if defined(OBJ_AOUT) | defined(OBJ_BOUT)
1905 S_GET_OTHER (symbolP
) == 0 &&
1906 S_GET_DESC (symbolP
) == 0 &&
1907 #endif /* OBJ_AOUT or OBJ_BOUT */
1908 (S_GET_SEGMENT (symbolP
) == bss_seg
1909 || (!S_IS_DEFINED (symbolP
) && S_GET_VALUE (symbolP
) == 0)))
1913 subseg_set (bss_seg
, 1);
1916 frag_align (align
, 0);
1917 /* detach from old frag */
1918 if (S_GET_SEGMENT (symbolP
) == bss_seg
)
1919 symbolP
->sy_frag
->fr_symbol
= NULL
;
1921 symbolP
->sy_frag
= frag_now
;
1922 pfrag
= frag_var (rs_org
, 1, 1, (relax_substateT
)0, symbolP
,
1926 S_SET_SEGMENT (symbolP
, bss_seg
);
1929 /* The symbol may already have been created with a preceding
1930 ".globl" directive -- be careful not to step on storage class
1931 in that case. Otherwise, set it to static. */
1932 if (S_GET_STORAGE_CLASS (symbolP
) != C_EXT
)
1934 S_SET_STORAGE_CLASS (symbolP
, C_STAT
);
1936 #endif /* OBJ_COFF */
1939 S_SET_SIZE (symbolP
, temp
);
1943 as_bad ("Ignoring attempt to re-define symbol `%s'.",
1944 S_GET_NAME (symbolP
));
1946 subseg_set (current_seg
, current_subseg
);
1948 demand_empty_rest_of_line ();
1955 register char *name
;
1959 register symbolS
*symbolP
;
1961 /* we permit ANY defined expression: BSD4.2 demands constants */
1962 name
= input_line_pointer
;
1963 c
= get_symbol_end ();
1964 p
= input_line_pointer
;
1967 if (*input_line_pointer
!= ',')
1970 as_bad ("Expected comma after name \"%s\"", name
);
1972 ignore_rest_of_line ();
1975 input_line_pointer
++;
1977 if (exp
.X_op
!= O_constant
1978 && exp
.X_op
!= O_register
)
1980 as_bad ("bad expression");
1981 ignore_rest_of_line ();
1985 symbolP
= symbol_find_or_make (name
);
1987 /* FIXME-SOON I pulled a (&& symbolP->sy_other == 0 &&
1988 symbolP->sy_desc == 0) out of this test because coff doesn't have
1989 those fields, and I can't see when they'd ever be tripped. I
1990 don't think I understand why they were here so I may have
1991 introduced a bug. As recently as 1.37 didn't have this test
1992 anyway. xoxorich. */
1994 if (S_GET_SEGMENT (symbolP
) == undefined_section
1995 && S_GET_VALUE (symbolP
) == 0)
1997 /* The name might be an undefined .global symbol; be sure to
1998 keep the "external" bit. */
1999 S_SET_SEGMENT (symbolP
,
2000 (exp
.X_op
== O_constant
2003 S_SET_VALUE (symbolP
, (valueT
) exp
.X_add_number
);
2007 as_bad ("Symbol %s already defined", name
);
2010 demand_empty_rest_of_line ();
2013 /* Read a line into an sb. */
2019 if (input_line_pointer
[-1] == '\n')
2020 bump_line_counters ();
2022 if (input_line_pointer
>= buffer_limit
)
2024 buffer_limit
= input_scrub_next_buffer (&input_line_pointer
);
2025 if (buffer_limit
== 0)
2029 while (! is_end_of_line
[(unsigned char) *input_line_pointer
])
2030 sb_add_char (line
, *input_line_pointer
++);
2031 while (input_line_pointer
< buffer_limit
2032 && is_end_of_line
[(unsigned char) *input_line_pointer
])
2034 if (input_line_pointer
[-1] == '\n')
2035 bump_line_counters ();
2036 ++input_line_pointer
;
2041 /* Define a macro. This is an interface to macro.c, which is shared
2042 between gas and gasp. */
2055 as_where (&file
, &line
);
2058 while (! is_end_of_line
[(unsigned char) *input_line_pointer
])
2059 sb_add_char (&s
, *input_line_pointer
++);
2062 if (line_label
!= NULL
)
2063 sb_add_string (&label
, S_GET_NAME (line_label
));
2065 err
= define_macro (0, &s
, &label
, get_line_sb
, &name
);
2067 as_bad_where (file
, line
, "%s", err
);
2070 if (line_label
!= NULL
)
2072 S_SET_SEGMENT (line_label
, undefined_section
);
2073 S_SET_VALUE (line_label
, 0);
2074 line_label
->sy_frag
= &zero_address_frag
;
2078 #ifdef NO_PSEUDO_DOT
2082 && hash_find (po_hash
, name
) != NULL
)
2085 && hash_find (po_hash
, name
+ 1) != NULL
))
2086 as_warn ("attempt to redefine pseudo-op `%s' ignored",
2093 /* Handle the .mexit pseudo-op, which immediately exits a macro
2100 buffer_limit
= input_scrub_next_buffer (&input_line_pointer
);
2103 /* Switch in and out of MRI mode. */
2111 on
= get_absolute_expression ();
2112 old_flag
= flag_mri
;
2126 #ifdef MRI_MODE_CHANGE
2128 MRI_MODE_CHANGE (on
);
2131 demand_empty_rest_of_line ();
2134 /* Handle changing the location counter. */
2137 do_org (segment
, exp
, fill
)
2142 if (segment
!= now_seg
&& segment
!= absolute_section
)
2143 as_bad ("invalid segment \"%s\"; segment \"%s\" assumed",
2144 segment_name (segment
), segment_name (now_seg
));
2146 if (now_seg
== absolute_section
)
2149 as_warn ("ignoring fill value in absolute section");
2150 if (exp
->X_op
!= O_constant
)
2152 as_bad ("only constant offsets supported in absolute section");
2153 exp
->X_add_number
= 0;
2155 abs_section_offset
= exp
->X_add_number
;
2161 p
= frag_var (rs_org
, 1, 1, (relax_substateT
) 0, exp
->X_add_symbol
,
2162 exp
->X_add_number
, (char *) NULL
);
2171 register segT segment
;
2173 register long temp_fill
;
2175 /* The m68k MRI assembler has a different meaning for .org. It
2176 means to create an absolute section at a given address. We can't
2177 support that--use a linker script instead. */
2180 as_bad ("MRI style ORG pseudo-op not supported");
2181 ignore_rest_of_line ();
2185 /* Don't believe the documentation of BSD 4.2 AS. There is no such
2186 thing as a sub-segment-relative origin. Any absolute origin is
2187 given a warning, then assumed to be segment-relative. Any
2188 segmented origin expression ("foo+42") had better be in the right
2189 segment or the .org is ignored.
2191 BSD 4.2 AS warns if you try to .org backwards. We cannot because
2192 we never know sub-segment sizes when we are reading code. BSD
2193 will crash trying to emit negative numbers of filler bytes in
2194 certain .orgs. We don't crash, but see as-write for that code.
2196 Don't make frag if need_pass_2==1. */
2197 segment
= get_known_segmented_expression (&exp
);
2198 if (*input_line_pointer
== ',')
2200 input_line_pointer
++;
2201 temp_fill
= get_absolute_expression ();
2207 do_org (segment
, &exp
, temp_fill
);
2209 demand_empty_rest_of_line ();
2212 /* Handle parsing for the MRI SECT/SECTION pseudo-op. This should be
2213 called by the obj-format routine which handles section changing
2214 when in MRI mode. It will create a new section, and return it. It
2215 will set *TYPE to the section type: one of 'C' (code), 'D' (data),
2216 'M' (mixed), or 'R' (romable). If BFD_ASSEMBLER is defined, the
2217 flags will be set in the section. */
2231 name
= input_line_pointer
;
2232 if (! isdigit ((unsigned char) *name
))
2233 c
= get_symbol_end ();
2238 ++input_line_pointer
;
2240 while (isdigit ((unsigned char) *input_line_pointer
));
2241 c
= *input_line_pointer
;
2242 *input_line_pointer
= '\0';
2245 name
= xstrdup (name
);
2247 *input_line_pointer
= c
;
2249 seg
= subseg_new (name
, 0);
2251 if (*input_line_pointer
== ',')
2255 ++input_line_pointer
;
2256 align
= get_absolute_expression ();
2257 record_alignment (seg
, align
);
2261 if (*input_line_pointer
== ',')
2263 c
= *++input_line_pointer
;
2264 c
= toupper ((unsigned char) c
);
2265 if (c
== 'C' || c
== 'D' || c
== 'M' || c
== 'R')
2268 as_bad ("unrecognized section type");
2269 ++input_line_pointer
;
2271 #ifdef BFD_ASSEMBLER
2275 flags
= SEC_NO_FLAGS
;
2277 flags
= SEC_ALLOC
| SEC_LOAD
| SEC_READONLY
| SEC_CODE
;
2278 else if (*type
== 'D' || *type
== 'M')
2279 flags
= SEC_ALLOC
| SEC_LOAD
| SEC_DATA
;
2280 else if (*type
== 'R')
2281 flags
= SEC_ALLOC
| SEC_LOAD
| SEC_DATA
| SEC_READONLY
| SEC_ROM
;
2282 if (flags
!= SEC_NO_FLAGS
)
2284 if (! bfd_set_section_flags (stdoutput
, seg
, flags
))
2285 as_warn ("error setting flags for \"%s\": %s",
2286 bfd_section_name (stdoutput
, seg
),
2287 bfd_errmsg (bfd_get_error ()));
2293 /* Ignore the HP type. */
2294 if (*input_line_pointer
== ',')
2295 input_line_pointer
+= 2;
2297 demand_empty_rest_of_line ();
2299 #else /* ! TC_M68K */
2308 name
= input_line_pointer
;
2309 c
= get_symbol_end ();
2311 name
= xstrdup (name
);
2313 *input_line_pointer
= c
;
2315 seg
= subseg_new (name
, 0);
2317 if (*input_line_pointer
!= ',')
2323 ++input_line_pointer
;
2325 sectype
= input_line_pointer
;
2326 c
= get_symbol_end ();
2327 if (*sectype
== '\0')
2329 else if (strcasecmp (sectype
, "text") == 0)
2331 else if (strcasecmp (sectype
, "data") == 0)
2333 else if (strcasecmp (sectype
, "romdata") == 0)
2336 as_warn ("unrecognized section type `%s'", sectype
);
2337 *input_line_pointer
= c
;
2340 if (*input_line_pointer
== ',')
2344 ++input_line_pointer
;
2346 seccmd
= input_line_pointer
;
2347 c
= get_symbol_end ();
2348 if (strcasecmp (seccmd
, "absolute") == 0)
2350 as_bad ("absolute sections are not supported");
2351 *input_line_pointer
= c
;
2352 ignore_rest_of_line ();
2355 else if (strcasecmp (seccmd
, "align") == 0)
2359 *input_line_pointer
= c
;
2360 align
= get_absolute_expression ();
2361 record_alignment (seg
, align
);
2365 as_warn ("unrecognized section command `%s'", seccmd
);
2366 *input_line_pointer
= c
;
2370 demand_empty_rest_of_line ();
2372 #else /* ! TC_I960 */
2373 /* The MRI assembler seems to use different forms of .sect for
2374 different targets. */
2376 #endif /* ! TC_I960 */
2377 #endif /* ! TC_M68K */
2380 /* Handle the .print pseudo-op. */
2389 s
= demand_copy_C_string (&len
);
2391 demand_empty_rest_of_line ();
2394 /* Handle the .purgem pseudo-op. */
2400 if (is_it_end_of_statement ())
2402 demand_empty_rest_of_line ();
2412 name
= input_line_pointer
;
2413 c
= get_symbol_end ();
2414 delete_macro (name
);
2415 *input_line_pointer
= c
;
2418 while (*input_line_pointer
++ == ',');
2420 --input_line_pointer
;
2421 demand_empty_rest_of_line ();
2424 /* Handle the .rept pseudo-op. */
2434 count
= get_absolute_expression ();
2437 if (! buffer_and_nest ("REPT", "ENDR", &one
, get_line_sb
))
2439 as_bad ("rept without endr");
2445 sb_add_sb (&many
, &one
);
2449 input_scrub_include_sb (&many
, input_line_pointer
);
2451 buffer_limit
= input_scrub_next_buffer (&input_line_pointer
);
2458 register char *name
;
2459 register char delim
;
2460 register char *end_name
;
2461 register symbolS
*symbolP
;
2464 * Especial apologies for the random logic:
2465 * this just grew, and could be parsed much more simply!
2468 name
= input_line_pointer
;
2469 delim
= get_symbol_end ();
2470 end_name
= input_line_pointer
;
2474 if (*input_line_pointer
!= ',')
2477 as_bad ("Expected comma after name \"%s\"", name
);
2479 ignore_rest_of_line ();
2483 input_line_pointer
++;
2486 if (name
[0] == '.' && name
[1] == '\0')
2488 /* Turn '. = mumble' into a .org mumble */
2489 register segT segment
;
2492 segment
= get_known_segmented_expression (&exp
);
2495 do_org (segment
, &exp
, 0);
2501 if ((symbolP
= symbol_find (name
)) == NULL
2502 && (symbolP
= md_undefined_symbol (name
)) == NULL
)
2504 symbolP
= symbol_new (name
, undefined_section
, 0, &zero_address_frag
);
2506 /* "set" symbols are local unless otherwise specified. */
2507 SF_SET_LOCAL (symbolP
);
2508 #endif /* OBJ_COFF */
2510 } /* make a new symbol */
2512 symbol_table_insert (symbolP
);
2515 pseudo_set (symbolP
);
2516 demand_empty_rest_of_line ();
2529 #ifdef md_flush_pending_output
2530 md_flush_pending_output ();
2534 stop
= mri_comment_field (&stopc
);
2536 /* In m68k MRI mode, we need to align to a word boundary, unless
2538 if (flag_m68k_mri
&& mult
> 1)
2540 if (now_seg
== absolute_section
)
2542 abs_section_offset
+= abs_section_offset
& 1;
2543 if (line_label
!= NULL
)
2544 S_SET_VALUE (line_label
, abs_section_offset
);
2546 else if (mri_common_symbol
!= NULL
)
2550 val
= S_GET_VALUE (mri_common_symbol
);
2553 S_SET_VALUE (mri_common_symbol
, val
+ 1);
2554 if (line_label
!= NULL
)
2556 know (line_label
->sy_value
.X_op
== O_symbol
);
2557 know (line_label
->sy_value
.X_add_symbol
== mri_common_symbol
);
2558 line_label
->sy_value
.X_add_number
+= 1;
2564 do_align (1, (char *) NULL
, 0);
2565 if (line_label
!= NULL
)
2567 line_label
->sy_frag
= frag_now
;
2568 S_SET_VALUE (line_label
, frag_now_fix ());
2576 if (*input_line_pointer
== ',')
2578 ++input_line_pointer
;
2583 val
.X_op
= O_constant
;
2584 val
.X_add_number
= 0;
2587 if (val
.X_op
!= O_constant
2588 || val
.X_add_number
< - 0x80
2589 || val
.X_add_number
> 0xff
2590 || (mult
!= 0 && mult
!= 1 && val
.X_add_number
!= 0))
2592 if (exp
.X_op
!= O_constant
)
2593 as_bad ("Unsupported variable size or fill value");
2600 for (i
= 0; i
< exp
.X_add_number
; i
++)
2601 emit_expr (&val
, mult
);
2606 if (exp
.X_op
== O_constant
)
2610 repeat
= exp
.X_add_number
;
2615 if (! flag_mri
|| repeat
< 0)
2616 as_warn (".space repeat count is %s, ignored",
2617 repeat
? "negative" : "zero");
2621 /* If we are in the absolute section, just bump the offset. */
2622 if (now_seg
== absolute_section
)
2624 abs_section_offset
+= repeat
;
2628 /* If we are secretly in an MRI common section, then
2629 creating space just increases the size of the common
2631 if (mri_common_symbol
!= NULL
)
2633 S_SET_VALUE (mri_common_symbol
,
2634 S_GET_VALUE (mri_common_symbol
) + repeat
);
2639 p
= frag_var (rs_fill
, 1, 1, (relax_substateT
) 0, (symbolS
*) 0,
2640 repeat
, (char *) 0);
2644 if (now_seg
== absolute_section
)
2646 as_bad ("space allocation too complex in absolute section");
2647 subseg_set (text_section
, 0);
2649 if (mri_common_symbol
!= NULL
)
2651 as_bad ("space allocation too complex in common section");
2652 mri_common_symbol
= NULL
;
2655 p
= frag_var (rs_space
, 1, 1, (relax_substateT
) 0,
2656 make_expr_symbol (&exp
), 0L, (char *) 0);
2660 *p
= val
.X_add_number
;
2665 mri_comment_end (stop
, stopc
);
2667 demand_empty_rest_of_line ();
2670 /* This is like s_space, but the value is a floating point number with
2671 the given precision. This is for the MRI dcb.s pseudo-op and
2675 s_float_space (float_type
)
2680 char temp
[MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT
];
2685 stop
= mri_comment_field (&stopc
);
2687 count
= get_absolute_expression ();
2690 if (*input_line_pointer
!= ',')
2692 as_bad ("missing value");
2694 mri_comment_end (stop
, stopc
);
2695 ignore_rest_of_line ();
2699 ++input_line_pointer
;
2703 /* Skip any 0{letter} that may be present. Don't even check if the
2704 * letter is legal. */
2705 if (input_line_pointer
[0] == '0' && isalpha (input_line_pointer
[1]))
2706 input_line_pointer
+= 2;
2708 /* Accept :xxxx, where the x's are hex digits, for a floating point
2709 with the exact digits specified. */
2710 if (input_line_pointer
[0] == ':')
2712 flen
= hex_float (float_type
, temp
);
2716 mri_comment_end (stop
, stopc
);
2717 ignore_rest_of_line ();
2725 err
= md_atof (float_type
, temp
, &flen
);
2726 know (flen
<= MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT
);
2730 as_bad ("Bad floating literal: %s", err
);
2732 mri_comment_end (stop
, stopc
);
2733 ignore_rest_of_line ();
2738 while (--count
>= 0)
2742 p
= frag_more (flen
);
2743 memcpy (p
, temp
, (unsigned int) flen
);
2747 mri_comment_end (stop
, stopc
);
2749 demand_empty_rest_of_line ();
2752 /* Handle the .struct pseudo-op, as found in MIPS assemblers. */
2762 stop
= mri_comment_field (&stopc
);
2763 abs_section_offset
= get_absolute_expression ();
2764 subseg_set (absolute_section
, 0);
2766 mri_comment_end (stop
, stopc
);
2767 demand_empty_rest_of_line ();
2776 temp
= get_absolute_expression ();
2777 subseg_set (text_section
, (subsegT
) temp
);
2778 demand_empty_rest_of_line ();
2780 const_flag
&= ~IN_DEFAULT_SECTION
;
2786 demand_empty_rest_of_line ()
2789 if (is_end_of_line
[(unsigned char) *input_line_pointer
])
2791 input_line_pointer
++;
2795 ignore_rest_of_line ();
2797 /* Return having already swallowed end-of-line. */
2798 } /* Return pointing just after end-of-line. */
2801 ignore_rest_of_line () /* For suspect lines: gives warning. */
2803 if (!is_end_of_line
[(unsigned char) *input_line_pointer
])
2805 if (isprint (*input_line_pointer
))
2806 as_bad ("Rest of line ignored. First ignored character is `%c'.",
2807 *input_line_pointer
);
2809 as_bad ("Rest of line ignored. First ignored character valued 0x%x.",
2810 *input_line_pointer
);
2811 while (input_line_pointer
< buffer_limit
2812 && !is_end_of_line
[(unsigned char) *input_line_pointer
])
2814 input_line_pointer
++;
2817 input_line_pointer
++; /* Return pointing just after end-of-line. */
2818 know (is_end_of_line
[(unsigned char) input_line_pointer
[-1]]);
2824 * In: Pointer to a symbol.
2825 * Input_line_pointer->expression.
2827 * Out: Input_line_pointer->just after any whitespace after expression.
2828 * Tried to set symbol to value of expression.
2829 * Will change symbols type, value, and frag;
2832 pseudo_set (symbolP
)
2836 #if (defined (OBJ_AOUT) || defined (OBJ_BOUT)) && ! defined (BFD_ASSEMBLER)
2838 #endif /* OBJ_AOUT or OBJ_BOUT */
2840 know (symbolP
); /* NULL pointer is logic error. */
2841 #if (defined (OBJ_AOUT) || defined (OBJ_BOUT)) && ! defined (BFD_ASSEMBLER)
2842 ext
= S_IS_EXTERNAL (symbolP
);
2843 #endif /* OBJ_AOUT or OBJ_BOUT */
2845 (void) expression (&exp
);
2847 if (exp
.X_op
== O_illegal
)
2848 as_bad ("illegal expression; zero assumed");
2849 else if (exp
.X_op
== O_absent
)
2850 as_bad ("missing expression; zero assumed");
2851 else if (exp
.X_op
== O_big
)
2852 as_bad ("%s number invalid; zero assumed",
2853 exp
.X_add_number
> 0 ? "bignum" : "floating point");
2854 else if (exp
.X_op
== O_subtract
2855 && (S_GET_SEGMENT (exp
.X_add_symbol
)
2856 == S_GET_SEGMENT (exp
.X_op_symbol
))
2857 && SEG_NORMAL (S_GET_SEGMENT (exp
.X_add_symbol
))
2858 && exp
.X_add_symbol
->sy_frag
== exp
.X_op_symbol
->sy_frag
)
2860 exp
.X_op
= O_constant
;
2861 exp
.X_add_number
= (S_GET_VALUE (exp
.X_add_symbol
)
2862 - S_GET_VALUE (exp
.X_op_symbol
));
2870 exp
.X_add_number
= 0;
2873 S_SET_SEGMENT (symbolP
, absolute_section
);
2874 #if (defined (OBJ_AOUT) || defined (OBJ_BOUT)) && ! defined (BFD_ASSEMBLER)
2876 S_SET_EXTERNAL (symbolP
);
2878 S_CLEAR_EXTERNAL (symbolP
);
2879 #endif /* OBJ_AOUT or OBJ_BOUT */
2880 S_SET_VALUE (symbolP
, (valueT
) exp
.X_add_number
);
2881 symbolP
->sy_frag
= &zero_address_frag
;
2885 S_SET_SEGMENT (symbolP
, reg_section
);
2886 S_SET_VALUE (symbolP
, (valueT
) exp
.X_add_number
);
2887 symbolP
->sy_frag
= &zero_address_frag
;
2891 if (S_GET_SEGMENT (exp
.X_add_symbol
) == undefined_section
2892 || exp
.X_add_number
!= 0)
2893 symbolP
->sy_value
= exp
;
2896 symbolS
*s
= exp
.X_add_symbol
;
2898 S_SET_SEGMENT (symbolP
, S_GET_SEGMENT (s
));
2899 #if (defined (OBJ_AOUT) || defined (OBJ_BOUT)) && ! defined (BFD_ASSEMBLER)
2901 S_SET_EXTERNAL (symbolP
);
2903 S_CLEAR_EXTERNAL (symbolP
);
2904 #endif /* OBJ_AOUT or OBJ_BOUT */
2905 S_SET_VALUE (symbolP
,
2906 exp
.X_add_number
+ S_GET_VALUE (s
));
2907 symbolP
->sy_frag
= s
->sy_frag
;
2908 copy_symbol_attributes (symbolP
, s
);
2913 /* The value is some complex expression.
2914 FIXME: Should we set the segment to anything? */
2915 symbolP
->sy_value
= exp
;
2923 * CONStruct more frag of .bytes, or .words etc.
2924 * Should need_pass_2 be 1 then emit no frag(s).
2925 * This understands EXPRESSIONS.
2929 * This has a split personality. We use expression() to read the
2930 * value. We can detect if the value won't fit in a byte or word.
2931 * But we can't detect if expression() discarded significant digits
2932 * in the case of a long. Not worth the crocks required to fix it.
2935 /* Select a parser for cons expressions. */
2937 /* Some targets need to parse the expression in various fancy ways.
2938 You can define TC_PARSE_CONS_EXPRESSION to do whatever you like
2939 (for example, the HPPA does this). Otherwise, you can define
2940 BITFIELD_CONS_EXPRESSIONS to permit bitfields to be specified, or
2941 REPEAT_CONS_EXPRESSIONS to permit repeat counts. If none of these
2942 are defined, which is the normal case, then only simple expressions
2946 parse_mri_cons
PARAMS ((expressionS
*exp
, unsigned int nbytes
));
2948 #ifndef TC_PARSE_CONS_EXPRESSION
2949 #ifdef BITFIELD_CONS_EXPRESSIONS
2950 #define TC_PARSE_CONS_EXPRESSION(EXP, NBYTES) parse_bitfield_cons (EXP, NBYTES)
2952 parse_bitfield_cons
PARAMS ((expressionS
*exp
, unsigned int nbytes
));
2954 #ifdef REPEAT_CONS_EXPRESSIONS
2955 #define TC_PARSE_CONS_EXPRESSION(EXP, NBYTES) parse_repeat_cons (EXP, NBYTES)
2957 parse_repeat_cons
PARAMS ((expressionS
*exp
, unsigned int nbytes
));
2960 /* If we haven't gotten one yet, just call expression. */
2961 #ifndef TC_PARSE_CONS_EXPRESSION
2962 #define TC_PARSE_CONS_EXPRESSION(EXP, NBYTES) expression (EXP)
2966 /* worker to do .byte etc statements */
2967 /* clobbers input_line_pointer, checks */
2970 cons_worker (nbytes
, rva
)
2971 register int nbytes
; /* 1=.byte, 2=.word, 4=.long */
2979 #ifdef md_flush_pending_output
2980 md_flush_pending_output ();
2984 stop
= mri_comment_field (&stopc
);
2986 if (is_it_end_of_statement ())
2989 mri_comment_end (stop
, stopc
);
2990 demand_empty_rest_of_line ();
2994 #ifdef md_cons_align
2995 md_cons_align (nbytes
);
3002 parse_mri_cons (&exp
, (unsigned int) nbytes
);
3004 TC_PARSE_CONS_EXPRESSION (&exp
, (unsigned int) nbytes
);
3008 if (exp
.X_op
== O_symbol
)
3009 exp
.X_op
= O_symbol_rva
;
3011 as_fatal ("rva without symbol");
3013 emit_expr (&exp
, (unsigned int) nbytes
);
3016 while (*input_line_pointer
++ == ',');
3018 /* In MRI mode, after an odd number of bytes, we must align to an
3019 even word boundary, unless the next instruction is a dc.b, ds.b
3021 if (flag_mri
&& nbytes
== 1 && (c
& 1) != 0)
3022 mri_pending_align
= 1;
3024 input_line_pointer
--; /* Put terminator back into stream. */
3027 mri_comment_end (stop
, stopc
);
3029 demand_empty_rest_of_line ();
3037 cons_worker (size
, 0);
3044 cons_worker (size
, 1);
3048 /* Put the contents of expression EXP into the object file using
3049 NBYTES bytes. If need_pass_2 is 1, this does nothing. */
3052 emit_expr (exp
, nbytes
)
3054 unsigned int nbytes
;
3058 valueT extra_digit
= 0;
3060 /* Don't do anything if we are going to make another pass. */
3066 /* Allow `.word 0' in the absolute section. */
3067 if (now_seg
== absolute_section
)
3069 if (op
!= O_constant
|| exp
->X_add_number
!= 0)
3070 as_bad ("attempt to store value in absolute section");
3071 abs_section_offset
+= nbytes
;
3075 /* Handle a negative bignum. */
3077 && exp
->X_add_number
== 0
3078 && exp
->X_add_symbol
->sy_value
.X_op
== O_big
3079 && exp
->X_add_symbol
->sy_value
.X_add_number
> 0)
3082 unsigned long carry
;
3084 exp
= &exp
->X_add_symbol
->sy_value
;
3086 /* Negate the bignum: one's complement each digit and add 1. */
3088 for (i
= 0; i
< exp
->X_add_number
; i
++)
3092 next
= (((~ (generic_bignum
[i
] & LITTLENUM_MASK
))
3095 generic_bignum
[i
] = next
& LITTLENUM_MASK
;
3096 carry
= next
>> LITTLENUM_NUMBER_OF_BITS
;
3099 /* We can ignore any carry out, because it will be handled by
3100 extra_digit if it is needed. */
3102 extra_digit
= (valueT
) -1;
3106 if (op
== O_absent
|| op
== O_illegal
)
3108 as_warn ("zero assumed for missing expression");
3109 exp
->X_add_number
= 0;
3112 else if (op
== O_big
&& exp
->X_add_number
<= 0)
3114 as_bad ("floating point number invalid; zero assumed");
3115 exp
->X_add_number
= 0;
3118 else if (op
== O_register
)
3120 as_warn ("register value used as expression");
3124 p
= frag_more ((int) nbytes
);
3126 #ifndef WORKING_DOT_WORD
3127 /* If we have the difference of two symbols in a word, save it on
3128 the broken_words list. See the code in write.c. */
3129 if (op
== O_subtract
&& nbytes
== 2)
3131 struct broken_word
*x
;
3133 x
= (struct broken_word
*) xmalloc (sizeof (struct broken_word
));
3134 x
->next_broken_word
= broken_words
;
3137 x
->word_goes_here
= p
;
3139 x
->add
= exp
->X_add_symbol
;
3140 x
->sub
= exp
->X_op_symbol
;
3141 x
->addnum
= exp
->X_add_number
;
3148 /* If we have an integer, but the number of bytes is too large to
3149 pass to md_number_to_chars, handle it as a bignum. */
3150 if (op
== O_constant
&& nbytes
> sizeof (valueT
))
3155 if (! exp
->X_unsigned
&& exp
->X_add_number
< 0)
3156 extra_digit
= (valueT
) -1;
3157 val
= (valueT
) exp
->X_add_number
;
3161 generic_bignum
[gencnt
] = val
& LITTLENUM_MASK
;
3162 val
>>= LITTLENUM_NUMBER_OF_BITS
;
3166 op
= exp
->X_op
= O_big
;
3167 exp
->X_add_number
= gencnt
;
3170 if (op
== O_constant
)
3172 register valueT get
;
3173 register valueT use
;
3174 register valueT mask
;
3175 register valueT unmask
;
3177 /* JF << of >= number of bits in the object is undefined. In
3178 particular SPARC (Sun 4) has problems */
3179 if (nbytes
>= sizeof (valueT
))
3182 mask
= ~(valueT
) 0 << (BITS_PER_CHAR
* nbytes
); /* Don't store these bits. */
3184 unmask
= ~mask
; /* Do store these bits. */
3187 "Do this mod if you want every overflow check to assume SIGNED 2's complement data.";
3188 mask
= ~(unmask
>> 1); /* Includes sign bit now. */
3191 get
= exp
->X_add_number
;
3193 if ((get
& mask
) != 0 && (get
& mask
) != mask
)
3194 { /* Leading bits contain both 0s & 1s. */
3195 as_warn ("Value 0x%lx truncated to 0x%lx.",
3196 (unsigned long) get
, (unsigned long) use
);
3198 /* put bytes in right order. */
3199 md_number_to_chars (p
, use
, (int) nbytes
);
3201 else if (op
== O_big
)
3204 LITTLENUM_TYPE
*nums
;
3206 know (nbytes
% CHARS_PER_LITTLENUM
== 0);
3208 size
= exp
->X_add_number
* CHARS_PER_LITTLENUM
;
3211 as_warn ("Bignum truncated to %d bytes", nbytes
);
3215 if (target_big_endian
)
3217 while (nbytes
> size
)
3219 md_number_to_chars (p
, extra_digit
, CHARS_PER_LITTLENUM
);
3220 nbytes
-= CHARS_PER_LITTLENUM
;
3221 p
+= CHARS_PER_LITTLENUM
;
3224 nums
= generic_bignum
+ size
/ CHARS_PER_LITTLENUM
;
3228 md_number_to_chars (p
, (valueT
) *nums
, CHARS_PER_LITTLENUM
);
3229 size
-= CHARS_PER_LITTLENUM
;
3230 p
+= CHARS_PER_LITTLENUM
;
3235 nums
= generic_bignum
;
3238 md_number_to_chars (p
, (valueT
) *nums
, CHARS_PER_LITTLENUM
);
3240 size
-= CHARS_PER_LITTLENUM
;
3241 p
+= CHARS_PER_LITTLENUM
;
3242 nbytes
-= CHARS_PER_LITTLENUM
;
3247 md_number_to_chars (p
, extra_digit
, CHARS_PER_LITTLENUM
);
3248 nbytes
-= CHARS_PER_LITTLENUM
;
3249 p
+= CHARS_PER_LITTLENUM
;
3255 memset (p
, 0, nbytes
);
3257 /* Now we need to generate a fixS to record the symbol value.
3258 This is easy for BFD. For other targets it can be more
3259 complex. For very complex cases (currently, the HPPA and
3260 NS32K), you can define TC_CONS_FIX_NEW to do whatever you
3261 want. For simpler cases, you can define TC_CONS_RELOC to be
3262 the name of the reloc code that should be stored in the fixS.
3263 If neither is defined, the code uses NO_RELOC if it is
3264 defined, and otherwise uses 0. */
3266 #ifdef BFD_ASSEMBLER
3267 #ifdef TC_CONS_FIX_NEW
3268 TC_CONS_FIX_NEW (frag_now
, p
- frag_now
->fr_literal
, nbytes
, exp
);
3271 bfd_reloc_code_real_type r
;
3288 as_bad ("unsupported BFD relocation size %u", nbytes
);
3292 fix_new_exp (frag_now
, p
- frag_now
->fr_literal
, (int) nbytes
, exp
,
3297 #ifdef TC_CONS_FIX_NEW
3298 TC_CONS_FIX_NEW (frag_now
, p
- frag_now
->fr_literal
, nbytes
, exp
);
3300 /* Figure out which reloc number to use. Use TC_CONS_RELOC if
3301 it is defined, otherwise use NO_RELOC if it is defined,
3303 #ifndef TC_CONS_RELOC
3305 #define TC_CONS_RELOC NO_RELOC
3307 #define TC_CONS_RELOC 0
3310 fix_new_exp (frag_now
, p
- frag_now
->fr_literal
, (int) nbytes
, exp
, 0,
3312 #endif /* TC_CONS_FIX_NEW */
3313 #endif /* BFD_ASSEMBLER */
3317 #ifdef BITFIELD_CONS_EXPRESSIONS
3319 /* i960 assemblers, (eg, asm960), allow bitfields after ".byte" as
3320 w:x,y:z, where w and y are bitwidths and x and y are values. They
3321 then pack them all together. We do a little better in that we allow
3322 them in words, longs, etc. and we'll pack them in target byte order
3325 The rules are: pack least significat bit first, if a field doesn't
3326 entirely fit, put it in the next unit. Overflowing the bitfield is
3327 explicitly *not* even a warning. The bitwidth should be considered
3330 To use this function the tc-XXX.h file should define
3331 BITFIELD_CONS_EXPRESSIONS. */
3334 parse_bitfield_cons (exp
, nbytes
)
3336 unsigned int nbytes
;
3338 unsigned int bits_available
= BITS_PER_CHAR
* nbytes
;
3339 char *hold
= input_line_pointer
;
3341 (void) expression (exp
);
3343 if (*input_line_pointer
== ':')
3349 unsigned long width
;
3351 if (*input_line_pointer
!= ':')
3353 input_line_pointer
= hold
;
3355 } /* next piece is not a bitfield */
3357 /* In the general case, we can't allow
3358 full expressions with symbol
3359 differences and such. The relocation
3360 entries for symbols not defined in this
3361 assembly would require arbitrary field
3362 widths, positions, and masks which most
3363 of our current object formats don't
3366 In the specific case where a symbol
3367 *is* defined in this assembly, we
3368 *could* build fixups and track it, but
3369 this could lead to confusion for the
3370 backends. I'm lazy. I'll take any
3371 SEG_ABSOLUTE. I think that means that
3372 you can use a previous .set or
3373 .equ type symbol. xoxorich. */
3375 if (exp
->X_op
== O_absent
)
3377 as_warn ("using a bit field width of zero");
3378 exp
->X_add_number
= 0;
3379 exp
->X_op
= O_constant
;
3380 } /* implied zero width bitfield */
3382 if (exp
->X_op
!= O_constant
)
3384 *input_line_pointer
= '\0';
3385 as_bad ("field width \"%s\" too complex for a bitfield", hold
);
3386 *input_line_pointer
= ':';
3387 demand_empty_rest_of_line ();
3391 if ((width
= exp
->X_add_number
) > (BITS_PER_CHAR
* nbytes
))
3393 as_warn ("field width %lu too big to fit in %d bytes: truncated to %d bits",
3394 width
, nbytes
, (BITS_PER_CHAR
* nbytes
));
3395 width
= BITS_PER_CHAR
* nbytes
;
3398 if (width
> bits_available
)
3400 /* FIXME-SOMEDAY: backing up and reparsing is wasteful. */
3401 input_line_pointer
= hold
;
3402 exp
->X_add_number
= value
;
3406 hold
= ++input_line_pointer
; /* skip ':' */
3408 (void) expression (exp
);
3409 if (exp
->X_op
!= O_constant
)
3411 char cache
= *input_line_pointer
;
3413 *input_line_pointer
= '\0';
3414 as_bad ("field value \"%s\" too complex for a bitfield", hold
);
3415 *input_line_pointer
= cache
;
3416 demand_empty_rest_of_line ();
3420 value
|= ((~(-1 << width
) & exp
->X_add_number
)
3421 << ((BITS_PER_CHAR
* nbytes
) - bits_available
));
3423 if ((bits_available
-= width
) == 0
3424 || is_it_end_of_statement ()
3425 || *input_line_pointer
!= ',')
3428 } /* all the bitfields we're gonna get */
3430 hold
= ++input_line_pointer
;
3431 (void) expression (exp
);
3432 } /* forever loop */
3434 exp
->X_add_number
= value
;
3435 exp
->X_op
= O_constant
;
3436 exp
->X_unsigned
= 1;
3437 } /* if looks like a bitfield */
3438 } /* parse_bitfield_cons() */
3440 #endif /* BITFIELD_CONS_EXPRESSIONS */
3442 /* Handle an MRI style string expression. */
3445 parse_mri_cons (exp
, nbytes
)
3447 unsigned int nbytes
;
3449 if (*input_line_pointer
!= '\''
3450 && (input_line_pointer
[1] != '\''
3451 || (*input_line_pointer
!= 'A'
3452 && *input_line_pointer
!= 'E')))
3453 TC_PARSE_CONS_EXPRESSION (exp
, nbytes
);
3457 unsigned int result
= 0;
3459 /* An MRI style string. Cut into as many bytes as will fit into
3460 a nbyte chunk, left justify if necessary, and separate with
3461 commas so we can try again later. */
3462 if (*input_line_pointer
== 'A')
3463 ++input_line_pointer
;
3464 else if (*input_line_pointer
== 'E')
3466 as_bad ("EBCDIC constants are not supported");
3467 ++input_line_pointer
;
3470 input_line_pointer
++;
3471 for (scan
= 0; scan
< nbytes
; scan
++)
3473 if (*input_line_pointer
== '\'')
3475 if (input_line_pointer
[1] == '\'')
3477 input_line_pointer
++;
3482 result
= (result
<< 8) | (*input_line_pointer
++);
3486 while (scan
< nbytes
)
3491 /* Create correct expression */
3492 exp
->X_op
= O_constant
;
3493 exp
->X_add_number
= result
;
3494 /* Fake it so that we can read the next char too */
3495 if (input_line_pointer
[0] != '\'' ||
3496 (input_line_pointer
[0] == '\'' && input_line_pointer
[1] == '\''))
3498 input_line_pointer
-= 2;
3499 input_line_pointer
[0] = ',';
3500 input_line_pointer
[1] = '\'';
3503 input_line_pointer
++;
3507 #ifdef REPEAT_CONS_EXPRESSIONS
3509 /* Parse a repeat expression for cons. This is used by the MIPS
3510 assembler. The format is NUMBER:COUNT; NUMBER appears in the
3511 object file COUNT times.
3513 To use this for a target, define REPEAT_CONS_EXPRESSIONS. */
3516 parse_repeat_cons (exp
, nbytes
)
3518 unsigned int nbytes
;
3525 if (*input_line_pointer
!= ':')
3527 /* No repeat count. */
3531 ++input_line_pointer
;
3532 expression (&count
);
3533 if (count
.X_op
!= O_constant
3534 || count
.X_add_number
<= 0)
3536 as_warn ("Unresolvable or nonpositive repeat count; using 1");
3540 /* The cons function is going to output this expression once. So we
3541 output it count - 1 times. */
3542 for (i
= count
.X_add_number
- 1; i
> 0; i
--)
3543 emit_expr (exp
, nbytes
);
3546 #endif /* REPEAT_CONS_EXPRESSIONS */
3548 /* Parse a floating point number represented as a hex constant. This
3549 permits users to specify the exact bits they want in the floating
3553 hex_float (float_type
, bytes
)
3587 as_bad ("Unknown floating type type '%c'", float_type
);
3591 /* It would be nice if we could go through expression to parse the
3592 hex constant, but if we get a bignum it's a pain to sort it into
3593 the buffer correctly. */
3595 while (hex_p (*input_line_pointer
) || *input_line_pointer
== '_')
3599 /* The MRI assembler accepts arbitrary underscores strewn about
3600 through the hex constant, so we ignore them as well. */
3601 if (*input_line_pointer
== '_')
3603 ++input_line_pointer
;
3609 as_warn ("Floating point constant too large");
3612 d
= hex_value (*input_line_pointer
) << 4;
3613 ++input_line_pointer
;
3614 while (*input_line_pointer
== '_')
3615 ++input_line_pointer
;
3616 if (hex_p (*input_line_pointer
))
3618 d
+= hex_value (*input_line_pointer
);
3619 ++input_line_pointer
;
3621 if (target_big_endian
)
3624 bytes
[length
- i
- 1] = d
;
3630 if (target_big_endian
)
3631 memset (bytes
+ i
, 0, length
- i
);
3633 memset (bytes
, 0, length
- i
);
3642 * CONStruct some more frag chars of .floats .ffloats etc.
3643 * Makes 0 or more new frags.
3644 * If need_pass_2 == 1, no frags are emitted.
3645 * This understands only floating literals, not expressions. Sorry.
3647 * A floating constant is defined by atof_generic(), except it is preceded
3648 * by 0d 0f 0g or 0h. After observing the STRANGE way my BSD AS does its
3649 * reading, I decided to be incompatible. This always tries to give you
3650 * rounded bits to the precision of the pseudo-op. Former AS did premature
3651 * truncatation, restored noisy bits instead of trailing 0s AND gave you
3652 * a choice of 2 flavours of noise according to which of 2 floating-point
3653 * scanners you directed AS to use.
3655 * In: input_line_pointer->whitespace before, or '0' of flonum.
3660 float_cons (float_type
)
3661 /* Clobbers input_line-pointer, checks end-of-line. */
3662 register int float_type
; /* 'f':.ffloat ... 'F':.float ... */
3665 int length
; /* Number of chars in an object. */
3666 register char *err
; /* Error from scanning floating literal. */
3667 char temp
[MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT
];
3669 if (is_it_end_of_statement ())
3671 demand_empty_rest_of_line ();
3675 #ifdef md_flush_pending_output
3676 md_flush_pending_output ();
3681 /* input_line_pointer->1st char of a flonum (we hope!). */
3684 /* Skip any 0{letter} that may be present. Don't even check if the
3685 * letter is legal. Someone may invent a "z" format and this routine
3686 * has no use for such information. Lusers beware: you get
3687 * diagnostics if your input is ill-conditioned.
3689 if (input_line_pointer
[0] == '0' && isalpha (input_line_pointer
[1]))
3690 input_line_pointer
+= 2;
3692 /* Accept :xxxx, where the x's are hex digits, for a floating
3693 point with the exact digits specified. */
3694 if (input_line_pointer
[0] == ':')
3696 ++input_line_pointer
;
3697 length
= hex_float (float_type
, temp
);
3700 ignore_rest_of_line ();
3706 err
= md_atof (float_type
, temp
, &length
);
3707 know (length
<= MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT
);
3711 as_bad ("Bad floating literal: %s", err
);
3712 ignore_rest_of_line ();
3723 #ifdef REPEAT_CONS_EXPRESSIONS
3724 if (*input_line_pointer
== ':')
3726 expressionS count_exp
;
3728 ++input_line_pointer
;
3729 expression (&count_exp
);
3730 if (count_exp
.X_op
!= O_constant
3731 || count_exp
.X_add_number
<= 0)
3733 as_warn ("unresolvable or nonpositive repeat count; using 1");
3736 count
= count_exp
.X_add_number
;
3740 while (--count
>= 0)
3742 p
= frag_more (length
);
3743 memcpy (p
, temp
, (unsigned int) length
);
3748 while (*input_line_pointer
++ == ',');
3750 --input_line_pointer
; /* Put terminator back into stream. */
3751 demand_empty_rest_of_line ();
3752 } /* float_cons() */
3757 * We read 0 or more ',' seperated, double-quoted strings.
3759 * Caller should have checked need_pass_2 is FALSE because we don't check it.
3764 stringer (append_zero
) /* Worker to do .ascii etc statements. */
3765 /* Checks end-of-line. */
3766 register int append_zero
; /* 0: don't append '\0', else 1 */
3768 register unsigned int c
;
3770 #ifdef md_flush_pending_output
3771 md_flush_pending_output ();
3775 * The following awkward logic is to parse ZERO or more strings,
3776 * comma seperated. Recall a string expression includes spaces
3777 * before the opening '\"' and spaces after the closing '\"'.
3778 * We fake a leading ',' if there is (supposed to be)
3779 * a 1st, expression. We keep demanding expressions for each
3782 if (is_it_end_of_statement ())
3784 c
= 0; /* Skip loop. */
3785 ++input_line_pointer
; /* Compensate for end of loop. */
3789 c
= ','; /* Do loop. */
3791 while (c
== ',' || c
== '<' || c
== '"')
3794 switch (*input_line_pointer
)
3797 ++input_line_pointer
; /*->1st char of string. */
3798 while (is_a_char (c
= next_char_of_string ()))
3800 FRAG_APPEND_1_CHAR (c
);
3804 FRAG_APPEND_1_CHAR (0);
3806 know (input_line_pointer
[-1] == '\"');
3809 input_line_pointer
++;
3810 c
= get_single_number ();
3811 FRAG_APPEND_1_CHAR (c
);
3812 if (*input_line_pointer
!= '>')
3814 as_bad ("Expected <nn>");
3816 input_line_pointer
++;
3819 input_line_pointer
++;
3823 c
= *input_line_pointer
;
3826 demand_empty_rest_of_line ();
3829 /* FIXME-SOMEDAY: I had trouble here on characters with the
3830 high bits set. We'll probably also have trouble with
3831 multibyte chars, wide chars, etc. Also be careful about
3832 returning values bigger than 1 byte. xoxorich. */
3835 next_char_of_string ()
3837 register unsigned int c
;
3839 c
= *input_line_pointer
++ & CHAR_MASK
;
3847 as_warn ("Unterminated string: Newline inserted.");
3848 bump_line_counters ();
3851 #ifndef NO_STRING_ESCAPES
3853 switch (c
= *input_line_pointer
++)
3881 break; /* As itself. */
3897 for (i
= 0, number
= 0; isdigit (c
) && i
< 3; c
= *input_line_pointer
++, i
++)
3899 number
= number
* 8 + c
- '0';
3903 --input_line_pointer
;
3912 c
= *input_line_pointer
++;
3913 while (isxdigit (c
))
3916 number
= number
* 16 + c
- '0';
3917 else if (isupper (c
))
3918 number
= number
* 16 + c
- 'A' + 10;
3920 number
= number
* 16 + c
- 'a' + 10;
3921 c
= *input_line_pointer
++;
3924 --input_line_pointer
;
3929 /* To be compatible with BSD 4.2 as: give the luser a linefeed!! */
3930 as_warn ("Unterminated string: Newline inserted.");
3932 bump_line_counters ();
3937 #ifdef ONLY_STANDARD_ESCAPES
3938 as_bad ("Bad escaped character in string, '?' assumed");
3940 #endif /* ONLY_STANDARD_ESCAPES */
3943 } /* switch on escaped char */
3945 #endif /* ! defined (NO_STRING_ESCAPES) */
3949 } /* switch on char */
3951 } /* next_char_of_string() */
3954 get_segmented_expression (expP
)
3955 register expressionS
*expP
;
3957 register segT retval
;
3959 retval
= expression (expP
);
3960 if (expP
->X_op
== O_illegal
3961 || expP
->X_op
== O_absent
3962 || expP
->X_op
== O_big
)
3964 as_bad ("expected address expression; zero assumed");
3965 expP
->X_op
= O_constant
;
3966 expP
->X_add_number
= 0;
3967 retval
= absolute_section
;
3973 get_known_segmented_expression (expP
)
3974 register expressionS
*expP
;
3976 register segT retval
;
3978 if ((retval
= get_segmented_expression (expP
)) == undefined_section
)
3980 /* There is no easy way to extract the undefined symbol from the
3982 if (expP
->X_add_symbol
!= NULL
3983 && S_GET_SEGMENT (expP
->X_add_symbol
) != expr_section
)
3984 as_warn ("symbol \"%s\" undefined; zero assumed",
3985 S_GET_NAME (expP
->X_add_symbol
));
3987 as_warn ("some symbol undefined; zero assumed");
3988 retval
= absolute_section
;
3989 expP
->X_op
= O_constant
;
3990 expP
->X_add_number
= 0;
3992 know (retval
== absolute_section
|| SEG_NORMAL (retval
));
3994 } /* get_known_segmented_expression() */
3997 get_absolute_expression ()
4002 if (exp
.X_op
!= O_constant
)
4004 if (exp
.X_op
!= O_absent
)
4005 as_bad ("bad or irreducible absolute expression; zero assumed");
4006 exp
.X_add_number
= 0;
4008 return exp
.X_add_number
;
4011 char /* return terminator */
4012 get_absolute_expression_and_terminator (val_pointer
)
4013 long *val_pointer
; /* return value of expression */
4015 /* FIXME: val_pointer should probably be offsetT *. */
4016 *val_pointer
= (long) get_absolute_expression ();
4017 return (*input_line_pointer
++);
4021 * demand_copy_C_string()
4023 * Like demand_copy_string, but return NULL if the string contains any '\0's.
4024 * Give a warning if that happens.
4027 demand_copy_C_string (len_pointer
)
4032 if ((s
= demand_copy_string (len_pointer
)) != 0)
4036 for (len
= *len_pointer
; len
> 0; len
--)
4043 as_bad ("This string may not contain \'\\0\'");
4051 * demand_copy_string()
4053 * Demand string, but return a safe (=private) copy of the string.
4054 * Return NULL if we can't read a string here.
4057 demand_copy_string (lenP
)
4060 register unsigned int c
;
4066 if (*input_line_pointer
== '\"')
4068 input_line_pointer
++; /* Skip opening quote. */
4070 while (is_a_char (c
= next_char_of_string ()))
4072 obstack_1grow (¬es
, c
);
4075 /* JF this next line is so demand_copy_C_string will return a
4076 null terminated string. */
4077 obstack_1grow (¬es
, '\0');
4078 retval
= obstack_finish (¬es
);
4082 as_warn ("Missing string");
4084 ignore_rest_of_line ();
4088 } /* demand_copy_string() */
4091 * is_it_end_of_statement()
4093 * In: Input_line_pointer->next character.
4095 * Do: Skip input_line_pointer over all whitespace.
4097 * Out: 1 if input_line_pointer->end-of-line.
4100 is_it_end_of_statement ()
4103 return (is_end_of_line
[(unsigned char) *input_line_pointer
]);
4104 } /* is_it_end_of_statement() */
4110 register symbolS
*symbolP
; /* symbol we are working with */
4114 input_line_pointer
++;
4115 if (*input_line_pointer
== '=')
4116 input_line_pointer
++;
4118 while (*input_line_pointer
== ' ' || *input_line_pointer
== '\t')
4119 input_line_pointer
++;
4122 stop
= mri_comment_field (&stopc
);
4124 if (sym_name
[0] == '.' && sym_name
[1] == '\0')
4126 /* Turn '. = mumble' into a .org mumble */
4127 register segT segment
;
4130 segment
= get_known_segmented_expression (&exp
);
4132 do_org (segment
, &exp
, 0);
4136 symbolP
= symbol_find_or_make (sym_name
);
4137 pseudo_set (symbolP
);
4141 mri_comment_end (stop
, stopc
);
4144 /* .include -- include a file at this point. */
4157 if (! flag_m68k_mri
)
4158 filename
= demand_copy_string (&i
);
4163 while (! is_end_of_line
[(unsigned char) *input_line_pointer
]
4164 && *input_line_pointer
!= ' '
4165 && *input_line_pointer
!= '\t')
4167 obstack_1grow (¬es
, *input_line_pointer
);
4168 ++input_line_pointer
;
4171 obstack_1grow (¬es
, '\0');
4172 filename
= obstack_finish (¬es
);
4173 while (! is_end_of_line
[(unsigned char) *input_line_pointer
])
4174 ++input_line_pointer
;
4176 demand_empty_rest_of_line ();
4177 path
= xmalloc ((unsigned long) i
+ include_dir_maxlen
+ 5 /* slop */ );
4178 for (i
= 0; i
< include_dir_count
; i
++)
4180 strcpy (path
, include_dirs
[i
]);
4182 strcat (path
, filename
);
4183 if (0 != (try = fopen (path
, "r")))
4192 /* malloc Storage leak when file is found on path. FIXME-SOMEDAY. */
4193 newbuf
= input_scrub_include_file (path
, input_line_pointer
);
4194 buffer_limit
= input_scrub_next_buffer (&input_line_pointer
);
4198 add_include_dir (path
)
4203 if (include_dir_count
== 0)
4205 include_dirs
= (char **) xmalloc (2 * sizeof (*include_dirs
));
4206 include_dirs
[0] = "."; /* Current dir */
4207 include_dir_count
= 2;
4211 include_dir_count
++;
4212 include_dirs
= (char **) realloc (include_dirs
,
4213 include_dir_count
* sizeof (*include_dirs
));
4216 include_dirs
[include_dir_count
- 1] = path
; /* New one */
4219 if (i
> include_dir_maxlen
)
4220 include_dir_maxlen
= i
;
4221 } /* add_include_dir() */
4227 while (!is_end_of_line
[(unsigned char) *input_line_pointer
])
4229 ++input_line_pointer
;
4231 ++input_line_pointer
;
4236 read_print_statistics (file
)
4239 hash_print_statistics (file
, "pseudo-op table", po_hash
);