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. */
45 #include "libiberty.h"
49 #ifndef TC_START_LABEL
50 #define TC_START_LABEL(x,y) (x==':')
53 /* The NOP_OPCODE is for the alignment fill value.
54 * fill it a nop instruction so that the disassembler does not choke
58 #define NOP_OPCODE 0x00
61 char *input_line_pointer
; /*->next char of source file to parse. */
63 int generate_asm_lineno
= 0; /* flag to generate line stab for .s file */
65 #if BITS_PER_CHAR != 8
66 /* The following table is indexed by[(char)] and will break if
67 a char does not have exactly 256 states (hopefully 0:255!)! */
72 /* The m88k unfortunately uses @ as a label beginner. */
77 /* The RS/6000 assembler uses {,},[,] as parts of symbol names. */
82 /* The Delta 68k assembler permits % inside label names. */
86 /* used by is_... macros. our ctype[] */
89 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* @ABCDEFGHIJKLMNO */
90 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* PQRSTUVWXYZ[\]^_ */
91 0, 0, 0, 0, 3, LEX_PCT
, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, /* _!"#$%&'()*+,-./ */
92 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, /* 0123456789:;<=>? */
93 LEX_AT
, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, /* @ABCDEFGHIJKLMNO */
94 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, LEX_BR
, 0, LEX_BR
, 0, 3, /* PQRSTUVWXYZ[\]^_ */
95 0, 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, 0, /* pqrstuvwxyz{|}~. */
97 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
98 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
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,
109 * Out: 1 if this character ends a line.
112 char is_end_of_line
[256] =
115 _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, 99, _
, _
, 99, _
, _
, /* @abcdefghijklmno */
117 _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, 99, _
, _
, _
, _
, _
, /* @abcdefghijklmno */
119 _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, /* */
121 _
,99, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, /* _!"#$%&'()*+,-./ */
122 _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, /* 0123456789:;<=>? */
124 _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, /* */
125 _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, 99, _
, _
, _
, _
, /* 0123456789:;<=>? */
127 _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, /* */
128 _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, /* */
129 _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, /* */
130 _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, /* */
131 _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, /* */
132 _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, /* */
133 _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, /* */
134 _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, /* */
135 _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, /* */
139 /* Functions private to this file. */
141 static char *buffer
; /* 1st char of each buffer of lines is here. */
142 static char *buffer_limit
; /*->1 + last char in buffer. */
144 #ifdef TARGET_BYTES_BIG_ENDIAN
145 /* Hack to deal with tc-*.h defining TARGET_BYTES_BIG_ENDIAN to empty
146 instead of to 0 or 1. */
147 #if 5 - TARGET_BYTES_BIG_ENDIAN - 5 == 10
148 #undef TARGET_BYTES_BIG_ENDIAN
149 #define TARGET_BYTES_BIG_ENDIAN 1
151 int target_big_endian
= TARGET_BYTES_BIG_ENDIAN
;
153 int target_big_endian
/* = 0 */;
156 static char *old_buffer
; /* JF a hack */
157 static char *old_input
;
158 static char *old_limit
;
160 /* Variables for handling include file directory list. */
162 char **include_dirs
; /* List of pointers to directories to
163 search for .include's */
164 int include_dir_count
; /* How many are in the list */
165 int include_dir_maxlen
= 1;/* Length of longest in list */
167 #ifndef WORKING_DOT_WORD
168 struct broken_word
*broken_words
;
169 int new_broken_words
;
172 /* If this line had an MRI style label, it is stored in this variable.
173 This is used by some of the MRI pseudo-ops. */
174 static symbolS
*mri_line_label
;
176 /* This global variable is used to support MRI common sections. We
177 translate such sections into a common symbol. This variable is
178 non-NULL when we are in an MRI common section. */
179 symbolS
*mri_common_symbol
;
181 char *demand_copy_string
PARAMS ((int *lenP
));
182 int is_it_end_of_statement
PARAMS ((void));
183 static segT get_segmented_expression
PARAMS ((expressionS
*expP
));
184 static segT get_known_segmented_expression
PARAMS ((expressionS
* expP
));
185 static void pobegin
PARAMS ((void));
194 obj_read_begin_hook ();
196 /* Something close -- but not too close -- to a multiple of 1024.
197 The debugging malloc I'm using has 24 bytes of overhead. */
198 obstack_begin (¬es
, 5090);
199 obstack_begin (&cond_obstack
, 990);
201 /* Use machine dependent syntax */
202 for (p
= line_separator_chars
; *p
; p
++)
203 is_end_of_line
[(unsigned char) *p
] = 1;
204 /* Use more. FIXME-SOMEDAY. */
210 /* set up pseudo-op tables */
212 static struct hash_control
*po_hash
;
214 static const pseudo_typeS potable
[] =
216 {"abort", s_abort
, 0},
217 {"align", s_align_ptwo
, 0},
218 {"ascii", stringer
, 0},
219 {"asciz", stringer
, 1},
220 {"balign", s_align_bytes
, 0},
224 {"common", s_mri_common
, 0},
225 {"common.s", s_mri_common
, 1},
229 {"dc.d", float_cons
, 'd'},
231 {"dc.s", float_cons
, 'f'},
233 {"dc.x", float_cons
, 'x'},
235 {"ds.b", s_space
, 1},
236 {"ds.l", s_space
, 4},
237 {"ds.w", s_space
, 2},
242 {"double", float_cons
, 'd'},
244 {"eject", listing_eject
, 0}, /* Formfeed listing */
247 {"endif", s_endif
, 0},
252 {"extern", s_ignore
, 0}, /* We treat all undef as ext */
253 {"appfile", s_app_file
, 1},
254 {"appline", s_app_line
, 0},
255 {"file", s_app_file
, 0},
257 {"float", float_cons
, 'f'},
258 {"global", s_globl
, 0},
259 {"globl", s_globl
, 0},
262 {"ifdef", s_ifdef
, 0},
263 {"ifeqs", s_ifeqs
, 0},
264 {"ifndef", s_ifdef
, 1},
265 {"ifnes", s_ifeqs
, 1},
266 {"ifnotdef", s_ifdef
, 1},
267 {"include", s_include
, 0},
269 {"lcomm", s_lcomm
, 0},
270 {"lflags", listing_flags
, 0}, /* Listing flags */
271 {"list", listing_list
, 1}, /* Turn listing on */
274 {"nolist", listing_list
, 0}, /* Turn listing off */
277 {"p2align", s_align_ptwo
, 0},
278 {"psize", listing_psize
, 0}, /* set paper size */
281 {"sbttl", listing_title
, 1}, /* Subtitle of listing */
286 {"single", float_cons
, 'f'},
288 {"space", s_space
, 0},
289 {"stabd", s_stab
, 'd'},
290 {"stabn", s_stab
, 'n'},
291 {"stabs", s_stab
, 's'},
292 {"string", stringer
, 1},
296 /* This is for gcc to use. It's only just been added (2/94), so gcc
297 won't be able to use it for a while -- probably a year or more.
298 But once this has been released, check with gcc maintainers
299 before deleting it or even changing the spelling. */
300 {"this_GCC_requires_the_GNU_assembler", s_ignore
, 0},
301 /* If we're folding case -- done for some targets, not necessarily
302 all -- the above string in an input file will be converted to
303 this one. Match it either way... */
304 {"this_gcc_requires_the_gnu_assembler", s_ignore
, 0},
306 {"title", listing_title
, 0}, /* Listing title */
310 {"xdef", s_globl
, 0},
311 {"xstabs", s_xstab
, 's'},
313 {"zero", s_space
, 0},
314 {NULL
} /* end sentinel */
317 static int pop_override_ok
= 0;
318 static const char *pop_table_name
;
322 const pseudo_typeS
*table
;
325 const pseudo_typeS
*pop
;
326 for (pop
= table
; pop
->poc_name
; pop
++)
328 errtxt
= hash_insert (po_hash
, pop
->poc_name
, (char *) pop
);
329 if (errtxt
&& (!pop_override_ok
|| strcmp (errtxt
, "exists")))
330 as_fatal ("error constructing %s pseudo-op table", pop_table_name
);
334 #ifndef md_pop_insert
335 #define md_pop_insert() pop_insert(md_pseudo_table)
338 #ifndef obj_pop_insert
339 #define obj_pop_insert() pop_insert(obj_pseudo_table)
345 po_hash
= hash_new ();
347 /* Do the target-specific pseudo ops. */
348 pop_table_name
= "md";
351 /* Now object specific. Skip any that were in the target table. */
352 pop_table_name
= "obj";
356 /* Now portable ones. Skip any that we've seen already. */
357 pop_table_name
= "standard";
358 pop_insert (potable
);
361 #define HANDLE_CONDITIONAL_ASSEMBLY() \
362 if (ignore_input ()) \
364 while (! is_end_of_line[(unsigned char) *input_line_pointer++]) \
365 if (input_line_pointer == buffer_limit) \
371 /* read_a_source_file()
373 * We read the file, putting things into a web that
374 * represents what we have been reading.
377 read_a_source_file (name
)
381 register char *s
; /* string of symbol, '\0' appended */
385 buffer
= input_scrub_new_file (name
);
388 listing_newline ("");
390 while ((buffer_limit
= input_scrub_next_buffer (&input_line_pointer
)) != 0)
391 { /* We have another line to parse. */
392 know (buffer_limit
[-1] == '\n'); /* Must have a sentinel. */
393 contin
: /* JF this goto is my fault I admit it.
394 Someone brave please re-write the whole
395 input section here? Pleeze??? */
396 while (input_line_pointer
< buffer_limit
)
398 /* We have more of this buffer to parse. */
401 * We now have input_line_pointer->1st char of next line.
402 * If input_line_pointer [-1] == '\n' then we just
403 * scanned another line: so bump line counters.
405 if (is_end_of_line
[(unsigned char) input_line_pointer
[-1]])
407 #ifdef md_start_line_hook
408 md_start_line_hook ();
411 if (input_line_pointer
[-1] == '\n')
412 bump_line_counters ();
415 #ifdef LABELS_WITHOUT_COLONS
420 mri_line_label
= NULL
;
422 /* Text at the start of a line must be a label, we
423 run down and stick a colon in. */
424 if (is_name_beginner (*input_line_pointer
))
426 char *line_start
= input_line_pointer
;
427 char c
= get_symbol_end ();
429 /* In MRI mode, the EQU pseudoop must be handled
433 if ((strncasecmp (input_line_pointer
+ 1, "EQU", 3)
435 && (input_line_pointer
[4] == ' '
436 || input_line_pointer
[4] == '\t'))
438 input_line_pointer
+= 4;
444 mri_line_label
= colon (line_start
);
445 *input_line_pointer
= c
;
447 input_line_pointer
++;
453 * We are at the begining of a line, or similar place.
454 * We expect a well-formed assembler statement.
455 * A "symbol-name:" is a statement.
457 * Depending on what compiler is used, the order of these tests
458 * may vary to catch most common case 1st.
459 * Each test is independent of all other tests at the (top) level.
460 * PLEASE make a compiler that doesn't use this assembler.
461 * It is crufty to waste a compiler's time encoding things for this
462 * assembler, which then wastes more time decoding it.
463 * (And communicating via (linear) files is silly!
464 * If you must pass stuff, please pass a tree!)
466 if ((c
= *input_line_pointer
++) == '\t'
471 c
= *input_line_pointer
++;
473 know (c
!= ' '); /* No further leading whitespace. */
476 * C is the 1st significant character.
477 * Input_line_pointer points after that character.
479 if (is_name_beginner (c
))
481 /* want user-defined label or pseudo/opcode */
482 HANDLE_CONDITIONAL_ASSEMBLY ();
484 s
= --input_line_pointer
;
485 c
= get_symbol_end (); /* name's delimiter */
487 * C is character after symbol.
488 * That character's place in the input line is now '\0'.
489 * S points to the beginning of the symbol.
490 * [In case of pseudo-op, s->'.'.]
491 * Input_line_pointer->'\0' where c was.
493 if (TC_START_LABEL(c
, input_line_pointer
))
495 colon (s
); /* user-defined label */
496 *input_line_pointer
++ = ':'; /* Put ':' back for error messages' sake. */
497 /* Input_line_pointer->after ':'. */
503 || (input_line_pointer
[1] == '='
504 #ifdef TC_EQUAL_IN_INSN
505 && ! TC_EQUAL_IN_INSN (c
, input_line_pointer
)
510 demand_empty_rest_of_line ();
513 { /* expect pseudo-op or machine instruction */
516 #define IGNORE_OPCODE_CASE
517 #ifdef IGNORE_OPCODE_CASE
535 /* The MRI assembler and the m88k use pseudo-ops
537 pop
= (pseudo_typeS
*) hash_find (po_hash
, s
);
538 if (pop
!= NULL
&& pop
->poc_handler
== NULL
)
542 if (pop
!= NULL
|| *s
== '.')
547 * WARNING: c has next char, which may be end-of-line.
548 * We lookup the pseudo-op table with s+1 because we
549 * already know that the pseudo-op begins with a '.'.
553 pop
= (pseudo_typeS
*) hash_find (po_hash
, s
+ 1);
555 /* Print the error msg now, while we still can */
558 as_bad ("Unknown pseudo-op: `%s'", s
);
559 *input_line_pointer
= c
;
564 /* Put it back for error messages etc. */
565 *input_line_pointer
= c
;
566 /* The following skip of whitespace is compulsory.
567 A well shaped space is sometimes all that separates
568 keyword from operands. */
569 if (c
== ' ' || c
== '\t')
570 input_line_pointer
++;
572 * Input_line is restored.
573 * Input_line_pointer->1st non-blank char
574 * after pseudo-operation.
576 (*pop
->poc_handler
) (pop
->poc_val
);
579 { /* machine instruction */
580 /* WARNING: c has char, which may be end-of-line. */
581 /* Also: input_line_pointer->`\0` where c was. */
582 *input_line_pointer
= c
;
583 while (!is_end_of_line
[(unsigned char) *input_line_pointer
]
584 #ifdef TC_EOL_IN_INSN
585 || TC_EOL_IN_INSN (input_line_pointer
)
589 input_line_pointer
++;
592 c
= *input_line_pointer
;
593 *input_line_pointer
= '\0';
595 #ifdef OBJ_GENERATE_ASM_LINENO
596 if (generate_asm_lineno
== 0)
598 if (ecoff_no_current_file ())
599 generate_asm_lineno
= 1;
601 if (generate_asm_lineno
== 1)
606 as_where (&s
, &lineno
);
607 OBJ_GENERATE_ASM_LINENO (s
, lineno
);
611 md_assemble (s
); /* Assemble 1 instruction. */
613 *input_line_pointer
++ = c
;
615 /* We resume loop AFTER the end-of-line from
620 } /* if (is_name_beginner(c) */
623 /* Empty statement? */
624 if (is_end_of_line
[(unsigned char) c
])
627 if ((LOCAL_LABELS_DOLLAR
|| LOCAL_LABELS_FB
)
630 /* local label ("4:") */
631 char *backup
= input_line_pointer
;
633 HANDLE_CONDITIONAL_ASSEMBLY ();
637 while (isdigit (*input_line_pointer
))
639 temp
= (temp
* 10) + *input_line_pointer
- '0';
640 ++input_line_pointer
;
641 } /* read the whole number */
643 if (LOCAL_LABELS_DOLLAR
644 && *input_line_pointer
== '$'
645 && *(input_line_pointer
+ 1) == ':')
647 input_line_pointer
+= 2;
649 if (dollar_label_defined (temp
))
651 as_fatal ("label \"%d$\" redefined", temp
);
654 define_dollar_label (temp
);
655 colon (dollar_label_name (temp
, 0));
660 && *input_line_pointer
++ == ':')
662 fb_label_instance_inc (temp
);
663 colon (fb_label_name (temp
, 0));
667 input_line_pointer
= backup
;
668 } /* local label ("4:") */
670 if (c
&& strchr (line_comment_chars
, c
))
671 { /* Its a comment. Better say APP or NO_APP */
675 unsigned int new_length
;
677 extern char *scrub_string
, *scrub_last_string
;
679 bump_line_counters ();
680 s
= input_line_pointer
;
681 if (strncmp (s
, "APP\n", 4))
682 continue; /* We ignore it */
685 ends
= strstr (s
, "#NO_APP\n");
689 unsigned int tmp_len
;
692 /* The end of the #APP wasn't in this buffer. We
693 keep reading in buffers until we find the #NO_APP
694 that goes with this #APP There is one. The specs
696 tmp_len
= buffer_limit
- s
;
697 tmp_buf
= xmalloc (tmp_len
+ 1);
698 memcpy (tmp_buf
, s
, tmp_len
);
701 new_tmp
= input_scrub_next_buffer (&buffer
);
705 buffer_limit
= new_tmp
;
706 input_line_pointer
= buffer
;
707 ends
= strstr (buffer
, "#NO_APP\n");
711 num
= buffer_limit
- buffer
;
713 tmp_buf
= xrealloc (tmp_buf
, tmp_len
+ num
);
714 memcpy (tmp_buf
+ tmp_len
, buffer
, num
);
719 input_line_pointer
= ends
? ends
+ 8 : NULL
;
727 input_line_pointer
= ends
+ 8;
729 new_buf
= xmalloc (100);
734 scrub_last_string
= ends
;
739 ch
= do_scrub_next_char (scrub_from_string
, scrub_to_string
);
743 if (new_tmp
== new_buf
+ new_length
)
745 new_buf
= xrealloc (new_buf
, new_length
+ 100);
746 new_tmp
= new_buf
+ new_length
;
754 old_input
= input_line_pointer
;
755 old_limit
= buffer_limit
;
757 input_line_pointer
= new_buf
;
758 buffer_limit
= new_tmp
;
762 HANDLE_CONDITIONAL_ASSEMBLY ();
764 /* as_warn("Junk character %d.",c); Now done by ignore_rest */
765 input_line_pointer
--; /* Report unknown char as ignored. */
766 ignore_rest_of_line ();
767 } /* while (input_line_pointer<buffer_limit) */
769 #ifdef md_after_pass_hook
770 md_after_pass_hook ();
775 bump_line_counters ();
779 input_line_pointer
= old_input
;
780 buffer_limit
= old_limit
;
785 } /* while (more buffers to scan) */
786 input_scrub_close (); /* Close the input file */
794 as_fatal (".abort detected. Abandoning ship.");
797 /* Guts of .align directive. */
804 md_do_align (n
, fill
, just_record_alignment
);
808 /* @@ Fix this right for BFD! */
810 static char nop_opcode
= NOP_OPCODE
;
812 if (now_seg
!= data_section
&& now_seg
!= bss_section
)
821 /* Only make a frag if we HAVE to. . . */
822 if (n
&& !need_pass_2
)
823 frag_align (n
, *fill
);
826 just_record_alignment
:
829 record_alignment (now_seg
, n
);
832 /* For machines where ".align 4" means align to a 4 byte boundary. */
837 register unsigned int temp
;
840 unsigned long max_alignment
= 1 << 15;
842 if (is_end_of_line
[(unsigned char) *input_line_pointer
])
843 temp
= arg
; /* Default value from pseudo-op table */
845 temp
= get_absolute_expression ();
847 if (temp
> max_alignment
)
849 as_bad ("Alignment too large: %d. assumed.", temp
= max_alignment
);
852 /* For the sparc, `.align (1<<n)' actually means `.align n' so we
853 have to convert it. */
856 for (i
= 0; (temp
& 1) == 0; temp
>>= 1, ++i
)
860 as_bad ("Alignment not a power of 2");
863 if (*input_line_pointer
== ',')
865 input_line_pointer
++;
866 temp_fill
= get_absolute_expression ();
867 do_align (temp
, &temp_fill
);
870 do_align (temp
, (char *) 0);
872 demand_empty_rest_of_line ();
875 /* For machines where ".align 4" means align to 2**4 boundary. */
877 s_align_ptwo (ignore
)
882 long max_alignment
= 15;
884 temp
= get_absolute_expression ();
885 if (temp
> max_alignment
)
886 as_bad ("Alignment too large: %d. assumed.", temp
= max_alignment
);
889 as_bad ("Alignment negative. 0 assumed.");
892 if (*input_line_pointer
== ',')
894 input_line_pointer
++;
895 temp_fill
= get_absolute_expression ();
896 do_align (temp
, &temp_fill
);
899 do_align (temp
, (char *) 0);
901 demand_empty_rest_of_line ();
912 register symbolS
*symbolP
;
914 name
= input_line_pointer
;
915 c
= get_symbol_end ();
916 /* just after name is now '\0' */
917 p
= input_line_pointer
;
920 if (*input_line_pointer
!= ',')
922 as_bad ("Expected comma after symbol-name: rest of line ignored.");
923 ignore_rest_of_line ();
926 input_line_pointer
++; /* skip ',' */
927 if ((temp
= get_absolute_expression ()) < 0)
929 as_warn (".COMMon length (%ld.) <0! Ignored.", (long) temp
);
930 ignore_rest_of_line ();
934 symbolP
= symbol_find_or_make (name
);
936 if (S_IS_DEFINED (symbolP
))
938 as_bad ("Ignoring attempt to re-define symbol `%s'.",
939 S_GET_NAME (symbolP
));
940 ignore_rest_of_line ();
943 if (S_GET_VALUE (symbolP
))
945 if (S_GET_VALUE (symbolP
) != (valueT
) temp
)
946 as_bad ("Length of .comm \"%s\" is already %ld. Not changed to %ld.",
947 S_GET_NAME (symbolP
),
948 (long) S_GET_VALUE (symbolP
),
953 S_SET_VALUE (symbolP
, (valueT
) temp
);
954 S_SET_EXTERNAL (symbolP
);
959 if ( (!temp
) || !flag_one
)
960 S_GET_OTHER(symbolP
) = const_flag
;
962 #endif /* not OBJ_VMS */
963 know (symbolP
->sy_frag
== &zero_address_frag
);
964 demand_empty_rest_of_line ();
967 /* The MRI COMMON pseudo-op. We handle this by creating a common
968 symbol with the appropriate name. We make s_space do the right
969 thing by increasing the size. */
989 name
= input_line_pointer
;
990 if (! isdigit ((unsigned char) *name
))
991 c
= get_symbol_end ();
996 ++input_line_pointer
;
998 while (isdigit ((unsigned char) *input_line_pointer
));
999 c
= *input_line_pointer
;
1000 *input_line_pointer
= '\0';
1002 if (mri_line_label
!= NULL
)
1004 alc
= (char *) xmalloc (strlen (S_GET_NAME (mri_line_label
))
1005 + (input_line_pointer
- name
)
1007 sprintf (alc
, "%s%s", name
, S_GET_NAME (mri_line_label
));
1012 sym
= symbol_find_or_make (name
);
1013 *input_line_pointer
= c
;
1017 if (*input_line_pointer
!= ',')
1021 ++input_line_pointer
;
1022 align
= get_absolute_expression ();
1025 if (S_IS_DEFINED (sym
))
1027 #if defined (S_IS_COMMON) || defined (BFD_ASSEMBLER)
1028 if (! S_IS_COMMON (sym
))
1031 as_bad ("attempt to re-define symbol `%s'", S_GET_NAME (sym
));
1032 ignore_rest_of_line ();
1037 S_SET_EXTERNAL (sym
);
1038 mri_common_symbol
= sym
;
1042 S_SET_ALIGN (sym
, align
);
1045 if (mri_line_label
!= NULL
)
1047 mri_line_label
->sy_value
.X_op
= O_symbol
;
1048 mri_line_label
->sy_value
.X_add_symbol
= sym
;
1049 mri_line_label
->sy_value
.X_add_number
= S_GET_VALUE (sym
);
1050 mri_line_label
->sy_frag
= &zero_address_frag
;
1051 S_SET_SEGMENT (mri_line_label
, expr_section
);
1054 /* FIXME: We just ignore the small argument, which distinguishes
1055 COMMON and COMMON.S. I don't know what we can do about it. */
1057 /* Ignore the type and hptype. */
1058 if (*input_line_pointer
== ',')
1059 input_line_pointer
+= 2;
1060 if (*input_line_pointer
== ',')
1061 input_line_pointer
+= 2;
1062 demand_empty_rest_of_line ();
1072 temp
= get_absolute_expression ();
1073 if (flag_readonly_data_in_text
)
1075 section
= text_section
;
1079 section
= data_section
;
1081 subseg_set (section
, (subsegT
) temp
);
1086 demand_empty_rest_of_line ();
1089 /* Handle the .appfile pseudo-op. This is automatically generated by
1090 do_scrub_next_char when a preprocessor # line comment is seen with
1091 a file name. This default definition may be overridden by the
1092 object or CPU specific pseudo-ops. This function is also the
1093 default definition for .file; the APPFILE argument is 1 for
1094 .appfile, 0 for .file. */
1097 s_app_file (appfile
)
1103 /* Some assemblers tolerate immediately following '"' */
1104 if ((s
= demand_copy_string (&length
)) != 0)
1106 /* If this is a fake .appfile, a fake newline was inserted into
1107 the buffer. Passing -2 to new_logical_line tells it to
1109 new_logical_line (s
, appfile
? -2 : -1);
1110 demand_empty_rest_of_line ();
1113 listing_source_file (s
);
1121 /* Handle the .appline pseudo-op. This is automatically generated by
1122 do_scrub_next_char when a preprocessor # line comment is seen.
1123 This default definition may be overridden by the object or CPU
1124 specific pseudo-ops. */
1132 /* The given number is that of the next line. */
1133 l
= get_absolute_expression () - 1;
1135 /* Some of the back ends can't deal with non-positive line numbers.
1136 Besides, it's silly. */
1137 as_warn ("Line numbers must be positive; line number %d rejected.", l
+1);
1140 new_logical_line ((char *) NULL
, l
);
1143 listing_source_line (l
);
1146 demand_empty_rest_of_line ();
1153 long temp_repeat
= 0;
1155 register long temp_fill
= 0;
1159 temp_repeat
= get_absolute_expression ();
1160 if (*input_line_pointer
== ',')
1162 input_line_pointer
++;
1163 temp_size
= get_absolute_expression ();
1164 if (*input_line_pointer
== ',')
1166 input_line_pointer
++;
1167 temp_fill
= get_absolute_expression ();
1170 /* This is to be compatible with BSD 4.2 AS, not for any rational reason. */
1171 #define BSD_FILL_SIZE_CROCK_8 (8)
1172 if (temp_size
> BSD_FILL_SIZE_CROCK_8
)
1174 as_warn (".fill size clamped to %d.", BSD_FILL_SIZE_CROCK_8
);
1175 temp_size
= BSD_FILL_SIZE_CROCK_8
;
1179 as_warn ("Size negative: .fill ignored.");
1182 else if (temp_repeat
<= 0)
1184 as_warn ("Repeat < 0, .fill ignored");
1188 if (temp_size
&& !need_pass_2
)
1190 p
= frag_var (rs_fill
, (int) temp_size
, (int) temp_size
, (relax_substateT
) 0, (symbolS
*) 0, temp_repeat
, (char *) 0);
1191 memset (p
, 0, (unsigned int) temp_size
);
1192 /* The magic number BSD_FILL_SIZE_CROCK_4 is from BSD 4.2 VAX
1193 * flavoured AS. The following bizzare behaviour is to be
1194 * compatible with above. I guess they tried to take up to 8
1195 * bytes from a 4-byte expression and they forgot to sign
1196 * extend. Un*x Sux. */
1197 #define BSD_FILL_SIZE_CROCK_4 (4)
1198 md_number_to_chars (p
, (valueT
) temp_fill
,
1199 (temp_size
> BSD_FILL_SIZE_CROCK_4
1200 ? BSD_FILL_SIZE_CROCK_4
1201 : (int) temp_size
));
1202 /* Note: .fill (),0 emits no frag (since we are asked to .fill 0 bytes)
1203 * but emits no error message because it seems a legal thing to do.
1204 * It is a degenerate case of .fill but could be emitted by a compiler.
1207 demand_empty_rest_of_line ();
1220 name
= input_line_pointer
;
1221 c
= get_symbol_end ();
1222 symbolP
= symbol_find_or_make (name
);
1223 *input_line_pointer
= c
;
1225 S_SET_EXTERNAL (symbolP
);
1228 input_line_pointer
++;
1230 if (*input_line_pointer
== '\n')
1235 demand_empty_rest_of_line ();
1239 s_lcomm (needs_align
)
1240 /* 1 if this was a ".bss" directive, which may require a 3rd argument
1241 (alignment); 0 if it was an ".lcomm" (2 args only) */
1244 register char *name
;
1248 register symbolS
*symbolP
;
1249 segT current_seg
= now_seg
;
1250 subsegT current_subseg
= now_subseg
;
1251 const int max_alignment
= 15;
1253 segT bss_seg
= bss_section
;
1255 name
= input_line_pointer
;
1256 c
= get_symbol_end ();
1257 p
= input_line_pointer
;
1261 /* Accept an optional comma after the name. The comma used to be
1262 required, but Irix 5 cc does not generate it. */
1263 if (*input_line_pointer
== ',')
1265 ++input_line_pointer
;
1269 if (*input_line_pointer
== '\n')
1271 as_bad ("Missing size expression");
1275 if ((temp
= get_absolute_expression ()) < 0)
1277 as_warn ("BSS length (%d.) <0! Ignored.", temp
);
1278 ignore_rest_of_line ();
1282 #if defined (TC_MIPS) || defined (TC_ALPHA)
1283 if (OUTPUT_FLAVOR
== bfd_target_ecoff_flavour
1284 || OUTPUT_FLAVOR
== bfd_target_elf_flavour
)
1286 /* For MIPS and Alpha ECOFF or ELF, small objects are put in .sbss. */
1287 if (temp
<= bfd_get_gp_size (stdoutput
))
1289 bss_seg
= subseg_new (".sbss", 1);
1290 seg_info (bss_seg
)->bss
= 1;
1296 /* FIXME. This needs to be machine independent. */
1306 record_alignment(bss_seg
, align
);
1313 if (*input_line_pointer
!= ',')
1315 as_bad ("Expected comma after size");
1316 ignore_rest_of_line ();
1319 input_line_pointer
++;
1321 if (*input_line_pointer
== '\n')
1323 as_bad ("Missing alignment");
1326 align
= get_absolute_expression ();
1327 if (align
> max_alignment
)
1329 align
= max_alignment
;
1330 as_warn ("Alignment too large: %d. assumed.", align
);
1335 as_warn ("Alignment negative. 0 assumed.");
1337 record_alignment (bss_seg
, align
);
1338 } /* if needs align */
1341 /* Assume some objects may require alignment on some systems. */
1345 align
= ffs (temp
) - 1;
1346 if (temp
% (1 << align
))
1353 symbolP
= symbol_find_or_make (name
);
1357 #if defined(OBJ_AOUT) | defined(OBJ_BOUT)
1358 S_GET_OTHER (symbolP
) == 0 &&
1359 S_GET_DESC (symbolP
) == 0 &&
1360 #endif /* OBJ_AOUT or OBJ_BOUT */
1361 (S_GET_SEGMENT (symbolP
) == bss_seg
1362 || (!S_IS_DEFINED (symbolP
) && S_GET_VALUE (symbolP
) == 0)))
1366 subseg_set (bss_seg
, 1);
1369 frag_align (align
, 0);
1370 /* detach from old frag */
1371 if (S_GET_SEGMENT (symbolP
) == bss_seg
)
1372 symbolP
->sy_frag
->fr_symbol
= NULL
;
1374 symbolP
->sy_frag
= frag_now
;
1375 pfrag
= frag_var (rs_org
, 1, 1, (relax_substateT
)0, symbolP
,
1379 S_SET_SEGMENT (symbolP
, bss_seg
);
1382 /* The symbol may already have been created with a preceding
1383 ".globl" directive -- be careful not to step on storage class
1384 in that case. Otherwise, set it to static. */
1385 if (S_GET_STORAGE_CLASS (symbolP
) != C_EXT
)
1387 S_SET_STORAGE_CLASS (symbolP
, C_STAT
);
1389 #endif /* OBJ_COFF */
1392 as_bad ("Ignoring attempt to re-define symbol `%s'.",
1393 S_GET_NAME (symbolP
));
1395 subseg_set (current_seg
, current_subseg
);
1397 demand_empty_rest_of_line ();
1404 register char *name
;
1408 register symbolS
*symbolP
;
1410 /* we permit ANY defined expression: BSD4.2 demands constants */
1411 name
= input_line_pointer
;
1412 c
= get_symbol_end ();
1413 p
= input_line_pointer
;
1416 if (*input_line_pointer
!= ',')
1419 as_bad ("Expected comma after name \"%s\"", name
);
1421 ignore_rest_of_line ();
1424 input_line_pointer
++;
1426 if (exp
.X_op
!= O_constant
1427 && exp
.X_op
!= O_register
)
1429 as_bad ("bad expression");
1430 ignore_rest_of_line ();
1434 symbolP
= symbol_find_or_make (name
);
1436 /* FIXME-SOON I pulled a (&& symbolP->sy_other == 0 &&
1437 symbolP->sy_desc == 0) out of this test because coff doesn't have
1438 those fields, and I can't see when they'd ever be tripped. I
1439 don't think I understand why they were here so I may have
1440 introduced a bug. As recently as 1.37 didn't have this test
1441 anyway. xoxorich. */
1443 if (S_GET_SEGMENT (symbolP
) == undefined_section
1444 && S_GET_VALUE (symbolP
) == 0)
1446 /* The name might be an undefined .global symbol; be sure to
1447 keep the "external" bit. */
1448 S_SET_SEGMENT (symbolP
,
1449 (exp
.X_op
== O_constant
1452 S_SET_VALUE (symbolP
, (valueT
) exp
.X_add_number
);
1456 as_bad ("Symbol %s already defined", name
);
1459 demand_empty_rest_of_line ();
1466 register segT segment
;
1468 register long temp_fill
;
1470 /* Don't believe the documentation of BSD 4.2 AS. There is no such
1471 thing as a sub-segment-relative origin. Any absolute origin is
1472 given a warning, then assumed to be segment-relative. Any
1473 segmented origin expression ("foo+42") had better be in the right
1474 segment or the .org is ignored.
1476 BSD 4.2 AS warns if you try to .org backwards. We cannot because
1477 we never know sub-segment sizes when we are reading code. BSD
1478 will crash trying to emit negative numbers of filler bytes in
1479 certain .orgs. We don't crash, but see as-write for that code.
1481 Don't make frag if need_pass_2==1. */
1482 segment
= get_known_segmented_expression (&exp
);
1483 if (*input_line_pointer
== ',')
1485 input_line_pointer
++;
1486 temp_fill
= get_absolute_expression ();
1492 if (segment
!= now_seg
&& segment
!= absolute_section
)
1493 as_bad ("Invalid segment \"%s\". Segment \"%s\" assumed.",
1494 segment_name (segment
), segment_name (now_seg
));
1495 p
= frag_var (rs_org
, 1, 1, (relax_substateT
) 0, exp
.X_add_symbol
,
1496 exp
.X_add_number
, (char *) 0);
1498 } /* if (ok to make frag) */
1499 demand_empty_rest_of_line ();
1506 register char *name
;
1507 register char delim
;
1508 register char *end_name
;
1509 register symbolS
*symbolP
;
1512 * Especial apologies for the random logic:
1513 * this just grew, and could be parsed much more simply!
1516 name
= input_line_pointer
;
1517 delim
= get_symbol_end ();
1518 end_name
= input_line_pointer
;
1522 if (*input_line_pointer
!= ',')
1525 as_bad ("Expected comma after name \"%s\"", name
);
1527 ignore_rest_of_line ();
1531 input_line_pointer
++;
1534 if (name
[0] == '.' && name
[1] == '\0')
1536 /* Turn '. = mumble' into a .org mumble */
1537 register segT segment
;
1541 segment
= get_known_segmented_expression (&exp
);
1545 if (segment
!= now_seg
&& segment
!= absolute_section
)
1546 as_bad ("Invalid segment \"%s\". Segment \"%s\" assumed.",
1547 segment_name (segment
),
1548 segment_name (now_seg
));
1549 ptr
= frag_var (rs_org
, 1, 1, (relax_substateT
) 0, exp
.X_add_symbol
,
1550 exp
.X_add_number
, (char *) 0);
1552 } /* if (ok to make frag) */
1558 if ((symbolP
= symbol_find (name
)) == NULL
1559 && (symbolP
= md_undefined_symbol (name
)) == NULL
)
1561 symbolP
= symbol_new (name
, undefined_section
, 0, &zero_address_frag
);
1563 /* "set" symbols are local unless otherwise specified. */
1564 SF_SET_LOCAL (symbolP
);
1565 #endif /* OBJ_COFF */
1567 } /* make a new symbol */
1569 symbol_table_insert (symbolP
);
1572 pseudo_set (symbolP
);
1573 demand_empty_rest_of_line ();
1584 #ifdef md_flush_pending_output
1585 md_flush_pending_output ();
1588 /* Just like .fill, but temp_size = 1 */
1590 if (exp
.X_op
== O_constant
)
1594 repeat
= exp
.X_add_number
;
1599 as_warn (".space repeat count is %s, ignored",
1600 repeat
? "negative" : "zero");
1601 ignore_rest_of_line ();
1605 /* If we are secretly in an MRI common section, then creating
1606 space just increases the size of the common symbol. */
1607 if (mri_common_symbol
!= NULL
)
1609 S_SET_VALUE (mri_common_symbol
,
1610 S_GET_VALUE (mri_common_symbol
) + repeat
);
1611 demand_empty_rest_of_line ();
1616 p
= frag_var (rs_fill
, 1, 1, (relax_substateT
) 0, (symbolS
*) 0,
1617 repeat
, (char *) 0);
1621 if (mri_common_symbol
!= NULL
)
1623 as_bad ("space allocation too complex in common section");
1624 mri_common_symbol
= NULL
;
1627 p
= frag_var (rs_space
, 1, 1, (relax_substateT
) 0,
1628 make_expr_symbol (&exp
), 0L, (char *) 0);
1631 if (*input_line_pointer
== ',')
1633 input_line_pointer
++;
1634 temp_fill
= get_absolute_expression ();
1644 demand_empty_rest_of_line ();
1653 temp
= get_absolute_expression ();
1654 subseg_set (text_section
, (subsegT
) temp
);
1655 demand_empty_rest_of_line ();
1657 const_flag
&= ~IN_DEFAULT_SECTION
;
1663 demand_empty_rest_of_line ()
1666 if (is_end_of_line
[(unsigned char) *input_line_pointer
])
1668 input_line_pointer
++;
1672 ignore_rest_of_line ();
1674 /* Return having already swallowed end-of-line. */
1675 } /* Return pointing just after end-of-line. */
1678 ignore_rest_of_line () /* For suspect lines: gives warning. */
1680 if (!is_end_of_line
[(unsigned char) *input_line_pointer
])
1682 if (isprint (*input_line_pointer
))
1683 as_bad ("Rest of line ignored. First ignored character is `%c'.",
1684 *input_line_pointer
);
1686 as_bad ("Rest of line ignored. First ignored character valued 0x%x.",
1687 *input_line_pointer
);
1688 while (input_line_pointer
< buffer_limit
1689 && !is_end_of_line
[(unsigned char) *input_line_pointer
])
1691 input_line_pointer
++;
1694 input_line_pointer
++; /* Return pointing just after end-of-line. */
1695 know (is_end_of_line
[(unsigned char) input_line_pointer
[-1]]);
1701 * In: Pointer to a symbol.
1702 * Input_line_pointer->expression.
1704 * Out: Input_line_pointer->just after any whitespace after expression.
1705 * Tried to set symbol to value of expression.
1706 * Will change symbols type, value, and frag;
1709 pseudo_set (symbolP
)
1713 #if (defined (OBJ_AOUT) || defined (OBJ_BOUT)) && ! defined (BFD_ASSEMBLER)
1715 #endif /* OBJ_AOUT or OBJ_BOUT */
1717 know (symbolP
); /* NULL pointer is logic error. */
1718 #if (defined (OBJ_AOUT) || defined (OBJ_BOUT)) && ! defined (BFD_ASSEMBLER)
1719 ext
= S_IS_EXTERNAL (symbolP
);
1720 #endif /* OBJ_AOUT or OBJ_BOUT */
1722 (void) expression (&exp
);
1724 if (exp
.X_op
== O_illegal
)
1725 as_bad ("illegal expression; zero assumed");
1726 else if (exp
.X_op
== O_absent
)
1727 as_bad ("missing expression; zero assumed");
1728 else if (exp
.X_op
== O_big
)
1729 as_bad ("%s number invalid; zero assumed",
1730 exp
.X_add_number
> 0 ? "bignum" : "floating point");
1731 else if (exp
.X_op
== O_subtract
1732 && (S_GET_SEGMENT (exp
.X_add_symbol
)
1733 == S_GET_SEGMENT (exp
.X_op_symbol
))
1734 && SEG_NORMAL (S_GET_SEGMENT (exp
.X_add_symbol
))
1735 && exp
.X_add_symbol
->sy_frag
== exp
.X_op_symbol
->sy_frag
)
1737 exp
.X_op
= O_constant
;
1738 exp
.X_add_number
= (S_GET_VALUE (exp
.X_add_symbol
)
1739 - S_GET_VALUE (exp
.X_op_symbol
));
1747 exp
.X_add_number
= 0;
1750 S_SET_SEGMENT (symbolP
, absolute_section
);
1751 #if (defined (OBJ_AOUT) || defined (OBJ_BOUT)) && ! defined (BFD_ASSEMBLER)
1753 S_SET_EXTERNAL (symbolP
);
1755 S_CLEAR_EXTERNAL (symbolP
);
1756 #endif /* OBJ_AOUT or OBJ_BOUT */
1757 S_SET_VALUE (symbolP
, (valueT
) exp
.X_add_number
);
1758 symbolP
->sy_frag
= &zero_address_frag
;
1762 S_SET_SEGMENT (symbolP
, reg_section
);
1763 S_SET_VALUE (symbolP
, (valueT
) exp
.X_add_number
);
1764 symbolP
->sy_frag
= &zero_address_frag
;
1768 if (S_GET_SEGMENT (exp
.X_add_symbol
) == undefined_section
1769 || exp
.X_add_number
!= 0)
1770 symbolP
->sy_value
= exp
;
1773 symbolS
*s
= exp
.X_add_symbol
;
1775 S_SET_SEGMENT (symbolP
, S_GET_SEGMENT (s
));
1776 #if (defined (OBJ_AOUT) || defined (OBJ_BOUT)) && ! defined (BFD_ASSEMBLER)
1778 S_SET_EXTERNAL (symbolP
);
1780 S_CLEAR_EXTERNAL (symbolP
);
1781 #endif /* OBJ_AOUT or OBJ_BOUT */
1782 S_SET_VALUE (symbolP
,
1783 exp
.X_add_number
+ S_GET_VALUE (s
));
1784 symbolP
->sy_frag
= s
->sy_frag
;
1785 copy_symbol_attributes (symbolP
, s
);
1790 /* The value is some complex expression.
1791 FIXME: Should we set the segment to anything? */
1792 symbolP
->sy_value
= exp
;
1800 * CONStruct more frag of .bytes, or .words etc.
1801 * Should need_pass_2 be 1 then emit no frag(s).
1802 * This understands EXPRESSIONS.
1806 * This has a split personality. We use expression() to read the
1807 * value. We can detect if the value won't fit in a byte or word.
1808 * But we can't detect if expression() discarded significant digits
1809 * in the case of a long. Not worth the crocks required to fix it.
1812 /* Select a parser for cons expressions. */
1814 /* Some targets need to parse the expression in various fancy ways.
1815 You can define TC_PARSE_CONS_EXPRESSION to do whatever you like
1816 (for example, the HPPA does this). Otherwise, you can define
1817 BITFIELD_CONS_EXPRESSIONS to permit bitfields to be specified, or
1818 REPEAT_CONS_EXPRESSIONS to permit repeat counts. If none of these
1819 are defined, which is the normal case, then only simple expressions
1823 parse_mri_cons
PARAMS ((expressionS
*exp
, unsigned int nbytes
));
1825 #ifndef TC_PARSE_CONS_EXPRESSION
1826 #ifdef BITFIELD_CONS_EXPRESSIONS
1827 #define TC_PARSE_CONS_EXPRESSION(EXP, NBYTES) parse_bitfield_cons (EXP, NBYTES)
1829 parse_bitfield_cons
PARAMS ((expressionS
*exp
, unsigned int nbytes
));
1831 #ifdef REPEAT_CONS_EXPRESSIONS
1832 #define TC_PARSE_CONS_EXPRESSION(EXP, NBYTES) parse_repeat_cons (EXP, NBYTES)
1834 parse_repeat_cons
PARAMS ((expressionS
*exp
, unsigned int nbytes
));
1837 /* If we haven't gotten one yet, just call expression. */
1838 #ifndef TC_PARSE_CONS_EXPRESSION
1839 #define TC_PARSE_CONS_EXPRESSION(EXP, NBYTES) expression (EXP)
1843 /* worker to do .byte etc statements */
1844 /* clobbers input_line_pointer, checks */
1848 register int nbytes
; /* 1=.byte, 2=.word, 4=.long */
1852 #ifdef md_flush_pending_output
1853 md_flush_pending_output ();
1856 if (is_it_end_of_statement ())
1858 demand_empty_rest_of_line ();
1865 parse_mri_cons (&exp
, (unsigned int) nbytes
);
1867 TC_PARSE_CONS_EXPRESSION (&exp
, (unsigned int) nbytes
);
1868 emit_expr (&exp
, (unsigned int) nbytes
);
1870 while (*input_line_pointer
++ == ',');
1872 input_line_pointer
--; /* Put terminator back into stream. */
1873 demand_empty_rest_of_line ();
1876 /* Put the contents of expression EXP into the object file using
1877 NBYTES bytes. If need_pass_2 is 1, this does nothing. */
1880 emit_expr (exp
, nbytes
)
1882 unsigned int nbytes
;
1886 valueT extra_digit
= 0;
1888 /* Don't do anything if we are going to make another pass. */
1894 /* Handle a negative bignum. */
1896 && exp
->X_add_number
== 0
1897 && exp
->X_add_symbol
->sy_value
.X_op
== O_big
1898 && exp
->X_add_symbol
->sy_value
.X_add_number
> 0)
1901 unsigned long carry
;
1903 exp
= &exp
->X_add_symbol
->sy_value
;
1905 /* Negate the bignum: one's complement each digit and add 1. */
1907 for (i
= 0; i
< exp
->X_add_number
; i
++)
1911 next
= (((~ (generic_bignum
[i
] & LITTLENUM_MASK
))
1914 generic_bignum
[i
] = next
& LITTLENUM_MASK
;
1915 carry
= next
>> LITTLENUM_NUMBER_OF_BITS
;
1918 /* We can ignore any carry out, because it will be handled by
1919 extra_digit if it is needed. */
1921 extra_digit
= (valueT
) -1;
1925 if (op
== O_absent
|| op
== O_illegal
)
1927 as_warn ("zero assumed for missing expression");
1928 exp
->X_add_number
= 0;
1931 else if (op
== O_big
&& exp
->X_add_number
<= 0)
1933 as_bad ("floating point number invalid; zero assumed");
1934 exp
->X_add_number
= 0;
1937 else if (op
== O_register
)
1939 as_warn ("register value used as expression");
1943 p
= frag_more ((int) nbytes
);
1945 #ifndef WORKING_DOT_WORD
1946 /* If we have the difference of two symbols in a word, save it on
1947 the broken_words list. See the code in write.c. */
1948 if (op
== O_subtract
&& nbytes
== 2)
1950 struct broken_word
*x
;
1952 x
= (struct broken_word
*) xmalloc (sizeof (struct broken_word
));
1953 x
->next_broken_word
= broken_words
;
1956 x
->word_goes_here
= p
;
1958 x
->add
= exp
->X_add_symbol
;
1959 x
->sub
= exp
->X_op_symbol
;
1960 x
->addnum
= exp
->X_add_number
;
1967 /* If we have an integer, but the number of bytes is too large to
1968 pass to md_number_to_chars, handle it as a bignum. */
1969 if (op
== O_constant
&& nbytes
> sizeof (valueT
))
1974 if (! exp
->X_unsigned
&& exp
->X_add_number
< 0)
1975 extra_digit
= (valueT
) -1;
1976 val
= (valueT
) exp
->X_add_number
;
1980 generic_bignum
[gencnt
] = val
& LITTLENUM_MASK
;
1981 val
>>= LITTLENUM_NUMBER_OF_BITS
;
1985 op
= exp
->X_op
= O_big
;
1986 exp
->X_add_number
= gencnt
;
1989 if (op
== O_constant
)
1991 register valueT get
;
1992 register valueT use
;
1993 register valueT mask
;
1994 register valueT unmask
;
1996 /* JF << of >= number of bits in the object is undefined. In
1997 particular SPARC (Sun 4) has problems */
1998 if (nbytes
>= sizeof (valueT
))
2001 mask
= ~(valueT
) 0 << (BITS_PER_CHAR
* nbytes
); /* Don't store these bits. */
2003 unmask
= ~mask
; /* Do store these bits. */
2006 "Do this mod if you want every overflow check to assume SIGNED 2's complement data.";
2007 mask
= ~(unmask
>> 1); /* Includes sign bit now. */
2010 get
= exp
->X_add_number
;
2012 if ((get
& mask
) != 0 && (get
& mask
) != mask
)
2013 { /* Leading bits contain both 0s & 1s. */
2014 as_warn ("Value 0x%lx truncated to 0x%lx.", get
, use
);
2016 /* put bytes in right order. */
2017 md_number_to_chars (p
, use
, (int) nbytes
);
2019 else if (op
== O_big
)
2022 LITTLENUM_TYPE
*nums
;
2024 know (nbytes
% CHARS_PER_LITTLENUM
== 0);
2026 size
= exp
->X_add_number
* CHARS_PER_LITTLENUM
;
2029 as_warn ("Bignum truncated to %d bytes", nbytes
);
2033 if (target_big_endian
)
2035 while (nbytes
> size
)
2037 md_number_to_chars (p
, extra_digit
, CHARS_PER_LITTLENUM
);
2038 nbytes
-= CHARS_PER_LITTLENUM
;
2039 p
+= CHARS_PER_LITTLENUM
;
2042 nums
= generic_bignum
+ size
/ CHARS_PER_LITTLENUM
;
2046 md_number_to_chars (p
, (valueT
) *nums
, CHARS_PER_LITTLENUM
);
2047 size
-= CHARS_PER_LITTLENUM
;
2048 p
+= CHARS_PER_LITTLENUM
;
2053 nums
= generic_bignum
;
2056 md_number_to_chars (p
, (valueT
) *nums
, CHARS_PER_LITTLENUM
);
2058 size
-= CHARS_PER_LITTLENUM
;
2059 p
+= CHARS_PER_LITTLENUM
;
2060 nbytes
-= CHARS_PER_LITTLENUM
;
2065 md_number_to_chars (p
, extra_digit
, CHARS_PER_LITTLENUM
);
2066 nbytes
-= CHARS_PER_LITTLENUM
;
2067 p
+= CHARS_PER_LITTLENUM
;
2073 memset (p
, 0, nbytes
);
2075 /* Now we need to generate a fixS to record the symbol value.
2076 This is easy for BFD. For other targets it can be more
2077 complex. For very complex cases (currently, the HPPA and
2078 NS32K), you can define TC_CONS_FIX_NEW to do whatever you
2079 want. For simpler cases, you can define TC_CONS_RELOC to be
2080 the name of the reloc code that should be stored in the fixS.
2081 If neither is defined, the code uses NO_RELOC if it is
2082 defined, and otherwise uses 0. */
2084 #ifdef BFD_ASSEMBLER
2085 #ifdef TC_CONS_FIX_NEW
2086 TC_CONS_FIX_NEW (frag_now
, p
- frag_now
->fr_literal
, nbytes
, exp
);
2088 fix_new_exp (frag_now
, p
- frag_now
->fr_literal
, (int) nbytes
, exp
, 0,
2089 /* @@ Should look at CPU word size. */
2090 nbytes
== 2 ? BFD_RELOC_16
2091 : nbytes
== 8 ? BFD_RELOC_64
2095 #ifdef TC_CONS_FIX_NEW
2096 TC_CONS_FIX_NEW (frag_now
, p
- frag_now
->fr_literal
, nbytes
, exp
);
2098 /* Figure out which reloc number to use. Use TC_CONS_RELOC if
2099 it is defined, otherwise use NO_RELOC if it is defined,
2101 #ifndef TC_CONS_RELOC
2103 #define TC_CONS_RELOC NO_RELOC
2105 #define TC_CONS_RELOC 0
2108 fix_new_exp (frag_now
, p
- frag_now
->fr_literal
, (int) nbytes
, exp
, 0,
2110 #endif /* TC_CONS_FIX_NEW */
2111 #endif /* BFD_ASSEMBLER */
2115 #ifdef BITFIELD_CONS_EXPRESSIONS
2117 /* i960 assemblers, (eg, asm960), allow bitfields after ".byte" as
2118 w:x,y:z, where w and y are bitwidths and x and y are values. They
2119 then pack them all together. We do a little better in that we allow
2120 them in words, longs, etc. and we'll pack them in target byte order
2123 The rules are: pack least significat bit first, if a field doesn't
2124 entirely fit, put it in the next unit. Overflowing the bitfield is
2125 explicitly *not* even a warning. The bitwidth should be considered
2128 To use this function the tc-XXX.h file should define
2129 BITFIELD_CONS_EXPRESSIONS. */
2132 parse_bitfield_cons (exp
, nbytes
)
2134 unsigned int nbytes
;
2136 unsigned int bits_available
= BITS_PER_CHAR
* nbytes
;
2137 char *hold
= input_line_pointer
;
2139 (void) expression (exp
);
2141 if (*input_line_pointer
== ':')
2147 unsigned long width
;
2149 if (*input_line_pointer
!= ':')
2151 input_line_pointer
= hold
;
2153 } /* next piece is not a bitfield */
2155 /* In the general case, we can't allow
2156 full expressions with symbol
2157 differences and such. The relocation
2158 entries for symbols not defined in this
2159 assembly would require arbitrary field
2160 widths, positions, and masks which most
2161 of our current object formats don't
2164 In the specific case where a symbol
2165 *is* defined in this assembly, we
2166 *could* build fixups and track it, but
2167 this could lead to confusion for the
2168 backends. I'm lazy. I'll take any
2169 SEG_ABSOLUTE. I think that means that
2170 you can use a previous .set or
2171 .equ type symbol. xoxorich. */
2173 if (exp
->X_op
== O_absent
)
2175 as_warn ("using a bit field width of zero");
2176 exp
->X_add_number
= 0;
2177 exp
->X_op
= O_constant
;
2178 } /* implied zero width bitfield */
2180 if (exp
->X_op
!= O_constant
)
2182 *input_line_pointer
= '\0';
2183 as_bad ("field width \"%s\" too complex for a bitfield", hold
);
2184 *input_line_pointer
= ':';
2185 demand_empty_rest_of_line ();
2189 if ((width
= exp
->X_add_number
) > (BITS_PER_CHAR
* nbytes
))
2191 as_warn ("field width %lu too big to fit in %d bytes: truncated to %d bits",
2192 width
, nbytes
, (BITS_PER_CHAR
* nbytes
));
2193 width
= BITS_PER_CHAR
* nbytes
;
2196 if (width
> bits_available
)
2198 /* FIXME-SOMEDAY: backing up and reparsing is wasteful. */
2199 input_line_pointer
= hold
;
2200 exp
->X_add_number
= value
;
2204 hold
= ++input_line_pointer
; /* skip ':' */
2206 (void) expression (exp
);
2207 if (exp
->X_op
!= O_constant
)
2209 char cache
= *input_line_pointer
;
2211 *input_line_pointer
= '\0';
2212 as_bad ("field value \"%s\" too complex for a bitfield", hold
);
2213 *input_line_pointer
= cache
;
2214 demand_empty_rest_of_line ();
2218 value
|= ((~(-1 << width
) & exp
->X_add_number
)
2219 << ((BITS_PER_CHAR
* nbytes
) - bits_available
));
2221 if ((bits_available
-= width
) == 0
2222 || is_it_end_of_statement ()
2223 || *input_line_pointer
!= ',')
2226 } /* all the bitfields we're gonna get */
2228 hold
= ++input_line_pointer
;
2229 (void) expression (exp
);
2230 } /* forever loop */
2232 exp
->X_add_number
= value
;
2233 exp
->X_op
= O_constant
;
2234 exp
->X_unsigned
= 1;
2235 } /* if looks like a bitfield */
2236 } /* parse_bitfield_cons() */
2238 #endif /* BITFIELD_CONS_EXPRESSIONS */
2240 /* Handle an MRI style string expression. */
2243 parse_mri_cons (exp
, nbytes
)
2245 unsigned int nbytes
;
2247 if (*input_line_pointer
!= '\''
2248 && (input_line_pointer
[1] != '\''
2249 || (*input_line_pointer
!= 'A'
2250 && *input_line_pointer
!= 'E')))
2251 TC_PARSE_CONS_EXPRESSION (exp
, nbytes
);
2255 unsigned int result
= 0;
2257 /* An MRI style string. Cut into as many bytes as will fit into
2258 a nbyte chunk, left justify if necessary, and separate with
2259 commas so we can try again later. */
2260 if (*input_line_pointer
== 'A')
2261 ++input_line_pointer
;
2262 else if (*input_line_pointer
== 'E')
2264 as_bad ("EBCDIC constants are not supported");
2265 ++input_line_pointer
;
2268 input_line_pointer
++;
2269 for (scan
= 0; scan
< nbytes
; scan
++)
2271 if (*input_line_pointer
== '\'')
2273 if (input_line_pointer
[1] == '\'')
2275 input_line_pointer
++;
2280 result
= (result
<< 8) | (*input_line_pointer
++);
2284 while (scan
< nbytes
)
2289 /* Create correct expression */
2290 exp
->X_op
= O_constant
;
2291 exp
->X_add_number
= result
;
2292 /* Fake it so that we can read the next char too */
2293 if (input_line_pointer
[0] != '\'' ||
2294 (input_line_pointer
[0] == '\'' && input_line_pointer
[1] == '\''))
2296 input_line_pointer
-= 2;
2297 input_line_pointer
[0] = ',';
2298 input_line_pointer
[1] = '\'';
2301 input_line_pointer
++;
2305 #ifdef REPEAT_CONS_EXPRESSIONS
2307 /* Parse a repeat expression for cons. This is used by the MIPS
2308 assembler. The format is NUMBER:COUNT; NUMBER appears in the
2309 object file COUNT times.
2311 To use this for a target, define REPEAT_CONS_EXPRESSIONS. */
2314 parse_repeat_cons (exp
, nbytes
)
2316 unsigned int nbytes
;
2323 if (*input_line_pointer
!= ':')
2325 /* No repeat count. */
2329 ++input_line_pointer
;
2330 expression (&count
);
2331 if (count
.X_op
!= O_constant
2332 || count
.X_add_number
<= 0)
2334 as_warn ("Unresolvable or nonpositive repeat count; using 1");
2338 /* The cons function is going to output this expression once. So we
2339 output it count - 1 times. */
2340 for (i
= count
.X_add_number
- 1; i
> 0; i
--)
2341 emit_expr (exp
, nbytes
);
2344 #endif /* REPEAT_CONS_EXPRESSIONS */
2349 * CONStruct some more frag chars of .floats .ffloats etc.
2350 * Makes 0 or more new frags.
2351 * If need_pass_2 == 1, no frags are emitted.
2352 * This understands only floating literals, not expressions. Sorry.
2354 * A floating constant is defined by atof_generic(), except it is preceded
2355 * by 0d 0f 0g or 0h. After observing the STRANGE way my BSD AS does its
2356 * reading, I decided to be incompatible. This always tries to give you
2357 * rounded bits to the precision of the pseudo-op. Former AS did premature
2358 * truncatation, restored noisy bits instead of trailing 0s AND gave you
2359 * a choice of 2 flavours of noise according to which of 2 floating-point
2360 * scanners you directed AS to use.
2362 * In: input_line_pointer->whitespace before, or '0' of flonum.
2367 float_cons (float_type
)
2368 /* Clobbers input_line-pointer, checks end-of-line. */
2369 register int float_type
; /* 'f':.ffloat ... 'F':.float ... */
2372 int length
; /* Number of chars in an object. */
2373 register char *err
; /* Error from scanning floating literal. */
2374 char temp
[MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT
];
2376 if (is_it_end_of_statement ())
2378 demand_empty_rest_of_line ();
2384 /* input_line_pointer->1st char of a flonum (we hope!). */
2387 /* Skip any 0{letter} that may be present. Don't even check if the
2388 * letter is legal. Someone may invent a "z" format and this routine
2389 * has no use for such information. Lusers beware: you get
2390 * diagnostics if your input is ill-conditioned.
2392 if (input_line_pointer
[0] == '0' && isalpha (input_line_pointer
[1]))
2393 input_line_pointer
+= 2;
2395 /* Accept :xxxx, where the x's are hex digits, for a floating
2396 point with the exact digits specified. */
2397 if (input_line_pointer
[0] == ':')
2428 as_bad ("Unknown floating type type '%c'", float_type
);
2429 ignore_rest_of_line ();
2433 /* It would be nice if we could go through expression to
2434 parse the hex constant, but if we get a bignum it's a
2435 pain to sort it into the buffer correctly. */
2437 ++input_line_pointer
;
2438 while (hex_p (*input_line_pointer
) || *input_line_pointer
== '_')
2442 /* The MRI assembler accepts arbitrary underscores
2443 strewn about through the hex constant, so we ignore
2445 if (*input_line_pointer
== '_')
2447 ++input_line_pointer
;
2453 as_warn ("Floating point constant too large");
2454 ignore_rest_of_line ();
2457 d
= hex_value (*input_line_pointer
) << 4;
2458 ++input_line_pointer
;
2459 while (*input_line_pointer
== '_')
2460 ++input_line_pointer
;
2461 if (hex_p (*input_line_pointer
))
2463 d
+= hex_value (*input_line_pointer
);
2464 ++input_line_pointer
;
2469 memset (temp
+ i
, 0, length
- i
);
2473 err
= md_atof (float_type
, temp
, &length
);
2474 know (length
<= MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT
);
2478 as_bad ("Bad floating literal: %s", err
);
2479 ignore_rest_of_line ();
2490 #ifdef REPEAT_CONS_EXPRESSIONS
2491 if (*input_line_pointer
== ':')
2493 expressionS count_exp
;
2495 ++input_line_pointer
;
2496 expression (&count_exp
);
2497 if (count_exp
.X_op
!= O_constant
2498 || count_exp
.X_add_number
<= 0)
2500 as_warn ("unresolvable or nonpositive repeat count; using 1");
2503 count
= count_exp
.X_add_number
;
2507 while (--count
>= 0)
2509 p
= frag_more (length
);
2510 memcpy (p
, temp
, (unsigned int) length
);
2515 while (*input_line_pointer
++ == ',');
2517 --input_line_pointer
; /* Put terminator back into stream. */
2518 demand_empty_rest_of_line ();
2519 } /* float_cons() */
2524 * We read 0 or more ',' seperated, double-quoted strings.
2526 * Caller should have checked need_pass_2 is FALSE because we don't check it.
2531 stringer (append_zero
) /* Worker to do .ascii etc statements. */
2532 /* Checks end-of-line. */
2533 register int append_zero
; /* 0: don't append '\0', else 1 */
2535 register unsigned int c
;
2537 #ifdef md_flush_pending_output
2538 md_flush_pending_output ();
2542 * The following awkward logic is to parse ZERO or more strings,
2543 * comma seperated. Recall a string expression includes spaces
2544 * before the opening '\"' and spaces after the closing '\"'.
2545 * We fake a leading ',' if there is (supposed to be)
2546 * a 1st, expression. We keep demanding expressions for each
2549 if (is_it_end_of_statement ())
2551 c
= 0; /* Skip loop. */
2552 ++input_line_pointer
; /* Compensate for end of loop. */
2556 c
= ','; /* Do loop. */
2558 while (c
== ',' || c
== '<' || c
== '"')
2561 switch (*input_line_pointer
)
2564 ++input_line_pointer
; /*->1st char of string. */
2565 while (is_a_char (c
= next_char_of_string ()))
2567 FRAG_APPEND_1_CHAR (c
);
2571 FRAG_APPEND_1_CHAR (0);
2573 know (input_line_pointer
[-1] == '\"');
2576 input_line_pointer
++;
2577 c
= get_single_number ();
2578 FRAG_APPEND_1_CHAR (c
);
2579 if (*input_line_pointer
!= '>')
2581 as_bad ("Expected <nn>");
2583 input_line_pointer
++;
2586 input_line_pointer
++;
2590 c
= *input_line_pointer
;
2593 demand_empty_rest_of_line ();
2596 /* FIXME-SOMEDAY: I had trouble here on characters with the
2597 high bits set. We'll probably also have trouble with
2598 multibyte chars, wide chars, etc. Also be careful about
2599 returning values bigger than 1 byte. xoxorich. */
2602 next_char_of_string ()
2604 register unsigned int c
;
2606 c
= *input_line_pointer
++ & CHAR_MASK
;
2613 #ifndef NO_STRING_ESCAPES
2615 switch (c
= *input_line_pointer
++)
2643 break; /* As itself. */
2659 for (i
= 0, number
= 0; isdigit (c
) && i
< 3; c
= *input_line_pointer
++, i
++)
2661 number
= number
* 8 + c
- '0';
2665 --input_line_pointer
;
2674 c
= *input_line_pointer
++;
2675 while (isxdigit (c
))
2678 number
= number
* 16 + c
- '0';
2679 else if (isupper (c
))
2680 number
= number
* 16 + c
- 'A' + 10;
2682 number
= number
* 16 + c
- 'a' + 10;
2683 c
= *input_line_pointer
++;
2686 --input_line_pointer
;
2691 /* To be compatible with BSD 4.2 as: give the luser a linefeed!! */
2692 as_warn ("Unterminated string: Newline inserted.");
2698 #ifdef ONLY_STANDARD_ESCAPES
2699 as_bad ("Bad escaped character in string, '?' assumed");
2701 #endif /* ONLY_STANDARD_ESCAPES */
2704 } /* switch on escaped char */
2706 #endif /* ! defined (NO_STRING_ESCAPES) */
2710 } /* switch on char */
2712 } /* next_char_of_string() */
2715 get_segmented_expression (expP
)
2716 register expressionS
*expP
;
2718 register segT retval
;
2720 retval
= expression (expP
);
2721 if (expP
->X_op
== O_illegal
2722 || expP
->X_op
== O_absent
2723 || expP
->X_op
== O_big
)
2725 as_bad ("expected address expression; zero assumed");
2726 expP
->X_op
= O_constant
;
2727 expP
->X_add_number
= 0;
2728 retval
= absolute_section
;
2734 get_known_segmented_expression (expP
)
2735 register expressionS
*expP
;
2737 register segT retval
;
2739 if ((retval
= get_segmented_expression (expP
)) == undefined_section
)
2741 /* There is no easy way to extract the undefined symbol from the
2743 if (expP
->X_add_symbol
!= NULL
2744 && S_GET_SEGMENT (expP
->X_add_symbol
) != expr_section
)
2745 as_warn ("symbol \"%s\" undefined; zero assumed",
2746 S_GET_NAME (expP
->X_add_symbol
));
2748 as_warn ("some symbol undefined; zero assumed");
2749 retval
= absolute_section
;
2750 expP
->X_op
= O_constant
;
2751 expP
->X_add_number
= 0;
2753 know (retval
== absolute_section
|| SEG_NORMAL (retval
));
2755 } /* get_known_segmented_expression() */
2758 get_absolute_expression ()
2763 if (exp
.X_op
!= O_constant
)
2765 if (exp
.X_op
!= O_absent
)
2766 as_bad ("bad or irreducible absolute expression; zero assumed");
2767 exp
.X_add_number
= 0;
2769 return exp
.X_add_number
;
2772 char /* return terminator */
2773 get_absolute_expression_and_terminator (val_pointer
)
2774 long *val_pointer
; /* return value of expression */
2776 /* FIXME: val_pointer should probably be offsetT *. */
2777 *val_pointer
= (long) get_absolute_expression ();
2778 return (*input_line_pointer
++);
2782 * demand_copy_C_string()
2784 * Like demand_copy_string, but return NULL if the string contains any '\0's.
2785 * Give a warning if that happens.
2788 demand_copy_C_string (len_pointer
)
2793 if ((s
= demand_copy_string (len_pointer
)) != 0)
2797 for (len
= *len_pointer
;
2806 as_bad ("This string may not contain \'\\0\'");
2814 * demand_copy_string()
2816 * Demand string, but return a safe (=private) copy of the string.
2817 * Return NULL if we can't read a string here.
2820 demand_copy_string (lenP
)
2823 register unsigned int c
;
2829 if (*input_line_pointer
== '\"')
2831 input_line_pointer
++; /* Skip opening quote. */
2833 while (is_a_char (c
= next_char_of_string ()))
2835 obstack_1grow (¬es
, c
);
2838 /* JF this next line is so demand_copy_C_string will return a null
2839 termanated string. */
2840 obstack_1grow (¬es
, '\0');
2841 retval
= obstack_finish (¬es
);
2845 as_warn ("Missing string");
2847 ignore_rest_of_line ();
2851 } /* demand_copy_string() */
2854 * is_it_end_of_statement()
2856 * In: Input_line_pointer->next character.
2858 * Do: Skip input_line_pointer over all whitespace.
2860 * Out: 1 if input_line_pointer->end-of-line.
2863 is_it_end_of_statement ()
2866 return (is_end_of_line
[(unsigned char) *input_line_pointer
]);
2867 } /* is_it_end_of_statement() */
2873 register symbolS
*symbolP
; /* symbol we are working with */
2875 input_line_pointer
++;
2876 if (*input_line_pointer
== '=')
2877 input_line_pointer
++;
2879 while (*input_line_pointer
== ' ' || *input_line_pointer
== '\t')
2880 input_line_pointer
++;
2882 if (sym_name
[0] == '.' && sym_name
[1] == '\0')
2884 /* Turn '. = mumble' into a .org mumble */
2885 register segT segment
;
2889 segment
= get_known_segmented_expression (&exp
);
2892 if (segment
!= now_seg
&& segment
!= absolute_section
)
2893 as_warn ("Illegal segment \"%s\". Segment \"%s\" assumed.",
2894 segment_name (segment
),
2895 segment_name (now_seg
));
2896 p
= frag_var (rs_org
, 1, 1, (relax_substateT
) 0, exp
.X_add_symbol
,
2897 exp
.X_add_number
, (char *) 0);
2899 } /* if (ok to make frag) */
2903 symbolP
= symbol_find_or_make (sym_name
);
2904 pseudo_set (symbolP
);
2908 /* .include -- include a file at this point. */
2921 filename
= demand_copy_string (&i
);
2922 demand_empty_rest_of_line ();
2923 path
= xmalloc ((unsigned long) i
+ include_dir_maxlen
+ 5 /* slop */ );
2924 for (i
= 0; i
< include_dir_count
; i
++)
2926 strcpy (path
, include_dirs
[i
]);
2928 strcat (path
, filename
);
2929 if (0 != (try = fopen (path
, "r")))
2938 /* malloc Storage leak when file is found on path. FIXME-SOMEDAY. */
2939 newbuf
= input_scrub_include_file (path
, input_line_pointer
);
2940 buffer_limit
= input_scrub_next_buffer (&input_line_pointer
);
2944 add_include_dir (path
)
2949 if (include_dir_count
== 0)
2951 include_dirs
= (char **) xmalloc (2 * sizeof (*include_dirs
));
2952 include_dirs
[0] = "."; /* Current dir */
2953 include_dir_count
= 2;
2957 include_dir_count
++;
2958 include_dirs
= (char **) realloc (include_dirs
,
2959 include_dir_count
* sizeof (*include_dirs
));
2962 include_dirs
[include_dir_count
- 1] = path
; /* New one */
2965 if (i
> include_dir_maxlen
)
2966 include_dir_maxlen
= i
;
2967 } /* add_include_dir() */
2973 while (!is_end_of_line
[(unsigned char) *input_line_pointer
])
2975 ++input_line_pointer
;
2977 ++input_line_pointer
;