1 /* read.c - read a source file -
2 Copyright (C) 1986, 1987, 1990, 1991, 1993, 1994
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. */
47 #include "libiberty.h"
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. */
88 /* used by is_... macros. our ctype[] */
91 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* @ABCDEFGHIJKLMNO */
92 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* PQRSTUVWXYZ[\]^_ */
93 0, 0, 0, 0, 3, LEX_PCT, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, /* _!"#$%&'()*+,-./ */
94 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, /* 0123456789:;<=>? */
95 LEX_AT, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, /* @ABCDEFGHIJKLMNO */
96 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, LEX_BR, 0, LEX_BR, 0, 3, /* PQRSTUVWXYZ[\]^_ */
97 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, /* `abcdefghijklmno */
98 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, LEX_BR, 0, LEX_BR, 0, 0, /* pqrstuvwxyz{|}~. */
99 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
100 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
101 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
102 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
103 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
104 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
105 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
111 * Out: 1 if this character ends a line.
114 char is_end_of_line[256] =
117 _, _, _, _, _, _, _, _, _, _, 99, _, _, 99, _, _, /* @abcdefghijklmno */
119 _, _, _, _, _, _, _, _, _, _, 99, _, _, _, _, _, /* @abcdefghijklmno */
121 _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, /* */
123 _,99, _, _, _, _, _, _, _, _, _, _, _, _, _, _, /* _!"#$%&'()*+,-./ */
124 _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, /* 0123456789:;<=>? */
126 _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, /* */
127 _, _, _, _, _, _, _, _, _, _, _, 99, _, _, _, _, /* 0123456789:;<=>? */
129 _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, /* */
130 _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, /* */
131 _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, /* */
132 _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, /* */
133 _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, /* */
134 _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, /* */
135 _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, /* */
136 _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, /* */
137 _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, /* */
141 /* Functions private to this file. */
143 static char *buffer; /* 1st char of each buffer of lines is here. */
144 static char *buffer_limit; /*->1 + last char in buffer. */
146 #ifdef TARGET_BYTES_BIG_ENDIAN
147 /* Hack to deal with tc-*.h defining TARGET_BYTES_BIG_ENDIAN to empty
148 instead of to 0 or 1. */
149 #if 5 - TARGET_BYTES_BIG_ENDIAN - 5 == 10
150 #undef TARGET_BYTES_BIG_ENDIAN
151 #define TARGET_BYTES_BIG_ENDIAN 1
153 int target_big_endian = TARGET_BYTES_BIG_ENDIAN;
155 int target_big_endian /* = 0 */;
158 static char *old_buffer; /* JF a hack */
159 static char *old_input;
160 static char *old_limit;
162 /* Variables for handling include file directory list. */
164 char **include_dirs; /* List of pointers to directories to
165 search for .include's */
166 int include_dir_count; /* How many are in the list */
167 int include_dir_maxlen = 1;/* Length of longest in list */
169 #ifndef WORKING_DOT_WORD
170 struct broken_word *broken_words;
171 int new_broken_words;
174 /* The current offset into the absolute section. We don't try to
175 build frags in the absolute section, since no data can be stored
176 there. We just keep track of the current offset. */
177 addressT abs_section_offset;
179 /* If this line had an MRI style label, it is stored in this variable.
180 This is used by some of the MRI pseudo-ops. */
183 /* This global variable is used to support MRI common sections. We
184 translate such sections into a common symbol. This variable is
185 non-NULL when we are in an MRI common section. */
186 symbolS *mri_common_symbol;
188 /* In MRI mode, after a dc.b pseudo-op with an odd number of bytes, we
189 need to align to an even byte boundary unless the next pseudo-op is
190 dc.b, ds.b, or dcb.b. This variable is set to 1 if an alignment
192 static int mri_pending_align;
194 static void do_align PARAMS ((int, char *));
195 static int hex_float PARAMS ((int, char *));
196 static void do_org PARAMS ((segT, expressionS *, int));
197 char *demand_copy_string PARAMS ((int *lenP));
198 int is_it_end_of_statement PARAMS ((void));
199 static segT get_segmented_expression PARAMS ((expressionS *expP));
200 static segT get_known_segmented_expression PARAMS ((expressionS * expP));
201 static void pobegin PARAMS ((void));
202 static int get_line_sb PARAMS ((sb *));
211 obj_read_begin_hook ();
213 /* Something close -- but not too close -- to a multiple of 1024.
214 The debugging malloc I'm using has 24 bytes of overhead. */
215 obstack_begin (¬es, 5090);
216 obstack_begin (&cond_obstack, 990);
218 /* Use machine dependent syntax */
219 for (p = line_separator_chars; *p; p++)
220 is_end_of_line[(unsigned char) *p] = 1;
221 /* Use more. FIXME-SOMEDAY. */
227 /* set up pseudo-op tables */
229 static struct hash_control *po_hash;
231 static const pseudo_typeS potable[] =
233 {"abort", s_abort, 0},
234 {"align", s_align_ptwo, 0},
235 {"ascii", stringer, 0},
236 {"asciz", stringer, 1},
237 {"balign", s_align_bytes, 0},
241 {"common", s_mri_common, 0},
242 {"common.s", s_mri_common, 1},
246 {"dc.d", float_cons, 'd'},
248 {"dc.s", float_cons, 'f'},
250 {"dc.x", float_cons, 'x'},
252 {"dcb.b", s_space, 1},
253 {"dcb.d", s_float_space, 'd'},
254 {"dcb.l", s_space, 4},
255 {"dcb.s", s_float_space, 'f'},
256 {"dcb.w", s_space, 2},
257 {"dcb.x", s_float_space, 'x'},
259 {"ds.b", s_space, 1},
260 {"ds.d", s_space, 8},
261 {"ds.l", s_space, 4},
262 {"ds.p", s_space, 12},
263 {"ds.s", s_space, 4},
264 {"ds.w", s_space, 2},
265 {"ds.x", s_space, 12},
270 {"double", float_cons, 'd'},
272 {"eject", listing_eject, 0}, /* Formfeed listing */
274 {"elsec", s_else, 0},
276 {"endc", s_endif, 0},
277 {"endif", s_endif, 0},
281 {"exitm", s_mexit, 0},
283 {"extern", s_ignore, 0}, /* We treat all undef as ext */
284 {"appfile", s_app_file, 1},
285 {"appline", s_app_line, 0},
287 {"file", s_app_file, 0},
289 {"float", float_cons, 'f'},
290 {"format", s_ignore, 0},
291 {"global", s_globl, 0},
292 {"globl", s_globl, 0},
294 {"if", s_if, (int) O_ne},
296 {"ifdef", s_ifdef, 0},
297 {"ifeq", s_if, (int) O_eq},
298 {"ifeqs", s_ifeqs, 0},
299 {"ifge", s_if, (int) O_ge},
300 {"ifgt", s_if, (int) O_gt},
301 {"ifle", s_if, (int) O_le},
302 {"iflt", s_if, (int) O_lt},
304 {"ifndef", s_ifdef, 1},
305 {"ifne", s_if, (int) O_ne},
306 {"ifnes", s_ifeqs, 1},
307 {"ifnotdef", s_ifdef, 1},
308 {"include", s_include, 0},
312 {"lcomm", s_lcomm, 0},
313 {"lflags", listing_flags, 0}, /* Listing flags */
314 {"list", listing_list, 1}, /* Turn listing on */
315 {"llen", listing_psize, 1},
318 {"macro", s_macro, 0},
319 {"mexit", s_mexit, 0},
320 {"noformat", s_ignore, 0},
321 {"nolist", listing_list, 0}, /* Turn listing off */
322 {"nopage", listing_nopage, 0},
324 {"offset", s_struct, 0},
326 {"p2align", s_align_ptwo, 0},
327 {"page", listing_eject, 0},
328 {"plen", listing_psize, 0},
329 {"psize", listing_psize, 0}, /* set paper size */
333 {"sbttl", listing_title, 1}, /* Subtitle of listing */
338 {"single", float_cons, 'f'},
340 {"space", s_space, 0},
341 {"spc", s_ignore, 0},
342 {"stabd", s_stab, 'd'},
343 {"stabn", s_stab, 'n'},
344 {"stabs", s_stab, 's'},
345 {"string", stringer, 1},
346 {"struct", s_struct, 0},
350 /* This is for gcc to use. It's only just been added (2/94), so gcc
351 won't be able to use it for a while -- probably a year or more.
352 But once this has been released, check with gcc maintainers
353 before deleting it or even changing the spelling. */
354 {"this_GCC_requires_the_GNU_assembler", s_ignore, 0},
355 /* If we're folding case -- done for some targets, not necessarily
356 all -- the above string in an input file will be converted to
357 this one. Match it either way... */
358 {"this_gcc_requires_the_gnu_assembler", s_ignore, 0},
360 {"title", listing_title, 0}, /* Listing title */
361 {"ttl", listing_title, 0},
366 {"xdef", s_globl, 0},
367 {"xref", s_ignore, 0},
368 {"xstabs", s_xstab, 's'},
370 {"zero", s_space, 0},
371 {NULL} /* end sentinel */
374 static int pop_override_ok = 0;
375 static const char *pop_table_name;
379 const pseudo_typeS *table;
382 const pseudo_typeS *pop;
383 for (pop = table; pop->poc_name; pop++)
385 errtxt = hash_insert (po_hash, pop->poc_name, (char *) pop);
386 if (errtxt && (!pop_override_ok || strcmp (errtxt, "exists")))
387 as_fatal ("error constructing %s pseudo-op table", pop_table_name);
391 #ifndef md_pop_insert
392 #define md_pop_insert() pop_insert(md_pseudo_table)
395 #ifndef obj_pop_insert
396 #define obj_pop_insert() pop_insert(obj_pseudo_table)
402 po_hash = hash_new ();
404 /* Do the target-specific pseudo ops. */
405 pop_table_name = "md";
408 /* Now object specific. Skip any that were in the target table. */
409 pop_table_name = "obj";
413 /* Now portable ones. Skip any that we've seen already. */
414 pop_table_name = "standard";
415 pop_insert (potable);
418 #define HANDLE_CONDITIONAL_ASSEMBLY() \
419 if (ignore_input ()) \
421 while (! is_end_of_line[(unsigned char) *input_line_pointer++]) \
422 if (input_line_pointer == buffer_limit) \
428 /* read_a_source_file()
430 * We read the file, putting things into a web that
431 * represents what we have been reading.
434 read_a_source_file (name)
438 register char *s; /* string of symbol, '\0' appended */
442 buffer = input_scrub_new_file (name);
445 listing_newline ("");
447 while ((buffer_limit = input_scrub_next_buffer (&input_line_pointer)) != 0)
448 { /* We have another line to parse. */
449 know (buffer_limit[-1] == '\n'); /* Must have a sentinel. */
450 contin: /* JF this goto is my fault I admit it.
451 Someone brave please re-write the whole
452 input section here? Pleeze??? */
453 while (input_line_pointer < buffer_limit)
455 /* We have more of this buffer to parse. */
458 * We now have input_line_pointer->1st char of next line.
459 * If input_line_pointer [-1] == '\n' then we just
460 * scanned another line: so bump line counters.
462 if (is_end_of_line[(unsigned char) input_line_pointer[-1]])
464 #ifdef md_start_line_hook
465 md_start_line_hook ();
468 if (input_line_pointer[-1] == '\n')
469 bump_line_counters ();
474 #ifdef LABELS_WITHOUT_COLONS
479 /* Text at the start of a line must be a label, we
480 run down and stick a colon in. */
481 if (is_name_beginner (*input_line_pointer))
483 char *line_start = input_line_pointer;
486 HANDLE_CONDITIONAL_ASSEMBLY ();
488 c = get_symbol_end ();
490 /* In MRI mode, the EQU pseudoop must be
491 handled specially. */
494 char *rest = input_line_pointer + 1;
498 if (*rest == ' ' || *rest == '\t')
500 if ((strncasecmp (rest, "EQU", 3) == 0
501 || strncasecmp (rest, "SET", 3) == 0)
502 && (rest[3] == ' ' || rest[3] == '\t'))
504 input_line_pointer = rest + 3;
510 line_label = colon (line_start);
512 *input_line_pointer = c;
514 input_line_pointer++;
520 * We are at the begining of a line, or similar place.
521 * We expect a well-formed assembler statement.
522 * A "symbol-name:" is a statement.
524 * Depending on what compiler is used, the order of these tests
525 * may vary to catch most common case 1st.
526 * Each test is independent of all other tests at the (top) level.
527 * PLEASE make a compiler that doesn't use this assembler.
528 * It is crufty to waste a compiler's time encoding things for this
529 * assembler, which then wastes more time decoding it.
530 * (And communicating via (linear) files is silly!
531 * If you must pass stuff, please pass a tree!)
533 if ((c = *input_line_pointer++) == '\t'
538 c = *input_line_pointer++;
540 know (c != ' '); /* No further leading whitespace. */
543 * C is the 1st significant character.
544 * Input_line_pointer points after that character.
546 if (is_name_beginner (c))
548 /* want user-defined label or pseudo/opcode */
549 HANDLE_CONDITIONAL_ASSEMBLY ();
551 s = --input_line_pointer;
552 c = get_symbol_end (); /* name's delimiter */
554 * C is character after symbol.
555 * That character's place in the input line is now '\0'.
556 * S points to the beginning of the symbol.
557 * [In case of pseudo-op, s->'.'.]
558 * Input_line_pointer->'\0' where c was.
560 if (TC_START_LABEL(c, input_line_pointer))
564 char *rest = input_line_pointer + 1;
566 /* In MRI mode, \tsym: set 0 is permitted. */
570 if (*rest == ' ' || *rest == '\t')
572 if ((strncasecmp (rest, "EQU", 3) == 0
573 || strncasecmp (rest, "SET", 3) == 0)
574 && (rest[3] == ' ' || rest[3] == '\t'))
576 input_line_pointer = rest + 3;
582 line_label = colon (s); /* user-defined label */
583 *input_line_pointer++ = ':'; /* Put ':' back for error messages' sake. */
584 /* Input_line_pointer->after ':'. */
590 || (input_line_pointer[1] == '='
591 #ifdef TC_EQUAL_IN_INSN
592 && ! TC_EQUAL_IN_INSN (c, input_line_pointer)
597 demand_empty_rest_of_line ();
600 { /* expect pseudo-op or machine instruction */
603 #define IGNORE_OPCODE_CASE
604 #ifdef IGNORE_OPCODE_CASE
622 /* The MRI assembler and the m88k use pseudo-ops
624 pop = (pseudo_typeS *) hash_find (po_hash, s);
625 if (pop != NULL && pop->poc_handler == NULL)
630 || (! flag_mri && *s == '.'))
635 * WARNING: c has next char, which may be end-of-line.
636 * We lookup the pseudo-op table with s+1 because we
637 * already know that the pseudo-op begins with a '.'.
641 pop = (pseudo_typeS *) hash_find (po_hash, s + 1);
643 /* In MRI mode, we may need to insert an
644 automatic alignment directive. What a hack
646 if (mri_pending_align
648 || ! ((pop->poc_handler == cons
649 && pop->poc_val == 1)
650 || (pop->poc_handler == s_space
651 && pop->poc_val == 1))))
653 do_align (1, (char *) NULL);
654 mri_pending_align = 0;
657 /* Print the error msg now, while we still can */
660 as_bad ("Unknown pseudo-op: `%s'", s);
661 *input_line_pointer = c;
666 /* Put it back for error messages etc. */
667 *input_line_pointer = c;
668 /* The following skip of whitespace is compulsory.
669 A well shaped space is sometimes all that separates
670 keyword from operands. */
671 if (c == ' ' || c == '\t')
672 input_line_pointer++;
674 * Input_line is restored.
675 * Input_line_pointer->1st non-blank char
676 * after pseudo-operation.
678 (*pop->poc_handler) (pop->poc_val);
680 /* If that was .end, just get out now. */
681 if (pop->poc_handler == s_end)
685 { /* machine instruction */
686 if (mri_pending_align)
688 do_align (1, (char *) NULL);
689 mri_pending_align = 0;
692 /* WARNING: c has char, which may be end-of-line. */
693 /* Also: input_line_pointer->`\0` where c was. */
694 *input_line_pointer = c;
695 while (!is_end_of_line[(unsigned char) *input_line_pointer]
696 #ifdef TC_EOL_IN_INSN
697 || TC_EOL_IN_INSN (input_line_pointer)
701 input_line_pointer++;
704 c = *input_line_pointer;
705 *input_line_pointer = '\0';
707 #ifdef OBJ_GENERATE_ASM_LINENO
708 if (generate_asm_lineno == 0)
710 if (ecoff_no_current_file ())
711 generate_asm_lineno = 1;
713 if (generate_asm_lineno == 1)
718 as_where (&s, &lineno);
719 OBJ_GENERATE_ASM_LINENO (s, lineno);
728 if (check_macro (s, &out, '\0', &err))
732 *input_line_pointer++ = c;
733 input_scrub_include_sb (&out,
737 input_scrub_next_buffer (&input_line_pointer);
742 md_assemble (s); /* Assemble 1 instruction. */
744 *input_line_pointer++ = c;
746 /* We resume loop AFTER the end-of-line from
751 } /* if (is_name_beginner(c) */
754 /* Empty statement? */
755 if (is_end_of_line[(unsigned char) c])
758 if ((LOCAL_LABELS_DOLLAR || LOCAL_LABELS_FB)
761 /* local label ("4:") */
762 char *backup = input_line_pointer;
764 HANDLE_CONDITIONAL_ASSEMBLY ();
768 while (isdigit (*input_line_pointer))
770 temp = (temp * 10) + *input_line_pointer - '0';
771 ++input_line_pointer;
772 } /* read the whole number */
774 if (LOCAL_LABELS_DOLLAR
775 && *input_line_pointer == '$'
776 && *(input_line_pointer + 1) == ':')
778 input_line_pointer += 2;
780 if (dollar_label_defined (temp))
782 as_fatal ("label \"%d$\" redefined", temp);
785 define_dollar_label (temp);
786 colon (dollar_label_name (temp, 0));
791 && *input_line_pointer++ == ':')
793 fb_label_instance_inc (temp);
794 colon (fb_label_name (temp, 0));
798 input_line_pointer = backup;
799 } /* local label ("4:") */
801 if (c && strchr (line_comment_chars, c))
802 { /* Its a comment. Better say APP or NO_APP */
806 unsigned int new_length;
808 extern char *scrub_string, *scrub_last_string;
810 bump_line_counters ();
811 s = input_line_pointer;
812 if (strncmp (s, "APP\n", 4))
813 continue; /* We ignore it */
816 ends = strstr (s, "#NO_APP\n");
820 unsigned int tmp_len;
823 /* The end of the #APP wasn't in this buffer. We
824 keep reading in buffers until we find the #NO_APP
825 that goes with this #APP There is one. The specs
827 tmp_len = buffer_limit - s;
828 tmp_buf = xmalloc (tmp_len + 1);
829 memcpy (tmp_buf, s, tmp_len);
832 new_tmp = input_scrub_next_buffer (&buffer);
836 buffer_limit = new_tmp;
837 input_line_pointer = buffer;
838 ends = strstr (buffer, "#NO_APP\n");
842 num = buffer_limit - buffer;
844 tmp_buf = xrealloc (tmp_buf, tmp_len + num);
845 memcpy (tmp_buf + tmp_len, buffer, num);
850 input_line_pointer = ends ? ends + 8 : NULL;
858 input_line_pointer = ends + 8;
860 new_buf = xmalloc (100);
865 scrub_last_string = ends;
870 ch = do_scrub_next_char (scrub_from_string, scrub_to_string);
874 if (new_tmp == new_buf + new_length)
876 new_buf = xrealloc (new_buf, new_length + 100);
877 new_tmp = new_buf + new_length;
885 old_input = input_line_pointer;
886 old_limit = buffer_limit;
888 input_line_pointer = new_buf;
889 buffer_limit = new_tmp;
893 HANDLE_CONDITIONAL_ASSEMBLY ();
895 /* as_warn("Junk character %d.",c); Now done by ignore_rest */
896 input_line_pointer--; /* Report unknown char as ignored. */
897 ignore_rest_of_line ();
898 } /* while (input_line_pointer<buffer_limit) */
900 #ifdef md_after_pass_hook
901 md_after_pass_hook ();
906 bump_line_counters ();
910 input_line_pointer = old_input;
911 buffer_limit = old_limit;
916 } /* while (more buffers to scan) */
919 input_scrub_close (); /* Close the input file */
926 as_fatal (".abort detected. Abandoning ship.");
929 /* Guts of .align directive. */
936 md_do_align (n, fill, just_record_alignment);
940 /* @@ Fix this right for BFD! */
942 static char nop_opcode = NOP_OPCODE;
944 if (now_seg != data_section && now_seg != bss_section)
953 /* Only make a frag if we HAVE to. . . */
954 if (n && !need_pass_2)
955 frag_align (n, *fill);
958 just_record_alignment:
961 record_alignment (now_seg, n);
964 /* For machines where ".align 4" means align to a 4 byte boundary. */
969 register unsigned int temp;
972 unsigned long max_alignment = 1 << 15;
974 if (is_end_of_line[(unsigned char) *input_line_pointer])
975 temp = arg; /* Default value from pseudo-op table */
977 temp = get_absolute_expression ();
979 if (temp > max_alignment)
981 as_bad ("Alignment too large: %d. assumed.", temp = max_alignment);
984 /* For the sparc, `.align (1<<n)' actually means `.align n' so we
985 have to convert it. */
988 for (i = 0; (temp & 1) == 0; temp >>= 1, ++i)
992 as_bad ("Alignment not a power of 2");
995 if (*input_line_pointer == ',')
997 input_line_pointer++;
998 temp_fill = get_absolute_expression ();
999 do_align (temp, &temp_fill);
1002 do_align (temp, (char *) 0);
1004 demand_empty_rest_of_line ();
1007 /* For machines where ".align 4" means align to 2**4 boundary. */
1009 s_align_ptwo (ignore)
1014 long max_alignment = 15;
1016 temp = get_absolute_expression ();
1017 if (temp > max_alignment)
1018 as_bad ("Alignment too large: %d. assumed.", temp = max_alignment);
1021 as_bad ("Alignment negative. 0 assumed.");
1024 if (*input_line_pointer == ',')
1026 input_line_pointer++;
1027 temp_fill = get_absolute_expression ();
1028 do_align (temp, &temp_fill);
1031 do_align (temp, (char *) 0);
1033 demand_empty_rest_of_line ();
1040 register char *name;
1044 register symbolS *symbolP;
1046 name = input_line_pointer;
1047 c = get_symbol_end ();
1048 /* just after name is now '\0' */
1049 p = input_line_pointer;
1052 if (*input_line_pointer != ',')
1054 as_bad ("Expected comma after symbol-name: rest of line ignored.");
1055 ignore_rest_of_line ();
1058 input_line_pointer++; /* skip ',' */
1059 if ((temp = get_absolute_expression ()) < 0)
1061 as_warn (".COMMon length (%ld.) <0! Ignored.", (long) temp);
1062 ignore_rest_of_line ();
1066 symbolP = symbol_find_or_make (name);
1068 if (S_IS_DEFINED (symbolP))
1070 as_bad ("Ignoring attempt to re-define symbol `%s'.",
1071 S_GET_NAME (symbolP));
1072 ignore_rest_of_line ();
1075 if (S_GET_VALUE (symbolP))
1077 if (S_GET_VALUE (symbolP) != (valueT) temp)
1078 as_bad ("Length of .comm \"%s\" is already %ld. Not changed to %ld.",
1079 S_GET_NAME (symbolP),
1080 (long) S_GET_VALUE (symbolP),
1085 S_SET_VALUE (symbolP, (valueT) temp);
1086 S_SET_EXTERNAL (symbolP);
1090 extern int flag_one;
1091 if ( (!temp) || !flag_one)
1092 S_GET_OTHER(symbolP) = const_flag;
1094 #endif /* not OBJ_VMS */
1095 know (symbolP->sy_frag == &zero_address_frag);
1096 demand_empty_rest_of_line ();
1099 /* The MRI COMMON pseudo-op. We handle this by creating a common
1100 symbol with the appropriate name. We make s_space do the right
1101 thing by increasing the size. */
1104 s_mri_common (small)
1121 name = input_line_pointer;
1122 if (! isdigit ((unsigned char) *name))
1123 c = get_symbol_end ();
1128 ++input_line_pointer;
1130 while (isdigit ((unsigned char) *input_line_pointer));
1131 c = *input_line_pointer;
1132 *input_line_pointer = '\0';
1134 if (line_label != NULL)
1136 alc = (char *) xmalloc (strlen (S_GET_NAME (line_label))
1137 + (input_line_pointer - name)
1139 sprintf (alc, "%s%s", name, S_GET_NAME (line_label));
1144 sym = symbol_find_or_make (name);
1145 *input_line_pointer = c;
1149 if (*input_line_pointer != ',')
1153 ++input_line_pointer;
1154 align = get_absolute_expression ();
1157 if (S_IS_DEFINED (sym))
1159 #if defined (S_IS_COMMON) || defined (BFD_ASSEMBLER)
1160 if (! S_IS_COMMON (sym))
1163 as_bad ("attempt to re-define symbol `%s'", S_GET_NAME (sym));
1164 ignore_rest_of_line ();
1169 S_SET_EXTERNAL (sym);
1170 mri_common_symbol = sym;
1174 S_SET_ALIGN (sym, align);
1177 if (line_label != NULL)
1179 line_label->sy_value.X_op = O_symbol;
1180 line_label->sy_value.X_add_symbol = sym;
1181 line_label->sy_value.X_add_number = S_GET_VALUE (sym);
1182 line_label->sy_frag = &zero_address_frag;
1183 S_SET_SEGMENT (line_label, expr_section);
1186 /* FIXME: We just ignore the small argument, which distinguishes
1187 COMMON and COMMON.S. I don't know what we can do about it. */
1189 /* Ignore the type and hptype. */
1190 if (*input_line_pointer == ',')
1191 input_line_pointer += 2;
1192 if (*input_line_pointer == ',')
1193 input_line_pointer += 2;
1194 demand_empty_rest_of_line ();
1204 temp = get_absolute_expression ();
1205 if (flag_readonly_data_in_text)
1207 section = text_section;
1211 section = data_section;
1213 subseg_set (section, (subsegT) temp);
1218 demand_empty_rest_of_line ();
1221 /* Handle the .appfile pseudo-op. This is automatically generated by
1222 do_scrub_next_char when a preprocessor # line comment is seen with
1223 a file name. This default definition may be overridden by the
1224 object or CPU specific pseudo-ops. This function is also the
1225 default definition for .file; the APPFILE argument is 1 for
1226 .appfile, 0 for .file. */
1229 s_app_file (appfile)
1235 /* Some assemblers tolerate immediately following '"' */
1236 if ((s = demand_copy_string (&length)) != 0)
1238 /* If this is a fake .appfile, a fake newline was inserted into
1239 the buffer. Passing -2 to new_logical_line tells it to
1241 new_logical_line (s, appfile ? -2 : -1);
1242 demand_empty_rest_of_line ();
1245 listing_source_file (s);
1253 /* Handle the .appline pseudo-op. This is automatically generated by
1254 do_scrub_next_char when a preprocessor # line comment is seen.
1255 This default definition may be overridden by the object or CPU
1256 specific pseudo-ops. */
1264 /* The given number is that of the next line. */
1265 l = get_absolute_expression () - 1;
1267 /* Some of the back ends can't deal with non-positive line numbers.
1268 Besides, it's silly. */
1269 as_warn ("Line numbers must be positive; line number %d rejected.", l+1);
1272 new_logical_line ((char *) NULL, l);
1275 listing_source_line (l);
1278 demand_empty_rest_of_line ();
1281 /* Handle the .end pseudo-op. Actually, the real work is done in
1282 read_a_source_file. */
1290 /* The MRI assembler permits the start symbol to follow .end,
1291 but we don't support that. */
1293 if (! is_end_of_line[(unsigned char) *input_line_pointer])
1294 as_warn ("start address not supported");
1298 /* Handle the MRI fail pseudo-op. */
1306 temp = get_absolute_expression ();
1308 as_warn (".fail %ld encountered", (long) temp);
1310 as_bad (".fail %ld encountered", (long) temp);
1311 demand_empty_rest_of_line ();
1318 long temp_repeat = 0;
1320 register long temp_fill = 0;
1324 temp_repeat = get_absolute_expression ();
1325 if (*input_line_pointer == ',')
1327 input_line_pointer++;
1328 temp_size = get_absolute_expression ();
1329 if (*input_line_pointer == ',')
1331 input_line_pointer++;
1332 temp_fill = get_absolute_expression ();
1335 /* This is to be compatible with BSD 4.2 AS, not for any rational reason. */
1336 #define BSD_FILL_SIZE_CROCK_8 (8)
1337 if (temp_size > BSD_FILL_SIZE_CROCK_8)
1339 as_warn (".fill size clamped to %d.", BSD_FILL_SIZE_CROCK_8);
1340 temp_size = BSD_FILL_SIZE_CROCK_8;
1344 as_warn ("Size negative: .fill ignored.");
1347 else if (temp_repeat <= 0)
1349 as_warn ("Repeat < 0, .fill ignored");
1353 if (temp_size && !need_pass_2)
1355 p = frag_var (rs_fill, (int) temp_size, (int) temp_size, (relax_substateT) 0, (symbolS *) 0, temp_repeat, (char *) 0);
1356 memset (p, 0, (unsigned int) temp_size);
1357 /* The magic number BSD_FILL_SIZE_CROCK_4 is from BSD 4.2 VAX
1358 * flavoured AS. The following bizzare behaviour is to be
1359 * compatible with above. I guess they tried to take up to 8
1360 * bytes from a 4-byte expression and they forgot to sign
1361 * extend. Un*x Sux. */
1362 #define BSD_FILL_SIZE_CROCK_4 (4)
1363 md_number_to_chars (p, (valueT) temp_fill,
1364 (temp_size > BSD_FILL_SIZE_CROCK_4
1365 ? BSD_FILL_SIZE_CROCK_4
1366 : (int) temp_size));
1367 /* Note: .fill (),0 emits no frag (since we are asked to .fill 0 bytes)
1368 * but emits no error message because it seems a legal thing to do.
1369 * It is a degenerate case of .fill but could be emitted by a compiler.
1372 demand_empty_rest_of_line ();
1385 name = input_line_pointer;
1386 c = get_symbol_end ();
1387 symbolP = symbol_find_or_make (name);
1388 *input_line_pointer = c;
1390 S_SET_EXTERNAL (symbolP);
1393 input_line_pointer++;
1395 if (*input_line_pointer == '\n')
1400 demand_empty_rest_of_line ();
1403 /* Handle the MRI IRP and IRPC pseudo-ops. */
1415 as_where (&file, &line);
1418 while (! is_end_of_line[(unsigned char) *input_line_pointer])
1419 sb_add_char (&s, *input_line_pointer++);
1423 err = expand_irp (irpc, 0, &s, &out, get_line_sb, '\0');
1425 as_bad_where (file, line, "%s", err);
1429 input_scrub_include_sb (&out, input_line_pointer);
1431 buffer_limit = input_scrub_next_buffer (&input_line_pointer);
1435 s_lcomm (needs_align)
1436 /* 1 if this was a ".bss" directive, which may require a 3rd argument
1437 (alignment); 0 if it was an ".lcomm" (2 args only) */
1440 register char *name;
1444 register symbolS *symbolP;
1445 segT current_seg = now_seg;
1446 subsegT current_subseg = now_subseg;
1447 const int max_alignment = 15;
1449 segT bss_seg = bss_section;
1451 name = input_line_pointer;
1452 c = get_symbol_end ();
1453 p = input_line_pointer;
1457 /* Accept an optional comma after the name. The comma used to be
1458 required, but Irix 5 cc does not generate it. */
1459 if (*input_line_pointer == ',')
1461 ++input_line_pointer;
1465 if (*input_line_pointer == '\n')
1467 as_bad ("Missing size expression");
1471 if ((temp = get_absolute_expression ()) < 0)
1473 as_warn ("BSS length (%d.) <0! Ignored.", temp);
1474 ignore_rest_of_line ();
1478 #if defined (TC_MIPS) || defined (TC_ALPHA)
1479 if (OUTPUT_FLAVOR == bfd_target_ecoff_flavour
1480 || OUTPUT_FLAVOR == bfd_target_elf_flavour)
1482 /* For MIPS and Alpha ECOFF or ELF, small objects are put in .sbss. */
1483 if (temp <= bfd_get_gp_size (stdoutput))
1485 bss_seg = subseg_new (".sbss", 1);
1486 seg_info (bss_seg)->bss = 1;
1492 /* FIXME. This needs to be machine independent. */
1502 record_alignment(bss_seg, align);
1509 if (*input_line_pointer != ',')
1511 as_bad ("Expected comma after size");
1512 ignore_rest_of_line ();
1515 input_line_pointer++;
1517 if (*input_line_pointer == '\n')
1519 as_bad ("Missing alignment");
1522 align = get_absolute_expression ();
1523 if (align > max_alignment)
1525 align = max_alignment;
1526 as_warn ("Alignment too large: %d. assumed.", align);
1531 as_warn ("Alignment negative. 0 assumed.");
1533 record_alignment (bss_seg, align);
1534 } /* if needs align */
1537 /* Assume some objects may require alignment on some systems. */
1541 align = ffs (temp) - 1;
1542 if (temp % (1 << align))
1549 symbolP = symbol_find_or_make (name);
1553 #if defined(OBJ_AOUT) | defined(OBJ_BOUT)
1554 S_GET_OTHER (symbolP) == 0 &&
1555 S_GET_DESC (symbolP) == 0 &&
1556 #endif /* OBJ_AOUT or OBJ_BOUT */
1557 (S_GET_SEGMENT (symbolP) == bss_seg
1558 || (!S_IS_DEFINED (symbolP) && S_GET_VALUE (symbolP) == 0)))
1562 subseg_set (bss_seg, 1);
1565 frag_align (align, 0);
1566 /* detach from old frag */
1567 if (S_GET_SEGMENT (symbolP) == bss_seg)
1568 symbolP->sy_frag->fr_symbol = NULL;
1570 symbolP->sy_frag = frag_now;
1571 pfrag = frag_var (rs_org, 1, 1, (relax_substateT)0, symbolP,
1575 S_SET_SEGMENT (symbolP, bss_seg);
1578 /* The symbol may already have been created with a preceding
1579 ".globl" directive -- be careful not to step on storage class
1580 in that case. Otherwise, set it to static. */
1581 if (S_GET_STORAGE_CLASS (symbolP) != C_EXT)
1583 S_SET_STORAGE_CLASS (symbolP, C_STAT);
1585 #endif /* OBJ_COFF */
1588 as_bad ("Ignoring attempt to re-define symbol `%s'.",
1589 S_GET_NAME (symbolP));
1591 subseg_set (current_seg, current_subseg);
1593 demand_empty_rest_of_line ();
1600 register char *name;
1604 register symbolS *symbolP;
1606 /* we permit ANY defined expression: BSD4.2 demands constants */
1607 name = input_line_pointer;
1608 c = get_symbol_end ();
1609 p = input_line_pointer;
1612 if (*input_line_pointer != ',')
1615 as_bad ("Expected comma after name \"%s\"", name);
1617 ignore_rest_of_line ();
1620 input_line_pointer++;
1622 if (exp.X_op != O_constant
1623 && exp.X_op != O_register)
1625 as_bad ("bad expression");
1626 ignore_rest_of_line ();
1630 symbolP = symbol_find_or_make (name);
1632 /* FIXME-SOON I pulled a (&& symbolP->sy_other == 0 &&
1633 symbolP->sy_desc == 0) out of this test because coff doesn't have
1634 those fields, and I can't see when they'd ever be tripped. I
1635 don't think I understand why they were here so I may have
1636 introduced a bug. As recently as 1.37 didn't have this test
1637 anyway. xoxorich. */
1639 if (S_GET_SEGMENT (symbolP) == undefined_section
1640 && S_GET_VALUE (symbolP) == 0)
1642 /* The name might be an undefined .global symbol; be sure to
1643 keep the "external" bit. */
1644 S_SET_SEGMENT (symbolP,
1645 (exp.X_op == O_constant
1648 S_SET_VALUE (symbolP, (valueT) exp.X_add_number);
1652 as_bad ("Symbol %s already defined", name);
1655 demand_empty_rest_of_line ();
1658 /* Read a line into an sb. */
1664 if (input_line_pointer >= buffer_limit)
1666 buffer_limit = input_scrub_next_buffer (&input_line_pointer);
1667 if (buffer_limit == 0)
1671 while (! is_end_of_line[(unsigned char) *input_line_pointer])
1672 sb_add_char (line, *input_line_pointer++);
1673 while (is_end_of_line[(unsigned char) *input_line_pointer])
1675 if (*input_line_pointer == '\n')
1677 bump_line_counters ();
1680 ++input_line_pointer;
1685 /* Define a macro. This is an interface to macro.c, which is shared
1686 between gas and gasp. */
1698 as_where (&file, &line);
1701 while (! is_end_of_line[(unsigned char) *input_line_pointer])
1702 sb_add_char (&s, *input_line_pointer++);
1705 if (line_label != NULL)
1706 sb_add_string (&label, S_GET_NAME (line_label));
1708 demand_empty_rest_of_line ();
1710 err = define_macro (0, &s, &label, get_line_sb);
1712 as_bad_where (file, line, "%s", err);
1715 if (line_label != NULL)
1717 S_SET_SEGMENT (line_label, undefined_section);
1718 S_SET_VALUE (line_label, 0);
1719 line_label->sy_frag = &zero_address_frag;
1726 /* Handle the .mexit pseudo-op, which immediately exits a macro
1733 buffer_limit = input_scrub_next_buffer (&input_line_pointer);
1736 /* Handle changing the location counter. */
1739 do_org (segment, exp, fill)
1744 if (segment != now_seg && segment != absolute_section)
1745 as_bad ("invalid segment \"%s\"; segment \"%s\" assumed",
1746 segment_name (segment), segment_name (now_seg));
1748 if (now_seg == absolute_section)
1751 as_warn ("ignoring fill value in absolute section");
1752 if (exp->X_op != O_constant)
1754 as_bad ("only constant offsets supported in absolute section");
1755 exp->X_add_number = 0;
1757 abs_section_offset = exp->X_add_number;
1763 p = frag_var (rs_org, 1, 1, (relax_substateT) 0, exp->X_add_symbol,
1764 exp->X_add_number, (char *) NULL);
1773 register segT segment;
1775 register long temp_fill;
1777 /* The MRI assembler has a different meaning for .org. It means to
1778 create an absolute section at a given address. We can't support
1779 that--use a linker script instead. */
1782 as_bad ("MRI style ORG pseudo-op not supported");
1783 ignore_rest_of_line ();
1787 /* Don't believe the documentation of BSD 4.2 AS. There is no such
1788 thing as a sub-segment-relative origin. Any absolute origin is
1789 given a warning, then assumed to be segment-relative. Any
1790 segmented origin expression ("foo+42") had better be in the right
1791 segment or the .org is ignored.
1793 BSD 4.2 AS warns if you try to .org backwards. We cannot because
1794 we never know sub-segment sizes when we are reading code. BSD
1795 will crash trying to emit negative numbers of filler bytes in
1796 certain .orgs. We don't crash, but see as-write for that code.
1798 Don't make frag if need_pass_2==1. */
1799 segment = get_known_segmented_expression (&exp);
1800 if (*input_line_pointer == ',')
1802 input_line_pointer++;
1803 temp_fill = get_absolute_expression ();
1809 do_org (segment, &exp, temp_fill);
1811 demand_empty_rest_of_line ();
1814 /* Handle parsing for the MRI SECT/SECTION pseudo-op. This should be
1815 called by the obj-format routine which handles section changing
1816 when in MRI mode. It will create a new section, and return it. It
1817 will set *TYPE to the section type: one of '\0' (unspecified), 'C'
1818 (code), 'D' (data), 'M' (mixed), or 'R' (romable). If
1819 BFD_ASSEMBLER is defined, the flags will be set in the section. */
1831 name = input_line_pointer;
1832 if (! isdigit ((unsigned char) *name))
1833 c = get_symbol_end ();
1838 ++input_line_pointer;
1840 while (isdigit ((unsigned char) *input_line_pointer));
1841 c = *input_line_pointer;
1842 *input_line_pointer = '\0';
1845 name = strdup (name);
1847 as_fatal ("virtual memory exhausted");
1849 *input_line_pointer = c;
1851 seg = subseg_new (name, 0);
1853 if (*input_line_pointer == ',')
1857 ++input_line_pointer;
1858 align = get_absolute_expression ();
1859 record_alignment (seg, align);
1863 if (*input_line_pointer == ',')
1865 c = *++input_line_pointer;
1866 c = toupper ((unsigned char) c);
1867 if (c == 'C' || c == 'D' || c == 'M' || c == 'R')
1870 as_bad ("unrecognized section type");
1871 ++input_line_pointer;
1873 #ifdef BFD_ASSEMBLER
1877 flags = SEC_NO_FLAGS;
1880 else if (*type == 'D')
1882 else if (*type == 'R')
1884 if (flags != SEC_NO_FLAGS)
1886 if (! bfd_set_section_flags (stdoutput, seg, flags))
1887 as_warn ("error setting flags for \"%s\": %s",
1888 bfd_section_name (stdoutput, seg),
1889 bfd_errmsg (bfd_get_error ()));
1895 /* Ignore the HP type. */
1896 if (*input_line_pointer == ',')
1897 input_line_pointer += 2;
1899 demand_empty_rest_of_line ();
1902 /* Handle the .rept pseudo-op. */
1912 count = get_absolute_expression ();
1915 if (! buffer_and_nest ("REPT", "ENDR", &one, get_line_sb))
1917 as_bad ("rept without endr");
1923 sb_add_sb (&many, &one);
1927 input_scrub_include_sb (&many, input_line_pointer);
1929 buffer_limit = input_scrub_next_buffer (&input_line_pointer);
1936 register char *name;
1937 register char delim;
1938 register char *end_name;
1939 register symbolS *symbolP;
1942 * Especial apologies for the random logic:
1943 * this just grew, and could be parsed much more simply!
1946 name = input_line_pointer;
1947 delim = get_symbol_end ();
1948 end_name = input_line_pointer;
1952 if (*input_line_pointer != ',')
1955 as_bad ("Expected comma after name \"%s\"", name);
1957 ignore_rest_of_line ();
1961 input_line_pointer++;
1964 if (name[0] == '.' && name[1] == '\0')
1966 /* Turn '. = mumble' into a .org mumble */
1967 register segT segment;
1970 segment = get_known_segmented_expression (&exp);
1973 do_org (segment, &exp, 0);
1979 if ((symbolP = symbol_find (name)) == NULL
1980 && (symbolP = md_undefined_symbol (name)) == NULL)
1982 symbolP = symbol_new (name, undefined_section, 0, &zero_address_frag);
1984 /* "set" symbols are local unless otherwise specified. */
1985 SF_SET_LOCAL (symbolP);
1986 #endif /* OBJ_COFF */
1988 } /* make a new symbol */
1990 symbol_table_insert (symbolP);
1993 pseudo_set (symbolP);
1994 demand_empty_rest_of_line ();
2005 #ifdef md_flush_pending_output
2006 md_flush_pending_output ();
2009 /* Just like .fill, but temp_size = 1 */
2011 if (exp.X_op == O_constant)
2015 repeat = exp.X_add_number;
2020 as_warn (".space repeat count is %s, ignored",
2021 repeat ? "negative" : "zero");
2022 ignore_rest_of_line ();
2026 /* If we are in the absolute section, just bump the offset. */
2027 if (now_seg == absolute_section)
2029 abs_section_offset += repeat;
2030 demand_empty_rest_of_line ();
2034 /* If we are secretly in an MRI common section, then creating
2035 space just increases the size of the common symbol. */
2036 if (mri_common_symbol != NULL)
2038 S_SET_VALUE (mri_common_symbol,
2039 S_GET_VALUE (mri_common_symbol) + repeat);
2040 demand_empty_rest_of_line ();
2045 p = frag_var (rs_fill, 1, 1, (relax_substateT) 0, (symbolS *) 0,
2046 repeat, (char *) 0);
2050 if (now_seg == absolute_section)
2052 as_bad ("space allocation too complex in absolute section");
2053 subseg_set (text_section, 0);
2055 if (mri_common_symbol != NULL)
2057 as_bad ("space allocation too complex in common section");
2058 mri_common_symbol = NULL;
2061 p = frag_var (rs_space, 1, 1, (relax_substateT) 0,
2062 make_expr_symbol (&exp), 0L, (char *) 0);
2065 if (*input_line_pointer == ',')
2067 input_line_pointer++;
2068 temp_fill = get_absolute_expression ();
2078 demand_empty_rest_of_line ();
2081 /* This is like s_space, but the value is a floating point number with
2082 the given precision. This is for the MRI dcb.s pseudo-op and
2086 s_float_space (float_type)
2091 char temp[MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT];
2093 count = get_absolute_expression ();
2096 if (*input_line_pointer != ',')
2098 as_bad ("missing value");
2099 ignore_rest_of_line ();
2103 ++input_line_pointer;
2107 /* Skip any 0{letter} that may be present. Don't even check if the
2108 * letter is legal. */
2109 if (input_line_pointer[0] == '0' && isalpha (input_line_pointer[1]))
2110 input_line_pointer += 2;
2112 /* Accept :xxxx, where the x's are hex digits, for a floating point
2113 with the exact digits specified. */
2114 if (input_line_pointer[0] == ':')
2116 flen = hex_float (float_type, temp);
2119 ignore_rest_of_line ();
2127 err = md_atof (float_type, temp, &flen);
2128 know (flen <= MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT);
2132 as_bad ("Bad floating literal: %s", err);
2133 ignore_rest_of_line ();
2138 while (--count >= 0)
2142 p = frag_more (flen);
2143 memcpy (p, temp, (unsigned int) flen);
2146 demand_empty_rest_of_line ();
2149 /* Handle the .struct pseudo-op, as found in MIPS assemblers. */
2155 abs_section_offset = get_absolute_expression ();
2156 subseg_set (absolute_section, 0);
2157 demand_empty_rest_of_line ();
2166 temp = get_absolute_expression ();
2167 subseg_set (text_section, (subsegT) temp);
2168 demand_empty_rest_of_line ();
2170 const_flag &= ~IN_DEFAULT_SECTION;
2176 demand_empty_rest_of_line ()
2179 if (is_end_of_line[(unsigned char) *input_line_pointer])
2181 input_line_pointer++;
2185 ignore_rest_of_line ();
2187 /* Return having already swallowed end-of-line. */
2188 } /* Return pointing just after end-of-line. */
2191 ignore_rest_of_line () /* For suspect lines: gives warning. */
2193 if (!is_end_of_line[(unsigned char) *input_line_pointer])
2195 if (isprint (*input_line_pointer))
2196 as_bad ("Rest of line ignored. First ignored character is `%c'.",
2197 *input_line_pointer);
2199 as_bad ("Rest of line ignored. First ignored character valued 0x%x.",
2200 *input_line_pointer);
2201 while (input_line_pointer < buffer_limit
2202 && !is_end_of_line[(unsigned char) *input_line_pointer])
2204 input_line_pointer++;
2207 input_line_pointer++; /* Return pointing just after end-of-line. */
2208 know (is_end_of_line[(unsigned char) input_line_pointer[-1]]);
2214 * In: Pointer to a symbol.
2215 * Input_line_pointer->expression.
2217 * Out: Input_line_pointer->just after any whitespace after expression.
2218 * Tried to set symbol to value of expression.
2219 * Will change symbols type, value, and frag;
2222 pseudo_set (symbolP)
2226 #if (defined (OBJ_AOUT) || defined (OBJ_BOUT)) && ! defined (BFD_ASSEMBLER)
2228 #endif /* OBJ_AOUT or OBJ_BOUT */
2230 know (symbolP); /* NULL pointer is logic error. */
2231 #if (defined (OBJ_AOUT) || defined (OBJ_BOUT)) && ! defined (BFD_ASSEMBLER)
2232 ext = S_IS_EXTERNAL (symbolP);
2233 #endif /* OBJ_AOUT or OBJ_BOUT */
2235 (void) expression (&exp);
2237 if (exp.X_op == O_illegal)
2238 as_bad ("illegal expression; zero assumed");
2239 else if (exp.X_op == O_absent)
2240 as_bad ("missing expression; zero assumed");
2241 else if (exp.X_op == O_big)
2242 as_bad ("%s number invalid; zero assumed",
2243 exp.X_add_number > 0 ? "bignum" : "floating point");
2244 else if (exp.X_op == O_subtract
2245 && (S_GET_SEGMENT (exp.X_add_symbol)
2246 == S_GET_SEGMENT (exp.X_op_symbol))
2247 && SEG_NORMAL (S_GET_SEGMENT (exp.X_add_symbol))
2248 && exp.X_add_symbol->sy_frag == exp.X_op_symbol->sy_frag)
2250 exp.X_op = O_constant;
2251 exp.X_add_number = (S_GET_VALUE (exp.X_add_symbol)
2252 - S_GET_VALUE (exp.X_op_symbol));
2260 exp.X_add_number = 0;
2263 S_SET_SEGMENT (symbolP, absolute_section);
2264 #if (defined (OBJ_AOUT) || defined (OBJ_BOUT)) && ! defined (BFD_ASSEMBLER)
2266 S_SET_EXTERNAL (symbolP);
2268 S_CLEAR_EXTERNAL (symbolP);
2269 #endif /* OBJ_AOUT or OBJ_BOUT */
2270 S_SET_VALUE (symbolP, (valueT) exp.X_add_number);
2271 symbolP->sy_frag = &zero_address_frag;
2275 S_SET_SEGMENT (symbolP, reg_section);
2276 S_SET_VALUE (symbolP, (valueT) exp.X_add_number);
2277 symbolP->sy_frag = &zero_address_frag;
2281 if (S_GET_SEGMENT (exp.X_add_symbol) == undefined_section
2282 || exp.X_add_number != 0)
2283 symbolP->sy_value = exp;
2286 symbolS *s = exp.X_add_symbol;
2288 S_SET_SEGMENT (symbolP, S_GET_SEGMENT (s));
2289 #if (defined (OBJ_AOUT) || defined (OBJ_BOUT)) && ! defined (BFD_ASSEMBLER)
2291 S_SET_EXTERNAL (symbolP);
2293 S_CLEAR_EXTERNAL (symbolP);
2294 #endif /* OBJ_AOUT or OBJ_BOUT */
2295 S_SET_VALUE (symbolP,
2296 exp.X_add_number + S_GET_VALUE (s));
2297 symbolP->sy_frag = s->sy_frag;
2298 copy_symbol_attributes (symbolP, s);
2303 /* The value is some complex expression.
2304 FIXME: Should we set the segment to anything? */
2305 symbolP->sy_value = exp;
2313 * CONStruct more frag of .bytes, or .words etc.
2314 * Should need_pass_2 be 1 then emit no frag(s).
2315 * This understands EXPRESSIONS.
2319 * This has a split personality. We use expression() to read the
2320 * value. We can detect if the value won't fit in a byte or word.
2321 * But we can't detect if expression() discarded significant digits
2322 * in the case of a long. Not worth the crocks required to fix it.
2325 /* Select a parser for cons expressions. */
2327 /* Some targets need to parse the expression in various fancy ways.
2328 You can define TC_PARSE_CONS_EXPRESSION to do whatever you like
2329 (for example, the HPPA does this). Otherwise, you can define
2330 BITFIELD_CONS_EXPRESSIONS to permit bitfields to be specified, or
2331 REPEAT_CONS_EXPRESSIONS to permit repeat counts. If none of these
2332 are defined, which is the normal case, then only simple expressions
2336 parse_mri_cons PARAMS ((expressionS *exp, unsigned int nbytes));
2338 #ifndef TC_PARSE_CONS_EXPRESSION
2339 #ifdef BITFIELD_CONS_EXPRESSIONS
2340 #define TC_PARSE_CONS_EXPRESSION(EXP, NBYTES) parse_bitfield_cons (EXP, NBYTES)
2342 parse_bitfield_cons PARAMS ((expressionS *exp, unsigned int nbytes));
2344 #ifdef REPEAT_CONS_EXPRESSIONS
2345 #define TC_PARSE_CONS_EXPRESSION(EXP, NBYTES) parse_repeat_cons (EXP, NBYTES)
2347 parse_repeat_cons PARAMS ((expressionS *exp, unsigned int nbytes));
2350 /* If we haven't gotten one yet, just call expression. */
2351 #ifndef TC_PARSE_CONS_EXPRESSION
2352 #define TC_PARSE_CONS_EXPRESSION(EXP, NBYTES) expression (EXP)
2356 /* worker to do .byte etc statements */
2357 /* clobbers input_line_pointer, checks */
2361 register int nbytes; /* 1=.byte, 2=.word, 4=.long */
2366 #ifdef md_flush_pending_output
2367 md_flush_pending_output ();
2370 if (is_it_end_of_statement ())
2372 demand_empty_rest_of_line ();
2380 parse_mri_cons (&exp, (unsigned int) nbytes);
2382 TC_PARSE_CONS_EXPRESSION (&exp, (unsigned int) nbytes);
2383 emit_expr (&exp, (unsigned int) nbytes);
2386 while (*input_line_pointer++ == ',');
2388 /* In MRI mode, after an odd number of bytes, we must align to an
2389 even word boundary, unless the next instruction is a dc.b, ds.b
2391 if (flag_mri && nbytes == 1 && (c & 1) != 0)
2392 mri_pending_align = 1;
2394 input_line_pointer--; /* Put terminator back into stream. */
2395 demand_empty_rest_of_line ();
2398 /* Put the contents of expression EXP into the object file using
2399 NBYTES bytes. If need_pass_2 is 1, this does nothing. */
2402 emit_expr (exp, nbytes)
2404 unsigned int nbytes;
2408 valueT extra_digit = 0;
2410 /* Don't do anything if we are going to make another pass. */
2416 /* Allow `.word 0' in the absolute section. */
2417 if (now_seg == absolute_section)
2419 if (op != O_constant || exp->X_add_number != 0)
2420 as_bad ("attempt to store value in absolute section");
2421 abs_section_offset += nbytes;
2425 /* Handle a negative bignum. */
2427 && exp->X_add_number == 0
2428 && exp->X_add_symbol->sy_value.X_op == O_big
2429 && exp->X_add_symbol->sy_value.X_add_number > 0)
2432 unsigned long carry;
2434 exp = &exp->X_add_symbol->sy_value;
2436 /* Negate the bignum: one's complement each digit and add 1. */
2438 for (i = 0; i < exp->X_add_number; i++)
2442 next = (((~ (generic_bignum[i] & LITTLENUM_MASK))
2445 generic_bignum[i] = next & LITTLENUM_MASK;
2446 carry = next >> LITTLENUM_NUMBER_OF_BITS;
2449 /* We can ignore any carry out, because it will be handled by
2450 extra_digit if it is needed. */
2452 extra_digit = (valueT) -1;
2456 if (op == O_absent || op == O_illegal)
2458 as_warn ("zero assumed for missing expression");
2459 exp->X_add_number = 0;
2462 else if (op == O_big && exp->X_add_number <= 0)
2464 as_bad ("floating point number invalid; zero assumed");
2465 exp->X_add_number = 0;
2468 else if (op == O_register)
2470 as_warn ("register value used as expression");
2474 p = frag_more ((int) nbytes);
2476 #ifndef WORKING_DOT_WORD
2477 /* If we have the difference of two symbols in a word, save it on
2478 the broken_words list. See the code in write.c. */
2479 if (op == O_subtract && nbytes == 2)
2481 struct broken_word *x;
2483 x = (struct broken_word *) xmalloc (sizeof (struct broken_word));
2484 x->next_broken_word = broken_words;
2487 x->word_goes_here = p;
2489 x->add = exp->X_add_symbol;
2490 x->sub = exp->X_op_symbol;
2491 x->addnum = exp->X_add_number;
2498 /* If we have an integer, but the number of bytes is too large to
2499 pass to md_number_to_chars, handle it as a bignum. */
2500 if (op == O_constant && nbytes > sizeof (valueT))
2505 if (! exp->X_unsigned && exp->X_add_number < 0)
2506 extra_digit = (valueT) -1;
2507 val = (valueT) exp->X_add_number;
2511 generic_bignum[gencnt] = val & LITTLENUM_MASK;
2512 val >>= LITTLENUM_NUMBER_OF_BITS;
2516 op = exp->X_op = O_big;
2517 exp->X_add_number = gencnt;
2520 if (op == O_constant)
2522 register valueT get;
2523 register valueT use;
2524 register valueT mask;
2525 register valueT unmask;
2527 /* JF << of >= number of bits in the object is undefined. In
2528 particular SPARC (Sun 4) has problems */
2529 if (nbytes >= sizeof (valueT))
2532 mask = ~(valueT) 0 << (BITS_PER_CHAR * nbytes); /* Don't store these bits. */
2534 unmask = ~mask; /* Do store these bits. */
2537 "Do this mod if you want every overflow check to assume SIGNED 2's complement data.";
2538 mask = ~(unmask >> 1); /* Includes sign bit now. */
2541 get = exp->X_add_number;
2543 if ((get & mask) != 0 && (get & mask) != mask)
2544 { /* Leading bits contain both 0s & 1s. */
2545 as_warn ("Value 0x%lx truncated to 0x%lx.", get, use);
2547 /* put bytes in right order. */
2548 md_number_to_chars (p, use, (int) nbytes);
2550 else if (op == O_big)
2553 LITTLENUM_TYPE *nums;
2555 know (nbytes % CHARS_PER_LITTLENUM == 0);
2557 size = exp->X_add_number * CHARS_PER_LITTLENUM;
2560 as_warn ("Bignum truncated to %d bytes", nbytes);
2564 if (target_big_endian)
2566 while (nbytes > size)
2568 md_number_to_chars (p, extra_digit, CHARS_PER_LITTLENUM);
2569 nbytes -= CHARS_PER_LITTLENUM;
2570 p += CHARS_PER_LITTLENUM;
2573 nums = generic_bignum + size / CHARS_PER_LITTLENUM;
2577 md_number_to_chars (p, (valueT) *nums, CHARS_PER_LITTLENUM);
2578 size -= CHARS_PER_LITTLENUM;
2579 p += CHARS_PER_LITTLENUM;
2584 nums = generic_bignum;
2587 md_number_to_chars (p, (valueT) *nums, CHARS_PER_LITTLENUM);
2589 size -= CHARS_PER_LITTLENUM;
2590 p += CHARS_PER_LITTLENUM;
2591 nbytes -= CHARS_PER_LITTLENUM;
2596 md_number_to_chars (p, extra_digit, CHARS_PER_LITTLENUM);
2597 nbytes -= CHARS_PER_LITTLENUM;
2598 p += CHARS_PER_LITTLENUM;
2604 memset (p, 0, nbytes);
2606 /* Now we need to generate a fixS to record the symbol value.
2607 This is easy for BFD. For other targets it can be more
2608 complex. For very complex cases (currently, the HPPA and
2609 NS32K), you can define TC_CONS_FIX_NEW to do whatever you
2610 want. For simpler cases, you can define TC_CONS_RELOC to be
2611 the name of the reloc code that should be stored in the fixS.
2612 If neither is defined, the code uses NO_RELOC if it is
2613 defined, and otherwise uses 0. */
2615 #ifdef BFD_ASSEMBLER
2616 #ifdef TC_CONS_FIX_NEW
2617 TC_CONS_FIX_NEW (frag_now, p - frag_now->fr_literal, nbytes, exp);
2619 fix_new_exp (frag_now, p - frag_now->fr_literal, (int) nbytes, exp, 0,
2620 /* @@ Should look at CPU word size. */
2621 nbytes == 2 ? BFD_RELOC_16
2622 : nbytes == 8 ? BFD_RELOC_64
2626 #ifdef TC_CONS_FIX_NEW
2627 TC_CONS_FIX_NEW (frag_now, p - frag_now->fr_literal, nbytes, exp);
2629 /* Figure out which reloc number to use. Use TC_CONS_RELOC if
2630 it is defined, otherwise use NO_RELOC if it is defined,
2632 #ifndef TC_CONS_RELOC
2634 #define TC_CONS_RELOC NO_RELOC
2636 #define TC_CONS_RELOC 0
2639 fix_new_exp (frag_now, p - frag_now->fr_literal, (int) nbytes, exp, 0,
2641 #endif /* TC_CONS_FIX_NEW */
2642 #endif /* BFD_ASSEMBLER */
2646 #ifdef BITFIELD_CONS_EXPRESSIONS
2648 /* i960 assemblers, (eg, asm960), allow bitfields after ".byte" as
2649 w:x,y:z, where w and y are bitwidths and x and y are values. They
2650 then pack them all together. We do a little better in that we allow
2651 them in words, longs, etc. and we'll pack them in target byte order
2654 The rules are: pack least significat bit first, if a field doesn't
2655 entirely fit, put it in the next unit. Overflowing the bitfield is
2656 explicitly *not* even a warning. The bitwidth should be considered
2659 To use this function the tc-XXX.h file should define
2660 BITFIELD_CONS_EXPRESSIONS. */
2663 parse_bitfield_cons (exp, nbytes)
2665 unsigned int nbytes;
2667 unsigned int bits_available = BITS_PER_CHAR * nbytes;
2668 char *hold = input_line_pointer;
2670 (void) expression (exp);
2672 if (*input_line_pointer == ':')
2678 unsigned long width;
2680 if (*input_line_pointer != ':')
2682 input_line_pointer = hold;
2684 } /* next piece is not a bitfield */
2686 /* In the general case, we can't allow
2687 full expressions with symbol
2688 differences and such. The relocation
2689 entries for symbols not defined in this
2690 assembly would require arbitrary field
2691 widths, positions, and masks which most
2692 of our current object formats don't
2695 In the specific case where a symbol
2696 *is* defined in this assembly, we
2697 *could* build fixups and track it, but
2698 this could lead to confusion for the
2699 backends. I'm lazy. I'll take any
2700 SEG_ABSOLUTE. I think that means that
2701 you can use a previous .set or
2702 .equ type symbol. xoxorich. */
2704 if (exp->X_op == O_absent)
2706 as_warn ("using a bit field width of zero");
2707 exp->X_add_number = 0;
2708 exp->X_op = O_constant;
2709 } /* implied zero width bitfield */
2711 if (exp->X_op != O_constant)
2713 *input_line_pointer = '\0';
2714 as_bad ("field width \"%s\" too complex for a bitfield", hold);
2715 *input_line_pointer = ':';
2716 demand_empty_rest_of_line ();
2720 if ((width = exp->X_add_number) > (BITS_PER_CHAR * nbytes))
2722 as_warn ("field width %lu too big to fit in %d bytes: truncated to %d bits",
2723 width, nbytes, (BITS_PER_CHAR * nbytes));
2724 width = BITS_PER_CHAR * nbytes;
2727 if (width > bits_available)
2729 /* FIXME-SOMEDAY: backing up and reparsing is wasteful. */
2730 input_line_pointer = hold;
2731 exp->X_add_number = value;
2735 hold = ++input_line_pointer; /* skip ':' */
2737 (void) expression (exp);
2738 if (exp->X_op != O_constant)
2740 char cache = *input_line_pointer;
2742 *input_line_pointer = '\0';
2743 as_bad ("field value \"%s\" too complex for a bitfield", hold);
2744 *input_line_pointer = cache;
2745 demand_empty_rest_of_line ();
2749 value |= ((~(-1 << width) & exp->X_add_number)
2750 << ((BITS_PER_CHAR * nbytes) - bits_available));
2752 if ((bits_available -= width) == 0
2753 || is_it_end_of_statement ()
2754 || *input_line_pointer != ',')
2757 } /* all the bitfields we're gonna get */
2759 hold = ++input_line_pointer;
2760 (void) expression (exp);
2761 } /* forever loop */
2763 exp->X_add_number = value;
2764 exp->X_op = O_constant;
2765 exp->X_unsigned = 1;
2766 } /* if looks like a bitfield */
2767 } /* parse_bitfield_cons() */
2769 #endif /* BITFIELD_CONS_EXPRESSIONS */
2771 /* Handle an MRI style string expression. */
2774 parse_mri_cons (exp, nbytes)
2776 unsigned int nbytes;
2778 if (*input_line_pointer != '\''
2779 && (input_line_pointer[1] != '\''
2780 || (*input_line_pointer != 'A'
2781 && *input_line_pointer != 'E')))
2782 TC_PARSE_CONS_EXPRESSION (exp, nbytes);
2786 unsigned int result = 0;
2788 /* An MRI style string. Cut into as many bytes as will fit into
2789 a nbyte chunk, left justify if necessary, and separate with
2790 commas so we can try again later. */
2791 if (*input_line_pointer == 'A')
2792 ++input_line_pointer;
2793 else if (*input_line_pointer == 'E')
2795 as_bad ("EBCDIC constants are not supported");
2796 ++input_line_pointer;
2799 input_line_pointer++;
2800 for (scan = 0; scan < nbytes; scan++)
2802 if (*input_line_pointer == '\'')
2804 if (input_line_pointer[1] == '\'')
2806 input_line_pointer++;
2811 result = (result << 8) | (*input_line_pointer++);
2815 while (scan < nbytes)
2820 /* Create correct expression */
2821 exp->X_op = O_constant;
2822 exp->X_add_number = result;
2823 /* Fake it so that we can read the next char too */
2824 if (input_line_pointer[0] != '\'' ||
2825 (input_line_pointer[0] == '\'' && input_line_pointer[1] == '\''))
2827 input_line_pointer -= 2;
2828 input_line_pointer[0] = ',';
2829 input_line_pointer[1] = '\'';
2832 input_line_pointer++;
2836 #ifdef REPEAT_CONS_EXPRESSIONS
2838 /* Parse a repeat expression for cons. This is used by the MIPS
2839 assembler. The format is NUMBER:COUNT; NUMBER appears in the
2840 object file COUNT times.
2842 To use this for a target, define REPEAT_CONS_EXPRESSIONS. */
2845 parse_repeat_cons (exp, nbytes)
2847 unsigned int nbytes;
2854 if (*input_line_pointer != ':')
2856 /* No repeat count. */
2860 ++input_line_pointer;
2861 expression (&count);
2862 if (count.X_op != O_constant
2863 || count.X_add_number <= 0)
2865 as_warn ("Unresolvable or nonpositive repeat count; using 1");
2869 /* The cons function is going to output this expression once. So we
2870 output it count - 1 times. */
2871 for (i = count.X_add_number - 1; i > 0; i--)
2872 emit_expr (exp, nbytes);
2875 #endif /* REPEAT_CONS_EXPRESSIONS */
2877 /* Parse a floating point number represented as a hex constant. This
2878 permits users to specify the exact bits they want in the floating
2882 hex_float (float_type, bytes)
2916 as_bad ("Unknown floating type type '%c'", float_type);
2920 /* It would be nice if we could go through expression to parse the
2921 hex constant, but if we get a bignum it's a pain to sort it into
2922 the buffer correctly. */
2924 while (hex_p (*input_line_pointer) || *input_line_pointer == '_')
2928 /* The MRI assembler accepts arbitrary underscores strewn about
2929 through the hex constant, so we ignore them as well. */
2930 if (*input_line_pointer == '_')
2932 ++input_line_pointer;
2938 as_warn ("Floating point constant too large");
2941 d = hex_value (*input_line_pointer) << 4;
2942 ++input_line_pointer;
2943 while (*input_line_pointer == '_')
2944 ++input_line_pointer;
2945 if (hex_p (*input_line_pointer))
2947 d += hex_value (*input_line_pointer);
2948 ++input_line_pointer;
2950 if (target_big_endian)
2953 bytes[length - i - 1] = d;
2959 if (target_big_endian)
2960 memset (bytes + i, 0, length - i);
2962 memset (bytes, 0, length - i);
2971 * CONStruct some more frag chars of .floats .ffloats etc.
2972 * Makes 0 or more new frags.
2973 * If need_pass_2 == 1, no frags are emitted.
2974 * This understands only floating literals, not expressions. Sorry.
2976 * A floating constant is defined by atof_generic(), except it is preceded
2977 * by 0d 0f 0g or 0h. After observing the STRANGE way my BSD AS does its
2978 * reading, I decided to be incompatible. This always tries to give you
2979 * rounded bits to the precision of the pseudo-op. Former AS did premature
2980 * truncatation, restored noisy bits instead of trailing 0s AND gave you
2981 * a choice of 2 flavours of noise according to which of 2 floating-point
2982 * scanners you directed AS to use.
2984 * In: input_line_pointer->whitespace before, or '0' of flonum.
2989 float_cons (float_type)
2990 /* Clobbers input_line-pointer, checks end-of-line. */
2991 register int float_type; /* 'f':.ffloat ... 'F':.float ... */
2994 int length; /* Number of chars in an object. */
2995 register char *err; /* Error from scanning floating literal. */
2996 char temp[MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT];
2998 if (is_it_end_of_statement ())
3000 demand_empty_rest_of_line ();
3006 /* input_line_pointer->1st char of a flonum (we hope!). */
3009 /* Skip any 0{letter} that may be present. Don't even check if the
3010 * letter is legal. Someone may invent a "z" format and this routine
3011 * has no use for such information. Lusers beware: you get
3012 * diagnostics if your input is ill-conditioned.
3014 if (input_line_pointer[0] == '0' && isalpha (input_line_pointer[1]))
3015 input_line_pointer += 2;
3017 /* Accept :xxxx, where the x's are hex digits, for a floating
3018 point with the exact digits specified. */
3019 if (input_line_pointer[0] == ':')
3021 ++input_line_pointer;
3022 length = hex_float (float_type, temp);
3025 ignore_rest_of_line ();
3031 err = md_atof (float_type, temp, &length);
3032 know (length <= MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT);
3036 as_bad ("Bad floating literal: %s", err);
3037 ignore_rest_of_line ();
3048 #ifdef REPEAT_CONS_EXPRESSIONS
3049 if (*input_line_pointer == ':')
3051 expressionS count_exp;
3053 ++input_line_pointer;
3054 expression (&count_exp);
3055 if (count_exp.X_op != O_constant
3056 || count_exp.X_add_number <= 0)
3058 as_warn ("unresolvable or nonpositive repeat count; using 1");
3061 count = count_exp.X_add_number;
3065 while (--count >= 0)
3067 p = frag_more (length);
3068 memcpy (p, temp, (unsigned int) length);
3073 while (*input_line_pointer++ == ',');
3075 --input_line_pointer; /* Put terminator back into stream. */
3076 demand_empty_rest_of_line ();
3077 } /* float_cons() */
3082 * We read 0 or more ',' seperated, double-quoted strings.
3084 * Caller should have checked need_pass_2 is FALSE because we don't check it.
3089 stringer (append_zero) /* Worker to do .ascii etc statements. */
3090 /* Checks end-of-line. */
3091 register int append_zero; /* 0: don't append '\0', else 1 */
3093 register unsigned int c;
3095 #ifdef md_flush_pending_output
3096 md_flush_pending_output ();
3100 * The following awkward logic is to parse ZERO or more strings,
3101 * comma seperated. Recall a string expression includes spaces
3102 * before the opening '\"' and spaces after the closing '\"'.
3103 * We fake a leading ',' if there is (supposed to be)
3104 * a 1st, expression. We keep demanding expressions for each
3107 if (is_it_end_of_statement ())
3109 c = 0; /* Skip loop. */
3110 ++input_line_pointer; /* Compensate for end of loop. */
3114 c = ','; /* Do loop. */
3116 while (c == ',' || c == '<' || c == '"')
3119 switch (*input_line_pointer)
3122 ++input_line_pointer; /*->1st char of string. */
3123 while (is_a_char (c = next_char_of_string ()))
3125 FRAG_APPEND_1_CHAR (c);
3129 FRAG_APPEND_1_CHAR (0);
3131 know (input_line_pointer[-1] == '\"');
3134 input_line_pointer++;
3135 c = get_single_number ();
3136 FRAG_APPEND_1_CHAR (c);
3137 if (*input_line_pointer != '>')
3139 as_bad ("Expected <nn>");
3141 input_line_pointer++;
3144 input_line_pointer++;
3148 c = *input_line_pointer;
3151 demand_empty_rest_of_line ();
3154 /* FIXME-SOMEDAY: I had trouble here on characters with the
3155 high bits set. We'll probably also have trouble with
3156 multibyte chars, wide chars, etc. Also be careful about
3157 returning values bigger than 1 byte. xoxorich. */
3160 next_char_of_string ()
3162 register unsigned int c;
3164 c = *input_line_pointer++ & CHAR_MASK;
3171 #ifndef NO_STRING_ESCAPES
3173 switch (c = *input_line_pointer++)
3201 break; /* As itself. */
3217 for (i = 0, number = 0; isdigit (c) && i < 3; c = *input_line_pointer++, i++)
3219 number = number * 8 + c - '0';
3223 --input_line_pointer;
3232 c = *input_line_pointer++;
3233 while (isxdigit (c))
3236 number = number * 16 + c - '0';
3237 else if (isupper (c))
3238 number = number * 16 + c - 'A' + 10;
3240 number = number * 16 + c - 'a' + 10;
3241 c = *input_line_pointer++;
3244 --input_line_pointer;
3249 /* To be compatible with BSD 4.2 as: give the luser a linefeed!! */
3250 as_warn ("Unterminated string: Newline inserted.");
3256 #ifdef ONLY_STANDARD_ESCAPES
3257 as_bad ("Bad escaped character in string, '?' assumed");
3259 #endif /* ONLY_STANDARD_ESCAPES */
3262 } /* switch on escaped char */
3264 #endif /* ! defined (NO_STRING_ESCAPES) */
3268 } /* switch on char */
3270 } /* next_char_of_string() */
3273 get_segmented_expression (expP)
3274 register expressionS *expP;
3276 register segT retval;
3278 retval = expression (expP);
3279 if (expP->X_op == O_illegal
3280 || expP->X_op == O_absent
3281 || expP->X_op == O_big)
3283 as_bad ("expected address expression; zero assumed");
3284 expP->X_op = O_constant;
3285 expP->X_add_number = 0;
3286 retval = absolute_section;
3292 get_known_segmented_expression (expP)
3293 register expressionS *expP;
3295 register segT retval;
3297 if ((retval = get_segmented_expression (expP)) == undefined_section)
3299 /* There is no easy way to extract the undefined symbol from the
3301 if (expP->X_add_symbol != NULL
3302 && S_GET_SEGMENT (expP->X_add_symbol) != expr_section)
3303 as_warn ("symbol \"%s\" undefined; zero assumed",
3304 S_GET_NAME (expP->X_add_symbol));
3306 as_warn ("some symbol undefined; zero assumed");
3307 retval = absolute_section;
3308 expP->X_op = O_constant;
3309 expP->X_add_number = 0;
3311 know (retval == absolute_section || SEG_NORMAL (retval));
3313 } /* get_known_segmented_expression() */
3316 get_absolute_expression ()
3321 if (exp.X_op != O_constant)
3323 if (exp.X_op != O_absent)
3324 as_bad ("bad or irreducible absolute expression; zero assumed");
3325 exp.X_add_number = 0;
3327 return exp.X_add_number;
3330 char /* return terminator */
3331 get_absolute_expression_and_terminator (val_pointer)
3332 long *val_pointer; /* return value of expression */
3334 /* FIXME: val_pointer should probably be offsetT *. */
3335 *val_pointer = (long) get_absolute_expression ();
3336 return (*input_line_pointer++);
3340 * demand_copy_C_string()
3342 * Like demand_copy_string, but return NULL if the string contains any '\0's.
3343 * Give a warning if that happens.
3346 demand_copy_C_string (len_pointer)
3351 if ((s = demand_copy_string (len_pointer)) != 0)
3355 for (len = *len_pointer;
3364 as_bad ("This string may not contain \'\\0\'");
3372 * demand_copy_string()
3374 * Demand string, but return a safe (=private) copy of the string.
3375 * Return NULL if we can't read a string here.
3378 demand_copy_string (lenP)
3381 register unsigned int c;
3387 if (*input_line_pointer == '\"')
3389 input_line_pointer++; /* Skip opening quote. */
3391 while (is_a_char (c = next_char_of_string ()))
3393 obstack_1grow (¬es, c);
3396 /* JF this next line is so demand_copy_C_string will return a null
3397 termanated string. */
3398 obstack_1grow (¬es, '\0');
3399 retval = obstack_finish (¬es);
3403 as_warn ("Missing string");
3405 ignore_rest_of_line ();
3409 } /* demand_copy_string() */
3412 * is_it_end_of_statement()
3414 * In: Input_line_pointer->next character.
3416 * Do: Skip input_line_pointer over all whitespace.
3418 * Out: 1 if input_line_pointer->end-of-line.
3421 is_it_end_of_statement ()
3424 return (is_end_of_line[(unsigned char) *input_line_pointer]);
3425 } /* is_it_end_of_statement() */
3431 register symbolS *symbolP; /* symbol we are working with */
3433 input_line_pointer++;
3434 if (*input_line_pointer == '=')
3435 input_line_pointer++;
3437 while (*input_line_pointer == ' ' || *input_line_pointer == '\t')
3438 input_line_pointer++;
3440 if (sym_name[0] == '.' && sym_name[1] == '\0')
3442 /* Turn '. = mumble' into a .org mumble */
3443 register segT segment;
3446 segment = get_known_segmented_expression (&exp);
3448 do_org (segment, &exp, 0);
3452 symbolP = symbol_find_or_make (sym_name);
3453 pseudo_set (symbolP);
3457 /* .include -- include a file at this point. */
3471 filename = demand_copy_string (&i);
3476 while (! is_end_of_line[(unsigned char) *input_line_pointer]
3477 && *input_line_pointer != ' '
3478 && *input_line_pointer != '\t')
3480 obstack_1grow (¬es, *input_line_pointer);
3481 ++input_line_pointer;
3484 obstack_1grow (¬es, '\0');
3485 filename = obstack_finish (¬es);
3487 demand_empty_rest_of_line ();
3488 path = xmalloc ((unsigned long) i + include_dir_maxlen + 5 /* slop */ );
3489 for (i = 0; i < include_dir_count; i++)
3491 strcpy (path, include_dirs[i]);
3493 strcat (path, filename);
3494 if (0 != (try = fopen (path, "r")))
3503 /* malloc Storage leak when file is found on path. FIXME-SOMEDAY. */
3504 newbuf = input_scrub_include_file (path, input_line_pointer);
3505 buffer_limit = input_scrub_next_buffer (&input_line_pointer);
3509 add_include_dir (path)
3514 if (include_dir_count == 0)
3516 include_dirs = (char **) xmalloc (2 * sizeof (*include_dirs));
3517 include_dirs[0] = "."; /* Current dir */
3518 include_dir_count = 2;
3522 include_dir_count++;
3523 include_dirs = (char **) realloc (include_dirs,
3524 include_dir_count * sizeof (*include_dirs));
3527 include_dirs[include_dir_count - 1] = path; /* New one */
3530 if (i > include_dir_maxlen)
3531 include_dir_maxlen = i;
3532 } /* add_include_dir() */
3538 while (!is_end_of_line[(unsigned char) *input_line_pointer])
3540 ++input_line_pointer;
3542 ++input_line_pointer;