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