]>
Commit | Line | Data |
---|---|---|
fecd2382 | 1 | /* read.c - read a source file - |
5ac34ac3 | 2 | Copyright (C) 1986, 1987, 1990, 1991, 1993 Free Software Foundation, Inc. |
3340f7e5 | 3 | |
f8701a3f SC |
4 | This file is part of GAS, the GNU Assembler. |
5 | ||
6 | GAS is free software; you can redistribute it and/or modify | |
7 | it under the terms of the GNU General Public License as published by | |
8 | the Free Software Foundation; either version 2, or (at your option) | |
9 | any later version. | |
10 | ||
11 | GAS is distributed in the hope that it will be useful, | |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 | GNU General Public License for more details. | |
15 | ||
16 | You should have received a copy of the GNU General Public License | |
17 | along with GAS; see the file COPYING. If not, write to | |
18 | the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ | |
fecd2382 | 19 | |
016e0d42 | 20 | #if 0 |
fecd2382 RP |
21 | #define MASK_CHAR (0xFF) /* If your chars aren't 8 bits, you will |
22 | change this a bit. But then, GNU isn't | |
23 | spozed to run on your machine anyway. | |
24 | (RMS is so shortsighted sometimes.) | |
25 | */ | |
016e0d42 ILT |
26 | #else |
27 | #define MASK_CHAR ((int)(unsigned char)-1) | |
28 | #endif | |
fecd2382 | 29 | |
9a7d824a | 30 | |
9471a360 KR |
31 | /* This is the largest known floating point format (for now). It will |
32 | grow when we do 4361 style flonums. */ | |
fecd2382 | 33 | |
9471a360 | 34 | #define MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT (16) |
fecd2382 | 35 | |
016e0d42 ILT |
36 | /* Routines that read assembler source text to build spagetti in memory. |
37 | Another group of these functions is in the expr.c module. */ | |
fecd2382 | 38 | |
9471a360 | 39 | /* for isdigit() */ |
6efd877d KR |
40 | #include <ctype.h> |
41 | ||
fecd2382 | 42 | #include "as.h" |
9471a360 | 43 | #include "subsegs.h" |
fecd2382 RP |
44 | |
45 | #include "obstack.h" | |
9a7d824a ILT |
46 | #include "listing.h" |
47 | ||
9a7d824a ILT |
48 | #ifndef TC_START_LABEL |
49 | #define TC_START_LABEL(x,y) (x==':') | |
50 | #endif | |
fecd2382 | 51 | |
016e0d42 ILT |
52 | /* The NOP_OPCODE is for the alignment fill value. |
53 | * fill it a nop instruction so that the disassembler does not choke | |
54 | * on it | |
55 | */ | |
56 | #ifndef NOP_OPCODE | |
57 | #define NOP_OPCODE 0x00 | |
58 | #endif | |
59 | ||
60 | char *input_line_pointer; /*->next char of source file to parse. */ | |
fecd2382 RP |
61 | |
62 | #if BITS_PER_CHAR != 8 | |
6efd877d KR |
63 | /* The following table is indexed by[(char)] and will break if |
64 | a char does not have exactly 256 states (hopefully 0:255!)! */ | |
65 | die horribly; | |
fecd2382 | 66 | #endif |
f8701a3f | 67 | |
c978e704 ILT |
68 | #ifndef LEX_AT |
69 | /* The m88k unfortunately uses @ as a label beginner. */ | |
70 | #define LEX_AT 0 | |
71 | #endif | |
72 | ||
016e0d42 ILT |
73 | /* used by is_... macros. our ctype[] */ |
74 | const char lex_type[256] = | |
75 | { | |
76 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* @ABCDEFGHIJKLMNO */ | |
77 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* PQRSTUVWXYZ[\]^_ */ | |
78 | 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, /* _!"#$%&'()*+,-./ */ | |
79 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, /* 0123456789:;<=>? */ | |
c978e704 | 80 | LEX_AT, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, /* @ABCDEFGHIJKLMNO */ |
44ce2f32 | 81 | 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 3, /* PQRSTUVWXYZ[\]^_ */ |
016e0d42 ILT |
82 | 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, /* `abcdefghijklmno */ |
83 | 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, /* pqrstuvwxyz{|}~. */ | |
84 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | |
85 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | |
86 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | |
87 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | |
88 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | |
89 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | |
90 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | |
91 | }; | |
92 | ||
93 | ||
94 | /* | |
fecd2382 RP |
95 | * In: a character. |
96 | * Out: 1 if this character ends a line. | |
97 | */ | |
98 | #define _ (0) | |
016e0d42 ILT |
99 | char is_end_of_line[256] = |
100 | { | |
fecd2382 | 101 | #ifdef CR_EOL |
016e0d42 | 102 | _, _, _, _, _, _, _, _, _, _, 99, _, _, 99, _, _, /* @abcdefghijklmno */ |
fecd2382 | 103 | #else |
016e0d42 | 104 | _, _, _, _, _, _, _, _, _, _, 99, _, _, _, _, _, /* @abcdefghijklmno */ |
fecd2382 | 105 | #endif |
016e0d42 | 106 | _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, /* */ |
40324362 KR |
107 | #ifdef TC_HPPA |
108 | _,99, _, _, _, _, _, _, _, _, _, _, _, _, _, _, /* _!"#$%&'()*+,-./ */ | |
109 | _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, /* 0123456789:;<=>? */ | |
110 | #else | |
016e0d42 ILT |
111 | _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, /* */ |
112 | _, _, _, _, _, _, _, _, _, _, _, 99, _, _, _, _, /* 0123456789:;<=>? */ | |
40324362 | 113 | #endif |
016e0d42 ILT |
114 | _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, /* */ |
115 | _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, /* */ | |
116 | _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, /* */ | |
117 | _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, /* */ | |
118 | _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, /* */ | |
119 | _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, /* */ | |
120 | _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, /* */ | |
121 | _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, /* */ | |
122 | _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, /* */ | |
123 | }; | |
fecd2382 RP |
124 | #undef _ |
125 | ||
016e0d42 ILT |
126 | /* Functions private to this file. */ |
127 | ||
128 | static char *buffer; /* 1st char of each buffer of lines is here. */ | |
129 | static char *buffer_limit; /*->1 + last char in buffer. */ | |
fecd2382 | 130 | |
9c6d3f66 KR |
131 | int target_big_endian; |
132 | ||
9471a360 | 133 | static char *old_buffer; /* JF a hack */ |
016e0d42 ILT |
134 | static char *old_input; |
135 | static char *old_limit; | |
fecd2382 | 136 | |
016e0d42 | 137 | /* Variables for handling include file directory list. */ |
fecd2382 | 138 | |
016e0d42 ILT |
139 | char **include_dirs; /* List of pointers to directories to |
140 | search for .include's */ | |
141 | int include_dir_count; /* How many are in the list */ | |
142 | int include_dir_maxlen = 1;/* Length of longest in list */ | |
fecd2382 RP |
143 | |
144 | #ifndef WORKING_DOT_WORD | |
016e0d42 | 145 | struct broken_word *broken_words; |
9471a360 | 146 | int new_broken_words; |
fecd2382 RP |
147 | #endif |
148 | ||
016e0d42 ILT |
149 | static char *demand_copy_string PARAMS ((int *lenP)); |
150 | int is_it_end_of_statement PARAMS ((void)); | |
5ac34ac3 | 151 | static segT get_segmented_expression PARAMS ((expressionS *expP)); |
016e0d42 | 152 | static segT get_known_segmented_expression PARAMS ((expressionS * expP)); |
016e0d42 | 153 | static void pobegin PARAMS ((void)); |
fecd2382 | 154 | \f |
6efd877d | 155 | |
016e0d42 ILT |
156 | void |
157 | read_begin () | |
fecd2382 | 158 | { |
016e0d42 | 159 | const char *p; |
f8701a3f | 160 | |
6efd877d KR |
161 | pobegin (); |
162 | obj_read_begin_hook (); | |
f8701a3f | 163 | |
4380166d KR |
164 | /* Something close -- but not too close -- to a multiple of 1024. |
165 | The debugging malloc I'm using has 24 bytes of overhead. */ | |
166 | obstack_begin (¬es, 5090); | |
167 | obstack_begin (&cond_obstack, 990); | |
f8701a3f | 168 | |
f8701a3f SC |
169 | /* Use machine dependent syntax */ |
170 | for (p = line_separator_chars; *p; p++) | |
58d4951d | 171 | is_end_of_line[(unsigned char) *p] = 1; |
f8701a3f | 172 | /* Use more. FIXME-SOMEDAY. */ |
fecd2382 RP |
173 | } |
174 | \f | |
175 | /* set up pseudo-op tables */ | |
176 | ||
c8863a58 | 177 | struct hash_control *po_hash; |
fecd2382 | 178 | |
016e0d42 | 179 | static const pseudo_typeS potable[] = |
fecd2382 | 180 | { |
6efd877d KR |
181 | {"abort", s_abort, 0}, |
182 | {"align", s_align_ptwo, 0}, | |
183 | {"ascii", stringer, 0}, | |
184 | {"asciz", stringer, 1}, | |
f8701a3f | 185 | /* block */ |
6efd877d KR |
186 | {"byte", cons, 1}, |
187 | {"comm", s_comm, 0}, | |
188 | {"data", s_data, 0}, | |
604633ae | 189 | #ifdef S_SET_DESC |
4064305e | 190 | {"desc", s_desc, 0}, |
604633ae | 191 | #endif |
f8701a3f | 192 | /* dim */ |
6efd877d | 193 | {"double", float_cons, 'd'}, |
f8701a3f | 194 | /* dsect */ |
6efd877d KR |
195 | {"eject", listing_eject, 0}, /* Formfeed listing */ |
196 | {"else", s_else, 0}, | |
197 | {"end", s_end, 0}, | |
198 | {"endif", s_endif, 0}, | |
f8701a3f | 199 | /* endef */ |
6efd877d | 200 | {"equ", s_set, 0}, |
f8701a3f SC |
201 | /* err */ |
202 | /* extend */ | |
6efd877d | 203 | {"extern", s_ignore, 0}, /* We treat all undef as ext */ |
9a7d824a ILT |
204 | {"appfile", s_app_file, 1}, |
205 | {"appline", s_app_line, 0}, | |
6efd877d KR |
206 | {"file", s_app_file, 0}, |
207 | {"fill", s_fill, 0}, | |
208 | {"float", float_cons, 'f'}, | |
6efd877d KR |
209 | {"global", s_globl, 0}, |
210 | {"globl", s_globl, 0}, | |
211 | {"hword", cons, 2}, | |
212 | {"if", s_if, 0}, | |
213 | {"ifdef", s_ifdef, 0}, | |
214 | {"ifeqs", s_ifeqs, 0}, | |
215 | {"ifndef", s_ifdef, 1}, | |
216 | {"ifnes", s_ifeqs, 1}, | |
217 | {"ifnotdef", s_ifdef, 1}, | |
218 | {"include", s_include, 0}, | |
219 | {"int", cons, 4}, | |
220 | {"lcomm", s_lcomm, 0}, | |
221 | {"lflags", listing_flags, 0}, /* Listing flags */ | |
222 | {"list", listing_list, 1}, /* Turn listing on */ | |
223 | {"long", cons, 4}, | |
224 | {"lsym", s_lsym, 0}, | |
225 | {"nolist", listing_list, 0}, /* Turn listing off */ | |
80aab579 | 226 | {"octa", cons, 16}, |
6efd877d KR |
227 | {"org", s_org, 0}, |
228 | {"psize", listing_psize, 0}, /* set paper size */ | |
f8701a3f | 229 | /* print */ |
80aab579 | 230 | {"quad", cons, 8}, |
6efd877d | 231 | {"sbttl", listing_title, 1}, /* Subtitle of listing */ |
f8701a3f SC |
232 | /* scl */ |
233 | /* sect */ | |
6efd877d KR |
234 | {"set", s_set, 0}, |
235 | {"short", cons, 2}, | |
236 | {"single", float_cons, 'f'}, | |
f8701a3f | 237 | /* size */ |
6efd877d | 238 | {"space", s_space, 0}, |
4064305e SS |
239 | {"stabd", s_stab, 'd'}, |
240 | {"stabn", s_stab, 'n'}, | |
241 | {"stabs", s_stab, 's'}, | |
ba71c54d | 242 | {"string", stringer, 1}, |
f8701a3f | 243 | /* tag */ |
6efd877d KR |
244 | {"text", s_text, 0}, |
245 | {"title", listing_title, 0}, /* Listing title */ | |
f8701a3f SC |
246 | /* type */ |
247 | /* use */ | |
248 | /* val */ | |
4064305e | 249 | {"xstabs", s_xstab, 's'}, |
6efd877d KR |
250 | {"word", cons, 2}, |
251 | {NULL} /* end sentinel */ | |
fecd2382 RP |
252 | }; |
253 | ||
6efd877d KR |
254 | static void |
255 | pobegin () | |
256 | { | |
604633ae | 257 | const char *errtxt; /* error text */ |
6efd877d KR |
258 | const pseudo_typeS *pop; |
259 | ||
260 | po_hash = hash_new (); | |
261 | ||
262 | /* Do the target-specific pseudo ops. */ | |
263 | for (pop = md_pseudo_table; pop->poc_name; pop++) | |
264 | { | |
265 | errtxt = hash_insert (po_hash, pop->poc_name, (char *) pop); | |
80aab579 | 266 | if (errtxt) |
6efd877d KR |
267 | { |
268 | as_fatal ("error constructing md pseudo-op table"); | |
269 | } /* on error */ | |
270 | } /* for each op */ | |
271 | ||
272 | /* Now object specific. Skip any that were in the target table. */ | |
273 | for (pop = obj_pseudo_table; pop->poc_name; pop++) | |
274 | { | |
275 | errtxt = hash_insert (po_hash, pop->poc_name, (char *) pop); | |
80aab579 | 276 | if (errtxt) |
6efd877d KR |
277 | { |
278 | if (!strcmp (errtxt, "exists")) | |
279 | { | |
fecd2382 | 280 | #ifdef DIE_ON_OVERRIDES |
6efd877d | 281 | as_fatal ("pseudo op \".%s\" overridden.\n", pop->poc_name); |
fecd2382 | 282 | #endif /* DIE_ON_OVERRIDES */ |
6efd877d KR |
283 | continue; /* OK if target table overrides. */ |
284 | } | |
285 | else | |
286 | { | |
287 | as_fatal ("error constructing obj pseudo-op table"); | |
288 | } /* if overridden */ | |
289 | } /* on error */ | |
290 | } /* for each op */ | |
291 | ||
292 | /* Now portable ones. Skip any that we've seen already. */ | |
293 | for (pop = potable; pop->poc_name; pop++) | |
294 | { | |
295 | errtxt = hash_insert (po_hash, pop->poc_name, (char *) pop); | |
80aab579 | 296 | if (errtxt) |
6efd877d KR |
297 | { |
298 | if (!strcmp (errtxt, "exists")) | |
299 | { | |
fecd2382 | 300 | #ifdef DIE_ON_OVERRIDES |
6efd877d | 301 | as_fatal ("pseudo op \".%s\" overridden.\n", pop->poc_name); |
fecd2382 | 302 | #endif /* DIE_ON_OVERRIDES */ |
6efd877d KR |
303 | continue; /* OK if target table overrides. */ |
304 | } | |
305 | else | |
306 | { | |
307 | as_fatal ("error constructing obj pseudo-op table"); | |
308 | } /* if overridden */ | |
309 | } /* on error */ | |
310 | } /* for each op */ | |
311 | ||
312 | return; | |
313 | } /* pobegin() */ | |
fecd2382 | 314 | \f |
58d4951d ILT |
315 | #define HANDLE_CONDITIONAL_ASSEMBLY() \ |
316 | if (ignore_input ()) \ | |
317 | { \ | |
318 | while (! is_end_of_line[(unsigned char) *input_line_pointer++]) \ | |
319 | if (input_line_pointer == buffer_limit) \ | |
320 | break; \ | |
321 | continue; \ | |
f8701a3f | 322 | } |
a39116f1 | 323 | |
fecd2382 RP |
324 | |
325 | /* read_a_source_file() | |
326 | * | |
327 | * We read the file, putting things into a web that | |
328 | * represents what we have been reading. | |
329 | */ | |
6efd877d KR |
330 | void |
331 | read_a_source_file (name) | |
332 | char *name; | |
fecd2382 | 333 | { |
f8701a3f | 334 | register char c; |
6efd877d | 335 | register char *s; /* string of symbol, '\0' appended */ |
f8701a3f | 336 | register int temp; |
6efd877d | 337 | pseudo_typeS *pop; |
f8701a3f | 338 | |
6efd877d | 339 | buffer = input_scrub_new_file (name); |
f8701a3f | 340 | |
6efd877d KR |
341 | listing_file (name); |
342 | listing_newline (""); | |
f8701a3f | 343 | |
6efd877d KR |
344 | while ((buffer_limit = input_scrub_next_buffer (&input_line_pointer)) != 0) |
345 | { /* We have another line to parse. */ | |
346 | know (buffer_limit[-1] == '\n'); /* Must have a sentinel. */ | |
9471a360 KR |
347 | contin: /* JF this goto is my fault I admit it. |
348 | Someone brave please re-write the whole | |
349 | input section here? Pleeze??? */ | |
6efd877d | 350 | while (input_line_pointer < buffer_limit) |
9471a360 KR |
351 | { |
352 | /* We have more of this buffer to parse. */ | |
f8701a3f SC |
353 | |
354 | /* | |
355 | * We now have input_line_pointer->1st char of next line. | |
356 | * If input_line_pointer [-1] == '\n' then we just | |
357 | * scanned another line: so bump line counters. | |
358 | */ | |
d2550c72 | 359 | if (is_end_of_line[(unsigned char) input_line_pointer[-1]]) |
6efd877d | 360 | { |
385ce433 JL |
361 | if (input_line_pointer[-1] == '\n') |
362 | bump_line_counters (); | |
f8701a3f | 363 | |
48c3dee6 | 364 | #if defined (MRI) || defined (LABELS_WITHOUT_COLONS) |
385ce433 JL |
365 | /* Text at the start of a line must be a label, we run down |
366 | and stick a colon in. */ | |
6efd877d KR |
367 | if (is_name_beginner (*input_line_pointer)) |
368 | { | |
369 | char *line_start = input_line_pointer; | |
370 | char c = get_symbol_end (); | |
371 | colon (line_start); | |
372 | *input_line_pointer = c; | |
373 | if (c == ':') | |
374 | input_line_pointer++; | |
375 | ||
376 | } | |
f8701a3f | 377 | #endif |
9471a360 | 378 | } |
f8701a3f SC |
379 | |
380 | ||
f8701a3f SC |
381 | /* |
382 | * We are at the begining of a line, or similar place. | |
383 | * We expect a well-formed assembler statement. | |
384 | * A "symbol-name:" is a statement. | |
385 | * | |
386 | * Depending on what compiler is used, the order of these tests | |
387 | * may vary to catch most common case 1st. | |
388 | * Each test is independent of all other tests at the (top) level. | |
389 | * PLEASE make a compiler that doesn't use this assembler. | |
390 | * It is crufty to waste a compiler's time encoding things for this | |
391 | * assembler, which then wastes more time decoding it. | |
392 | * (And communicating via (linear) files is silly! | |
393 | * If you must pass stuff, please pass a tree!) | |
394 | */ | |
9471a360 KR |
395 | if ((c = *input_line_pointer++) == '\t' |
396 | || c == ' ' | |
397 | || c == '\f' | |
398 | || c == 0) | |
6efd877d KR |
399 | { |
400 | c = *input_line_pointer++; | |
401 | } | |
402 | know (c != ' '); /* No further leading whitespace. */ | |
403 | LISTING_NEWLINE (); | |
f8701a3f SC |
404 | /* |
405 | * C is the 1st significant character. | |
406 | * Input_line_pointer points after that character. | |
407 | */ | |
6efd877d KR |
408 | if (is_name_beginner (c)) |
409 | { /* want user-defined label or pseudo/opcode */ | |
410 | HANDLE_CONDITIONAL_ASSEMBLY (); | |
411 | ||
f8701a3f | 412 | s = --input_line_pointer; |
6efd877d | 413 | c = get_symbol_end (); /* name's delimiter */ |
f8701a3f SC |
414 | /* |
415 | * C is character after symbol. | |
416 | * That character's place in the input line is now '\0'. | |
417 | * S points to the beginning of the symbol. | |
418 | * [In case of pseudo-op, s->'.'.] | |
419 | * Input_line_pointer->'\0' where c was. | |
420 | */ | |
9a7d824a | 421 | if (TC_START_LABEL(c, input_line_pointer)) |
6efd877d KR |
422 | { |
423 | colon (s); /* user-defined label */ | |
424 | *input_line_pointer++ = ':'; /* Put ':' back for error messages' sake. */ | |
f8701a3f | 425 | /* Input_line_pointer->after ':'. */ |
6efd877d KR |
426 | SKIP_WHITESPACE (); |
427 | ||
f8701a3f | 428 | |
6efd877d | 429 | } |
4064305e SS |
430 | else if (c == '=' |
431 | || (input_line_pointer[1] == '=' | |
432 | #ifdef TC_EQUAL_IN_INSN | |
433 | && ! TC_EQUAL_IN_INSN (c, input_line_pointer) | |
434 | #endif | |
435 | )) | |
9c6d3f66 | 436 | { |
6efd877d KR |
437 | equals (s); |
438 | demand_empty_rest_of_line (); | |
439 | } | |
440 | else | |
441 | { /* expect pseudo-op or machine instruction */ | |
f8701a3f | 442 | #ifdef MRI |
6efd877d KR |
443 | if (!done_pseudo (s)) |
444 | ||
f8701a3f | 445 | #else |
8ff6f40e ILT |
446 | |
447 | pop = NULL; | |
448 | ||
d4c8cbd8 JL |
449 | #define IGNORE_OPCODE_CASE |
450 | #ifdef IGNORE_OPCODE_CASE | |
451 | { | |
452 | char *s2 = s; | |
453 | while (*s2) | |
454 | { | |
455 | if (isupper (*s2)) | |
456 | *s2 = tolower (*s2); | |
457 | s2++; | |
458 | } | |
459 | } | |
460 | #endif | |
461 | ||
8ff6f40e ILT |
462 | #ifdef NO_PSEUDO_DOT |
463 | /* The m88k uses pseudo-ops without a period. */ | |
464 | pop = (pseudo_typeS *) hash_find (po_hash, s); | |
cf897ce2 ILT |
465 | if (pop != NULL && pop->poc_handler == NULL) |
466 | pop = NULL; | |
8ff6f40e ILT |
467 | #endif |
468 | ||
469 | if (pop != NULL || *s == '.') | |
6efd877d KR |
470 | { |
471 | /* | |
9471a360 KR |
472 | * PSEUDO - OP. |
473 | * | |
474 | * WARNING: c has next char, which may be end-of-line. | |
475 | * We lookup the pseudo-op table with s+1 because we | |
476 | * already know that the pseudo-op begins with a '.'. | |
477 | */ | |
6efd877d | 478 | |
8ff6f40e ILT |
479 | if (pop == NULL) |
480 | pop = (pseudo_typeS *) hash_find (po_hash, s + 1); | |
6efd877d KR |
481 | |
482 | /* Print the error msg now, while we still can */ | |
8ff6f40e | 483 | if (pop == NULL) |
6efd877d KR |
484 | { |
485 | as_bad ("Unknown pseudo-op: `%s'", s); | |
f8701a3f | 486 | *input_line_pointer = c; |
6efd877d | 487 | s_ignore (0); |
46b81190 | 488 | continue; |
6efd877d KR |
489 | } |
490 | ||
491 | /* Put it back for error messages etc. */ | |
492 | *input_line_pointer = c; | |
9c6d3f66 KR |
493 | /* The following skip of whitespace is compulsory. |
494 | A well shaped space is sometimes all that separates | |
495 | keyword from operands. */ | |
6efd877d | 496 | if (c == ' ' || c == '\t') |
d4c8cbd8 | 497 | input_line_pointer++; |
6efd877d | 498 | /* |
9471a360 KR |
499 | * Input_line is restored. |
500 | * Input_line_pointer->1st non-blank char | |
501 | * after pseudo-operation. | |
502 | */ | |
46b81190 | 503 | (*pop->poc_handler) (pop->poc_val); |
6efd877d KR |
504 | } |
505 | else | |
f8701a3f | 506 | #endif |
6efd877d KR |
507 | { /* machine instruction */ |
508 | /* WARNING: c has char, which may be end-of-line. */ | |
509 | /* Also: input_line_pointer->`\0` where c was. */ | |
510 | *input_line_pointer = c; | |
58d4951d | 511 | while (!is_end_of_line[(unsigned char) *input_line_pointer] |
4064305e SS |
512 | #ifdef TC_EOL_IN_INSN |
513 | || TC_EOL_IN_INSN (input_line_pointer) | |
514 | #endif | |
515 | ) | |
6efd877d KR |
516 | { |
517 | input_line_pointer++; | |
518 | } | |
f8701a3f | 519 | |
6efd877d KR |
520 | c = *input_line_pointer; |
521 | *input_line_pointer = '\0'; | |
f8701a3f | 522 | |
6efd877d | 523 | md_assemble (s); /* Assemble 1 instruction. */ |
f8701a3f | 524 | |
6efd877d | 525 | *input_line_pointer++ = c; |
f8701a3f | 526 | |
d4c8cbd8 JL |
527 | /* We resume loop AFTER the end-of-line from |
528 | this instruction. */ | |
6efd877d | 529 | } /* if (*s=='.') */ |
6efd877d | 530 | } /* if c==':' */ |
f8701a3f | 531 | continue; |
6efd877d | 532 | } /* if (is_name_beginner(c) */ |
f8701a3f | 533 | |
f8701a3f | 534 | |
d4c8cbd8 | 535 | /* Empty statement? */ |
58d4951d | 536 | if (is_end_of_line[(unsigned char) c]) |
d4c8cbd8 | 537 | continue; |
6efd877d KR |
538 | |
539 | #if defined(LOCAL_LABELS_DOLLAR) || defined(LOCAL_LABELS_FB) | |
540 | if (isdigit (c)) | |
d4c8cbd8 JL |
541 | { |
542 | /* local label ("4:") */ | |
6efd877d KR |
543 | char *backup = input_line_pointer; |
544 | ||
545 | HANDLE_CONDITIONAL_ASSEMBLY (); | |
546 | ||
547 | temp = c - '0'; | |
548 | ||
549 | while (isdigit (*input_line_pointer)) | |
550 | { | |
551 | temp = (temp * 10) + *input_line_pointer - '0'; | |
552 | ++input_line_pointer; | |
553 | } /* read the whole number */ | |
554 | ||
555 | #ifdef LOCAL_LABELS_DOLLAR | |
556 | if (*input_line_pointer == '$' | |
557 | && *(input_line_pointer + 1) == ':') | |
558 | { | |
559 | input_line_pointer += 2; | |
560 | ||
561 | if (dollar_label_defined (temp)) | |
562 | { | |
563 | as_fatal ("label \"%d$\" redefined", temp); | |
564 | } | |
565 | ||
566 | define_dollar_label (temp); | |
567 | colon (dollar_label_name (temp, 0)); | |
568 | continue; | |
569 | } | |
f8701a3f | 570 | #endif /* LOCAL_LABELS_DOLLAR */ |
6efd877d | 571 | |
f8701a3f | 572 | #ifdef LOCAL_LABELS_FB |
6efd877d KR |
573 | if (*input_line_pointer++ == ':') |
574 | { | |
575 | fb_label_instance_inc (temp); | |
576 | colon (fb_label_name (temp, 0)); | |
577 | continue; | |
578 | } | |
f8701a3f | 579 | #endif /* LOCAL_LABELS_FB */ |
6efd877d KR |
580 | |
581 | input_line_pointer = backup; | |
582 | } /* local label ("4:") */ | |
f8701a3f SC |
583 | #endif /* LOCAL_LABELS_DOLLAR or LOCAL_LABELS_FB */ |
584 | ||
6efd877d KR |
585 | if (c && strchr (line_comment_chars, c)) |
586 | { /* Its a comment. Better say APP or NO_APP */ | |
f8701a3f SC |
587 | char *ends; |
588 | char *new_buf; | |
589 | char *new_tmp; | |
604633ae | 590 | unsigned int new_length; |
f8701a3f | 591 | char *tmp_buf = 0; |
6efd877d KR |
592 | extern char *scrub_string, *scrub_last_string; |
593 | ||
594 | bump_line_counters (); | |
595 | s = input_line_pointer; | |
596 | if (strncmp (s, "APP\n", 4)) | |
597 | continue; /* We ignore it */ | |
598 | s += 4; | |
599 | ||
600 | ends = strstr (s, "#NO_APP\n"); | |
601 | ||
602 | if (!ends) | |
603 | { | |
604633ae ILT |
604 | unsigned int tmp_len; |
605 | unsigned int num; | |
6efd877d | 606 | |
f8701a3f SC |
607 | /* The end of the #APP wasn't in this buffer. We |
608 | keep reading in buffers until we find the #NO_APP | |
609 | that goes with this #APP There is one. The specs | |
610 | guarentee it. . . */ | |
6efd877d | 611 | tmp_len = buffer_limit - s; |
85825401 | 612 | tmp_buf = xmalloc (tmp_len + 1); |
4380166d | 613 | memcpy (tmp_buf, s, tmp_len); |
6efd877d KR |
614 | do |
615 | { | |
616 | new_tmp = input_scrub_next_buffer (&buffer); | |
f8701a3f | 617 | if (!new_tmp) |
6efd877d | 618 | break; |
f8701a3f | 619 | else |
6efd877d | 620 | buffer_limit = new_tmp; |
f8701a3f | 621 | input_line_pointer = buffer; |
6efd877d | 622 | ends = strstr (buffer, "#NO_APP\n"); |
f8701a3f | 623 | if (ends) |
6efd877d | 624 | num = ends - buffer; |
f8701a3f | 625 | else |
6efd877d KR |
626 | num = buffer_limit - buffer; |
627 | ||
628 | tmp_buf = xrealloc (tmp_buf, tmp_len + num); | |
4380166d | 629 | memcpy (tmp_buf, buffer + tmp_len, num); |
6efd877d KR |
630 | tmp_len += num; |
631 | } | |
632 | while (!ends); | |
633 | ||
634 | input_line_pointer = ends ? ends + 8 : NULL; | |
635 | ||
636 | s = tmp_buf; | |
637 | ends = s + tmp_len; | |
638 | ||
639 | } | |
640 | else | |
641 | { | |
642 | input_line_pointer = ends + 8; | |
643 | } | |
644 | new_buf = xmalloc (100); | |
645 | new_length = 100; | |
646 | new_tmp = new_buf; | |
647 | ||
648 | scrub_string = s; | |
f8701a3f | 649 | scrub_last_string = ends; |
6efd877d KR |
650 | for (;;) |
651 | { | |
f8701a3f SC |
652 | int ch; |
653 | ||
6efd877d KR |
654 | ch = do_scrub_next_char (scrub_from_string, scrub_to_string); |
655 | if (ch == EOF) | |
656 | break; | |
657 | *new_tmp++ = ch; | |
658 | if (new_tmp == new_buf + new_length) | |
659 | { | |
660 | new_buf = xrealloc (new_buf, new_length + 100); | |
661 | new_tmp = new_buf + new_length; | |
662 | new_length += 100; | |
f8701a3f | 663 | } |
fecd2382 | 664 | } |
f8701a3f SC |
665 | |
666 | if (tmp_buf) | |
6efd877d KR |
667 | free (tmp_buf); |
668 | old_buffer = buffer; | |
669 | old_input = input_line_pointer; | |
670 | old_limit = buffer_limit; | |
671 | buffer = new_buf; | |
672 | input_line_pointer = new_buf; | |
673 | buffer_limit = new_tmp; | |
f8701a3f SC |
674 | continue; |
675 | } | |
676 | ||
6efd877d | 677 | HANDLE_CONDITIONAL_ASSEMBLY (); |
f8701a3f SC |
678 | |
679 | /* as_warn("Junk character %d.",c); Now done by ignore_rest */ | |
680 | input_line_pointer--; /* Report unknown char as ignored. */ | |
6efd877d KR |
681 | ignore_rest_of_line (); |
682 | } /* while (input_line_pointer<buffer_limit) */ | |
683 | if (old_buffer) | |
684 | { | |
685 | bump_line_counters (); | |
686 | if (old_input != 0) | |
687 | { | |
688 | buffer = old_buffer; | |
689 | input_line_pointer = old_input; | |
690 | buffer_limit = old_limit; | |
f8701a3f SC |
691 | old_buffer = 0; |
692 | goto contin; | |
693 | } | |
694 | } | |
6efd877d KR |
695 | } /* while (more buffers to scan) */ |
696 | input_scrub_close (); /* Close the input file */ | |
f8701a3f | 697 | |
6efd877d | 698 | } /* read_a_source_file() */ |
fecd2382 | 699 | |
6efd877d | 700 | void |
604633ae ILT |
701 | s_abort (ignore) |
702 | int ignore; | |
6efd877d KR |
703 | { |
704 | as_fatal (".abort detected. Abandoning ship."); | |
705 | } /* s_abort() */ | |
fecd2382 RP |
706 | |
707 | /* For machines where ".align 4" means align to a 4 byte boundary. */ | |
6efd877d KR |
708 | void |
709 | s_align_bytes (arg) | |
710 | int arg; | |
fecd2382 | 711 | { |
6efd877d KR |
712 | register unsigned int temp; |
713 | register long temp_fill; | |
714 | unsigned int i = 0; | |
715 | unsigned long max_alignment = 1 << 15; | |
f8701a3f | 716 | |
58d4951d | 717 | if (is_end_of_line[(unsigned char) *input_line_pointer]) |
6efd877d KR |
718 | temp = arg; /* Default value from pseudo-op table */ |
719 | else | |
720 | temp = get_absolute_expression (); | |
f8701a3f | 721 | |
6efd877d KR |
722 | if (temp > max_alignment) |
723 | { | |
724 | as_bad ("Alignment too large: %d. assumed.", temp = max_alignment); | |
f8701a3f SC |
725 | } |
726 | ||
6efd877d | 727 | /* |
f8701a3f SC |
728 | * For the sparc, `.align (1<<n)' actually means `.align n' |
729 | * so we have to convert it. | |
730 | */ | |
6efd877d KR |
731 | if (temp != 0) |
732 | { | |
733 | for (i = 0; (temp & 1) == 0; temp >>= 1, ++i) | |
734 | ; | |
f8701a3f | 735 | } |
6efd877d KR |
736 | if (temp != 1) |
737 | as_bad ("Alignment not a power of 2"); | |
f8701a3f | 738 | |
6efd877d KR |
739 | temp = i; |
740 | if (*input_line_pointer == ',') | |
741 | { | |
742 | input_line_pointer++; | |
743 | temp_fill = get_absolute_expression (); | |
f8701a3f | 744 | } |
9471a360 | 745 | else if (now_seg != data_section && now_seg != bss_section) |
016e0d42 | 746 | temp_fill = NOP_OPCODE; |
6efd877d | 747 | else |
016e0d42 | 748 | temp_fill = 0; |
6efd877d KR |
749 | /* Only make a frag if we HAVE to. . . */ |
750 | if (temp && !need_pass_2) | |
604633ae | 751 | frag_align ((int) temp, (int) temp_fill); |
f8701a3f | 752 | |
604633ae | 753 | record_alignment (now_seg, (int) temp); |
49864cfa | 754 | |
6efd877d KR |
755 | demand_empty_rest_of_line (); |
756 | } /* s_align_bytes() */ | |
fecd2382 RP |
757 | |
758 | /* For machines where ".align 4" means align to 2**4 boundary. */ | |
6efd877d | 759 | void |
604633ae ILT |
760 | s_align_ptwo (ignore) |
761 | int ignore; | |
6efd877d KR |
762 | { |
763 | register int temp; | |
764 | register long temp_fill; | |
765 | long max_alignment = 15; | |
766 | ||
767 | temp = get_absolute_expression (); | |
768 | if (temp > max_alignment) | |
769 | as_bad ("Alignment too large: %d. assumed.", temp = max_alignment); | |
770 | else if (temp < 0) | |
771 | { | |
772 | as_bad ("Alignment negative. 0 assumed."); | |
773 | temp = 0; | |
774 | } | |
775 | if (*input_line_pointer == ',') | |
776 | { | |
777 | input_line_pointer++; | |
778 | temp_fill = get_absolute_expression (); | |
779 | } | |
9471a360 KR |
780 | /* @@ Fix this right for BFD! */ |
781 | else if (now_seg != data_section && now_seg != bss_section) | |
016e0d42 | 782 | temp_fill = NOP_OPCODE; |
6efd877d KR |
783 | else |
784 | temp_fill = 0; | |
785 | /* Only make a frag if we HAVE to. . . */ | |
786 | if (temp && !need_pass_2) | |
787 | frag_align (temp, (int) temp_fill); | |
788 | ||
789 | record_alignment (now_seg, temp); | |
790 | ||
791 | demand_empty_rest_of_line (); | |
792 | } /* s_align_ptwo() */ | |
793 | ||
794 | void | |
604633ae ILT |
795 | s_comm (ignore) |
796 | int ignore; | |
6efd877d KR |
797 | { |
798 | register char *name; | |
799 | register char c; | |
800 | register char *p; | |
58d4951d | 801 | offsetT temp; |
6efd877d KR |
802 | register symbolS *symbolP; |
803 | ||
804 | name = input_line_pointer; | |
805 | c = get_symbol_end (); | |
806 | /* just after name is now '\0' */ | |
807 | p = input_line_pointer; | |
808 | *p = c; | |
809 | SKIP_WHITESPACE (); | |
810 | if (*input_line_pointer != ',') | |
811 | { | |
812 | as_bad ("Expected comma after symbol-name: rest of line ignored."); | |
813 | ignore_rest_of_line (); | |
814 | return; | |
815 | } | |
816 | input_line_pointer++; /* skip ',' */ | |
817 | if ((temp = get_absolute_expression ()) < 0) | |
818 | { | |
58d4951d | 819 | as_warn (".COMMon length (%ld.) <0! Ignored.", (long) temp); |
6efd877d KR |
820 | ignore_rest_of_line (); |
821 | return; | |
822 | } | |
823 | *p = 0; | |
824 | symbolP = symbol_find_or_make (name); | |
825 | *p = c; | |
826 | if (S_IS_DEFINED (symbolP)) | |
827 | { | |
828 | as_bad ("Ignoring attempt to re-define symbol"); | |
829 | ignore_rest_of_line (); | |
830 | return; | |
831 | } | |
832 | if (S_GET_VALUE (symbolP)) | |
833 | { | |
58d4951d ILT |
834 | if (S_GET_VALUE (symbolP) != (valueT) temp) |
835 | as_bad ("Length of .comm \"%s\" is already %ld. Not changed to %ld.", | |
6efd877d | 836 | S_GET_NAME (symbolP), |
58d4951d ILT |
837 | (long) S_GET_VALUE (symbolP), |
838 | (long) temp); | |
6efd877d KR |
839 | } |
840 | else | |
841 | { | |
58d4951d | 842 | S_SET_VALUE (symbolP, (valueT) temp); |
6efd877d KR |
843 | S_SET_EXTERNAL (symbolP); |
844 | } | |
9471a360 | 845 | #ifdef OBJ_VMS |
4064305e SS |
846 | if ( (!temp) || !flagseen['1']) |
847 | S_GET_OTHER(symbolP) = const_flag; | |
9471a360 | 848 | #endif /* not OBJ_VMS */ |
6efd877d KR |
849 | know (symbolP->sy_frag == &zero_address_frag); |
850 | demand_empty_rest_of_line (); | |
851 | } /* s_comm() */ | |
fecd2382 RP |
852 | |
853 | void | |
604633ae ILT |
854 | s_data (ignore) |
855 | int ignore; | |
fecd2382 | 856 | { |
ffffc8fb | 857 | segT section; |
6efd877d | 858 | register int temp; |
f8701a3f | 859 | |
6efd877d | 860 | temp = get_absolute_expression (); |
ffffc8fb ILT |
861 | if (flagseen['R']) |
862 | { | |
863 | section = text_section; | |
864 | temp += 1000; | |
865 | } | |
866 | else | |
867 | section = data_section; | |
868 | ||
ffffc8fb | 869 | subseg_set (section, (subsegT) temp); |
f8701a3f | 870 | |
9471a360 | 871 | #ifdef OBJ_VMS |
6efd877d | 872 | const_flag = 0; |
fecd2382 | 873 | #endif |
6efd877d | 874 | demand_empty_rest_of_line (); |
fecd2382 RP |
875 | } |
876 | ||
9a7d824a ILT |
877 | /* Handle the .appfile pseudo-op. This is automatically generated by |
878 | do_scrub_next_char when a preprocessor # line comment is seen with | |
879 | a file name. This default definition may be overridden by the | |
880 | object or CPU specific pseudo-ops. This function is also the | |
881 | default definition for .file; the APPFILE argument is 1 for | |
882 | .appfile, 0 for .file. */ | |
883 | ||
6efd877d | 884 | void |
9a7d824a ILT |
885 | s_app_file (appfile) |
886 | int appfile; | |
6efd877d KR |
887 | { |
888 | register char *s; | |
889 | int length; | |
f8701a3f | 890 | |
6efd877d KR |
891 | /* Some assemblers tolerate immediately following '"' */ |
892 | if ((s = demand_copy_string (&length)) != 0) | |
893 | { | |
9a7d824a ILT |
894 | /* If this is a fake .appfile, a fake newline was inserted into |
895 | the buffer. Passing -2 to new_logical_line tells it to | |
896 | account for it. */ | |
897 | new_logical_line (s, appfile ? -2 : -1); | |
6efd877d | 898 | demand_empty_rest_of_line (); |
9a7d824a ILT |
899 | #ifdef LISTING |
900 | if (listing) | |
901 | listing_source_file (s); | |
902 | #endif | |
6efd877d | 903 | } |
fecd2382 | 904 | #ifdef OBJ_COFF |
6efd877d | 905 | c_dot_file_symbol (s); |
fecd2382 | 906 | #endif /* OBJ_COFF */ |
40324362 KR |
907 | #ifdef OBJ_ELF |
908 | elf_file_symbol (s); | |
909 | #endif | |
910 | } | |
fecd2382 | 911 | |
9a7d824a ILT |
912 | /* Handle the .appline pseudo-op. This is automatically generated by |
913 | do_scrub_next_char when a preprocessor # line comment is seen. | |
914 | This default definition may be overridden by the object or CPU | |
915 | specific pseudo-ops. */ | |
916 | ||
917 | void | |
604633ae ILT |
918 | s_app_line (ignore) |
919 | int ignore; | |
9a7d824a ILT |
920 | { |
921 | int l; | |
922 | ||
923 | /* The given number is that of the next line. */ | |
924 | l = get_absolute_expression () - 1; | |
925 | new_logical_line ((char *) NULL, l); | |
926 | #ifdef LISTING | |
927 | if (listing) | |
928 | listing_source_line (l); | |
929 | #endif | |
930 | demand_empty_rest_of_line (); | |
931 | } | |
932 | ||
6efd877d | 933 | void |
604633ae ILT |
934 | s_fill (ignore) |
935 | int ignore; | |
6efd877d KR |
936 | { |
937 | long temp_repeat = 0; | |
938 | long temp_size = 1; | |
939 | register long temp_fill = 0; | |
940 | char *p; | |
f8701a3f | 941 | |
7c2d4011 | 942 | |
6efd877d KR |
943 | temp_repeat = get_absolute_expression (); |
944 | if (*input_line_pointer == ',') | |
945 | { | |
946 | input_line_pointer++; | |
947 | temp_size = get_absolute_expression (); | |
948 | if (*input_line_pointer == ',') | |
7c2d4011 SC |
949 | { |
950 | input_line_pointer++; | |
6efd877d | 951 | temp_fill = get_absolute_expression (); |
fecd2382 | 952 | } |
6efd877d | 953 | } |
c8863a58 | 954 | /* This is to be compatible with BSD 4.2 AS, not for any rational reason. */ |
fecd2382 | 955 | #define BSD_FILL_SIZE_CROCK_8 (8) |
6efd877d KR |
956 | if (temp_size > BSD_FILL_SIZE_CROCK_8) |
957 | { | |
958 | as_warn (".fill size clamped to %d.", BSD_FILL_SIZE_CROCK_8); | |
959 | temp_size = BSD_FILL_SIZE_CROCK_8; | |
960 | } | |
961 | if (temp_size < 0) | |
962 | { | |
963 | as_warn ("Size negative: .fill ignored."); | |
964 | temp_size = 0; | |
965 | } | |
966 | else if (temp_repeat <= 0) | |
967 | { | |
968 | as_warn ("Repeat < 0, .fill ignored"); | |
969 | temp_size = 0; | |
970 | } | |
7fd3560a | 971 | |
6efd877d KR |
972 | if (temp_size && !need_pass_2) |
973 | { | |
974 | p = frag_var (rs_fill, (int) temp_size, (int) temp_size, (relax_substateT) 0, (symbolS *) 0, temp_repeat, (char *) 0); | |
604633ae | 975 | memset (p, 0, (unsigned int) temp_size); |
c8863a58 KR |
976 | /* The magic number BSD_FILL_SIZE_CROCK_4 is from BSD 4.2 VAX |
977 | * flavoured AS. The following bizzare behaviour is to be | |
978 | * compatible with above. I guess they tried to take up to 8 | |
979 | * bytes from a 4-byte expression and they forgot to sign | |
980 | * extend. Un*x Sux. */ | |
fecd2382 | 981 | #define BSD_FILL_SIZE_CROCK_4 (4) |
604633ae | 982 | md_number_to_chars (p, (valueT) temp_fill, |
c8863a58 KR |
983 | (temp_size > BSD_FILL_SIZE_CROCK_4 |
984 | ? BSD_FILL_SIZE_CROCK_4 | |
985 | : (int) temp_size)); | |
986 | /* Note: .fill (),0 emits no frag (since we are asked to .fill 0 bytes) | |
987 | * but emits no error message because it seems a legal thing to do. | |
988 | * It is a degenerate case of .fill but could be emitted by a compiler. | |
989 | */ | |
6efd877d | 990 | } |
6efd877d | 991 | demand_empty_rest_of_line (); |
f8701a3f SC |
992 | } |
993 | ||
6efd877d | 994 | void |
604633ae ILT |
995 | s_globl (ignore) |
996 | int ignore; | |
6efd877d | 997 | { |
40324362 KR |
998 | char *name; |
999 | int c; | |
1000 | symbolS *symbolP; | |
fecd2382 | 1001 | |
6efd877d KR |
1002 | do |
1003 | { | |
1004 | name = input_line_pointer; | |
1005 | c = get_symbol_end (); | |
1006 | symbolP = symbol_find_or_make (name); | |
1007 | *input_line_pointer = c; | |
1008 | SKIP_WHITESPACE (); | |
1009 | S_SET_EXTERNAL (symbolP); | |
1010 | if (c == ',') | |
1011 | { | |
1012 | input_line_pointer++; | |
1013 | SKIP_WHITESPACE (); | |
1014 | if (*input_line_pointer == '\n') | |
1015 | c = '\n'; | |
1016 | } | |
1017 | } | |
1018 | while (c == ','); | |
1019 | demand_empty_rest_of_line (); | |
40324362 | 1020 | } |
6efd877d KR |
1021 | |
1022 | void | |
1023 | s_lcomm (needs_align) | |
c8863a58 KR |
1024 | /* 1 if this was a ".bss" directive, which may require a 3rd argument |
1025 | (alignment); 0 if it was an ".lcomm" (2 args only) */ | |
1026 | int needs_align; | |
fecd2382 | 1027 | { |
6efd877d KR |
1028 | register char *name; |
1029 | register char c; | |
1030 | register char *p; | |
1031 | register int temp; | |
1032 | register symbolS *symbolP; | |
9a7d824a ILT |
1033 | segT current_seg = now_seg; |
1034 | subsegT current_subseg = now_subseg; | |
6efd877d KR |
1035 | const int max_alignment = 15; |
1036 | int align = 0; | |
9a7d824a | 1037 | segT bss_seg = bss_section; |
6efd877d KR |
1038 | |
1039 | name = input_line_pointer; | |
1040 | c = get_symbol_end (); | |
1041 | p = input_line_pointer; | |
1042 | *p = c; | |
1043 | SKIP_WHITESPACE (); | |
46b81190 ILT |
1044 | |
1045 | /* Accept an optional comma after the name. The comma used to be | |
1046 | required, but Irix 5 cc does not generate it. */ | |
1047 | if (*input_line_pointer == ',') | |
6efd877d | 1048 | { |
46b81190 ILT |
1049 | ++input_line_pointer; |
1050 | SKIP_WHITESPACE (); | |
6efd877d | 1051 | } |
f8701a3f | 1052 | |
6efd877d KR |
1053 | if (*input_line_pointer == '\n') |
1054 | { | |
1055 | as_bad ("Missing size expression"); | |
1056 | return; | |
1057 | } | |
f8701a3f | 1058 | |
6efd877d KR |
1059 | if ((temp = get_absolute_expression ()) < 0) |
1060 | { | |
1061 | as_warn ("BSS length (%d.) <0! Ignored.", temp); | |
1062 | ignore_rest_of_line (); | |
1063 | return; | |
1064 | } | |
f8701a3f | 1065 | |
9a7d824a | 1066 | #ifdef TC_MIPS |
efe8ef02 ILT |
1067 | #if defined (OBJ_ECOFF) || defined (OBJ_ELF) |
1068 | /* For MIPS ECOFF or ELF, small objects are put in .sbss. */ | |
9a7d824a | 1069 | if (temp <= bfd_get_gp_size (stdoutput)) |
46b81190 ILT |
1070 | { |
1071 | bss_seg = subseg_new (".sbss", 1); | |
1072 | seg_info (bss_seg)->bss = 1; | |
1073 | } | |
9a7d824a ILT |
1074 | #endif |
1075 | #endif | |
1076 | ||
6efd877d KR |
1077 | if (needs_align) |
1078 | { | |
1079 | align = 0; | |
1080 | SKIP_WHITESPACE (); | |
1081 | if (*input_line_pointer != ',') | |
1082 | { | |
1083 | as_bad ("Expected comma after size"); | |
1084 | ignore_rest_of_line (); | |
1085 | return; | |
1086 | } | |
1087 | input_line_pointer++; | |
1088 | SKIP_WHITESPACE (); | |
1089 | if (*input_line_pointer == '\n') | |
1090 | { | |
1091 | as_bad ("Missing alignment"); | |
1092 | return; | |
1093 | } | |
1094 | align = get_absolute_expression (); | |
1095 | if (align > max_alignment) | |
1096 | { | |
1097 | align = max_alignment; | |
1098 | as_warn ("Alignment too large: %d. assumed.", align); | |
1099 | } | |
1100 | else if (align < 0) | |
1101 | { | |
1102 | align = 0; | |
1103 | as_warn ("Alignment negative. 0 assumed."); | |
1104 | } | |
9a7d824a | 1105 | record_alignment (bss_seg, align); |
6efd877d | 1106 | } /* if needs align */ |
f8701a3f | 1107 | |
6efd877d KR |
1108 | *p = 0; |
1109 | symbolP = symbol_find_or_make (name); | |
1110 | *p = c; | |
f8701a3f | 1111 | |
6efd877d | 1112 | if ( |
fecd2382 | 1113 | #if defined(OBJ_AOUT) | defined(OBJ_BOUT) |
6efd877d KR |
1114 | S_GET_OTHER (symbolP) == 0 && |
1115 | S_GET_DESC (symbolP) == 0 && | |
fecd2382 | 1116 | #endif /* OBJ_AOUT or OBJ_BOUT */ |
9a7d824a | 1117 | (S_GET_SEGMENT (symbolP) == bss_seg |
6efd877d KR |
1118 | || (!S_IS_DEFINED (symbolP) && S_GET_VALUE (symbolP) == 0))) |
1119 | { | |
604633ae | 1120 | char *pfrag; |
85825401 | 1121 | |
9a7d824a | 1122 | subseg_set (bss_seg, 1); |
85825401 ILT |
1123 | |
1124 | if (align) | |
1125 | frag_align (align, 0); | |
1126 | /* detach from old frag */ | |
9a7d824a | 1127 | if (S_GET_SEGMENT (symbolP) == bss_seg) |
85825401 ILT |
1128 | symbolP->sy_frag->fr_symbol = NULL; |
1129 | ||
1130 | symbolP->sy_frag = frag_now; | |
604633ae ILT |
1131 | pfrag = frag_var (rs_org, 1, 1, (relax_substateT)0, symbolP, |
1132 | temp, (char *)0); | |
1133 | *pfrag = 0; | |
f8701a3f | 1134 | |
9a7d824a | 1135 | S_SET_SEGMENT (symbolP, bss_seg); |
85825401 | 1136 | |
fecd2382 | 1137 | #ifdef OBJ_COFF |
6efd877d | 1138 | /* The symbol may already have been created with a preceding |
c8863a58 KR |
1139 | ".globl" directive -- be careful not to step on storage class |
1140 | in that case. Otherwise, set it to static. */ | |
6efd877d KR |
1141 | if (S_GET_STORAGE_CLASS (symbolP) != C_EXT) |
1142 | { | |
1143 | S_SET_STORAGE_CLASS (symbolP, C_STAT); | |
fecd2382 | 1144 | } |
6efd877d | 1145 | #endif /* OBJ_COFF */ |
6efd877d KR |
1146 | } |
1147 | else | |
1148 | { | |
85825401 | 1149 | as_bad ("Ignoring attempt to re-define symbol %s.", name); |
6efd877d | 1150 | } |
f8701a3f | 1151 | |
9a7d824a | 1152 | subseg_set (current_seg, current_subseg); |
9a7d824a ILT |
1153 | |
1154 | demand_empty_rest_of_line (); | |
6efd877d | 1155 | } /* s_lcomm() */ |
fecd2382 | 1156 | |
6efd877d | 1157 | void |
604633ae ILT |
1158 | s_lsym (ignore) |
1159 | int ignore; | |
6efd877d KR |
1160 | { |
1161 | register char *name; | |
1162 | register char c; | |
1163 | register char *p; | |
6efd877d KR |
1164 | expressionS exp; |
1165 | register symbolS *symbolP; | |
1166 | ||
1167 | /* we permit ANY defined expression: BSD4.2 demands constants */ | |
1168 | name = input_line_pointer; | |
1169 | c = get_symbol_end (); | |
1170 | p = input_line_pointer; | |
1171 | *p = c; | |
1172 | SKIP_WHITESPACE (); | |
1173 | if (*input_line_pointer != ',') | |
1174 | { | |
1175 | *p = 0; | |
1176 | as_bad ("Expected comma after name \"%s\"", name); | |
1177 | *p = c; | |
1178 | ignore_rest_of_line (); | |
1179 | return; | |
1180 | } | |
1181 | input_line_pointer++; | |
b31f2abb KR |
1182 | expression (&exp); |
1183 | if (exp.X_op != O_constant | |
1184 | && exp.X_op != O_register) | |
1185 | { | |
1186 | as_bad ("bad expression"); | |
1187 | ignore_rest_of_line (); | |
1188 | return; | |
1189 | } | |
6efd877d KR |
1190 | *p = 0; |
1191 | symbolP = symbol_find_or_make (name); | |
f8701a3f | 1192 | |
c8863a58 KR |
1193 | /* FIXME-SOON I pulled a (&& symbolP->sy_other == 0 && |
1194 | symbolP->sy_desc == 0) out of this test because coff doesn't have | |
1195 | those fields, and I can't see when they'd ever be tripped. I | |
1196 | don't think I understand why they were here so I may have | |
1197 | introduced a bug. As recently as 1.37 didn't have this test | |
1198 | anyway. xoxorich. */ | |
f8701a3f | 1199 | |
9471a360 | 1200 | if (S_GET_SEGMENT (symbolP) == undefined_section |
6efd877d KR |
1201 | && S_GET_VALUE (symbolP) == 0) |
1202 | { | |
c8863a58 KR |
1203 | /* The name might be an undefined .global symbol; be sure to |
1204 | keep the "external" bit. */ | |
b31f2abb KR |
1205 | S_SET_SEGMENT (symbolP, |
1206 | (exp.X_op == O_constant | |
1207 | ? absolute_section | |
1208 | : reg_section)); | |
1209 | S_SET_VALUE (symbolP, (valueT) exp.X_add_number); | |
6efd877d KR |
1210 | } |
1211 | else | |
1212 | { | |
1213 | as_bad ("Symbol %s already defined", name); | |
1214 | } | |
1215 | *p = c; | |
1216 | demand_empty_rest_of_line (); | |
1217 | } /* s_lsym() */ | |
1218 | ||
1219 | void | |
604633ae ILT |
1220 | s_org (ignore) |
1221 | int ignore; | |
6efd877d KR |
1222 | { |
1223 | register segT segment; | |
1224 | expressionS exp; | |
1225 | register long temp_fill; | |
1226 | register char *p; | |
9471a360 KR |
1227 | /* Don't believe the documentation of BSD 4.2 AS. There is no such |
1228 | thing as a sub-segment-relative origin. Any absolute origin is | |
1229 | given a warning, then assumed to be segment-relative. Any | |
1230 | segmented origin expression ("foo+42") had better be in the right | |
1231 | segment or the .org is ignored. | |
1232 | ||
1233 | BSD 4.2 AS warns if you try to .org backwards. We cannot because | |
1234 | we never know sub-segment sizes when we are reading code. BSD | |
1235 | will crash trying to emit negative numbers of filler bytes in | |
1236 | certain .orgs. We don't crash, but see as-write for that code. | |
1237 | ||
1238 | Don't make frag if need_pass_2==1. */ | |
6efd877d KR |
1239 | segment = get_known_segmented_expression (&exp); |
1240 | if (*input_line_pointer == ',') | |
1241 | { | |
1242 | input_line_pointer++; | |
1243 | temp_fill = get_absolute_expression (); | |
1244 | } | |
1245 | else | |
1246 | temp_fill = 0; | |
1247 | if (!need_pass_2) | |
1248 | { | |
9471a360 | 1249 | if (segment != now_seg && segment != absolute_section) |
6efd877d KR |
1250 | as_bad ("Invalid segment \"%s\". Segment \"%s\" assumed.", |
1251 | segment_name (segment), segment_name (now_seg)); | |
1252 | p = frag_var (rs_org, 1, 1, (relax_substateT) 0, exp.X_add_symbol, | |
1253 | exp.X_add_number, (char *) 0); | |
1254 | *p = temp_fill; | |
1255 | } /* if (ok to make frag) */ | |
1256 | demand_empty_rest_of_line (); | |
1257 | } /* s_org() */ | |
1258 | ||
1259 | void | |
604633ae ILT |
1260 | s_set (ignore) |
1261 | int ignore; | |
6efd877d KR |
1262 | { |
1263 | register char *name; | |
1264 | register char delim; | |
1265 | register char *end_name; | |
1266 | register symbolS *symbolP; | |
1267 | ||
1268 | /* | |
c8863a58 KR |
1269 | * Especial apologies for the random logic: |
1270 | * this just grew, and could be parsed much more simply! | |
1271 | * Dean in haste. | |
1272 | */ | |
6efd877d KR |
1273 | name = input_line_pointer; |
1274 | delim = get_symbol_end (); | |
1275 | end_name = input_line_pointer; | |
1276 | *end_name = delim; | |
1277 | SKIP_WHITESPACE (); | |
f8701a3f | 1278 | |
6efd877d KR |
1279 | if (*input_line_pointer != ',') |
1280 | { | |
1281 | *end_name = 0; | |
1282 | as_bad ("Expected comma after name \"%s\"", name); | |
1283 | *end_name = delim; | |
1284 | ignore_rest_of_line (); | |
1285 | return; | |
1286 | } | |
1287 | ||
1288 | input_line_pointer++; | |
1289 | *end_name = 0; | |
1290 | ||
1291 | if (name[0] == '.' && name[1] == '\0') | |
1292 | { | |
1293 | /* Turn '. = mumble' into a .org mumble */ | |
1294 | register segT segment; | |
1295 | expressionS exp; | |
1296 | register char *ptr; | |
1297 | ||
1298 | segment = get_known_segmented_expression (&exp); | |
f8701a3f | 1299 | |
6efd877d KR |
1300 | if (!need_pass_2) |
1301 | { | |
9471a360 | 1302 | if (segment != now_seg && segment != absolute_section) |
6efd877d KR |
1303 | as_bad ("Invalid segment \"%s\". Segment \"%s\" assumed.", |
1304 | segment_name (segment), | |
1305 | segment_name (now_seg)); | |
1306 | ptr = frag_var (rs_org, 1, 1, (relax_substateT) 0, exp.X_add_symbol, | |
1307 | exp.X_add_number, (char *) 0); | |
1308 | *ptr = 0; | |
1309 | } /* if (ok to make frag) */ | |
1310 | ||
1311 | *end_name = delim; | |
1312 | return; | |
1313 | } | |
1314 | ||
1315 | if ((symbolP = symbol_find (name)) == NULL | |
1316 | && (symbolP = md_undefined_symbol (name)) == NULL) | |
1317 | { | |
9471a360 | 1318 | symbolP = symbol_new (name, undefined_section, 0, &zero_address_frag); |
fecd2382 | 1319 | #ifdef OBJ_COFF |
6efd877d KR |
1320 | /* "set" symbols are local unless otherwise specified. */ |
1321 | SF_SET_LOCAL (symbolP); | |
fecd2382 | 1322 | #endif /* OBJ_COFF */ |
f8701a3f | 1323 | |
6efd877d | 1324 | } /* make a new symbol */ |
f8701a3f | 1325 | |
6efd877d | 1326 | symbol_table_insert (symbolP); |
f8701a3f | 1327 | |
6efd877d KR |
1328 | *end_name = delim; |
1329 | pseudo_set (symbolP); | |
1330 | demand_empty_rest_of_line (); | |
1331 | } /* s_set() */ | |
fecd2382 | 1332 | |
6efd877d KR |
1333 | void |
1334 | s_space (mult) | |
1335 | int mult; | |
b53ccaac | 1336 | { |
6efd877d KR |
1337 | long temp_repeat; |
1338 | register long temp_fill; | |
1339 | register char *p; | |
1340 | ||
1341 | /* Just like .fill, but temp_size = 1 */ | |
1342 | if (get_absolute_expression_and_terminator (&temp_repeat) == ',') | |
1343 | { | |
1344 | temp_fill = get_absolute_expression (); | |
1345 | } | |
1346 | else | |
1347 | { | |
1348 | input_line_pointer--; /* Backup over what was not a ','. */ | |
1349 | temp_fill = 0; | |
1350 | } | |
1351 | if (mult) | |
1352 | { | |
bf449293 | 1353 | temp_repeat *= mult; |
6efd877d KR |
1354 | } |
1355 | if (temp_repeat <= 0) | |
1356 | { | |
1357 | as_warn ("Repeat < 0, .space ignored"); | |
1358 | ignore_rest_of_line (); | |
1359 | return; | |
1360 | } | |
1361 | if (!need_pass_2) | |
1362 | { | |
1363 | p = frag_var (rs_fill, 1, 1, (relax_substateT) 0, (symbolS *) 0, | |
1364 | temp_repeat, (char *) 0); | |
1365 | *p = temp_fill; | |
1366 | } | |
1367 | demand_empty_rest_of_line (); | |
1368 | } /* s_space() */ | |
fecd2382 RP |
1369 | |
1370 | void | |
604633ae ILT |
1371 | s_text (ignore) |
1372 | int ignore; | |
fecd2382 | 1373 | { |
6efd877d | 1374 | register int temp; |
f8701a3f | 1375 | |
6efd877d | 1376 | temp = get_absolute_expression (); |
9471a360 | 1377 | subseg_set (text_section, (subsegT) temp); |
6efd877d KR |
1378 | demand_empty_rest_of_line (); |
1379 | } /* s_text() */ | |
fecd2382 | 1380 | \f |
6efd877d | 1381 | |
6efd877d KR |
1382 | void |
1383 | demand_empty_rest_of_line () | |
1384 | { | |
1385 | SKIP_WHITESPACE (); | |
58d4951d | 1386 | if (is_end_of_line[(unsigned char) *input_line_pointer]) |
6efd877d KR |
1387 | { |
1388 | input_line_pointer++; | |
1389 | } | |
1390 | else | |
1391 | { | |
1392 | ignore_rest_of_line (); | |
1393 | } | |
1394 | /* Return having already swallowed end-of-line. */ | |
1395 | } /* Return pointing just after end-of-line. */ | |
fecd2382 RP |
1396 | |
1397 | void | |
6efd877d | 1398 | ignore_rest_of_line () /* For suspect lines: gives warning. */ |
fecd2382 | 1399 | { |
58d4951d | 1400 | if (!is_end_of_line[(unsigned char) *input_line_pointer]) |
f8701a3f | 1401 | { |
6efd877d KR |
1402 | if (isprint (*input_line_pointer)) |
1403 | as_bad ("Rest of line ignored. First ignored character is `%c'.", | |
f8701a3f SC |
1404 | *input_line_pointer); |
1405 | else | |
6efd877d | 1406 | as_bad ("Rest of line ignored. First ignored character valued 0x%x.", |
f8701a3f SC |
1407 | *input_line_pointer); |
1408 | while (input_line_pointer < buffer_limit | |
58d4951d | 1409 | && !is_end_of_line[(unsigned char) *input_line_pointer]) |
f8701a3f | 1410 | { |
6efd877d | 1411 | input_line_pointer++; |
f8701a3f SC |
1412 | } |
1413 | } | |
6efd877d | 1414 | input_line_pointer++; /* Return pointing just after end-of-line. */ |
58d4951d | 1415 | know (is_end_of_line[(unsigned char) input_line_pointer[-1]]); |
fecd2382 RP |
1416 | } |
1417 | ||
1418 | /* | |
1419 | * pseudo_set() | |
1420 | * | |
1421 | * In: Pointer to a symbol. | |
1422 | * Input_line_pointer->expression. | |
1423 | * | |
1424 | * Out: Input_line_pointer->just after any whitespace after expression. | |
1425 | * Tried to set symbol to value of expression. | |
1426 | * Will change symbols type, value, and frag; | |
fecd2382 RP |
1427 | */ |
1428 | void | |
f8701a3f | 1429 | pseudo_set (symbolP) |
6efd877d | 1430 | symbolS *symbolP; |
fecd2382 | 1431 | { |
6efd877d | 1432 | expressionS exp; |
fecd2382 | 1433 | #if defined(OBJ_AOUT) | defined(OBJ_BOUT) |
f8701a3f | 1434 | int ext; |
fecd2382 | 1435 | #endif /* OBJ_AOUT or OBJ_BOUT */ |
f8701a3f | 1436 | |
6efd877d | 1437 | know (symbolP); /* NULL pointer is logic error. */ |
fecd2382 | 1438 | #if defined(OBJ_AOUT) | defined(OBJ_BOUT) |
9471a360 | 1439 | /* @@ Fix this right for BFD. */ |
6efd877d | 1440 | ext = S_IS_EXTERNAL (symbolP); |
fecd2382 | 1441 | #endif /* OBJ_AOUT or OBJ_BOUT */ |
f8701a3f | 1442 | |
5ac34ac3 | 1443 | (void) expression (&exp); |
f8701a3f | 1444 | |
5ac34ac3 ILT |
1445 | if (exp.X_op == O_illegal) |
1446 | as_bad ("illegal expression; zero assumed"); | |
1447 | else if (exp.X_op == O_absent) | |
1448 | as_bad ("missing expression; zero assumed"); | |
1449 | else if (exp.X_op == O_big) | |
1450 | as_bad ("%s number invalid; zero assumed", | |
1451 | exp.X_add_number > 0 ? "bignum" : "floating point"); | |
1452 | else if (exp.X_op == O_subtract | |
1453 | && (S_GET_SEGMENT (exp.X_add_symbol) | |
1454 | == S_GET_SEGMENT (exp.X_op_symbol)) | |
1455 | && SEG_NORMAL (S_GET_SEGMENT (exp.X_add_symbol)) | |
1456 | && exp.X_add_symbol->sy_frag == exp.X_op_symbol->sy_frag) | |
9471a360 | 1457 | { |
5ac34ac3 ILT |
1458 | exp.X_op = O_constant; |
1459 | exp.X_add_number = (S_GET_VALUE (exp.X_add_symbol) | |
1460 | - S_GET_VALUE (exp.X_op_symbol)); | |
9471a360 | 1461 | } |
5ac34ac3 ILT |
1462 | |
1463 | switch (exp.X_op) | |
9471a360 | 1464 | { |
5ac34ac3 ILT |
1465 | case O_illegal: |
1466 | case O_absent: | |
1467 | case O_big: | |
1468 | exp.X_add_number = 0; | |
1469 | /* Fall through. */ | |
1470 | case O_constant: | |
9471a360 | 1471 | S_SET_SEGMENT (symbolP, absolute_section); |
fecd2382 | 1472 | #if defined(OBJ_AOUT) | defined(OBJ_BOUT) |
9471a360 | 1473 | /* @@ Fix this right for BFD. */ |
5ac34ac3 ILT |
1474 | if (ext) |
1475 | S_SET_EXTERNAL (symbolP); | |
6efd877d | 1476 | else |
6efd877d | 1477 | S_CLEAR_EXTERNAL (symbolP); |
fecd2382 | 1478 | #endif /* OBJ_AOUT or OBJ_BOUT */ |
604633ae | 1479 | S_SET_VALUE (symbolP, (valueT) exp.X_add_number); |
6efd877d | 1480 | symbolP->sy_frag = &zero_address_frag; |
5ac34ac3 | 1481 | break; |
f8701a3f | 1482 | |
5ac34ac3 ILT |
1483 | case O_register: |
1484 | S_SET_SEGMENT (symbolP, reg_section); | |
604633ae | 1485 | S_SET_VALUE (symbolP, (valueT) exp.X_add_number); |
5ac34ac3 ILT |
1486 | symbolP->sy_frag = &zero_address_frag; |
1487 | break; | |
1488 | ||
1489 | case O_symbol: | |
1490 | if (S_GET_SEGMENT (exp.X_add_symbol) == undefined_section) | |
1491 | symbolP->sy_value = exp; | |
6efd877d KR |
1492 | else |
1493 | { | |
5ac34ac3 ILT |
1494 | S_SET_SEGMENT (symbolP, S_GET_SEGMENT (exp.X_add_symbol)); |
1495 | #if defined(OBJ_AOUT) | defined(OBJ_BOUT) | |
1496 | /* @@ Fix this right for BFD! */ | |
1497 | if (ext) | |
1498 | S_SET_EXTERNAL (symbolP); | |
1499 | else | |
1500 | S_CLEAR_EXTERNAL (symbolP); | |
fecd2382 | 1501 | #endif /* OBJ_AOUT or OBJ_BOUT */ |
5ac34ac3 ILT |
1502 | S_SET_VALUE (symbolP, |
1503 | exp.X_add_number + S_GET_VALUE (exp.X_add_symbol)); | |
1504 | symbolP->sy_frag = exp.X_add_symbol->sy_frag; | |
1505 | } | |
1506 | break; | |
f8701a3f | 1507 | |
5ac34ac3 ILT |
1508 | default: |
1509 | /* The value is some complex expression. | |
1510 | FIXME: Should we set the segment to anything? */ | |
1511 | symbolP->sy_value = exp; | |
1512 | break; | |
f8701a3f | 1513 | } |
fecd2382 RP |
1514 | } |
1515 | \f | |
1516 | /* | |
1517 | * cons() | |
1518 | * | |
1519 | * CONStruct more frag of .bytes, or .words etc. | |
1520 | * Should need_pass_2 be 1 then emit no frag(s). | |
80aab579 | 1521 | * This understands EXPRESSIONS. |
fecd2382 RP |
1522 | * |
1523 | * Bug (?) | |
1524 | * | |
1525 | * This has a split personality. We use expression() to read the | |
1526 | * value. We can detect if the value won't fit in a byte or word. | |
1527 | * But we can't detect if expression() discarded significant digits | |
1528 | * in the case of a long. Not worth the crocks required to fix it. | |
1529 | */ | |
1530 | ||
40324362 KR |
1531 | /* Select a parser for cons expressions. */ |
1532 | ||
1533 | /* Some targets need to parse the expression in various fancy ways. | |
1534 | You can define TC_PARSE_CONS_EXPRESSION to do whatever you like | |
1535 | (for example, the HPPA does this). Otherwise, you can define | |
1536 | BITFIELD_CONS_EXPRESSIONS to permit bitfields to be specified, or | |
1537 | REPEAT_CONS_EXPRESSIONS to permit repeat counts. If none of these | |
1538 | are defined, which is the normal case, then only simple expressions | |
1539 | are permitted. */ | |
1540 | ||
1541 | #ifndef TC_PARSE_CONS_EXPRESSION | |
1542 | #ifdef BITFIELD_CONS_EXPRESSIONS | |
1543 | #define TC_PARSE_CONS_EXPRESSION(EXP, NBYTES) parse_bitfield_cons (EXP, NBYTES) | |
1544 | static void | |
1545 | parse_bitfield_cons PARAMS ((expressionS *exp, unsigned int nbytes)); | |
1546 | #endif | |
1547 | #ifdef MRI | |
1548 | #define TC_PARSE_CONS_EXPRESSION(EXP, NBYTES) parse_mri_cons (EXP) | |
1549 | static void | |
1550 | parse_mri_cons PARAMS ((expressionS *exp)); | |
1551 | #endif | |
1552 | #ifdef REPEAT_CONS_EXPRESSIONS | |
1553 | #define TC_PARSE_CONS_EXPRESSION(EXP, NBYTES) parse_repeat_cons (EXP, NBYTES) | |
1554 | static void | |
1555 | parse_repeat_cons PARAMS ((expressionS *exp, unsigned int nbytes)); | |
1556 | #endif | |
1557 | ||
1558 | /* If we haven't gotten one yet, just call expression. */ | |
1559 | #ifndef TC_PARSE_CONS_EXPRESSION | |
1560 | #define TC_PARSE_CONS_EXPRESSION(EXP, NBYTES) expression (EXP) | |
1561 | #endif | |
1562 | #endif | |
1563 | ||
6efd877d KR |
1564 | /* worker to do .byte etc statements */ |
1565 | /* clobbers input_line_pointer, checks */ | |
1566 | /* end-of-line. */ | |
1567 | void | |
1568 | cons (nbytes) | |
604633ae | 1569 | register int nbytes; /* 1=.byte, 2=.word, 4=.long */ |
fecd2382 | 1570 | { |
6efd877d | 1571 | expressionS exp; |
f8701a3f | 1572 | |
40324362 | 1573 | if (is_it_end_of_statement ()) |
6efd877d | 1574 | { |
40324362 KR |
1575 | demand_empty_rest_of_line (); |
1576 | return; | |
6efd877d | 1577 | } |
40324362 KR |
1578 | |
1579 | do | |
6efd877d | 1580 | { |
604633ae ILT |
1581 | TC_PARSE_CONS_EXPRESSION (&exp, (unsigned int) nbytes); |
1582 | emit_expr (&exp, (unsigned int) nbytes); | |
40324362 KR |
1583 | } |
1584 | while (*input_line_pointer++ == ','); | |
1585 | ||
1586 | input_line_pointer--; /* Put terminator back into stream. */ | |
1587 | demand_empty_rest_of_line (); | |
30d3a445 | 1588 | } |
f8701a3f | 1589 | |
40324362 KR |
1590 | /* Put the contents of expression EXP into the object file using |
1591 | NBYTES bytes. If need_pass_2 is 1, this does nothing. */ | |
f8701a3f | 1592 | |
40324362 KR |
1593 | void |
1594 | emit_expr (exp, nbytes) | |
1595 | expressionS *exp; | |
1596 | unsigned int nbytes; | |
1597 | { | |
5ac34ac3 | 1598 | operatorT op; |
40324362 | 1599 | register char *p; |
80aab579 | 1600 | valueT extra_digit = 0; |
f8701a3f | 1601 | |
40324362 KR |
1602 | /* Don't do anything if we are going to make another pass. */ |
1603 | if (need_pass_2) | |
1604 | return; | |
1605 | ||
5ac34ac3 | 1606 | op = exp->X_op; |
40324362 | 1607 | |
80aab579 ILT |
1608 | /* Handle a negative bignum. */ |
1609 | if (op == O_uminus | |
1610 | && exp->X_add_number == 0 | |
1611 | && exp->X_add_symbol->sy_value.X_op == O_big | |
1612 | && exp->X_add_symbol->sy_value.X_add_number > 0) | |
1613 | { | |
1614 | int i; | |
1615 | unsigned long carry; | |
1616 | ||
1617 | exp = &exp->X_add_symbol->sy_value; | |
1618 | ||
1619 | /* Negate the bignum: one's complement each digit and add 1. */ | |
1620 | carry = 1; | |
1621 | for (i = 0; i < exp->X_add_number; i++) | |
1622 | { | |
1623 | unsigned long next; | |
1624 | ||
1625 | next = (((~ (generic_bignum[i] & LITTLENUM_MASK)) | |
1626 | & LITTLENUM_MASK) | |
1627 | + carry); | |
1628 | generic_bignum[i] = next & LITTLENUM_MASK; | |
1629 | carry = next >> LITTLENUM_NUMBER_OF_BITS; | |
1630 | } | |
1631 | ||
1632 | /* We can ignore any carry out, because it will be handled by | |
1633 | extra_digit if it is needed. */ | |
1634 | ||
1635 | extra_digit = (valueT) -1; | |
1636 | op = O_big; | |
1637 | } | |
1638 | ||
5ac34ac3 | 1639 | if (op == O_absent || op == O_illegal) |
6efd877d | 1640 | { |
5ac34ac3 ILT |
1641 | as_warn ("zero assumed for missing expression"); |
1642 | exp->X_add_number = 0; | |
1643 | op = O_constant; | |
6efd877d | 1644 | } |
80aab579 | 1645 | else if (op == O_big && exp->X_add_number <= 0) |
6efd877d | 1646 | { |
80aab579 | 1647 | as_bad ("floating point number invalid; zero assumed"); |
40324362 | 1648 | exp->X_add_number = 0; |
5ac34ac3 | 1649 | op = O_constant; |
40324362 | 1650 | } |
5ac34ac3 | 1651 | else if (op == O_register) |
6efd877d | 1652 | { |
5ac34ac3 ILT |
1653 | as_warn ("register value used as expression"); |
1654 | op = O_constant; | |
40324362 | 1655 | } |
6efd877d | 1656 | |
604633ae | 1657 | p = frag_more ((int) nbytes); |
6efd877d | 1658 | |
40324362 KR |
1659 | #ifndef WORKING_DOT_WORD |
1660 | /* If we have the difference of two symbols in a word, save it on | |
1661 | the broken_words list. See the code in write.c. */ | |
5ac34ac3 | 1662 | if (op == O_subtract && nbytes == 2) |
40324362 KR |
1663 | { |
1664 | struct broken_word *x; | |
1665 | ||
1666 | x = (struct broken_word *) xmalloc (sizeof (struct broken_word)); | |
1667 | x->next_broken_word = broken_words; | |
1668 | broken_words = x; | |
1669 | x->frag = frag_now; | |
1670 | x->word_goes_here = p; | |
1671 | x->dispfrag = 0; | |
1672 | x->add = exp->X_add_symbol; | |
5ac34ac3 | 1673 | x->sub = exp->X_op_symbol; |
40324362 KR |
1674 | x->addnum = exp->X_add_number; |
1675 | x->added = 0; | |
1676 | new_broken_words++; | |
1677 | return; | |
1678 | } | |
f8701a3f | 1679 | #endif |
6efd877d | 1680 | |
80aab579 ILT |
1681 | /* If we have an integer, but the number of bytes is too large to |
1682 | pass to md_number_to_chars, handle it as a bignum. */ | |
1683 | if (op == O_constant && nbytes > sizeof (valueT)) | |
1684 | { | |
1685 | valueT val; | |
1686 | int gencnt; | |
1687 | ||
1688 | if (! exp->X_unsigned && exp->X_add_number < 0) | |
1689 | extra_digit = (valueT) -1; | |
1690 | val = (valueT) exp->X_add_number; | |
1691 | gencnt = 0; | |
1692 | do | |
1693 | { | |
1694 | generic_bignum[gencnt] = val & LITTLENUM_MASK; | |
1695 | val >>= LITTLENUM_NUMBER_OF_BITS; | |
1696 | ++gencnt; | |
1697 | } | |
1698 | while (val != 0); | |
1699 | op = exp->X_op = O_big; | |
1700 | exp->X_add_number = gencnt; | |
1701 | } | |
1702 | ||
5ac34ac3 | 1703 | if (op == O_constant) |
40324362 | 1704 | { |
44ce2f32 DE |
1705 | register valueT get; |
1706 | register valueT use; | |
1707 | register valueT mask; | |
1708 | register valueT unmask; | |
40324362 KR |
1709 | |
1710 | /* JF << of >= number of bits in the object is undefined. In | |
1711 | particular SPARC (Sun 4) has problems */ | |
44ce2f32 | 1712 | if (nbytes >= sizeof (valueT)) |
40324362 KR |
1713 | mask = 0; |
1714 | else | |
d2550c72 | 1715 | mask = ~(valueT) 0 << (BITS_PER_CHAR * nbytes); /* Don't store these bits. */ |
6efd877d | 1716 | |
40324362 | 1717 | unmask = ~mask; /* Do store these bits. */ |
6efd877d | 1718 | |
40324362 KR |
1719 | #ifdef NEVER |
1720 | "Do this mod if you want every overflow check to assume SIGNED 2's complement data."; | |
1721 | mask = ~(unmask >> 1); /* Includes sign bit now. */ | |
1722 | #endif | |
6efd877d | 1723 | |
40324362 KR |
1724 | get = exp->X_add_number; |
1725 | use = get & unmask; | |
1726 | if ((get & mask) != 0 && (get & mask) != mask) | |
1727 | { /* Leading bits contain both 0s & 1s. */ | |
58d4951d | 1728 | as_warn ("Value 0x%lx truncated to 0x%lx.", get, use); |
40324362 | 1729 | } |
604633ae | 1730 | /* put bytes in right order. */ |
44ce2f32 | 1731 | md_number_to_chars (p, use, (int) nbytes); |
40324362 | 1732 | } |
80aab579 ILT |
1733 | else if (op == O_big) |
1734 | { | |
1735 | int size; | |
1736 | LITTLENUM_TYPE *nums; | |
1737 | ||
1738 | know (nbytes % CHARS_PER_LITTLENUM == 0); | |
1739 | ||
1740 | size = exp->X_add_number * CHARS_PER_LITTLENUM; | |
1741 | if (nbytes < size) | |
1742 | { | |
1743 | as_warn ("Bignum truncated to %d bytes", nbytes); | |
1744 | size = nbytes; | |
1745 | } | |
1746 | ||
1747 | if (target_big_endian) | |
1748 | { | |
1749 | while (nbytes > size) | |
1750 | { | |
1751 | md_number_to_chars (p, extra_digit, CHARS_PER_LITTLENUM); | |
1752 | nbytes -= CHARS_PER_LITTLENUM; | |
1753 | p += CHARS_PER_LITTLENUM; | |
1754 | } | |
1755 | ||
1756 | nums = generic_bignum + size / CHARS_PER_LITTLENUM; | |
1757 | while (size > 0) | |
1758 | { | |
1759 | --nums; | |
1760 | md_number_to_chars (p, (valueT) *nums, CHARS_PER_LITTLENUM); | |
1761 | size -= CHARS_PER_LITTLENUM; | |
1762 | p += CHARS_PER_LITTLENUM; | |
1763 | } | |
1764 | } | |
1765 | else | |
1766 | { | |
1767 | nums = generic_bignum; | |
1768 | while (size > 0) | |
1769 | { | |
1770 | md_number_to_chars (p, (valueT) *nums, CHARS_PER_LITTLENUM); | |
1771 | ++nums; | |
1772 | size -= CHARS_PER_LITTLENUM; | |
1773 | p += CHARS_PER_LITTLENUM; | |
1774 | nbytes -= CHARS_PER_LITTLENUM; | |
1775 | } | |
1776 | ||
1777 | while (nbytes > 0) | |
1778 | { | |
1779 | md_number_to_chars (p, extra_digit, CHARS_PER_LITTLENUM); | |
1780 | nbytes -= CHARS_PER_LITTLENUM; | |
1781 | p += CHARS_PER_LITTLENUM; | |
1782 | } | |
1783 | } | |
1784 | } | |
40324362 KR |
1785 | else |
1786 | { | |
604633ae | 1787 | md_number_to_chars (p, (valueT) 0, (int) nbytes); |
6efd877d | 1788 | |
40324362 KR |
1789 | /* Now we need to generate a fixS to record the symbol value. |
1790 | This is easy for BFD. For other targets it can be more | |
1791 | complex. For very complex cases (currently, the HPPA and | |
1792 | NS32K), you can define TC_CONS_FIX_NEW to do whatever you | |
1793 | want. For simpler cases, you can define TC_CONS_RELOC to be | |
1794 | the name of the reloc code that should be stored in the fixS. | |
1795 | If neither is defined, the code uses NO_RELOC if it is | |
1796 | defined, and otherwise uses 0. */ | |
6efd877d | 1797 | |
40324362 | 1798 | #ifdef BFD_ASSEMBLER |
4064305e SS |
1799 | #ifdef TC_CONS_FIX_NEW |
1800 | TC_CONS_FIX_NEW (frag_now, p - frag_now->fr_literal, nbytes, exp); | |
1801 | #else | |
604633ae | 1802 | fix_new_exp (frag_now, p - frag_now->fr_literal, (int) nbytes, exp, 0, |
5ac34ac3 | 1803 | /* @@ Should look at CPU word size. */ |
ba71c54d KR |
1804 | nbytes == 2 ? BFD_RELOC_16 |
1805 | : nbytes == 8 ? BFD_RELOC_64 | |
1806 | : BFD_RELOC_32); | |
4064305e | 1807 | #endif |
40324362 KR |
1808 | #else |
1809 | #ifdef TC_CONS_FIX_NEW | |
1810 | TC_CONS_FIX_NEW (frag_now, p - frag_now->fr_literal, nbytes, exp); | |
1811 | #else | |
1812 | /* Figure out which reloc number to use. Use TC_CONS_RELOC if | |
1813 | it is defined, otherwise use NO_RELOC if it is defined, | |
1814 | otherwise use 0. */ | |
1815 | #ifndef TC_CONS_RELOC | |
1816 | #ifdef NO_RELOC | |
1817 | #define TC_CONS_RELOC NO_RELOC | |
1818 | #else | |
1819 | #define TC_CONS_RELOC 0 | |
1820 | #endif | |
1821 | #endif | |
80aab579 | 1822 | fix_new_exp (frag_now, p - frag_now->fr_literal, (int) nbytes, exp, 0, |
5ac34ac3 | 1823 | TC_CONS_RELOC); |
40324362 KR |
1824 | #endif /* TC_CONS_FIX_NEW */ |
1825 | #endif /* BFD_ASSEMBLER */ | |
1826 | } | |
1827 | } | |
1828 | \f | |
1829 | #ifdef BITFIELD_CONS_EXPRESSIONS | |
6efd877d | 1830 | |
40324362 KR |
1831 | /* i960 assemblers, (eg, asm960), allow bitfields after ".byte" as |
1832 | w:x,y:z, where w and y are bitwidths and x and y are values. They | |
1833 | then pack them all together. We do a little better in that we allow | |
1834 | them in words, longs, etc. and we'll pack them in target byte order | |
1835 | for you. | |
6efd877d | 1836 | |
40324362 KR |
1837 | The rules are: pack least significat bit first, if a field doesn't |
1838 | entirely fit, put it in the next unit. Overflowing the bitfield is | |
1839 | explicitly *not* even a warning. The bitwidth should be considered | |
1840 | a "mask". | |
6efd877d | 1841 | |
40324362 KR |
1842 | To use this function the tc-XXX.h file should define |
1843 | BITFIELD_CONS_EXPRESSIONS. */ | |
f8701a3f | 1844 | |
40324362 KR |
1845 | static void |
1846 | parse_bitfield_cons (exp, nbytes) | |
1847 | expressionS *exp; | |
1848 | unsigned int nbytes; | |
1849 | { | |
1850 | unsigned int bits_available = BITS_PER_CHAR * nbytes; | |
1851 | char *hold = input_line_pointer; | |
f8701a3f | 1852 | |
5ac34ac3 | 1853 | (void) expression (exp); |
f8701a3f | 1854 | |
40324362 KR |
1855 | if (*input_line_pointer == ':') |
1856 | { /* bitfields */ | |
1857 | long value = 0; | |
f8701a3f | 1858 | |
40324362 KR |
1859 | for (;;) |
1860 | { | |
1861 | unsigned long width; | |
f8701a3f | 1862 | |
40324362 KR |
1863 | if (*input_line_pointer != ':') |
1864 | { | |
1865 | input_line_pointer = hold; | |
1866 | break; | |
1867 | } /* next piece is not a bitfield */ | |
1868 | ||
1869 | /* In the general case, we can't allow | |
1870 | full expressions with symbol | |
1871 | differences and such. The relocation | |
1872 | entries for symbols not defined in this | |
1873 | assembly would require arbitrary field | |
1874 | widths, positions, and masks which most | |
1875 | of our current object formats don't | |
1876 | support. | |
1877 | ||
1878 | In the specific case where a symbol | |
1879 | *is* defined in this assembly, we | |
1880 | *could* build fixups and track it, but | |
1881 | this could lead to confusion for the | |
1882 | backends. I'm lazy. I'll take any | |
1883 | SEG_ABSOLUTE. I think that means that | |
1884 | you can use a previous .set or | |
1885 | .equ type symbol. xoxorich. */ | |
1886 | ||
5ac34ac3 | 1887 | if (exp->X_op == O_absent) |
6efd877d | 1888 | { |
5ac34ac3 | 1889 | as_warn ("using a bit field width of zero"); |
40324362 | 1890 | exp->X_add_number = 0; |
5ac34ac3 | 1891 | exp->X_op = O_constant; |
40324362 KR |
1892 | } /* implied zero width bitfield */ |
1893 | ||
5ac34ac3 | 1894 | if (exp->X_op != O_constant) |
6efd877d | 1895 | { |
40324362 | 1896 | *input_line_pointer = '\0'; |
5ac34ac3 | 1897 | as_bad ("field width \"%s\" too complex for a bitfield", hold); |
40324362 KR |
1898 | *input_line_pointer = ':'; |
1899 | demand_empty_rest_of_line (); | |
1900 | return; | |
1901 | } /* too complex */ | |
1902 | ||
1903 | if ((width = exp->X_add_number) > (BITS_PER_CHAR * nbytes)) | |
9471a360 | 1904 | { |
80aab579 | 1905 | as_warn ("field width %lu too big to fit in %d bytes: truncated to %d bits", |
40324362 KR |
1906 | width, nbytes, (BITS_PER_CHAR * nbytes)); |
1907 | width = BITS_PER_CHAR * nbytes; | |
1908 | } /* too big */ | |
1909 | ||
1910 | if (width > bits_available) | |
9471a360 | 1911 | { |
40324362 KR |
1912 | /* FIXME-SOMEDAY: backing up and reparsing is wasteful. */ |
1913 | input_line_pointer = hold; | |
1914 | exp->X_add_number = value; | |
1915 | break; | |
1916 | } /* won't fit */ | |
1917 | ||
1918 | hold = ++input_line_pointer; /* skip ':' */ | |
1919 | ||
5ac34ac3 ILT |
1920 | (void) expression (exp); |
1921 | if (exp->X_op != O_constant) | |
9471a360 | 1922 | { |
40324362 KR |
1923 | char cache = *input_line_pointer; |
1924 | ||
1925 | *input_line_pointer = '\0'; | |
5ac34ac3 | 1926 | as_bad ("field value \"%s\" too complex for a bitfield", hold); |
40324362 KR |
1927 | *input_line_pointer = cache; |
1928 | demand_empty_rest_of_line (); | |
1929 | return; | |
1930 | } /* too complex */ | |
1931 | ||
5ac34ac3 ILT |
1932 | value |= ((~(-1 << width) & exp->X_add_number) |
1933 | << ((BITS_PER_CHAR * nbytes) - bits_available)); | |
40324362 KR |
1934 | |
1935 | if ((bits_available -= width) == 0 | |
1936 | || is_it_end_of_statement () | |
1937 | || *input_line_pointer != ',') | |
1938 | { | |
1939 | break; | |
1940 | } /* all the bitfields we're gonna get */ | |
1941 | ||
1942 | hold = ++input_line_pointer; | |
5ac34ac3 | 1943 | (void) expression (exp); |
40324362 KR |
1944 | } /* forever loop */ |
1945 | ||
1946 | exp->X_add_number = value; | |
5ac34ac3 | 1947 | exp->X_op = O_constant; |
80aab579 | 1948 | exp->X_unsigned = 1; |
40324362 KR |
1949 | } /* if looks like a bitfield */ |
1950 | } /* parse_bitfield_cons() */ | |
1951 | ||
1952 | #endif /* BITFIELD_CONS_EXPRESSIONS */ | |
1953 | \f | |
1954 | #ifdef MRI | |
1955 | ||
1956 | static void | |
1957 | parse_mri_cons (exp, nbytes) | |
1958 | expressionS *exp; | |
1959 | unsigned int nbytes; | |
1960 | { | |
1961 | if (*input_line_pointer == '\'') | |
1962 | { | |
1963 | /* An MRI style string, cut into as many bytes as will fit into | |
1964 | a nbyte chunk, left justify if necessary, and separate with | |
1965 | commas so we can try again later */ | |
1966 | int scan = 0; | |
1967 | unsigned int result = 0; | |
1968 | input_line_pointer++; | |
1969 | for (scan = 0; scan < nbytes; scan++) | |
1970 | { | |
1971 | if (*input_line_pointer == '\'') | |
1972 | { | |
1973 | if (input_line_pointer[1] == '\'') | |
6efd877d | 1974 | { |
40324362 | 1975 | input_line_pointer++; |
f8701a3f | 1976 | } |
40324362 KR |
1977 | else |
1978 | break; | |
9471a360 | 1979 | } |
40324362 KR |
1980 | result = (result << 8) | (*input_line_pointer++); |
1981 | } | |
f8701a3f | 1982 | |
40324362 KR |
1983 | /* Left justify */ |
1984 | while (scan < nbytes) | |
1985 | { | |
1986 | result <<= 8; | |
1987 | scan++; | |
1988 | } | |
1989 | /* Create correct expression */ | |
5ac34ac3 | 1990 | exp->X_op = O_constant; |
40324362 | 1991 | exp->X_add_number = result; |
40324362 KR |
1992 | /* Fake it so that we can read the next char too */ |
1993 | if (input_line_pointer[0] != '\'' || | |
1994 | (input_line_pointer[0] == '\'' && input_line_pointer[1] == '\'')) | |
1995 | { | |
1996 | input_line_pointer -= 2; | |
1997 | input_line_pointer[0] = ','; | |
1998 | input_line_pointer[1] = '\''; | |
1999 | } | |
2000 | else | |
2001 | input_line_pointer++; | |
2002 | } | |
2003 | else | |
2004 | expression (&exp); | |
2005 | } | |
2006 | ||
2007 | #endif /* MRI */ | |
2008 | \f | |
2009 | #ifdef REPEAT_CONS_EXPRESSIONS | |
2010 | ||
2011 | /* Parse a repeat expression for cons. This is used by the MIPS | |
2012 | assembler. The format is NUMBER:COUNT; NUMBER appears in the | |
2013 | object file COUNT times. | |
2014 | ||
2015 | To use this for a target, define REPEAT_CONS_EXPRESSIONS. */ | |
2016 | ||
2017 | static void | |
2018 | parse_repeat_cons (exp, nbytes) | |
2019 | expressionS *exp; | |
2020 | unsigned int nbytes; | |
2021 | { | |
2022 | expressionS count; | |
40324362 KR |
2023 | register int i; |
2024 | ||
2025 | expression (exp); | |
2026 | ||
2027 | if (*input_line_pointer != ':') | |
2028 | { | |
2029 | /* No repeat count. */ | |
2030 | return; | |
2031 | } | |
2032 | ||
2033 | ++input_line_pointer; | |
5ac34ac3 ILT |
2034 | expression (&count); |
2035 | if (count.X_op != O_constant | |
40324362 KR |
2036 | || count.X_add_number <= 0) |
2037 | { | |
2038 | as_warn ("Unresolvable or nonpositive repeat count; using 1"); | |
2039 | return; | |
2040 | } | |
2041 | ||
2042 | /* The cons function is going to output this expression once. So we | |
2043 | output it count - 1 times. */ | |
2044 | for (i = count.X_add_number - 1; i > 0; i--) | |
2045 | emit_expr (exp, nbytes); | |
2046 | } | |
2047 | ||
2048 | #endif /* REPEAT_CONS_EXPRESSIONS */ | |
fecd2382 | 2049 | \f |
fecd2382 RP |
2050 | /* |
2051 | * float_cons() | |
2052 | * | |
2053 | * CONStruct some more frag chars of .floats .ffloats etc. | |
2054 | * Makes 0 or more new frags. | |
2055 | * If need_pass_2 == 1, no frags are emitted. | |
2056 | * This understands only floating literals, not expressions. Sorry. | |
2057 | * | |
2058 | * A floating constant is defined by atof_generic(), except it is preceded | |
2059 | * by 0d 0f 0g or 0h. After observing the STRANGE way my BSD AS does its | |
2060 | * reading, I decided to be incompatible. This always tries to give you | |
2061 | * rounded bits to the precision of the pseudo-op. Former AS did premature | |
2062 | * truncatation, restored noisy bits instead of trailing 0s AND gave you | |
2063 | * a choice of 2 flavours of noise according to which of 2 floating-point | |
2064 | * scanners you directed AS to use. | |
2065 | * | |
2066 | * In: input_line_pointer->whitespace before, or '0' of flonum. | |
2067 | * | |
2068 | */ | |
2069 | ||
ba71c54d KR |
2070 | void |
2071 | float_cons (float_type) | |
6efd877d | 2072 | /* Clobbers input_line-pointer, checks end-of-line. */ |
f8701a3f | 2073 | register int float_type; /* 'f':.ffloat ... 'F':.float ... */ |
fecd2382 | 2074 | { |
6efd877d | 2075 | register char *p; |
6efd877d KR |
2076 | int length; /* Number of chars in an object. */ |
2077 | register char *err; /* Error from scanning floating literal. */ | |
2078 | char temp[MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT]; | |
f8701a3f | 2079 | |
6efd877d | 2080 | if (is_it_end_of_statement ()) |
f8701a3f | 2081 | { |
1e9cf565 ILT |
2082 | demand_empty_rest_of_line (); |
2083 | return; | |
f8701a3f | 2084 | } |
1e9cf565 ILT |
2085 | |
2086 | do | |
f8701a3f SC |
2087 | { |
2088 | /* input_line_pointer->1st char of a flonum (we hope!). */ | |
6efd877d | 2089 | SKIP_WHITESPACE (); |
1e9cf565 | 2090 | |
f8701a3f SC |
2091 | /* Skip any 0{letter} that may be present. Don't even check if the |
2092 | * letter is legal. Someone may invent a "z" format and this routine | |
2093 | * has no use for such information. Lusers beware: you get | |
2094 | * diagnostics if your input is ill-conditioned. | |
2095 | */ | |
6efd877d KR |
2096 | if (input_line_pointer[0] == '0' && isalpha (input_line_pointer[1])) |
2097 | input_line_pointer += 2; | |
f8701a3f SC |
2098 | |
2099 | err = md_atof (float_type, temp, &length); | |
6efd877d KR |
2100 | know (length <= MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT); |
2101 | know (length > 0); | |
80aab579 | 2102 | if (err) |
f8701a3f | 2103 | { |
6efd877d KR |
2104 | as_bad ("Bad floating literal: %s", err); |
2105 | ignore_rest_of_line (); | |
1e9cf565 | 2106 | return; |
f8701a3f | 2107 | } |
1e9cf565 ILT |
2108 | |
2109 | if (!need_pass_2) | |
f8701a3f | 2110 | { |
1e9cf565 ILT |
2111 | int count; |
2112 | ||
2113 | count = 1; | |
2114 | ||
2115 | #ifdef REPEAT_CONS_EXPRESSIONS | |
2116 | if (*input_line_pointer == ':') | |
2117 | { | |
1e9cf565 ILT |
2118 | expressionS count_exp; |
2119 | ||
2120 | ++input_line_pointer; | |
5ac34ac3 ILT |
2121 | expression (&count_exp); |
2122 | if (count_exp.X_op != O_constant | |
1e9cf565 ILT |
2123 | || count_exp.X_add_number <= 0) |
2124 | { | |
5ac34ac3 | 2125 | as_warn ("unresolvable or nonpositive repeat count; using 1"); |
1e9cf565 ILT |
2126 | } |
2127 | else | |
2128 | count = count_exp.X_add_number; | |
2129 | } | |
2130 | #endif | |
2131 | ||
2132 | while (--count >= 0) | |
a39116f1 | 2133 | { |
f8701a3f | 2134 | p = frag_more (length); |
604633ae | 2135 | memcpy (p, temp, (unsigned int) length); |
a39116f1 | 2136 | } |
542e1629 | 2137 | } |
1e9cf565 | 2138 | SKIP_WHITESPACE (); |
f8701a3f | 2139 | } |
1e9cf565 ILT |
2140 | while (*input_line_pointer++ == ','); |
2141 | ||
2142 | --input_line_pointer; /* Put terminator back into stream. */ | |
6efd877d | 2143 | demand_empty_rest_of_line (); |
f8701a3f | 2144 | } /* float_cons() */ |
fecd2382 RP |
2145 | \f |
2146 | /* | |
2147 | * stringer() | |
2148 | * | |
2149 | * We read 0 or more ',' seperated, double-quoted strings. | |
2150 | * | |
2151 | * Caller should have checked need_pass_2 is FALSE because we don't check it. | |
2152 | */ | |
a39116f1 RP |
2153 | |
2154 | ||
6efd877d KR |
2155 | void |
2156 | stringer (append_zero) /* Worker to do .ascii etc statements. */ | |
2157 | /* Checks end-of-line. */ | |
f8701a3f | 2158 | register int append_zero; /* 0: don't append '\0', else 1 */ |
fecd2382 | 2159 | { |
f8701a3f | 2160 | register unsigned int c; |
6efd877d | 2161 | |
f8701a3f SC |
2162 | /* |
2163 | * The following awkward logic is to parse ZERO or more strings, | |
2164 | * comma seperated. Recall a string expression includes spaces | |
2165 | * before the opening '\"' and spaces after the closing '\"'. | |
2166 | * We fake a leading ',' if there is (supposed to be) | |
2167 | * a 1st, expression. We keep demanding expressions for each | |
2168 | * ','. | |
2169 | */ | |
6efd877d KR |
2170 | if (is_it_end_of_statement ()) |
2171 | { | |
2172 | c = 0; /* Skip loop. */ | |
2173 | ++input_line_pointer; /* Compensate for end of loop. */ | |
2174 | } | |
f8701a3f | 2175 | else |
6efd877d KR |
2176 | { |
2177 | c = ','; /* Do loop. */ | |
2178 | } | |
2179 | while (c == ',' || c == '<' || c == '"') | |
2180 | { | |
2181 | SKIP_WHITESPACE (); | |
2182 | switch (*input_line_pointer) | |
2183 | { | |
2184 | case '\"': | |
2185 | ++input_line_pointer; /*->1st char of string. */ | |
2186 | while (is_a_char (c = next_char_of_string ())) | |
2187 | { | |
2188 | FRAG_APPEND_1_CHAR (c); | |
2189 | } | |
2190 | if (append_zero) | |
2191 | { | |
2192 | FRAG_APPEND_1_CHAR (0); | |
2193 | } | |
2194 | know (input_line_pointer[-1] == '\"'); | |
2195 | break; | |
2196 | case '<': | |
2197 | input_line_pointer++; | |
2198 | c = get_single_number (); | |
2199 | FRAG_APPEND_1_CHAR (c); | |
2200 | if (*input_line_pointer != '>') | |
2201 | { | |
2202 | as_bad ("Expected <nn>"); | |
2203 | } | |
2204 | input_line_pointer++; | |
2205 | break; | |
2206 | case ',': | |
2207 | input_line_pointer++; | |
2208 | break; | |
2209 | } | |
2210 | SKIP_WHITESPACE (); | |
2211 | c = *input_line_pointer; | |
f8701a3f | 2212 | } |
f8701a3f | 2213 | |
6efd877d KR |
2214 | demand_empty_rest_of_line (); |
2215 | } /* stringer() */ | |
fecd2382 | 2216 | \f |
6efd877d | 2217 | /* FIXME-SOMEDAY: I had trouble here on characters with the |
f8701a3f SC |
2218 | high bits set. We'll probably also have trouble with |
2219 | multibyte chars, wide chars, etc. Also be careful about | |
2220 | returning values bigger than 1 byte. xoxorich. */ | |
fecd2382 | 2221 | |
6efd877d KR |
2222 | unsigned int |
2223 | next_char_of_string () | |
2224 | { | |
2225 | register unsigned int c; | |
2226 | ||
2227 | c = *input_line_pointer++ & CHAR_MASK; | |
2228 | switch (c) | |
2229 | { | |
2230 | case '\"': | |
2231 | c = NOT_A_CHAR; | |
2232 | break; | |
2233 | ||
2234 | case '\\': | |
2235 | switch (c = *input_line_pointer++) | |
2236 | { | |
2237 | case 'b': | |
2238 | c = '\b'; | |
2239 | break; | |
2240 | ||
2241 | case 'f': | |
2242 | c = '\f'; | |
2243 | break; | |
2244 | ||
2245 | case 'n': | |
2246 | c = '\n'; | |
2247 | break; | |
2248 | ||
2249 | case 'r': | |
2250 | c = '\r'; | |
2251 | break; | |
2252 | ||
2253 | case 't': | |
2254 | c = '\t'; | |
2255 | break; | |
2256 | ||
fecd2382 | 2257 | #ifdef BACKSLASH_V |
6efd877d KR |
2258 | case 'v': |
2259 | c = '\013'; | |
2260 | break; | |
fecd2382 | 2261 | #endif |
6efd877d KR |
2262 | |
2263 | case '\\': | |
2264 | case '"': | |
2265 | break; /* As itself. */ | |
2266 | ||
2267 | case '0': | |
2268 | case '1': | |
2269 | case '2': | |
2270 | case '3': | |
2271 | case '4': | |
2272 | case '5': | |
2273 | case '6': | |
2274 | case '7': | |
2275 | case '8': | |
2276 | case '9': | |
2277 | { | |
2278 | long number; | |
d4c8cbd8 | 2279 | int i; |
6efd877d | 2280 | |
d4c8cbd8 | 2281 | for (i = 0, number = 0; isdigit (c) && i < 3; c = *input_line_pointer++, i++) |
6efd877d KR |
2282 | { |
2283 | number = number * 8 + c - '0'; | |
2284 | } | |
2285 | c = number & 0xff; | |
2286 | } | |
2287 | --input_line_pointer; | |
2288 | break; | |
2289 | ||
d4c8cbd8 JL |
2290 | case 'x': |
2291 | case 'X': | |
2292 | { | |
2293 | long number; | |
2294 | ||
2295 | number = 0; | |
2296 | c = *input_line_pointer++; | |
2297 | while (isxdigit (c)) | |
2298 | { | |
2299 | if (isdigit (c)) | |
2300 | number = number * 16 + c - '0'; | |
2301 | else if (isupper (c)) | |
2302 | number = number * 16 + c - 'A' + 10; | |
2303 | else | |
2304 | number = number * 16 + c - 'a' + 10; | |
2305 | c = *input_line_pointer++; | |
2306 | } | |
2307 | c = number & 0xff; | |
2308 | --input_line_pointer; | |
2309 | } | |
2310 | break; | |
2311 | ||
6efd877d KR |
2312 | case '\n': |
2313 | /* To be compatible with BSD 4.2 as: give the luser a linefeed!! */ | |
2314 | as_warn ("Unterminated string: Newline inserted."); | |
2315 | c = '\n'; | |
2316 | break; | |
2317 | ||
2318 | default: | |
2319 | ||
fecd2382 | 2320 | #ifdef ONLY_STANDARD_ESCAPES |
6efd877d KR |
2321 | as_bad ("Bad escaped character in string, '?' assumed"); |
2322 | c = '?'; | |
fecd2382 | 2323 | #endif /* ONLY_STANDARD_ESCAPES */ |
6efd877d KR |
2324 | |
2325 | break; | |
2326 | } /* switch on escaped char */ | |
2327 | break; | |
2328 | ||
2329 | default: | |
2330 | break; | |
2331 | } /* switch on char */ | |
2332 | return (c); | |
2333 | } /* next_char_of_string() */ | |
fecd2382 RP |
2334 | \f |
2335 | static segT | |
f8701a3f | 2336 | get_segmented_expression (expP) |
6efd877d | 2337 | register expressionS *expP; |
fecd2382 | 2338 | { |
6efd877d | 2339 | register segT retval; |
f8701a3f | 2340 | |
9471a360 | 2341 | retval = expression (expP); |
5ac34ac3 ILT |
2342 | if (expP->X_op == O_illegal |
2343 | || expP->X_op == O_absent | |
2344 | || expP->X_op == O_big) | |
f8701a3f | 2345 | { |
5ac34ac3 ILT |
2346 | as_bad ("expected address expression; zero assumed"); |
2347 | expP->X_op = O_constant; | |
6efd877d | 2348 | expP->X_add_number = 0; |
5ac34ac3 | 2349 | retval = absolute_section; |
f8701a3f | 2350 | } |
5ac34ac3 | 2351 | return retval; |
fecd2382 RP |
2352 | } |
2353 | ||
6efd877d KR |
2354 | static segT |
2355 | get_known_segmented_expression (expP) | |
2356 | register expressionS *expP; | |
fecd2382 | 2357 | { |
6efd877d | 2358 | register segT retval; |
f8701a3f | 2359 | |
9471a360 | 2360 | if ((retval = get_segmented_expression (expP)) == undefined_section) |
f8701a3f | 2361 | { |
5ac34ac3 ILT |
2362 | /* There is no easy way to extract the undefined symbol from the |
2363 | expression. */ | |
2364 | if (expP->X_add_symbol != NULL | |
2365 | && S_GET_SEGMENT (expP->X_add_symbol) != expr_section) | |
2366 | as_warn ("symbol \"%s\" undefined; zero assumed", | |
2367 | S_GET_NAME (expP->X_add_symbol)); | |
f8701a3f | 2368 | else |
5ac34ac3 ILT |
2369 | as_warn ("some symbol undefined; zero assumed"); |
2370 | retval = absolute_section; | |
2371 | expP->X_op = O_constant; | |
6efd877d | 2372 | expP->X_add_number = 0; |
f8701a3f | 2373 | } |
5ac34ac3 | 2374 | know (retval == absolute_section || SEG_NORMAL (retval)); |
f8701a3f | 2375 | return (retval); |
fecd2382 RP |
2376 | } /* get_known_segmented_expression() */ |
2377 | ||
58d4951d | 2378 | offsetT |
f8701a3f | 2379 | get_absolute_expression () |
fecd2382 | 2380 | { |
6efd877d | 2381 | expressionS exp; |
f8701a3f | 2382 | |
5ac34ac3 ILT |
2383 | expression (&exp); |
2384 | if (exp.X_op != O_constant) | |
f8701a3f | 2385 | { |
5ac34ac3 ILT |
2386 | if (exp.X_op != O_absent) |
2387 | as_bad ("bad absolute expression; zero assumed"); | |
6efd877d | 2388 | exp.X_add_number = 0; |
f8701a3f | 2389 | } |
5ac34ac3 | 2390 | return exp.X_add_number; |
fecd2382 RP |
2391 | } |
2392 | ||
6efd877d KR |
2393 | char /* return terminator */ |
2394 | get_absolute_expression_and_terminator (val_pointer) | |
2395 | long *val_pointer; /* return value of expression */ | |
fecd2382 | 2396 | { |
58d4951d ILT |
2397 | /* FIXME: val_pointer should probably be offsetT *. */ |
2398 | *val_pointer = (long) get_absolute_expression (); | |
6efd877d | 2399 | return (*input_line_pointer++); |
fecd2382 RP |
2400 | } |
2401 | \f | |
2402 | /* | |
2403 | * demand_copy_C_string() | |
2404 | * | |
2405 | * Like demand_copy_string, but return NULL if the string contains any '\0's. | |
2406 | * Give a warning if that happens. | |
2407 | */ | |
2408 | char * | |
f8701a3f | 2409 | demand_copy_C_string (len_pointer) |
6efd877d | 2410 | int *len_pointer; |
fecd2382 | 2411 | { |
6efd877d | 2412 | register char *s; |
f8701a3f | 2413 | |
6efd877d | 2414 | if ((s = demand_copy_string (len_pointer)) != 0) |
f8701a3f SC |
2415 | { |
2416 | register int len; | |
2417 | ||
6efd877d | 2418 | for (len = *len_pointer; |
f8701a3f SC |
2419 | len > 0; |
2420 | len--) | |
2421 | { | |
6efd877d | 2422 | if (*s == 0) |
fecd2382 | 2423 | { |
f8701a3f SC |
2424 | s = 0; |
2425 | len = 1; | |
6efd877d KR |
2426 | *len_pointer = 0; |
2427 | as_bad ("This string may not contain \'\\0\'"); | |
fecd2382 | 2428 | } |
f8701a3f SC |
2429 | } |
2430 | } | |
2431 | return (s); | |
fecd2382 RP |
2432 | } |
2433 | \f | |
2434 | /* | |
2435 | * demand_copy_string() | |
2436 | * | |
2437 | * Demand string, but return a safe (=private) copy of the string. | |
2438 | * Return NULL if we can't read a string here. | |
2439 | */ | |
6efd877d KR |
2440 | static char * |
2441 | demand_copy_string (lenP) | |
2442 | int *lenP; | |
fecd2382 | 2443 | { |
6efd877d KR |
2444 | register unsigned int c; |
2445 | register int len; | |
2446 | char *retval; | |
2447 | ||
2448 | len = 0; | |
2449 | SKIP_WHITESPACE (); | |
2450 | if (*input_line_pointer == '\"') | |
2451 | { | |
2452 | input_line_pointer++; /* Skip opening quote. */ | |
2453 | ||
2454 | while (is_a_char (c = next_char_of_string ())) | |
2455 | { | |
2456 | obstack_1grow (¬es, c); | |
2457 | len++; | |
fecd2382 | 2458 | } |
6efd877d KR |
2459 | /* JF this next line is so demand_copy_C_string will return a null |
2460 | termanated string. */ | |
2461 | obstack_1grow (¬es, '\0'); | |
2462 | retval = obstack_finish (¬es); | |
2463 | } | |
2464 | else | |
2465 | { | |
2466 | as_warn ("Missing string"); | |
2467 | retval = NULL; | |
2468 | ignore_rest_of_line (); | |
2469 | } | |
2470 | *lenP = len; | |
2471 | return (retval); | |
2472 | } /* demand_copy_string() */ | |
fecd2382 RP |
2473 | \f |
2474 | /* | |
2475 | * is_it_end_of_statement() | |
2476 | * | |
2477 | * In: Input_line_pointer->next character. | |
2478 | * | |
2479 | * Do: Skip input_line_pointer over all whitespace. | |
2480 | * | |
2481 | * Out: 1 if input_line_pointer->end-of-line. | |
f8701a3f | 2482 | */ |
6efd877d KR |
2483 | int |
2484 | is_it_end_of_statement () | |
2485 | { | |
2486 | SKIP_WHITESPACE (); | |
58d4951d | 2487 | return (is_end_of_line[(unsigned char) *input_line_pointer]); |
6efd877d | 2488 | } /* is_it_end_of_statement() */ |
fecd2382 | 2489 | |
6efd877d KR |
2490 | void |
2491 | equals (sym_name) | |
2492 | char *sym_name; | |
fecd2382 | 2493 | { |
6efd877d | 2494 | register symbolS *symbolP; /* symbol we are working with */ |
f8701a3f SC |
2495 | |
2496 | input_line_pointer++; | |
6efd877d | 2497 | if (*input_line_pointer == '=') |
f8701a3f SC |
2498 | input_line_pointer++; |
2499 | ||
6efd877d | 2500 | while (*input_line_pointer == ' ' || *input_line_pointer == '\t') |
f8701a3f SC |
2501 | input_line_pointer++; |
2502 | ||
6efd877d KR |
2503 | if (sym_name[0] == '.' && sym_name[1] == '\0') |
2504 | { | |
2505 | /* Turn '. = mumble' into a .org mumble */ | |
2506 | register segT segment; | |
2507 | expressionS exp; | |
2508 | register char *p; | |
f8701a3f | 2509 | |
6efd877d KR |
2510 | segment = get_known_segmented_expression (&exp); |
2511 | if (!need_pass_2) | |
2512 | { | |
9471a360 | 2513 | if (segment != now_seg && segment != absolute_section) |
6efd877d KR |
2514 | as_warn ("Illegal segment \"%s\". Segment \"%s\" assumed.", |
2515 | segment_name (segment), | |
2516 | segment_name (now_seg)); | |
2517 | p = frag_var (rs_org, 1, 1, (relax_substateT) 0, exp.X_add_symbol, | |
2518 | exp.X_add_number, (char *) 0); | |
2519 | *p = 0; | |
2520 | } /* if (ok to make frag) */ | |
2521 | } | |
2522 | else | |
2523 | { | |
2524 | symbolP = symbol_find_or_make (sym_name); | |
2525 | pseudo_set (symbolP); | |
2526 | } | |
2527 | } /* equals() */ | |
fecd2382 RP |
2528 | |
2529 | /* .include -- include a file at this point. */ | |
2530 | ||
2531 | /* ARGSUSED */ | |
6efd877d KR |
2532 | void |
2533 | s_include (arg) | |
2534 | int arg; | |
fecd2382 | 2535 | { |
f8701a3f SC |
2536 | char *newbuf; |
2537 | char *filename; | |
2538 | int i; | |
2539 | FILE *try; | |
2540 | char *path; | |
2541 | ||
6efd877d KR |
2542 | filename = demand_copy_string (&i); |
2543 | demand_empty_rest_of_line (); | |
604633ae | 2544 | path = xmalloc ((unsigned long) i + include_dir_maxlen + 5 /* slop */ ); |
6efd877d KR |
2545 | for (i = 0; i < include_dir_count; i++) |
2546 | { | |
2547 | strcpy (path, include_dirs[i]); | |
2548 | strcat (path, "/"); | |
2549 | strcat (path, filename); | |
30d3a445 | 2550 | if (0 != (try = fopen (path, FOPEN_RT))) |
6efd877d KR |
2551 | { |
2552 | fclose (try); | |
2553 | goto gotit; | |
2554 | } | |
2555 | } | |
2556 | free (path); | |
f8701a3f SC |
2557 | path = filename; |
2558 | gotit: | |
2559 | /* malloc Storage leak when file is found on path. FIXME-SOMEDAY. */ | |
2560 | newbuf = input_scrub_include_file (path, input_line_pointer); | |
2561 | buffer_limit = input_scrub_next_buffer (&input_line_pointer); | |
6efd877d | 2562 | } /* s_include() */ |
fecd2382 | 2563 | |
6efd877d KR |
2564 | void |
2565 | add_include_dir (path) | |
2566 | char *path; | |
fecd2382 | 2567 | { |
f8701a3f SC |
2568 | int i; |
2569 | ||
2570 | if (include_dir_count == 0) | |
2571 | { | |
6efd877d | 2572 | include_dirs = (char **) xmalloc (2 * sizeof (*include_dirs)); |
f8701a3f SC |
2573 | include_dirs[0] = "."; /* Current dir */ |
2574 | include_dir_count = 2; | |
2575 | } | |
2576 | else | |
2577 | { | |
2578 | include_dir_count++; | |
6efd877d KR |
2579 | include_dirs = (char **) realloc (include_dirs, |
2580 | include_dir_count * sizeof (*include_dirs)); | |
f8701a3f SC |
2581 | } |
2582 | ||
6efd877d | 2583 | include_dirs[include_dir_count - 1] = path; /* New one */ |
f8701a3f | 2584 | |
6efd877d KR |
2585 | i = strlen (path); |
2586 | if (i > include_dir_maxlen) | |
2587 | include_dir_maxlen = i; | |
2588 | } /* add_include_dir() */ | |
fecd2382 | 2589 | |
6efd877d KR |
2590 | void |
2591 | s_ignore (arg) | |
2592 | int arg; | |
fecd2382 | 2593 | { |
58d4951d | 2594 | while (!is_end_of_line[(unsigned char) *input_line_pointer]) |
6efd877d KR |
2595 | { |
2596 | ++input_line_pointer; | |
2597 | } | |
2598 | ++input_line_pointer; | |
4064305e SS |
2599 | } |
2600 | ||
604633ae | 2601 | |
fecd2382 | 2602 | /* end of read.c */ |