* win32-nat.c (handle_exception): Return a value indicating
[deliverable/binutils-gdb.git] / gas / read.c
CommitLineData
fecd2382 1/* read.c - read a source file -
a986926b 2 Copyright (C) 1986, 87, 90, 91, 92, 93, 94, 95, 96, 1997
ddb393cf 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
8ff75001
ILT
18along with GAS; see the file COPYING. If not, write to the Free
19Software Foundation, 59 Temple Place - Suite 330, Boston, MA
2002111-1307, USA. */
fecd2382 21
016e0d42 22#if 0
fecd2382
RP
23#define MASK_CHAR (0xFF) /* If your chars aren't 8 bits, you will
24 change this a bit. But then, GNU isn't
25 spozed to run on your machine anyway.
26 (RMS is so shortsighted sometimes.)
27 */
016e0d42
ILT
28#else
29#define MASK_CHAR ((int)(unsigned char)-1)
30#endif
fecd2382 31
9a7d824a 32
9471a360
KR
33/* This is the largest known floating point format (for now). It will
34 grow when we do 4361 style flonums. */
fecd2382 35
9471a360 36#define MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT (16)
fecd2382 37
016e0d42
ILT
38/* Routines that read assembler source text to build spagetti in memory.
39 Another group of these functions is in the expr.c module. */
fecd2382 40
9471a360 41/* for isdigit() */
6efd877d
KR
42#include <ctype.h>
43
fecd2382 44#include "as.h"
9471a360 45#include "subsegs.h"
7e047ac2
ILT
46#include "sb.h"
47#include "macro.h"
fecd2382 48#include "obstack.h"
9a7d824a 49#include "listing.h"
a69e5977 50#include "ecoff.h"
9a7d824a 51
9a7d824a
ILT
52#ifndef TC_START_LABEL
53#define TC_START_LABEL(x,y) (x==':')
54#endif
fecd2382 55
016e0d42
ILT
56/* The NOP_OPCODE is for the alignment fill value.
57 * fill it a nop instruction so that the disassembler does not choke
58 * on it
59 */
60#ifndef NOP_OPCODE
61#define NOP_OPCODE 0x00
62#endif
63
64char *input_line_pointer; /*->next char of source file to parse. */
fecd2382
RP
65
66#if BITS_PER_CHAR != 8
6efd877d
KR
67/* The following table is indexed by[(char)] and will break if
68 a char does not have exactly 256 states (hopefully 0:255!)! */
69die horribly;
fecd2382 70#endif
f8701a3f 71
c978e704
ILT
72#ifndef LEX_AT
73/* The m88k unfortunately uses @ as a label beginner. */
74#define LEX_AT 0
75#endif
76
ddb393cf
ILT
77#ifndef LEX_BR
78/* The RS/6000 assembler uses {,},[,] as parts of symbol names. */
79#define LEX_BR 0
80#endif
81
6ef37255
KR
82#ifndef LEX_PCT
83/* The Delta 68k assembler permits % inside label names. */
84#define LEX_PCT 0
85#endif
86
18c9057f
ILT
87#ifndef LEX_QM
88/* The PowerPC Windows NT assemblers permits ? inside label names. */
89#define LEX_QM 0
90#endif
91
6594d6b9
KR
92#ifndef LEX_DOLLAR
93/* The a29k assembler does not permits labels to start with $. */
94#define LEX_DOLLAR 3
95#endif
96
151c3ec0
ILT
97#ifndef LEX_TILDE
98/* The Delta 68k assembler permits ~ at start of label names. */
99#define LEX_TILDE 0
100#endif
101
016e0d42 102/* used by is_... macros. our ctype[] */
1356d77d 103char lex_type[256] =
016e0d42
ILT
104{
105 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* @ABCDEFGHIJKLMNO */
106 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* PQRSTUVWXYZ[\]^_ */
6594d6b9 107 0, 0, 0, 0, LEX_DOLLAR, LEX_PCT, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, /* _!"#$%&'()*+,-./ */
18c9057f 108 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, LEX_QM, /* 0123456789:;<=>? */
c978e704 109 LEX_AT, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, /* @ABCDEFGHIJKLMNO */
ddb393cf 110 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, LEX_BR, 0, LEX_BR, 0, 3, /* PQRSTUVWXYZ[\]^_ */
016e0d42 111 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, /* `abcdefghijklmno */
151c3ec0 112 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, LEX_BR, 0, LEX_BR, LEX_TILDE, 0, /* pqrstuvwxyz{|}~. */
016e0d42
ILT
113 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
114 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
115 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
116 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
117 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
118 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
119 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
120};
121
122
123/*
fecd2382
RP
124 * In: a character.
125 * Out: 1 if this character ends a line.
126 */
127#define _ (0)
016e0d42
ILT
128char is_end_of_line[256] =
129{
fecd2382 130#ifdef CR_EOL
016e0d42 131 _, _, _, _, _, _, _, _, _, _, 99, _, _, 99, _, _, /* @abcdefghijklmno */
fecd2382 132#else
016e0d42 133 _, _, _, _, _, _, _, _, _, _, 99, _, _, _, _, _, /* @abcdefghijklmno */
fecd2382 134#endif
016e0d42 135 _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, /* */
40324362
KR
136#ifdef TC_HPPA
137 _,99, _, _, _, _, _, _, _, _, _, _, _, _, _, _, /* _!"#$%&'()*+,-./ */
138 _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, /* 0123456789:;<=>? */
139#else
016e0d42
ILT
140 _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, /* */
141 _, _, _, _, _, _, _, _, _, _, _, 99, _, _, _, _, /* 0123456789:;<=>? */
40324362 142#endif
016e0d42
ILT
143 _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, /* */
144 _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, /* */
145 _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, /* */
146 _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, /* */
147 _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, /* */
148 _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, /* */
149 _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, /* */
150 _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, /* */
151 _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, /* */
152};
fecd2382
RP
153#undef _
154
016e0d42
ILT
155/* Functions private to this file. */
156
157static char *buffer; /* 1st char of each buffer of lines is here. */
158static char *buffer_limit; /*->1 + last char in buffer. */
fecd2382 159
d428c89f
ILT
160/* TARGET_BYTES_BIG_ENDIAN is required to be defined to either 0 or 1 in the
161 tc-<CPU>.h file. See the "Porting GAS" section of the internals manual. */
2209b19c 162int target_big_endian = TARGET_BYTES_BIG_ENDIAN;
9c6d3f66 163
9471a360 164static char *old_buffer; /* JF a hack */
016e0d42
ILT
165static char *old_input;
166static char *old_limit;
fecd2382 167
016e0d42 168/* Variables for handling include file directory list. */
fecd2382 169
016e0d42
ILT
170char **include_dirs; /* List of pointers to directories to
171 search for .include's */
172int include_dir_count; /* How many are in the list */
173int include_dir_maxlen = 1;/* Length of longest in list */
fecd2382
RP
174
175#ifndef WORKING_DOT_WORD
016e0d42 176struct broken_word *broken_words;
9471a360 177int new_broken_words;
fecd2382
RP
178#endif
179
e28c40d7
ILT
180/* The current offset into the absolute section. We don't try to
181 build frags in the absolute section, since no data can be stored
182 there. We just keep track of the current offset. */
183addressT abs_section_offset;
184
1356d77d
ILT
185/* If this line had an MRI style label, it is stored in this variable.
186 This is used by some of the MRI pseudo-ops. */
7e047ac2 187symbolS *line_label;
1356d77d
ILT
188
189/* This global variable is used to support MRI common sections. We
190 translate such sections into a common symbol. This variable is
191 non-NULL when we are in an MRI common section. */
192symbolS *mri_common_symbol;
193
286cb27a
ILT
194/* In MRI mode, after a dc.b pseudo-op with an odd number of bytes, we
195 need to align to an even byte boundary unless the next pseudo-op is
196 dc.b, ds.b, or dcb.b. This variable is set to 1 if an alignment
197 may be needed. */
198static int mri_pending_align;
199
7cd06f44 200static void cons_worker PARAMS ((int, int));
86038ada 201static int scrub_from_string PARAMS ((char **));
d428c89f
ILT
202static void do_align PARAMS ((int, char *, int, int));
203static void s_align PARAMS ((int, int));
e28c40d7
ILT
204static int hex_float PARAMS ((int, char *));
205static void do_org PARAMS ((segT, expressionS *, int));
6ef37255 206char *demand_copy_string PARAMS ((int *lenP));
5ac34ac3 207static segT get_segmented_expression PARAMS ((expressionS *expP));
016e0d42 208static segT get_known_segmented_expression PARAMS ((expressionS * expP));
016e0d42 209static void pobegin PARAMS ((void));
7e047ac2 210static int get_line_sb PARAMS ((sb *));
fecd2382 211\f
6efd877d 212
016e0d42
ILT
213void
214read_begin ()
fecd2382 215{
016e0d42 216 const char *p;
f8701a3f 217
6efd877d
KR
218 pobegin ();
219 obj_read_begin_hook ();
f8701a3f 220
4380166d
KR
221 /* Something close -- but not too close -- to a multiple of 1024.
222 The debugging malloc I'm using has 24 bytes of overhead. */
6594d6b9
KR
223 obstack_begin (&notes, chunksize);
224 obstack_begin (&cond_obstack, chunksize);
f8701a3f 225
f8701a3f
SC
226 /* Use machine dependent syntax */
227 for (p = line_separator_chars; *p; p++)
58d4951d 228 is_end_of_line[(unsigned char) *p] = 1;
f8701a3f 229 /* Use more. FIXME-SOMEDAY. */
1356d77d
ILT
230
231 if (flag_mri)
232 lex_type['?'] = 3;
fecd2382
RP
233}
234\f
235/* set up pseudo-op tables */
236
1356d77d 237static struct hash_control *po_hash;
fecd2382 238
016e0d42 239static const pseudo_typeS potable[] =
fecd2382 240{
6efd877d
KR
241 {"abort", s_abort, 0},
242 {"align", s_align_ptwo, 0},
243 {"ascii", stringer, 0},
244 {"asciz", stringer, 1},
931a8fab 245 {"balign", s_align_bytes, 0},
4080c270
ILT
246 {"balignw", s_align_bytes, -2},
247 {"balignl", s_align_bytes, -4},
f8701a3f 248/* block */
6efd877d
KR
249 {"byte", cons, 1},
250 {"comm", s_comm, 0},
1356d77d
ILT
251 {"common", s_mri_common, 0},
252 {"common.s", s_mri_common, 1},
6efd877d 253 {"data", s_data, 0},
1356d77d
ILT
254 {"dc", cons, 2},
255 {"dc.b", cons, 1},
256 {"dc.d", float_cons, 'd'},
257 {"dc.l", cons, 4},
258 {"dc.s", float_cons, 'f'},
259 {"dc.w", cons, 2},
260 {"dc.x", float_cons, 'x'},
e28c40d7
ILT
261 {"dcb", s_space, 2},
262 {"dcb.b", s_space, 1},
263 {"dcb.d", s_float_space, 'd'},
264 {"dcb.l", s_space, 4},
265 {"dcb.s", s_float_space, 'f'},
266 {"dcb.w", s_space, 2},
267 {"dcb.x", s_float_space, 'x'},
1356d77d
ILT
268 {"ds", s_space, 2},
269 {"ds.b", s_space, 1},
e28c40d7 270 {"ds.d", s_space, 8},
1356d77d 271 {"ds.l", s_space, 4},
e28c40d7
ILT
272 {"ds.p", s_space, 12},
273 {"ds.s", s_space, 4},
1356d77d 274 {"ds.w", s_space, 2},
e28c40d7 275 {"ds.x", s_space, 12},
42ac8fa8 276 {"debug", s_ignore, 0},
604633ae 277#ifdef S_SET_DESC
4064305e 278 {"desc", s_desc, 0},
604633ae 279#endif
f8701a3f 280/* dim */
6efd877d 281 {"double", float_cons, 'd'},
f8701a3f 282/* dsect */
6efd877d
KR
283 {"eject", listing_eject, 0}, /* Formfeed listing */
284 {"else", s_else, 0},
e28c40d7 285 {"elsec", s_else, 0},
6efd877d 286 {"end", s_end, 0},
e28c40d7 287 {"endc", s_endif, 0},
6efd877d 288 {"endif", s_endif, 0},
f8701a3f 289/* endef */
6efd877d 290 {"equ", s_set, 0},
cd924033 291 {"equiv", s_set, 1},
42ac8fa8 292 {"err", s_err, 0},
7e047ac2 293 {"exitm", s_mexit, 0},
f8701a3f 294/* extend */
6efd877d 295 {"extern", s_ignore, 0}, /* We treat all undef as ext */
9a7d824a
ILT
296 {"appfile", s_app_file, 1},
297 {"appline", s_app_line, 0},
e28c40d7 298 {"fail", s_fail, 0},
6efd877d
KR
299 {"file", s_app_file, 0},
300 {"fill", s_fill, 0},
301 {"float", float_cons, 'f'},
e28c40d7 302 {"format", s_ignore, 0},
6efd877d
KR
303 {"global", s_globl, 0},
304 {"globl", s_globl, 0},
305 {"hword", cons, 2},
e28c40d7 306 {"if", s_if, (int) O_ne},
7e047ac2 307 {"ifc", s_ifc, 0},
6efd877d 308 {"ifdef", s_ifdef, 0},
e28c40d7 309 {"ifeq", s_if, (int) O_eq},
6efd877d 310 {"ifeqs", s_ifeqs, 0},
e28c40d7
ILT
311 {"ifge", s_if, (int) O_ge},
312 {"ifgt", s_if, (int) O_gt},
313 {"ifle", s_if, (int) O_le},
314 {"iflt", s_if, (int) O_lt},
7e047ac2 315 {"ifnc", s_ifc, 1},
6efd877d 316 {"ifndef", s_ifdef, 1},
e28c40d7 317 {"ifne", s_if, (int) O_ne},
6efd877d
KR
318 {"ifnes", s_ifeqs, 1},
319 {"ifnotdef", s_ifdef, 1},
320 {"include", s_include, 0},
321 {"int", cons, 4},
7e047ac2 322 {"irp", s_irp, 0},
42ac8fa8 323 {"irep", s_irp, 0},
7e047ac2 324 {"irpc", s_irp, 1},
42ac8fa8 325 {"irepc", s_irp, 1},
6efd877d
KR
326 {"lcomm", s_lcomm, 0},
327 {"lflags", listing_flags, 0}, /* Listing flags */
7d3741ed 328 {"linkonce", s_linkonce, 0},
6efd877d 329 {"list", listing_list, 1}, /* Turn listing on */
e28c40d7 330 {"llen", listing_psize, 1},
6efd877d
KR
331 {"long", cons, 4},
332 {"lsym", s_lsym, 0},
7e047ac2
ILT
333 {"macro", s_macro, 0},
334 {"mexit", s_mexit, 0},
20710f1c
ILT
335 {"mri", s_mri, 0},
336 {".mri", s_mri, 0}, /* Special case so .mri works in MRI mode. */
cef72a92 337 {"name", s_ignore, 0},
e28c40d7 338 {"noformat", s_ignore, 0},
6efd877d 339 {"nolist", listing_list, 0}, /* Turn listing off */
69e077f3 340 {"nopage", listing_nopage, 0},
80aab579 341 {"octa", cons, 16},
e28c40d7 342 {"offset", s_struct, 0},
6efd877d 343 {"org", s_org, 0},
931a8fab 344 {"p2align", s_align_ptwo, 0},
4080c270
ILT
345 {"p2alignw", s_align_ptwo, -2},
346 {"p2alignl", s_align_ptwo, -4},
69e077f3
ILT
347 {"page", listing_eject, 0},
348 {"plen", listing_psize, 0},
42ac8fa8 349 {"print", s_print, 0},
6efd877d 350 {"psize", listing_psize, 0}, /* set paper size */
42ac8fa8 351 {"purgem", s_purgem, 0},
80aab579 352 {"quad", cons, 8},
42ac8fa8 353 {"rep", s_rept, 0},
7e047ac2 354 {"rept", s_rept, 0},
86038ada 355 {"rva", s_rva, 4},
6efd877d 356 {"sbttl", listing_title, 1}, /* Subtitle of listing */
f8701a3f
SC
357/* scl */
358/* sect */
6efd877d
KR
359 {"set", s_set, 0},
360 {"short", cons, 2},
361 {"single", float_cons, 'f'},
f8701a3f 362/* size */
6efd877d 363 {"space", s_space, 0},
adeab39b 364 {"skip", s_space, 0},
cd924033 365 {"sleb128", s_leb128, 1},
e14994d9 366 {"spc", s_ignore, 0},
4064305e
SS
367 {"stabd", s_stab, 'd'},
368 {"stabn", s_stab, 'n'},
369 {"stabs", s_stab, 's'},
ba71c54d 370 {"string", stringer, 1},
e28c40d7 371 {"struct", s_struct, 0},
f8701a3f 372/* tag */
6efd877d 373 {"text", s_text, 0},
6ef37255
KR
374
375 /* This is for gcc to use. It's only just been added (2/94), so gcc
376 won't be able to use it for a while -- probably a year or more.
377 But once this has been released, check with gcc maintainers
378 before deleting it or even changing the spelling. */
379 {"this_GCC_requires_the_GNU_assembler", s_ignore, 0},
380 /* If we're folding case -- done for some targets, not necessarily
381 all -- the above string in an input file will be converted to
382 this one. Match it either way... */
383 {"this_gcc_requires_the_gnu_assembler", s_ignore, 0},
384
6efd877d 385 {"title", listing_title, 0}, /* Listing title */
e14994d9 386 {"ttl", listing_title, 0},
f8701a3f 387/* type */
cd924033 388 {"uleb128", s_leb128, 0},
f8701a3f
SC
389/* use */
390/* val */
e14994d9 391 {"xcom", s_comm, 0},
1356d77d 392 {"xdef", s_globl, 0},
e14994d9 393 {"xref", s_ignore, 0},
4064305e 394 {"xstabs", s_xstab, 's'},
6efd877d 395 {"word", cons, 2},
c02fd8dc 396 {"zero", s_space, 0},
6efd877d 397 {NULL} /* end sentinel */
fecd2382
RP
398};
399
2209b19c
KR
400static int pop_override_ok = 0;
401static const char *pop_table_name;
402
403void
404pop_insert (table)
405 const pseudo_typeS *table;
6efd877d 406{
2209b19c 407 const char *errtxt;
6efd877d 408 const pseudo_typeS *pop;
2209b19c
KR
409 for (pop = table; pop->poc_name; pop++)
410 {
411 errtxt = hash_insert (po_hash, pop->poc_name, (char *) pop);
412 if (errtxt && (!pop_override_ok || strcmp (errtxt, "exists")))
6594d6b9
KR
413 as_fatal ("error constructing %s pseudo-op table: %s", pop_table_name,
414 errtxt);
2209b19c
KR
415 }
416}
6efd877d 417
2209b19c
KR
418#ifndef md_pop_insert
419#define md_pop_insert() pop_insert(md_pseudo_table)
420#endif
421
422#ifndef obj_pop_insert
423#define obj_pop_insert() pop_insert(obj_pseudo_table)
424#endif
425
426static void
427pobegin ()
428{
6efd877d
KR
429 po_hash = hash_new ();
430
431 /* Do the target-specific pseudo ops. */
2209b19c
KR
432 pop_table_name = "md";
433 md_pop_insert ();
6efd877d
KR
434
435 /* Now object specific. Skip any that were in the target table. */
2209b19c
KR
436 pop_table_name = "obj";
437 pop_override_ok = 1;
438 obj_pop_insert ();
6efd877d
KR
439
440 /* Now portable ones. Skip any that we've seen already. */
2209b19c
KR
441 pop_table_name = "standard";
442 pop_insert (potable);
443}
fecd2382 444\f
58d4951d
ILT
445#define HANDLE_CONDITIONAL_ASSEMBLY() \
446 if (ignore_input ()) \
447 { \
448 while (! is_end_of_line[(unsigned char) *input_line_pointer++]) \
449 if (input_line_pointer == buffer_limit) \
450 break; \
451 continue; \
f8701a3f 452 }
a39116f1 453
fecd2382 454
86038ada
ILT
455/* This function is used when scrubbing the characters between #APP
456 and #NO_APP. */
457
458static char *scrub_string;
459static char *scrub_string_end;
460
461static int
462scrub_from_string (from)
463 char **from;
464{
465 int size;
466
467 *from = scrub_string;
468 size = scrub_string_end - scrub_string;
469 scrub_string = scrub_string_end;
470 return size;
471}
472
fecd2382
RP
473/* read_a_source_file()
474 *
475 * We read the file, putting things into a web that
476 * represents what we have been reading.
477 */
6efd877d
KR
478void
479read_a_source_file (name)
480 char *name;
fecd2382 481{
f8701a3f 482 register char c;
6efd877d 483 register char *s; /* string of symbol, '\0' appended */
f8701a3f 484 register int temp;
6efd877d 485 pseudo_typeS *pop;
f8701a3f 486
6efd877d 487 buffer = input_scrub_new_file (name);
f8701a3f 488
6efd877d
KR
489 listing_file (name);
490 listing_newline ("");
cd924033 491 register_dependency (name);
f8701a3f 492
6efd877d
KR
493 while ((buffer_limit = input_scrub_next_buffer (&input_line_pointer)) != 0)
494 { /* We have another line to parse. */
495 know (buffer_limit[-1] == '\n'); /* Must have a sentinel. */
9471a360
KR
496 contin: /* JF this goto is my fault I admit it.
497 Someone brave please re-write the whole
498 input section here? Pleeze??? */
6efd877d 499 while (input_line_pointer < buffer_limit)
9471a360
KR
500 {
501 /* We have more of this buffer to parse. */
f8701a3f
SC
502
503 /*
504 * We now have input_line_pointer->1st char of next line.
505 * If input_line_pointer [-1] == '\n' then we just
506 * scanned another line: so bump line counters.
507 */
d2550c72 508 if (is_end_of_line[(unsigned char) input_line_pointer[-1]])
6efd877d 509 {
a2a5a4fa
KR
510#ifdef md_start_line_hook
511 md_start_line_hook ();
512#endif
513
385ce433
JL
514 if (input_line_pointer[-1] == '\n')
515 bump_line_counters ();
f8701a3f 516
7e047ac2
ILT
517 line_label = NULL;
518
cef72a92 519 if (flag_m68k_mri
1356d77d
ILT
520#ifdef LABELS_WITHOUT_COLONS
521 || 1
522#endif
523 )
6efd877d 524 {
1356d77d
ILT
525 /* Text at the start of a line must be a label, we
526 run down and stick a colon in. */
527 if (is_name_beginner (*input_line_pointer))
528 {
529 char *line_start = input_line_pointer;
7e047ac2 530 char c;
8ff75001 531 int mri_line_macro;
7e047ac2 532
d428c89f 533 LISTING_NEWLINE ();
7e047ac2 534 HANDLE_CONDITIONAL_ASSEMBLY ();
1356d77d 535
7e047ac2
ILT
536 c = get_symbol_end ();
537
8ff75001
ILT
538 /* In MRI mode, the EQU and MACRO pseudoops must
539 be handled specially. */
540 mri_line_macro = 0;
cef72a92 541 if (flag_m68k_mri)
1356d77d 542 {
7e047ac2
ILT
543 char *rest = input_line_pointer + 1;
544
545 if (*rest == ':')
546 ++rest;
547 if (*rest == ' ' || *rest == '\t')
548 ++rest;
549 if ((strncasecmp (rest, "EQU", 3) == 0
550 || strncasecmp (rest, "SET", 3) == 0)
551 && (rest[3] == ' ' || rest[3] == '\t'))
1356d77d 552 {
7e047ac2 553 input_line_pointer = rest + 3;
d428c89f
ILT
554 equals (line_start,
555 strncasecmp (rest, "SET", 3) == 0);
7e047ac2 556 continue;
1356d77d 557 }
8ff75001
ILT
558 if (strncasecmp (rest, "MACRO", 5) == 0
559 && (rest[5] == ' '
560 || rest[5] == '\t'
561 || is_end_of_line[(unsigned char) rest[5]]))
562 mri_line_macro = 1;
1356d77d 563 }
6efd877d 564
8ff75001
ILT
565 /* In MRI mode, we need to handle the MACRO
566 pseudo-op specially: we don't want to put the
567 symbol in the symbol table. */
568 if (! mri_line_macro)
569 line_label = colon (line_start);
570 else
571 line_label = symbol_create (line_start,
572 absolute_section,
573 (valueT) 0,
574 &zero_address_frag);
7e047ac2 575
1356d77d
ILT
576 *input_line_pointer = c;
577 if (c == ':')
578 input_line_pointer++;
579 }
6efd877d 580 }
9471a360 581 }
f8701a3f 582
f8701a3f
SC
583 /*
584 * We are at the begining of a line, or similar place.
585 * We expect a well-formed assembler statement.
586 * A "symbol-name:" is a statement.
587 *
588 * Depending on what compiler is used, the order of these tests
589 * may vary to catch most common case 1st.
590 * Each test is independent of all other tests at the (top) level.
591 * PLEASE make a compiler that doesn't use this assembler.
592 * It is crufty to waste a compiler's time encoding things for this
593 * assembler, which then wastes more time decoding it.
594 * (And communicating via (linear) files is silly!
595 * If you must pass stuff, please pass a tree!)
596 */
9471a360
KR
597 if ((c = *input_line_pointer++) == '\t'
598 || c == ' '
599 || c == '\f'
600 || c == 0)
6efd877d
KR
601 {
602 c = *input_line_pointer++;
603 }
604 know (c != ' '); /* No further leading whitespace. */
605 LISTING_NEWLINE ();
f8701a3f
SC
606 /*
607 * C is the 1st significant character.
608 * Input_line_pointer points after that character.
609 */
6efd877d 610 if (is_name_beginner (c))
6ef37255
KR
611 {
612 /* want user-defined label or pseudo/opcode */
6efd877d
KR
613 HANDLE_CONDITIONAL_ASSEMBLY ();
614
f8701a3f 615 s = --input_line_pointer;
6efd877d 616 c = get_symbol_end (); /* name's delimiter */
f8701a3f
SC
617 /*
618 * C is character after symbol.
619 * That character's place in the input line is now '\0'.
620 * S points to the beginning of the symbol.
621 * [In case of pseudo-op, s->'.'.]
622 * Input_line_pointer->'\0' where c was.
623 */
9a7d824a 624 if (TC_START_LABEL(c, input_line_pointer))
6efd877d 625 {
cef72a92 626 if (flag_m68k_mri)
7e047ac2
ILT
627 {
628 char *rest = input_line_pointer + 1;
629
630 /* In MRI mode, \tsym: set 0 is permitted. */
631
632 if (*rest == ':')
633 ++rest;
634 if (*rest == ' ' || *rest == '\t')
635 ++rest;
636 if ((strncasecmp (rest, "EQU", 3) == 0
637 || strncasecmp (rest, "SET", 3) == 0)
638 && (rest[3] == ' ' || rest[3] == '\t'))
639 {
640 input_line_pointer = rest + 3;
d428c89f 641 equals (s, 1);
7e047ac2
ILT
642 continue;
643 }
644 }
645
646 line_label = colon (s); /* user-defined label */
6efd877d 647 *input_line_pointer++ = ':'; /* Put ':' back for error messages' sake. */
f8701a3f 648 /* Input_line_pointer->after ':'. */
6efd877d
KR
649 SKIP_WHITESPACE ();
650
f8701a3f 651
6efd877d 652 }
4064305e 653 else if (c == '='
a6b200da
ILT
654 || ((c == ' ' || c == '\t')
655 && input_line_pointer[1] == '='
4064305e
SS
656#ifdef TC_EQUAL_IN_INSN
657 && ! TC_EQUAL_IN_INSN (c, input_line_pointer)
658#endif
659 ))
9c6d3f66 660 {
d428c89f 661 equals (s, 1);
6efd877d
KR
662 demand_empty_rest_of_line ();
663 }
664 else
665 { /* expect pseudo-op or machine instruction */
8ff6f40e
ILT
666 pop = NULL;
667
d4c8cbd8
JL
668#define IGNORE_OPCODE_CASE
669#ifdef IGNORE_OPCODE_CASE
670 {
671 char *s2 = s;
672 while (*s2)
673 {
674 if (isupper (*s2))
675 *s2 = tolower (*s2);
676 s2++;
677 }
678 }
679#endif
680
cef72a92 681 if (flag_m68k_mri
8ff6f40e 682#ifdef NO_PSEUDO_DOT
1356d77d 683 || 1
8ff6f40e 684#endif
1356d77d
ILT
685 )
686 {
687 /* The MRI assembler and the m88k use pseudo-ops
688 without a period. */
689 pop = (pseudo_typeS *) hash_find (po_hash, s);
690 if (pop != NULL && pop->poc_handler == NULL)
691 pop = NULL;
692 }
8ff6f40e 693
7e047ac2 694 if (pop != NULL
cef72a92 695 || (! flag_m68k_mri && *s == '.'))
6efd877d
KR
696 {
697 /*
9471a360
KR
698 * PSEUDO - OP.
699 *
700 * WARNING: c has next char, which may be end-of-line.
701 * We lookup the pseudo-op table with s+1 because we
702 * already know that the pseudo-op begins with a '.'.
703 */
6efd877d 704
8ff6f40e
ILT
705 if (pop == NULL)
706 pop = (pseudo_typeS *) hash_find (po_hash, s + 1);
6efd877d 707
286cb27a
ILT
708 /* In MRI mode, we may need to insert an
709 automatic alignment directive. What a hack
710 this is. */
711 if (mri_pending_align
712 && (pop == NULL
713 || ! ((pop->poc_handler == cons
714 && pop->poc_val == 1)
715 || (pop->poc_handler == s_space
a986926b
ILT
716 && pop->poc_val == 1)
717#ifdef tc_conditional_pseudoop
718 || tc_conditional_pseudoop (pop)
719#endif
720 || pop->poc_handler == s_if
721 || pop->poc_handler == s_ifdef
722 || pop->poc_handler == s_ifc
723 || pop->poc_handler == s_ifeqs
724 || pop->poc_handler == s_else
a75abb6f
ILT
725 || pop->poc_handler == s_endif
726 || pop->poc_handler == s_globl
727 || pop->poc_handler == s_ignore)))
286cb27a 728 {
d428c89f 729 do_align (1, (char *) NULL, 0, 0);
286cb27a 730 mri_pending_align = 0;
a6b200da
ILT
731 if (line_label != NULL)
732 {
733 line_label->sy_frag = frag_now;
734 S_SET_VALUE (line_label, frag_now_fix ());
735 }
286cb27a
ILT
736 }
737
6efd877d 738 /* Print the error msg now, while we still can */
8ff6f40e 739 if (pop == NULL)
6efd877d
KR
740 {
741 as_bad ("Unknown pseudo-op: `%s'", s);
f8701a3f 742 *input_line_pointer = c;
6efd877d 743 s_ignore (0);
46b81190 744 continue;
6efd877d
KR
745 }
746
747 /* Put it back for error messages etc. */
748 *input_line_pointer = c;
9c6d3f66
KR
749 /* The following skip of whitespace is compulsory.
750 A well shaped space is sometimes all that separates
751 keyword from operands. */
6efd877d 752 if (c == ' ' || c == '\t')
d4c8cbd8 753 input_line_pointer++;
6efd877d 754 /*
9471a360
KR
755 * Input_line is restored.
756 * Input_line_pointer->1st non-blank char
757 * after pseudo-operation.
758 */
46b81190 759 (*pop->poc_handler) (pop->poc_val);
e28c40d7
ILT
760
761 /* If that was .end, just get out now. */
762 if (pop->poc_handler == s_end)
763 goto quit;
6efd877d
KR
764 }
765 else
20868ec6 766 {
4026c122
ILT
767 int inquote = 0;
768
6efd877d
KR
769 /* WARNING: c has char, which may be end-of-line. */
770 /* Also: input_line_pointer->`\0` where c was. */
771 *input_line_pointer = c;
58d4951d 772 while (!is_end_of_line[(unsigned char) *input_line_pointer]
4026c122 773 || inquote
4064305e
SS
774#ifdef TC_EOL_IN_INSN
775 || TC_EOL_IN_INSN (input_line_pointer)
776#endif
777 )
6efd877d 778 {
cef72a92 779 if (flag_m68k_mri && *input_line_pointer == '\'')
4026c122 780 inquote = ! inquote;
6efd877d
KR
781 input_line_pointer++;
782 }
f8701a3f 783
6efd877d
KR
784 c = *input_line_pointer;
785 *input_line_pointer = '\0';
f8701a3f 786
cd924033
ILT
787 if (debug_type == DEBUG_STABS)
788 stabs_generate_asm_lineno ();
789
326d16ca 790#ifdef OBJ_GENERATE_ASM_LINENO
cd924033
ILT
791#ifdef ECOFF_DEBUGGING
792 /* ECOFF assemblers automatically generate
793 debugging information. FIXME: This should
794 probably be handled elsewhere. */
795 if (debug_type == DEBUG_NONE)
326d16ca 796 {
cd924033
ILT
797 if (ecoff_no_current_file ())
798 debug_type = DEBUG_ECOFF;
326d16ca 799 }
cd924033
ILT
800
801 if (debug_type == DEBUG_ECOFF)
f10a96cb 802 {
1b434ced
ILT
803 unsigned int lineno;
804 char *s;
805
daad3bbf 806 as_where (&s, &lineno);
326d16ca 807 OBJ_GENERATE_ASM_LINENO (s, lineno);
cd924033
ILT
808 }
809#endif
daad3bbf
KH
810#endif
811
7e047ac2
ILT
812 if (macro_defined)
813 {
814 sb out;
815 const char *err;
816
817 if (check_macro (s, &out, '\0', &err))
818 {
819 if (err != NULL)
820 as_bad (err);
821 *input_line_pointer++ = c;
822 input_scrub_include_sb (&out,
823 input_line_pointer);
824 sb_kill (&out);
825 buffer_limit =
826 input_scrub_next_buffer (&input_line_pointer);
827 continue;
828 }
829 }
830
20868ec6
ILT
831 if (mri_pending_align)
832 {
d428c89f 833 do_align (1, (char *) NULL, 0, 0);
20868ec6 834 mri_pending_align = 0;
a6b200da
ILT
835 if (line_label != NULL)
836 {
837 line_label->sy_frag = frag_now;
838 S_SET_VALUE (line_label, frag_now_fix ());
839 }
20868ec6
ILT
840 }
841
6efd877d 842 md_assemble (s); /* Assemble 1 instruction. */
f8701a3f 843
6efd877d 844 *input_line_pointer++ = c;
f8701a3f 845
d4c8cbd8
JL
846 /* We resume loop AFTER the end-of-line from
847 this instruction. */
6efd877d 848 } /* if (*s=='.') */
6efd877d 849 } /* if c==':' */
f8701a3f 850 continue;
6efd877d 851 } /* if (is_name_beginner(c) */
f8701a3f 852
f8701a3f 853
d4c8cbd8 854 /* Empty statement? */
58d4951d 855 if (is_end_of_line[(unsigned char) c])
d4c8cbd8 856 continue;
6efd877d 857
9777b772
KR
858 if ((LOCAL_LABELS_DOLLAR || LOCAL_LABELS_FB)
859 && isdigit (c))
d4c8cbd8
JL
860 {
861 /* local label ("4:") */
6efd877d
KR
862 char *backup = input_line_pointer;
863
864 HANDLE_CONDITIONAL_ASSEMBLY ();
865
866 temp = c - '0';
867
868 while (isdigit (*input_line_pointer))
869 {
870 temp = (temp * 10) + *input_line_pointer - '0';
871 ++input_line_pointer;
872 } /* read the whole number */
873
9777b772
KR
874 if (LOCAL_LABELS_DOLLAR
875 && *input_line_pointer == '$'
6efd877d
KR
876 && *(input_line_pointer + 1) == ':')
877 {
878 input_line_pointer += 2;
879
880 if (dollar_label_defined (temp))
881 {
882 as_fatal ("label \"%d$\" redefined", temp);
883 }
884
885 define_dollar_label (temp);
886 colon (dollar_label_name (temp, 0));
887 continue;
888 }
6efd877d 889
9777b772
KR
890 if (LOCAL_LABELS_FB
891 && *input_line_pointer++ == ':')
6efd877d
KR
892 {
893 fb_label_instance_inc (temp);
894 colon (fb_label_name (temp, 0));
895 continue;
896 }
6efd877d
KR
897
898 input_line_pointer = backup;
899 } /* local label ("4:") */
f8701a3f 900
6efd877d
KR
901 if (c && strchr (line_comment_chars, c))
902 { /* Its a comment. Better say APP or NO_APP */
f8701a3f
SC
903 char *ends;
904 char *new_buf;
905 char *new_tmp;
604633ae 906 unsigned int new_length;
f8701a3f 907 char *tmp_buf = 0;
6efd877d
KR
908
909 bump_line_counters ();
910 s = input_line_pointer;
911 if (strncmp (s, "APP\n", 4))
912 continue; /* We ignore it */
913 s += 4;
914
915 ends = strstr (s, "#NO_APP\n");
916
917 if (!ends)
918 {
604633ae
ILT
919 unsigned int tmp_len;
920 unsigned int num;
6efd877d 921
f8701a3f
SC
922 /* The end of the #APP wasn't in this buffer. We
923 keep reading in buffers until we find the #NO_APP
924 that goes with this #APP There is one. The specs
925 guarentee it. . . */
6efd877d 926 tmp_len = buffer_limit - s;
85825401 927 tmp_buf = xmalloc (tmp_len + 1);
4380166d 928 memcpy (tmp_buf, s, tmp_len);
6efd877d
KR
929 do
930 {
931 new_tmp = input_scrub_next_buffer (&buffer);
f8701a3f 932 if (!new_tmp)
6efd877d 933 break;
f8701a3f 934 else
6efd877d 935 buffer_limit = new_tmp;
f8701a3f 936 input_line_pointer = buffer;
6efd877d 937 ends = strstr (buffer, "#NO_APP\n");
f8701a3f 938 if (ends)
6efd877d 939 num = ends - buffer;
f8701a3f 940 else
6efd877d
KR
941 num = buffer_limit - buffer;
942
943 tmp_buf = xrealloc (tmp_buf, tmp_len + num);
9eb5f4b8 944 memcpy (tmp_buf + tmp_len, buffer, num);
6efd877d
KR
945 tmp_len += num;
946 }
947 while (!ends);
948
949 input_line_pointer = ends ? ends + 8 : NULL;
950
951 s = tmp_buf;
952 ends = s + tmp_len;
953
954 }
955 else
956 {
957 input_line_pointer = ends + 8;
958 }
6efd877d
KR
959
960 scrub_string = s;
86038ada
ILT
961 scrub_string_end = ends;
962
963 new_length = ends - s;
964 new_buf = (char *) xmalloc (new_length);
965 new_tmp = new_buf;
6efd877d
KR
966 for (;;)
967 {
86038ada
ILT
968 int space;
969 int size;
f8701a3f 970
86038ada
ILT
971 space = (new_buf + new_length) - new_tmp;
972 size = do_scrub_chars (scrub_from_string, new_tmp, space);
973
974 if (size < space)
6efd877d 975 {
86038ada
ILT
976 new_tmp += size;
977 break;
f8701a3f 978 }
86038ada
ILT
979
980 new_buf = xrealloc (new_buf, new_length + 100);
981 new_tmp = new_buf + new_length;
982 new_length += 100;
fecd2382 983 }
f8701a3f
SC
984
985 if (tmp_buf)
6efd877d
KR
986 free (tmp_buf);
987 old_buffer = buffer;
988 old_input = input_line_pointer;
989 old_limit = buffer_limit;
990 buffer = new_buf;
991 input_line_pointer = new_buf;
992 buffer_limit = new_tmp;
f8701a3f
SC
993 continue;
994 }
995
6efd877d 996 HANDLE_CONDITIONAL_ASSEMBLY ();
f8701a3f 997
cef72a92
ILT
998#ifdef tc_unrecognized_line
999 if (tc_unrecognized_line (c))
1000 continue;
1001#endif
1002
f8701a3f
SC
1003 /* as_warn("Junk character %d.",c); Now done by ignore_rest */
1004 input_line_pointer--; /* Report unknown char as ignored. */
6efd877d
KR
1005 ignore_rest_of_line ();
1006 } /* while (input_line_pointer<buffer_limit) */
a2a5a4fa
KR
1007
1008#ifdef md_after_pass_hook
1009 md_after_pass_hook ();
1010#endif
1011
6efd877d
KR
1012 if (old_buffer)
1013 {
86038ada 1014 free (buffer);
6efd877d
KR
1015 bump_line_counters ();
1016 if (old_input != 0)
1017 {
1018 buffer = old_buffer;
1019 input_line_pointer = old_input;
1020 buffer_limit = old_limit;
f8701a3f
SC
1021 old_buffer = 0;
1022 goto contin;
1023 }
1024 }
6efd877d 1025 } /* while (more buffers to scan) */
f8701a3f 1026
e28c40d7 1027 quit:
20868ec6
ILT
1028
1029#ifdef md_cleanup
1030 md_cleanup();
1031#endif
e28c40d7 1032 input_scrub_close (); /* Close the input file */
4075afe1 1033}
fecd2382 1034
18c9057f
ILT
1035/* For most MRI pseudo-ops, the line actually ends at the first
1036 nonquoted space. This function looks for that point, stuffs a null
1037 in, and sets *STOPCP to the character that used to be there, and
42ac8fa8
ILT
1038 returns the location.
1039
1040 Until I hear otherwise, I am going to assume that this is only true
1041 for the m68k MRI assembler. */
18c9057f
ILT
1042
1043char *
1044mri_comment_field (stopcp)
1045 char *stopcp;
1046{
42ac8fa8
ILT
1047#ifdef TC_M68K
1048
18c9057f
ILT
1049 char *s;
1050 int inquote = 0;
1051
cef72a92 1052 know (flag_m68k_mri);
18c9057f
ILT
1053
1054 for (s = input_line_pointer;
1055 ((! is_end_of_line[(unsigned char) *s] && *s != ' ' && *s != '\t')
1056 || inquote);
1057 s++)
1058 {
1059 if (*s == '\'')
1060 inquote = ! inquote;
1061 }
1062 *stopcp = *s;
1063 *s = '\0';
1064 return s;
42ac8fa8
ILT
1065
1066#else
1067
1068 char *s;
1069
1070 for (s = input_line_pointer; ! is_end_of_line[(unsigned char) *s]; s++)
1071 ;
1072 *stopcp = *s;
1073 *s = '\0';
1074 return s;
1075
1076#endif
1077
18c9057f
ILT
1078}
1079
1080/* Skip to the end of an MRI comment field. */
1081
1082void
1083mri_comment_end (stop, stopc)
1084 char *stop;
1085 int stopc;
1086{
1087 know (flag_mri);
1088
1089 input_line_pointer = stop;
1090 *stop = stopc;
1091 while (! is_end_of_line[(unsigned char) *input_line_pointer])
1092 ++input_line_pointer;
1093}
1094
6efd877d 1095void
604633ae
ILT
1096s_abort (ignore)
1097 int ignore;
6efd877d
KR
1098{
1099 as_fatal (".abort detected. Abandoning ship.");
4075afe1
KR
1100}
1101
d428c89f
ILT
1102/* Guts of .align directive. N is the power of two to which to align.
1103 FILL may be NULL, or it may point to the bytes of the fill pattern.
1104 LEN is the length of whatever FILL points to, if anything. MAX is
1105 the maximum number of characters to skip when doing the alignment,
1106 or 0 if there is no maximum. */
1107
4075afe1 1108static void
d428c89f 1109do_align (n, fill, len, max)
4075afe1
KR
1110 int n;
1111 char *fill;
71dd3c40 1112 int len;
d428c89f 1113 int max;
4075afe1 1114{
d428c89f
ILT
1115 char default_fill;
1116
4075afe1 1117#ifdef md_do_align
d428c89f 1118 md_do_align (n, fill, len, max, just_record_alignment);
4075afe1 1119#endif
4075afe1 1120
d428c89f
ILT
1121 if (fill == NULL)
1122 {
cd924033
ILT
1123 int maybe_text;
1124
1125#ifdef BFD_ASSEMBLER
1126 if ((bfd_get_section_flags (stdoutput, now_seg) & SEC_CODE) != 0)
1127 maybe_text = 1;
1128 else
1129 maybe_text = 0;
1130#else
4075afe1 1131 if (now_seg != data_section && now_seg != bss_section)
cd924033
ILT
1132 maybe_text = 1;
1133 else
1134 maybe_text = 0;
1135#endif
1136
1137 if (maybe_text)
d428c89f 1138 default_fill = NOP_OPCODE;
4075afe1 1139 else
d428c89f
ILT
1140 default_fill = 0;
1141 fill = &default_fill;
71dd3c40 1142 len = 1;
4075afe1 1143 }
71dd3c40 1144
4075afe1 1145 /* Only make a frag if we HAVE to. . . */
d428c89f 1146 if (n != 0 && !need_pass_2)
71dd3c40
ILT
1147 {
1148 if (len <= 1)
d428c89f 1149 frag_align (n, *fill, max);
71dd3c40 1150 else
d428c89f 1151 frag_align_pattern (n, fill, len, max);
71dd3c40 1152 }
4075afe1 1153
c02fd8dc 1154#ifdef md_do_align
4075afe1 1155 just_record_alignment:
c02fd8dc
ILT
1156#endif
1157
4075afe1
KR
1158 record_alignment (now_seg, n);
1159}
fecd2382 1160
d428c89f
ILT
1161/* Handle the .align pseudo-op. A positive ARG is a default alignment
1162 (in bytes). A negative ARG is the negative of the length of the
1163 fill pattern. BYTES_P is non-zero if the alignment value should be
1164 interpreted as the byte boundary, rather than the power of 2. */
1165
1166static void
1167s_align (arg, bytes_p)
6efd877d 1168 int arg;
d428c89f 1169 int bytes_p;
fecd2382 1170{
d428c89f 1171 register unsigned int align;
18c9057f
ILT
1172 char *stop = NULL;
1173 char stopc;
d428c89f
ILT
1174 offsetT fill = 0;
1175 int max;
1176 int fill_p;
18c9057f
ILT
1177
1178 if (flag_mri)
1179 stop = mri_comment_field (&stopc);
f8701a3f 1180
58d4951d 1181 if (is_end_of_line[(unsigned char) *input_line_pointer])
4080c270
ILT
1182 {
1183 if (arg < 0)
d428c89f 1184 align = 0;
4080c270 1185 else
d428c89f 1186 align = arg; /* Default value from pseudo-op table */
4080c270 1187 }
6efd877d 1188 else
6efd877d 1189 {
d428c89f
ILT
1190 align = get_absolute_expression ();
1191 SKIP_WHITESPACE ();
f8701a3f
SC
1192 }
1193
d428c89f 1194 if (bytes_p)
6efd877d 1195 {
d428c89f
ILT
1196 /* Convert to a power of 2. */
1197 if (align != 0)
1198 {
1199 unsigned int i;
1200
1201 for (i = 0; (align & 1) == 0; align >>= 1, ++i)
1202 ;
1203 if (align != 1)
1204 as_bad ("Alignment not a power of 2");
1205 align = i;
1206 }
f8701a3f 1207 }
f8701a3f 1208
d428c89f 1209 if (align > 15)
6efd877d 1210 {
d428c89f
ILT
1211 align = 15;
1212 as_bad ("Alignment too large: %u assumed", align);
1213 }
71dd3c40 1214
d428c89f
ILT
1215 if (*input_line_pointer != ',')
1216 {
1217 fill_p = 0;
1218 max = 0;
1219 }
1220 else
1221 {
1222 ++input_line_pointer;
1223 if (*input_line_pointer == ',')
1224 fill_p = 0;
4080c270 1225 else
71dd3c40 1226 {
d428c89f
ILT
1227 fill = get_absolute_expression ();
1228 SKIP_WHITESPACE ();
1229 fill_p = 1;
71dd3c40 1230 }
d428c89f
ILT
1231
1232 if (*input_line_pointer != ',')
1233 max = 0;
71dd3c40
ILT
1234 else
1235 {
d428c89f
ILT
1236 ++input_line_pointer;
1237 max = get_absolute_expression ();
71dd3c40 1238 }
f8701a3f 1239 }
d428c89f
ILT
1240
1241 if (! fill_p)
71dd3c40 1242 {
4080c270 1243 if (arg < 0)
71dd3c40 1244 as_warn ("expected fill pattern missing");
d428c89f 1245 do_align (align, (char *) NULL, 0, max);
6efd877d 1246 }
d428c89f 1247 else
6efd877d 1248 {
d428c89f 1249 int fill_len;
71dd3c40 1250
4080c270 1251 if (arg >= 0)
d428c89f 1252 fill_len = 1;
4080c270 1253 else
d428c89f
ILT
1254 fill_len = - arg;
1255 if (fill_len <= 1)
71dd3c40 1256 {
d428c89f
ILT
1257 char fill_char;
1258
1259 fill_char = fill;
1260 do_align (align, &fill_char, fill_len, max);
71dd3c40
ILT
1261 }
1262 else
1263 {
1264 char ab[16];
1265
d428c89f 1266 if (fill_len > sizeof ab)
71dd3c40 1267 abort ();
d428c89f
ILT
1268 md_number_to_chars (ab, fill, fill_len);
1269 do_align (align, ab, fill_len, max);
71dd3c40 1270 }
6efd877d 1271 }
6efd877d 1272
18c9057f
ILT
1273 if (flag_mri)
1274 mri_comment_end (stop, stopc);
1275
6efd877d 1276 demand_empty_rest_of_line ();
4075afe1 1277}
6efd877d 1278
d428c89f
ILT
1279/* Handle the .align pseudo-op on machines where ".align 4" means
1280 align to a 4 byte boundary. */
1281
1282void
1283s_align_bytes (arg)
1284 int arg;
1285{
1286 s_align (arg, 1);
1287}
1288
1289/* Handle the .align pseud-op on machines where ".align 4" means align
1290 to a 2**4 boundary. */
1291
1292void
1293s_align_ptwo (arg)
1294 int arg;
1295{
1296 s_align (arg, 0);
1297}
1298
6efd877d 1299void
604633ae
ILT
1300s_comm (ignore)
1301 int ignore;
6efd877d
KR
1302{
1303 register char *name;
1304 register char c;
1305 register char *p;
58d4951d 1306 offsetT temp;
6efd877d 1307 register symbolS *symbolP;
18c9057f
ILT
1308 char *stop = NULL;
1309 char stopc;
1310
1311 if (flag_mri)
1312 stop = mri_comment_field (&stopc);
6efd877d
KR
1313
1314 name = input_line_pointer;
1315 c = get_symbol_end ();
1316 /* just after name is now '\0' */
1317 p = input_line_pointer;
1318 *p = c;
1319 SKIP_WHITESPACE ();
1320 if (*input_line_pointer != ',')
1321 {
1322 as_bad ("Expected comma after symbol-name: rest of line ignored.");
18c9057f
ILT
1323 if (flag_mri)
1324 mri_comment_end (stop, stopc);
6efd877d
KR
1325 ignore_rest_of_line ();
1326 return;
1327 }
1328 input_line_pointer++; /* skip ',' */
1329 if ((temp = get_absolute_expression ()) < 0)
1330 {
58d4951d 1331 as_warn (".COMMon length (%ld.) <0! Ignored.", (long) temp);
18c9057f
ILT
1332 if (flag_mri)
1333 mri_comment_end (stop, stopc);
6efd877d
KR
1334 ignore_rest_of_line ();
1335 return;
1336 }
1337 *p = 0;
1338 symbolP = symbol_find_or_make (name);
1339 *p = c;
cd924033 1340 if (S_IS_DEFINED (symbolP) && ! S_IS_COMMON (symbolP))
6efd877d 1341 {
6ef37255
KR
1342 as_bad ("Ignoring attempt to re-define symbol `%s'.",
1343 S_GET_NAME (symbolP));
18c9057f
ILT
1344 if (flag_mri)
1345 mri_comment_end (stop, stopc);
6efd877d
KR
1346 ignore_rest_of_line ();
1347 return;
1348 }
1349 if (S_GET_VALUE (symbolP))
1350 {
58d4951d
ILT
1351 if (S_GET_VALUE (symbolP) != (valueT) temp)
1352 as_bad ("Length of .comm \"%s\" is already %ld. Not changed to %ld.",
6efd877d 1353 S_GET_NAME (symbolP),
58d4951d
ILT
1354 (long) S_GET_VALUE (symbolP),
1355 (long) temp);
6efd877d
KR
1356 }
1357 else
1358 {
58d4951d 1359 S_SET_VALUE (symbolP, (valueT) temp);
6efd877d
KR
1360 S_SET_EXTERNAL (symbolP);
1361 }
9471a360 1362#ifdef OBJ_VMS
def66e24
DM
1363 {
1364 extern int flag_one;
1365 if ( (!temp) || !flag_one)
1366 S_GET_OTHER(symbolP) = const_flag;
1367 }
9471a360 1368#endif /* not OBJ_VMS */
6efd877d 1369 know (symbolP->sy_frag == &zero_address_frag);
18c9057f
ILT
1370
1371 if (flag_mri)
1372 mri_comment_end (stop, stopc);
1373
6efd877d
KR
1374 demand_empty_rest_of_line ();
1375} /* s_comm() */
fecd2382 1376
1356d77d
ILT
1377/* The MRI COMMON pseudo-op. We handle this by creating a common
1378 symbol with the appropriate name. We make s_space do the right
1379 thing by increasing the size. */
1380
1381void
1382s_mri_common (small)
1383 int small;
1384{
1385 char *name;
1386 char c;
1387 char *alc = NULL;
1388 symbolS *sym;
1389 offsetT align;
18c9057f
ILT
1390 char *stop = NULL;
1391 char stopc;
1356d77d
ILT
1392
1393 if (! flag_mri)
1394 {
1395 s_comm (0);
1396 return;
1397 }
1398
18c9057f
ILT
1399 stop = mri_comment_field (&stopc);
1400
1356d77d
ILT
1401 SKIP_WHITESPACE ();
1402
1403 name = input_line_pointer;
1404 if (! isdigit ((unsigned char) *name))
1405 c = get_symbol_end ();
1406 else
1407 {
1408 do
1409 {
1410 ++input_line_pointer;
1411 }
1412 while (isdigit ((unsigned char) *input_line_pointer));
1413 c = *input_line_pointer;
1414 *input_line_pointer = '\0';
1415
7e047ac2 1416 if (line_label != NULL)
1356d77d 1417 {
7e047ac2 1418 alc = (char *) xmalloc (strlen (S_GET_NAME (line_label))
1356d77d
ILT
1419 + (input_line_pointer - name)
1420 + 1);
7e047ac2 1421 sprintf (alc, "%s%s", name, S_GET_NAME (line_label));
1356d77d
ILT
1422 name = alc;
1423 }
1424 }
1425
1426 sym = symbol_find_or_make (name);
1427 *input_line_pointer = c;
1428 if (alc != NULL)
1429 free (alc);
1430
1431 if (*input_line_pointer != ',')
1432 align = 0;
1433 else
1434 {
1435 ++input_line_pointer;
1436 align = get_absolute_expression ();
1437 }
1438
cd924033 1439 if (S_IS_DEFINED (sym) && ! S_IS_COMMON (sym))
1356d77d 1440 {
cd924033
ILT
1441 as_bad ("attempt to re-define symbol `%s'", S_GET_NAME (sym));
1442 mri_comment_end (stop, stopc);
1443 ignore_rest_of_line ();
1444 return;
1356d77d
ILT
1445 }
1446
1447 S_SET_EXTERNAL (sym);
1448 mri_common_symbol = sym;
1449
1450#ifdef S_SET_ALIGN
1451 if (align != 0)
1452 S_SET_ALIGN (sym, align);
1453#endif
1454
7e047ac2 1455 if (line_label != NULL)
1356d77d 1456 {
7e047ac2
ILT
1457 line_label->sy_value.X_op = O_symbol;
1458 line_label->sy_value.X_add_symbol = sym;
1459 line_label->sy_value.X_add_number = S_GET_VALUE (sym);
1460 line_label->sy_frag = &zero_address_frag;
1461 S_SET_SEGMENT (line_label, expr_section);
1356d77d
ILT
1462 }
1463
1464 /* FIXME: We just ignore the small argument, which distinguishes
1465 COMMON and COMMON.S. I don't know what we can do about it. */
1466
1467 /* Ignore the type and hptype. */
1468 if (*input_line_pointer == ',')
1469 input_line_pointer += 2;
1470 if (*input_line_pointer == ',')
1471 input_line_pointer += 2;
18c9057f
ILT
1472
1473 mri_comment_end (stop, stopc);
1474
1356d77d
ILT
1475 demand_empty_rest_of_line ();
1476}
1477
fecd2382 1478void
604633ae
ILT
1479s_data (ignore)
1480 int ignore;
fecd2382 1481{
ffffc8fb 1482 segT section;
6efd877d 1483 register int temp;
f8701a3f 1484
6efd877d 1485 temp = get_absolute_expression ();
def66e24 1486 if (flag_readonly_data_in_text)
ffffc8fb
ILT
1487 {
1488 section = text_section;
1489 temp += 1000;
1490 }
1491 else
1492 section = data_section;
1493
ffffc8fb 1494 subseg_set (section, (subsegT) temp);
f8701a3f 1495
9471a360 1496#ifdef OBJ_VMS
6efd877d 1497 const_flag = 0;
fecd2382 1498#endif
6efd877d 1499 demand_empty_rest_of_line ();
fecd2382
RP
1500}
1501
9a7d824a 1502/* Handle the .appfile pseudo-op. This is automatically generated by
86038ada
ILT
1503 do_scrub_chars when a preprocessor # line comment is seen with a
1504 file name. This default definition may be overridden by the object
1505 or CPU specific pseudo-ops. This function is also the default
1506 definition for .file; the APPFILE argument is 1 for .appfile, 0 for
1507 .file. */
9a7d824a 1508
6efd877d 1509void
9a7d824a
ILT
1510s_app_file (appfile)
1511 int appfile;
6efd877d
KR
1512{
1513 register char *s;
1514 int length;
f8701a3f 1515
6efd877d
KR
1516 /* Some assemblers tolerate immediately following '"' */
1517 if ((s = demand_copy_string (&length)) != 0)
1518 {
9a7d824a
ILT
1519 /* If this is a fake .appfile, a fake newline was inserted into
1520 the buffer. Passing -2 to new_logical_line tells it to
1521 account for it. */
1522 new_logical_line (s, appfile ? -2 : -1);
cef72a92
ILT
1523
1524 /* In MRI mode, the preprocessor may have inserted an extraneous
1525 backquote. */
1526 if (flag_m68k_mri
1527 && *input_line_pointer == '\''
1528 && is_end_of_line[(unsigned char) input_line_pointer[1]])
1529 ++input_line_pointer;
1530
6efd877d 1531 demand_empty_rest_of_line ();
9a7d824a
ILT
1532#ifdef LISTING
1533 if (listing)
1534 listing_source_file (s);
1535#endif
cd924033 1536 register_dependency (s);
6efd877d 1537 }
2209b19c
KR
1538#ifdef obj_app_file
1539 obj_app_file (s);
40324362
KR
1540#endif
1541}
fecd2382 1542
9a7d824a 1543/* Handle the .appline pseudo-op. This is automatically generated by
86038ada
ILT
1544 do_scrub_chars when a preprocessor # line comment is seen. This
1545 default definition may be overridden by the object or CPU specific
1546 pseudo-ops. */
9a7d824a
ILT
1547
1548void
604633ae
ILT
1549s_app_line (ignore)
1550 int ignore;
9a7d824a
ILT
1551{
1552 int l;
1553
1554 /* The given number is that of the next line. */
1555 l = get_absolute_expression () - 1;
931a8fab
KR
1556 if (l < 0)
1557 /* Some of the back ends can't deal with non-positive line numbers.
1558 Besides, it's silly. */
1559 as_warn ("Line numbers must be positive; line number %d rejected.", l+1);
1560 else
1561 {
1562 new_logical_line ((char *) NULL, l);
9a7d824a 1563#ifdef LISTING
931a8fab
KR
1564 if (listing)
1565 listing_source_line (l);
9a7d824a 1566#endif
931a8fab 1567 }
9a7d824a
ILT
1568 demand_empty_rest_of_line ();
1569}
1570
e28c40d7
ILT
1571/* Handle the .end pseudo-op. Actually, the real work is done in
1572 read_a_source_file. */
1573
1574void
1575s_end (ignore)
1576 int ignore;
1577{
1578 if (flag_mri)
1579 {
1580 /* The MRI assembler permits the start symbol to follow .end,
1581 but we don't support that. */
1582 SKIP_WHITESPACE ();
18c9057f
ILT
1583 if (! is_end_of_line[(unsigned char) *input_line_pointer]
1584 && *input_line_pointer != '*'
1585 && *input_line_pointer != '!')
e28c40d7
ILT
1586 as_warn ("start address not supported");
1587 }
1588}
1589
42ac8fa8
ILT
1590/* Handle the .err pseudo-op. */
1591
1592void
1593s_err (ignore)
1594 int ignore;
1595{
1596 as_bad (".err encountered");
1597 demand_empty_rest_of_line ();
1598}
1599
e28c40d7
ILT
1600/* Handle the MRI fail pseudo-op. */
1601
1602void
1603s_fail (ignore)
1604 int ignore;
1605{
1606 offsetT temp;
18c9057f
ILT
1607 char *stop = NULL;
1608 char stopc;
1609
1610 if (flag_mri)
1611 stop = mri_comment_field (&stopc);
e28c40d7
ILT
1612
1613 temp = get_absolute_expression ();
1614 if (temp >= 500)
1615 as_warn (".fail %ld encountered", (long) temp);
1616 else
1617 as_bad (".fail %ld encountered", (long) temp);
18c9057f
ILT
1618
1619 if (flag_mri)
1620 mri_comment_end (stop, stopc);
1621
e28c40d7
ILT
1622 demand_empty_rest_of_line ();
1623}
1624
6efd877d 1625void
604633ae
ILT
1626s_fill (ignore)
1627 int ignore;
6efd877d
KR
1628{
1629 long temp_repeat = 0;
1630 long temp_size = 1;
1631 register long temp_fill = 0;
1632 char *p;
f8701a3f 1633
624c91d1
KR
1634#ifdef md_flush_pending_output
1635 md_flush_pending_output ();
1636#endif
7c2d4011 1637
6efd877d
KR
1638 temp_repeat = get_absolute_expression ();
1639 if (*input_line_pointer == ',')
1640 {
1641 input_line_pointer++;
1642 temp_size = get_absolute_expression ();
1643 if (*input_line_pointer == ',')
7c2d4011
SC
1644 {
1645 input_line_pointer++;
6efd877d 1646 temp_fill = get_absolute_expression ();
fecd2382 1647 }
6efd877d 1648 }
c8863a58 1649 /* This is to be compatible with BSD 4.2 AS, not for any rational reason. */
fecd2382 1650#define BSD_FILL_SIZE_CROCK_8 (8)
6efd877d
KR
1651 if (temp_size > BSD_FILL_SIZE_CROCK_8)
1652 {
1653 as_warn (".fill size clamped to %d.", BSD_FILL_SIZE_CROCK_8);
1654 temp_size = BSD_FILL_SIZE_CROCK_8;
1655 }
1656 if (temp_size < 0)
1657 {
1658 as_warn ("Size negative: .fill ignored.");
1659 temp_size = 0;
1660 }
1661 else if (temp_repeat <= 0)
1662 {
a69e5977
ILT
1663 if (temp_repeat < 0)
1664 as_warn ("Repeat < 0, .fill ignored");
6efd877d
KR
1665 temp_size = 0;
1666 }
7fd3560a 1667
6efd877d
KR
1668 if (temp_size && !need_pass_2)
1669 {
cd924033
ILT
1670 p = frag_var (rs_fill, (int) temp_size, (int) temp_size,
1671 (relax_substateT) 0, (symbolS *) 0, (offsetT) temp_repeat,
1672 (char *) 0);
604633ae 1673 memset (p, 0, (unsigned int) temp_size);
c8863a58
KR
1674 /* The magic number BSD_FILL_SIZE_CROCK_4 is from BSD 4.2 VAX
1675 * flavoured AS. The following bizzare behaviour is to be
1676 * compatible with above. I guess they tried to take up to 8
1677 * bytes from a 4-byte expression and they forgot to sign
1678 * extend. Un*x Sux. */
fecd2382 1679#define BSD_FILL_SIZE_CROCK_4 (4)
604633ae 1680 md_number_to_chars (p, (valueT) temp_fill,
c8863a58
KR
1681 (temp_size > BSD_FILL_SIZE_CROCK_4
1682 ? BSD_FILL_SIZE_CROCK_4
1683 : (int) temp_size));
1684 /* Note: .fill (),0 emits no frag (since we are asked to .fill 0 bytes)
1685 * but emits no error message because it seems a legal thing to do.
1686 * It is a degenerate case of .fill but could be emitted by a compiler.
1687 */
6efd877d 1688 }
6efd877d 1689 demand_empty_rest_of_line ();
f8701a3f
SC
1690}
1691
6efd877d 1692void
604633ae
ILT
1693s_globl (ignore)
1694 int ignore;
6efd877d 1695{
40324362
KR
1696 char *name;
1697 int c;
1698 symbolS *symbolP;
18c9057f
ILT
1699 char *stop = NULL;
1700 char stopc;
1701
1702 if (flag_mri)
1703 stop = mri_comment_field (&stopc);
fecd2382 1704
6efd877d
KR
1705 do
1706 {
1707 name = input_line_pointer;
1708 c = get_symbol_end ();
1709 symbolP = symbol_find_or_make (name);
1710 *input_line_pointer = c;
1711 SKIP_WHITESPACE ();
1712 S_SET_EXTERNAL (symbolP);
1713 if (c == ',')
1714 {
1715 input_line_pointer++;
1716 SKIP_WHITESPACE ();
1717 if (*input_line_pointer == '\n')
1718 c = '\n';
1719 }
1720 }
1721 while (c == ',');
18c9057f
ILT
1722
1723 if (flag_mri)
1724 mri_comment_end (stop, stopc);
1725
6efd877d 1726 demand_empty_rest_of_line ();
40324362 1727}
6efd877d 1728
7e047ac2
ILT
1729/* Handle the MRI IRP and IRPC pseudo-ops. */
1730
1731void
1732s_irp (irpc)
1733 int irpc;
1734{
1735 char *file;
1736 unsigned int line;
1737 sb s;
1738 const char *err;
1739 sb out;
1740
1741 as_where (&file, &line);
1742
1743 sb_new (&s);
1744 while (! is_end_of_line[(unsigned char) *input_line_pointer])
1745 sb_add_char (&s, *input_line_pointer++);
1746
1747 sb_new (&out);
1748
1749 err = expand_irp (irpc, 0, &s, &out, get_line_sb, '\0');
1750 if (err != NULL)
1751 as_bad_where (file, line, "%s", err);
1752
1753 sb_kill (&s);
1754
1755 input_scrub_include_sb (&out, input_line_pointer);
1756 sb_kill (&out);
1757 buffer_limit = input_scrub_next_buffer (&input_line_pointer);
1758}
1759
7d3741ed
ILT
1760/* Handle the .linkonce pseudo-op. This tells the assembler to mark
1761 the section to only be linked once. However, this is not supported
1762 by most object file formats. This takes an optional argument,
1763 which is what to do about duplicates. */
1764
1765void
1766s_linkonce (ignore)
1767 int ignore;
1768{
1769 enum linkonce_type type;
1770
1771 SKIP_WHITESPACE ();
1772
1773 type = LINKONCE_DISCARD;
1774
1775 if (! is_end_of_line[(unsigned char) *input_line_pointer])
1776 {
1777 char *s;
1778 char c;
1779
1780 s = input_line_pointer;
1781 c = get_symbol_end ();
1782 if (strcasecmp (s, "discard") == 0)
1783 type = LINKONCE_DISCARD;
1784 else if (strcasecmp (s, "one_only") == 0)
1785 type = LINKONCE_ONE_ONLY;
1786 else if (strcasecmp (s, "same_size") == 0)
1787 type = LINKONCE_SAME_SIZE;
1788 else if (strcasecmp (s, "same_contents") == 0)
1789 type = LINKONCE_SAME_CONTENTS;
1790 else
1791 as_warn ("unrecognized .linkonce type `%s'", s);
1792
1793 *input_line_pointer = c;
1794 }
1795
1796#ifdef obj_handle_link_once
1797 obj_handle_link_once (type);
1798#else /* ! defined (obj_handle_link_once) */
1799#ifdef BFD_ASSEMBLER
1800 {
1801 flagword flags;
1802
1803 if ((bfd_applicable_section_flags (stdoutput) & SEC_LINK_ONCE) == 0)
1804 as_warn (".linkonce is not supported for this object file format");
1805
1806 flags = bfd_get_section_flags (stdoutput, now_seg);
1807 flags |= SEC_LINK_ONCE;
1808 switch (type)
1809 {
1810 default:
1811 abort ();
1812 case LINKONCE_DISCARD:
1813 flags |= SEC_LINK_DUPLICATES_DISCARD;
1814 break;
1815 case LINKONCE_ONE_ONLY:
1816 flags |= SEC_LINK_DUPLICATES_ONE_ONLY;
1817 break;
1818 case LINKONCE_SAME_SIZE:
1819 flags |= SEC_LINK_DUPLICATES_SAME_SIZE;
1820 break;
1821 case LINKONCE_SAME_CONTENTS:
1822 flags |= SEC_LINK_DUPLICATES_SAME_CONTENTS;
1823 break;
1824 }
1825 if (! bfd_set_section_flags (stdoutput, now_seg, flags))
1826 as_bad ("bfd_set_section_flags: %s",
1827 bfd_errmsg (bfd_get_error ()));
1828 }
1829#else /* ! defined (BFD_ASSEMBLER) */
1830 as_warn (".linkonce is not supported for this object file format");
1831#endif /* ! defined (BFD_ASSEMBLER) */
1832#endif /* ! defined (obj_handle_link_once) */
1833
1834 demand_empty_rest_of_line ();
1835}
1836
6efd877d
KR
1837void
1838s_lcomm (needs_align)
c8863a58
KR
1839 /* 1 if this was a ".bss" directive, which may require a 3rd argument
1840 (alignment); 0 if it was an ".lcomm" (2 args only) */
1841 int needs_align;
fecd2382 1842{
6efd877d
KR
1843 register char *name;
1844 register char c;
1845 register char *p;
1846 register int temp;
1847 register symbolS *symbolP;
9a7d824a
ILT
1848 segT current_seg = now_seg;
1849 subsegT current_subseg = now_subseg;
6efd877d
KR
1850 const int max_alignment = 15;
1851 int align = 0;
9a7d824a 1852 segT bss_seg = bss_section;
6efd877d
KR
1853
1854 name = input_line_pointer;
1855 c = get_symbol_end ();
1856 p = input_line_pointer;
1857 *p = c;
1858 SKIP_WHITESPACE ();
46b81190
ILT
1859
1860 /* Accept an optional comma after the name. The comma used to be
1861 required, but Irix 5 cc does not generate it. */
1862 if (*input_line_pointer == ',')
6efd877d 1863 {
46b81190
ILT
1864 ++input_line_pointer;
1865 SKIP_WHITESPACE ();
6efd877d 1866 }
f8701a3f 1867
6efd877d
KR
1868 if (*input_line_pointer == '\n')
1869 {
1870 as_bad ("Missing size expression");
1871 return;
1872 }
f8701a3f 1873
6efd877d
KR
1874 if ((temp = get_absolute_expression ()) < 0)
1875 {
1876 as_warn ("BSS length (%d.) <0! Ignored.", temp);
1877 ignore_rest_of_line ();
1878 return;
1879 }
f8701a3f 1880
2ef7731d 1881#if defined (TC_MIPS) || defined (TC_ALPHA)
a2a5a4fa
KR
1882 if (OUTPUT_FLAVOR == bfd_target_ecoff_flavour
1883 || OUTPUT_FLAVOR == bfd_target_elf_flavour)
46b81190 1884 {
a2a5a4fa
KR
1885 /* For MIPS and Alpha ECOFF or ELF, small objects are put in .sbss. */
1886 if (temp <= bfd_get_gp_size (stdoutput))
1887 {
1888 bss_seg = subseg_new (".sbss", 1);
1889 seg_info (bss_seg)->bss = 1;
b95bee13
ILT
1890#ifdef BFD_ASSEMBLER
1891 if (! bfd_set_section_flags (stdoutput, bss_seg, SEC_ALLOC))
1892 as_warn ("error setting flags for \".sbss\": %s",
1893 bfd_errmsg (bfd_get_error ()));
1894#endif
a2a5a4fa 1895 }
46b81190 1896 }
9a7d824a 1897#endif
ede7bc1c
SC
1898 if (!needs_align)
1899 {
1900 /* FIXME. This needs to be machine independent. */
9d90491e
ILT
1901 if (temp >= 8)
1902 align = 3;
1903 else if (temp >= 4)
ede7bc1c
SC
1904 align = 2;
1905 else if (temp >= 2)
1906 align = 1;
1907 else
c71a604a 1908 align = 0;
ede7bc1c 1909
a69e5977
ILT
1910#ifdef OBJ_EVAX
1911 /* FIXME: This needs to be done in a more general fashion. */
1912 align = 3;
1913#endif
1914
ede7bc1c
SC
1915 record_alignment(bss_seg, align);
1916 }
9a7d824a 1917
6efd877d
KR
1918 if (needs_align)
1919 {
1920 align = 0;
1921 SKIP_WHITESPACE ();
1922 if (*input_line_pointer != ',')
1923 {
1924 as_bad ("Expected comma after size");
1925 ignore_rest_of_line ();
1926 return;
1927 }
1928 input_line_pointer++;
1929 SKIP_WHITESPACE ();
1930 if (*input_line_pointer == '\n')
1931 {
1932 as_bad ("Missing alignment");
1933 return;
1934 }
1935 align = get_absolute_expression ();
1936 if (align > max_alignment)
1937 {
1938 align = max_alignment;
1939 as_warn ("Alignment too large: %d. assumed.", align);
1940 }
1941 else if (align < 0)
1942 {
1943 align = 0;
1944 as_warn ("Alignment negative. 0 assumed.");
1945 }
9a7d824a 1946 record_alignment (bss_seg, align);
6efd877d 1947 } /* if needs align */
4075afe1
KR
1948 else
1949 {
1950 /* Assume some objects may require alignment on some systems. */
a69e5977 1951#if defined (TC_ALPHA) && ! defined (VMS)
4075afe1
KR
1952 if (temp > 1)
1953 {
1954 align = ffs (temp) - 1;
1955 if (temp % (1 << align))
1956 abort ();
1957 }
1958#endif
1959 }
f8701a3f 1960
6efd877d
KR
1961 *p = 0;
1962 symbolP = symbol_find_or_make (name);
1963 *p = c;
f8701a3f 1964
6efd877d 1965 if (
fecd2382 1966#if defined(OBJ_AOUT) | defined(OBJ_BOUT)
6efd877d
KR
1967 S_GET_OTHER (symbolP) == 0 &&
1968 S_GET_DESC (symbolP) == 0 &&
fecd2382 1969#endif /* OBJ_AOUT or OBJ_BOUT */
9a7d824a 1970 (S_GET_SEGMENT (symbolP) == bss_seg
6efd877d
KR
1971 || (!S_IS_DEFINED (symbolP) && S_GET_VALUE (symbolP) == 0)))
1972 {
604633ae 1973 char *pfrag;
85825401 1974
9a7d824a 1975 subseg_set (bss_seg, 1);
85825401
ILT
1976
1977 if (align)
d428c89f 1978 frag_align (align, 0, 0);
85825401 1979 /* detach from old frag */
9a7d824a 1980 if (S_GET_SEGMENT (symbolP) == bss_seg)
85825401
ILT
1981 symbolP->sy_frag->fr_symbol = NULL;
1982
1983 symbolP->sy_frag = frag_now;
604633ae 1984 pfrag = frag_var (rs_org, 1, 1, (relax_substateT)0, symbolP,
cd924033 1985 (offsetT) temp, (char *) 0);
604633ae 1986 *pfrag = 0;
f8701a3f 1987
9a7d824a 1988 S_SET_SEGMENT (symbolP, bss_seg);
85825401 1989
fecd2382 1990#ifdef OBJ_COFF
6efd877d 1991 /* The symbol may already have been created with a preceding
c8863a58
KR
1992 ".globl" directive -- be careful not to step on storage class
1993 in that case. Otherwise, set it to static. */
6efd877d
KR
1994 if (S_GET_STORAGE_CLASS (symbolP) != C_EXT)
1995 {
1996 S_SET_STORAGE_CLASS (symbolP, C_STAT);
fecd2382 1997 }
6efd877d 1998#endif /* OBJ_COFF */
cef72a92
ILT
1999
2000#ifdef S_SET_SIZE
2001 S_SET_SIZE (symbolP, temp);
2002#endif
6efd877d
KR
2003 }
2004 else
6ef37255
KR
2005 as_bad ("Ignoring attempt to re-define symbol `%s'.",
2006 S_GET_NAME (symbolP));
f8701a3f 2007
9a7d824a 2008 subseg_set (current_seg, current_subseg);
9a7d824a
ILT
2009
2010 demand_empty_rest_of_line ();
6efd877d 2011} /* s_lcomm() */
fecd2382 2012
6efd877d 2013void
604633ae
ILT
2014s_lsym (ignore)
2015 int ignore;
6efd877d
KR
2016{
2017 register char *name;
2018 register char c;
2019 register char *p;
6efd877d
KR
2020 expressionS exp;
2021 register symbolS *symbolP;
2022
2023 /* we permit ANY defined expression: BSD4.2 demands constants */
2024 name = input_line_pointer;
2025 c = get_symbol_end ();
2026 p = input_line_pointer;
2027 *p = c;
2028 SKIP_WHITESPACE ();
2029 if (*input_line_pointer != ',')
2030 {
2031 *p = 0;
2032 as_bad ("Expected comma after name \"%s\"", name);
2033 *p = c;
2034 ignore_rest_of_line ();
2035 return;
2036 }
2037 input_line_pointer++;
b31f2abb
KR
2038 expression (&exp);
2039 if (exp.X_op != O_constant
2040 && exp.X_op != O_register)
2041 {
2042 as_bad ("bad expression");
2043 ignore_rest_of_line ();
2044 return;
2045 }
6efd877d
KR
2046 *p = 0;
2047 symbolP = symbol_find_or_make (name);
f8701a3f 2048
c8863a58
KR
2049 /* FIXME-SOON I pulled a (&& symbolP->sy_other == 0 &&
2050 symbolP->sy_desc == 0) out of this test because coff doesn't have
2051 those fields, and I can't see when they'd ever be tripped. I
2052 don't think I understand why they were here so I may have
2053 introduced a bug. As recently as 1.37 didn't have this test
2054 anyway. xoxorich. */
f8701a3f 2055
9471a360 2056 if (S_GET_SEGMENT (symbolP) == undefined_section
6efd877d
KR
2057 && S_GET_VALUE (symbolP) == 0)
2058 {
c8863a58
KR
2059 /* The name might be an undefined .global symbol; be sure to
2060 keep the "external" bit. */
b31f2abb
KR
2061 S_SET_SEGMENT (symbolP,
2062 (exp.X_op == O_constant
2063 ? absolute_section
2064 : reg_section));
2065 S_SET_VALUE (symbolP, (valueT) exp.X_add_number);
6efd877d
KR
2066 }
2067 else
2068 {
2069 as_bad ("Symbol %s already defined", name);
2070 }
2071 *p = c;
2072 demand_empty_rest_of_line ();
2073} /* s_lsym() */
2074
7e047ac2
ILT
2075/* Read a line into an sb. */
2076
2077static int
2078get_line_sb (line)
2079 sb *line;
2080{
d428c89f
ILT
2081 char quote1, quote2, inquote;
2082
adeab39b
MM
2083 if (input_line_pointer[-1] == '\n')
2084 bump_line_counters ();
2085
7e047ac2
ILT
2086 if (input_line_pointer >= buffer_limit)
2087 {
2088 buffer_limit = input_scrub_next_buffer (&input_line_pointer);
2089 if (buffer_limit == 0)
2090 return 0;
2091 }
2092
d428c89f
ILT
2093 /* If app.c sets any other characters to LEX_IS_STRINGQUOTE, this
2094 code needs to be changed. */
2095 if (! flag_m68k_mri)
2096 quote1 = '"';
2097 else
2098 quote1 = '\0';
2099
2100 quote2 = '\0';
2101 if (flag_m68k_mri)
2102 quote2 = '\'';
2103#ifdef LEX_IS_STRINGQUOTE
2104 quote2 = '\'';
2105#endif
2106
2107 inquote = '\0';
2108 while (! is_end_of_line[(unsigned char) *input_line_pointer]
2109 || (inquote != '\0' && *input_line_pointer != '\n'))
2110 {
2111 if (inquote == *input_line_pointer)
2112 inquote = '\0';
2113 else if (inquote == '\0')
2114 {
2115 if (*input_line_pointer == quote1)
2116 inquote = quote1;
2117 else if (*input_line_pointer == quote2)
2118 inquote = quote2;
2119 }
2120 sb_add_char (line, *input_line_pointer++);
2121 }
2122 while (input_line_pointer < buffer_limit && *input_line_pointer == '\n')
7e047ac2 2123 {
adeab39b
MM
2124 if (input_line_pointer[-1] == '\n')
2125 bump_line_counters ();
7e047ac2
ILT
2126 ++input_line_pointer;
2127 }
2128 return 1;
2129}
2130
2131/* Define a macro. This is an interface to macro.c, which is shared
2132 between gas and gasp. */
2133
2134void
2135s_macro (ignore)
2136 int ignore;
2137{
2138 char *file;
2139 unsigned int line;
2140 sb s;
2141 sb label;
2142 const char *err;
a69e5977 2143 const char *name;
7e047ac2
ILT
2144
2145 as_where (&file, &line);
2146
2147 sb_new (&s);
2148 while (! is_end_of_line[(unsigned char) *input_line_pointer])
2149 sb_add_char (&s, *input_line_pointer++);
2150
2151 sb_new (&label);
2152 if (line_label != NULL)
2153 sb_add_string (&label, S_GET_NAME (line_label));
2154
a69e5977 2155 err = define_macro (0, &s, &label, get_line_sb, &name);
7e047ac2
ILT
2156 if (err != NULL)
2157 as_bad_where (file, line, "%s", err);
2158 else
2159 {
2160 if (line_label != NULL)
2161 {
2162 S_SET_SEGMENT (line_label, undefined_section);
2163 S_SET_VALUE (line_label, 0);
2164 line_label->sy_frag = &zero_address_frag;
2165 }
a69e5977
ILT
2166
2167 if (((flag_m68k_mri
2168#ifdef NO_PSEUDO_DOT
2169 || 1
2170#endif
2171 )
2172 && hash_find (po_hash, name) != NULL)
2173 || (! flag_m68k_mri
2174 && *name == '.'
2175 && hash_find (po_hash, name + 1) != NULL))
2176 as_warn ("attempt to redefine pseudo-op `%s' ignored",
2177 name);
7e047ac2
ILT
2178 }
2179
2180 sb_kill (&s);
2181}
2182
2183/* Handle the .mexit pseudo-op, which immediately exits a macro
2184 expansion. */
2185
2186void
2187s_mexit (ignore)
2188 int ignore;
2189{
cd924033 2190 cond_exit_macro (macro_nest);
7e047ac2
ILT
2191 buffer_limit = input_scrub_next_buffer (&input_line_pointer);
2192}
2193
20710f1c
ILT
2194/* Switch in and out of MRI mode. */
2195
2196void
2197s_mri (ignore)
2198 int ignore;
2199{
2200 int on, old_flag;
2201
2202 on = get_absolute_expression ();
2203 old_flag = flag_mri;
2204 if (on != 0)
2205 {
2206 flag_mri = 1;
2207#ifdef TC_M68K
2208 flag_m68k_mri = 1;
2209#endif
2210 }
2211 else
2212 {
2213 flag_mri = 0;
2214 flag_m68k_mri = 0;
2215 }
2216
2217#ifdef MRI_MODE_CHANGE
2218 if (on != old_flag)
2219 MRI_MODE_CHANGE (on);
2220#endif
2221
2222 demand_empty_rest_of_line ();
2223}
2224
e28c40d7
ILT
2225/* Handle changing the location counter. */
2226
2227static void
2228do_org (segment, exp, fill)
2229 segT segment;
2230 expressionS *exp;
2231 int fill;
2232{
2233 if (segment != now_seg && segment != absolute_section)
2234 as_bad ("invalid segment \"%s\"; segment \"%s\" assumed",
2235 segment_name (segment), segment_name (now_seg));
2236
2237 if (now_seg == absolute_section)
2238 {
2239 if (fill != 0)
2240 as_warn ("ignoring fill value in absolute section");
2241 if (exp->X_op != O_constant)
2242 {
2243 as_bad ("only constant offsets supported in absolute section");
2244 exp->X_add_number = 0;
2245 }
2246 abs_section_offset = exp->X_add_number;
2247 }
2248 else
2249 {
2250 char *p;
2251
2252 p = frag_var (rs_org, 1, 1, (relax_substateT) 0, exp->X_add_symbol,
2253 exp->X_add_number, (char *) NULL);
2254 *p = fill;
2255 }
2256}
2257
6efd877d 2258void
604633ae
ILT
2259s_org (ignore)
2260 int ignore;
6efd877d
KR
2261{
2262 register segT segment;
2263 expressionS exp;
2264 register long temp_fill;
e28c40d7 2265
42ac8fa8
ILT
2266 /* The m68k MRI assembler has a different meaning for .org. It
2267 means to create an absolute section at a given address. We can't
2268 support that--use a linker script instead. */
cef72a92 2269 if (flag_m68k_mri)
69e077f3
ILT
2270 {
2271 as_bad ("MRI style ORG pseudo-op not supported");
2272 ignore_rest_of_line ();
2273 return;
2274 }
2275
9471a360
KR
2276 /* Don't believe the documentation of BSD 4.2 AS. There is no such
2277 thing as a sub-segment-relative origin. Any absolute origin is
2278 given a warning, then assumed to be segment-relative. Any
2279 segmented origin expression ("foo+42") had better be in the right
2280 segment or the .org is ignored.
2281
2282 BSD 4.2 AS warns if you try to .org backwards. We cannot because
2283 we never know sub-segment sizes when we are reading code. BSD
2284 will crash trying to emit negative numbers of filler bytes in
2285 certain .orgs. We don't crash, but see as-write for that code.
2286
2287 Don't make frag if need_pass_2==1. */
6efd877d
KR
2288 segment = get_known_segmented_expression (&exp);
2289 if (*input_line_pointer == ',')
2290 {
2291 input_line_pointer++;
2292 temp_fill = get_absolute_expression ();
2293 }
2294 else
2295 temp_fill = 0;
e28c40d7 2296
6efd877d 2297 if (!need_pass_2)
e28c40d7
ILT
2298 do_org (segment, &exp, temp_fill);
2299
6efd877d
KR
2300 demand_empty_rest_of_line ();
2301} /* s_org() */
2302
e14994d9
ILT
2303/* Handle parsing for the MRI SECT/SECTION pseudo-op. This should be
2304 called by the obj-format routine which handles section changing
2305 when in MRI mode. It will create a new section, and return it. It
c7a89bde
ILT
2306 will set *TYPE to the section type: one of 'C' (code), 'D' (data),
2307 'M' (mixed), or 'R' (romable). If BFD_ASSEMBLER is defined, the
2308 flags will be set in the section. */
e14994d9
ILT
2309
2310void
2311s_mri_sect (type)
2312 char *type;
2313{
42ac8fa8
ILT
2314#ifdef TC_M68K
2315
e14994d9
ILT
2316 char *name;
2317 char c;
2318 segT seg;
2319
2320 SKIP_WHITESPACE ();
2321
2322 name = input_line_pointer;
2323 if (! isdigit ((unsigned char) *name))
2324 c = get_symbol_end ();
2325 else
2326 {
2327 do
2328 {
2329 ++input_line_pointer;
2330 }
2331 while (isdigit ((unsigned char) *input_line_pointer));
2332 c = *input_line_pointer;
2333 *input_line_pointer = '\0';
2334 }
2335
c7a89bde 2336 name = xstrdup (name);
e14994d9
ILT
2337
2338 *input_line_pointer = c;
2339
2340 seg = subseg_new (name, 0);
2341
2342 if (*input_line_pointer == ',')
2343 {
2344 int align;
2345
2346 ++input_line_pointer;
2347 align = get_absolute_expression ();
2348 record_alignment (seg, align);
2349 }
2350
c7a89bde 2351 *type = 'C';
e14994d9
ILT
2352 if (*input_line_pointer == ',')
2353 {
2354 c = *++input_line_pointer;
2355 c = toupper ((unsigned char) c);
2356 if (c == 'C' || c == 'D' || c == 'M' || c == 'R')
2357 *type = c;
2358 else
2359 as_bad ("unrecognized section type");
2360 ++input_line_pointer;
2361
2362#ifdef BFD_ASSEMBLER
2363 {
2364 flagword flags;
2365
2366 flags = SEC_NO_FLAGS;
ca232972 2367 if (*type == 'C')
c7a89bde
ILT
2368 flags = SEC_ALLOC | SEC_LOAD | SEC_READONLY | SEC_CODE;
2369 else if (*type == 'D' || *type == 'M')
2370 flags = SEC_ALLOC | SEC_LOAD | SEC_DATA;
ca232972 2371 else if (*type == 'R')
c7a89bde 2372 flags = SEC_ALLOC | SEC_LOAD | SEC_DATA | SEC_READONLY | SEC_ROM;
e14994d9
ILT
2373 if (flags != SEC_NO_FLAGS)
2374 {
2375 if (! bfd_set_section_flags (stdoutput, seg, flags))
2376 as_warn ("error setting flags for \"%s\": %s",
ca232972 2377 bfd_section_name (stdoutput, seg),
e14994d9
ILT
2378 bfd_errmsg (bfd_get_error ()));
2379 }
2380 }
2381#endif
2382 }
2383
2384 /* Ignore the HP type. */
2385 if (*input_line_pointer == ',')
2386 input_line_pointer += 2;
2387
2388 demand_empty_rest_of_line ();
42ac8fa8
ILT
2389
2390#else /* ! TC_M68K */
2391#ifdef TC_I960
2392
2393 char *name;
2394 char c;
2395 segT seg;
2396
2397 SKIP_WHITESPACE ();
2398
2399 name = input_line_pointer;
2400 c = get_symbol_end ();
2401
c7a89bde 2402 name = xstrdup (name);
42ac8fa8
ILT
2403
2404 *input_line_pointer = c;
2405
2406 seg = subseg_new (name, 0);
2407
2408 if (*input_line_pointer != ',')
2409 *type = 'C';
2410 else
2411 {
2412 char *sectype;
2413
2414 ++input_line_pointer;
2415 SKIP_WHITESPACE ();
2416 sectype = input_line_pointer;
2417 c = get_symbol_end ();
2418 if (*sectype == '\0')
2419 *type = 'C';
2420 else if (strcasecmp (sectype, "text") == 0)
2421 *type = 'C';
2422 else if (strcasecmp (sectype, "data") == 0)
2423 *type = 'D';
2424 else if (strcasecmp (sectype, "romdata") == 0)
2425 *type = 'R';
2426 else
2427 as_warn ("unrecognized section type `%s'", sectype);
2428 *input_line_pointer = c;
2429 }
2430
2431 if (*input_line_pointer == ',')
2432 {
2433 char *seccmd;
2434
2435 ++input_line_pointer;
2436 SKIP_WHITESPACE ();
2437 seccmd = input_line_pointer;
2438 c = get_symbol_end ();
2439 if (strcasecmp (seccmd, "absolute") == 0)
2440 {
2441 as_bad ("absolute sections are not supported");
2442 *input_line_pointer = c;
2443 ignore_rest_of_line ();
2444 return;
2445 }
2446 else if (strcasecmp (seccmd, "align") == 0)
2447 {
2448 int align;
2449
2450 *input_line_pointer = c;
2451 align = get_absolute_expression ();
2452 record_alignment (seg, align);
2453 }
2454 else
2455 {
2456 as_warn ("unrecognized section command `%s'", seccmd);
2457 *input_line_pointer = c;
2458 }
2459 }
2460
2461 demand_empty_rest_of_line ();
2462
2463#else /* ! TC_I960 */
2464 /* The MRI assembler seems to use different forms of .sect for
2465 different targets. */
2466 abort ();
2467#endif /* ! TC_I960 */
2468#endif /* ! TC_M68K */
2469}
2470
2471/* Handle the .print pseudo-op. */
2472
2473void
2474s_print (ignore)
2475 int ignore;
2476{
2477 char *s;
2478 int len;
2479
2480 s = demand_copy_C_string (&len);
2481 printf ("%s\n", s);
2482 demand_empty_rest_of_line ();
2483}
2484
2485/* Handle the .purgem pseudo-op. */
2486
2487void
2488s_purgem (ignore)
2489 int ignore;
2490{
2491 if (is_it_end_of_statement ())
2492 {
2493 demand_empty_rest_of_line ();
2494 return;
2495 }
2496
2497 do
2498 {
2499 char *name;
2500 char c;
2501
2502 SKIP_WHITESPACE ();
2503 name = input_line_pointer;
2504 c = get_symbol_end ();
2505 delete_macro (name);
2506 *input_line_pointer = c;
2507 SKIP_WHITESPACE ();
2508 }
2509 while (*input_line_pointer++ == ',');
2510
2511 --input_line_pointer;
2512 demand_empty_rest_of_line ();
e14994d9
ILT
2513}
2514
7e047ac2
ILT
2515/* Handle the .rept pseudo-op. */
2516
2517void
2518s_rept (ignore)
2519 int ignore;
2520{
2521 int count;
2522 sb one;
2523 sb many;
2524
2525 count = get_absolute_expression ();
2526
2527 sb_new (&one);
2528 if (! buffer_and_nest ("REPT", "ENDR", &one, get_line_sb))
2529 {
2530 as_bad ("rept without endr");
2531 return;
2532 }
2533
2534 sb_new (&many);
2535 while (count-- > 0)
2536 sb_add_sb (&many, &one);
2537
2538 sb_kill (&one);
2539
2540 input_scrub_include_sb (&many, input_line_pointer);
2541 sb_kill (&many);
2542 buffer_limit = input_scrub_next_buffer (&input_line_pointer);
2543}
2544
cd924033
ILT
2545/* Handle the .equ, .equiv and .set directives. If EQUIV is 1, then
2546 this is .equiv, and it is an error if the symbol is already
2547 defined. */
2548
6efd877d 2549void
cd924033
ILT
2550s_set (equiv)
2551 int equiv;
6efd877d
KR
2552{
2553 register char *name;
2554 register char delim;
2555 register char *end_name;
2556 register symbolS *symbolP;
2557
2558 /*
c8863a58
KR
2559 * Especial apologies for the random logic:
2560 * this just grew, and could be parsed much more simply!
2561 * Dean in haste.
2562 */
6efd877d
KR
2563 name = input_line_pointer;
2564 delim = get_symbol_end ();
2565 end_name = input_line_pointer;
2566 *end_name = delim;
2567 SKIP_WHITESPACE ();
f8701a3f 2568
6efd877d
KR
2569 if (*input_line_pointer != ',')
2570 {
2571 *end_name = 0;
2572 as_bad ("Expected comma after name \"%s\"", name);
2573 *end_name = delim;
2574 ignore_rest_of_line ();
2575 return;
2576 }
2577
2578 input_line_pointer++;
2579 *end_name = 0;
2580
2581 if (name[0] == '.' && name[1] == '\0')
2582 {
2583 /* Turn '. = mumble' into a .org mumble */
2584 register segT segment;
2585 expressionS exp;
6efd877d
KR
2586
2587 segment = get_known_segmented_expression (&exp);
f8701a3f 2588
6efd877d 2589 if (!need_pass_2)
e28c40d7 2590 do_org (segment, &exp, 0);
6efd877d
KR
2591
2592 *end_name = delim;
2593 return;
2594 }
2595
2596 if ((symbolP = symbol_find (name)) == NULL
2597 && (symbolP = md_undefined_symbol (name)) == NULL)
2598 {
9471a360 2599 symbolP = symbol_new (name, undefined_section, 0, &zero_address_frag);
fecd2382 2600#ifdef OBJ_COFF
6efd877d
KR
2601 /* "set" symbols are local unless otherwise specified. */
2602 SF_SET_LOCAL (symbolP);
fecd2382 2603#endif /* OBJ_COFF */
f8701a3f 2604
6efd877d 2605 } /* make a new symbol */
f8701a3f 2606
6efd877d 2607 symbol_table_insert (symbolP);
f8701a3f 2608
6efd877d 2609 *end_name = delim;
cd924033
ILT
2610
2611 if (equiv
2612 && S_IS_DEFINED (symbolP)
2613 && S_GET_SEGMENT (symbolP) != reg_section)
2614 as_bad ("symbol `%s' already defined", S_GET_NAME (symbolP));
2615
6efd877d
KR
2616 pseudo_set (symbolP);
2617 demand_empty_rest_of_line ();
2618} /* s_set() */
fecd2382 2619
6efd877d
KR
2620void
2621s_space (mult)
2622 int mult;
b53ccaac 2623{
cd3b81bd 2624 expressionS exp;
adeab39b 2625 expressionS val;
cd3b81bd 2626 char *p = 0;
3dce804d
ILT
2627 char *stop = NULL;
2628 char stopc;
a6b200da 2629 int bytes;
6efd877d 2630
a2a5a4fa
KR
2631#ifdef md_flush_pending_output
2632 md_flush_pending_output ();
2633#endif
2634
3dce804d 2635 if (flag_mri)
18c9057f 2636 stop = mri_comment_field (&stopc);
3dce804d 2637
a69e5977
ILT
2638 /* In m68k MRI mode, we need to align to a word boundary, unless
2639 this is ds.b. */
2640 if (flag_m68k_mri && mult > 1)
2641 {
2642 if (now_seg == absolute_section)
2643 {
2644 abs_section_offset += abs_section_offset & 1;
2645 if (line_label != NULL)
2646 S_SET_VALUE (line_label, abs_section_offset);
2647 }
2648 else if (mri_common_symbol != NULL)
2649 {
2650 valueT val;
2651
2652 val = S_GET_VALUE (mri_common_symbol);
2653 if ((val & 1) != 0)
2654 {
2655 S_SET_VALUE (mri_common_symbol, val + 1);
2656 if (line_label != NULL)
2657 {
2658 know (line_label->sy_value.X_op == O_symbol);
2659 know (line_label->sy_value.X_add_symbol == mri_common_symbol);
2660 line_label->sy_value.X_add_number += 1;
2661 }
2662 }
2663 }
2664 else
2665 {
d428c89f 2666 do_align (1, (char *) NULL, 0, 0);
a69e5977
ILT
2667 if (line_label != NULL)
2668 {
2669 line_label->sy_frag = frag_now;
2670 S_SET_VALUE (line_label, frag_now_fix ());
2671 }
2672 }
2673 }
2674
a6b200da
ILT
2675 bytes = mult;
2676
cd3b81bd 2677 expression (&exp);
cd3b81bd 2678
adeab39b
MM
2679 SKIP_WHITESPACE ();
2680 if (*input_line_pointer == ',')
2681 {
2682 ++input_line_pointer;
2683 expression (&val);
2684 }
2685 else
2686 {
2687 val.X_op = O_constant;
2688 val.X_add_number = 0;
2689 }
cd3b81bd 2690
adeab39b
MM
2691 if (val.X_op != O_constant
2692 || val.X_add_number < - 0x80
2693 || val.X_add_number > 0xff
2694 || (mult != 0 && mult != 1 && val.X_add_number != 0))
2695 {
2696 if (exp.X_op != O_constant)
2697 as_bad ("Unsupported variable size or fill value");
2698 else
e28c40d7 2699 {
adeab39b 2700 offsetT i;
e28c40d7 2701
adeab39b
MM
2702 if (mult == 0)
2703 mult = 1;
a6b200da 2704 bytes = mult * exp.X_add_number;
adeab39b
MM
2705 for (i = 0; i < exp.X_add_number; i++)
2706 emit_expr (&val, mult);
1356d77d 2707 }
6efd877d
KR
2708 }
2709 else
2710 {
adeab39b 2711 if (exp.X_op == O_constant)
e28c40d7 2712 {
adeab39b
MM
2713 long repeat;
2714
2715 repeat = exp.X_add_number;
2716 if (mult)
2717 repeat *= mult;
a6b200da 2718 bytes = repeat;
adeab39b
MM
2719 if (repeat <= 0)
2720 {
2721 if (! flag_mri || repeat < 0)
2722 as_warn (".space repeat count is %s, ignored",
2723 repeat ? "negative" : "zero");
2724 goto getout;
2725 }
2726
2727 /* If we are in the absolute section, just bump the offset. */
2728 if (now_seg == absolute_section)
2729 {
2730 abs_section_offset += repeat;
2731 goto getout;
2732 }
2733
2734 /* If we are secretly in an MRI common section, then
2735 creating space just increases the size of the common
2736 symbol. */
2737 if (mri_common_symbol != NULL)
2738 {
2739 S_SET_VALUE (mri_common_symbol,
2740 S_GET_VALUE (mri_common_symbol) + repeat);
2741 goto getout;
2742 }
2743
2744 if (!need_pass_2)
2745 p = frag_var (rs_fill, 1, 1, (relax_substateT) 0, (symbolS *) 0,
cd924033 2746 (offsetT) repeat, (char *) 0);
e28c40d7 2747 }
adeab39b 2748 else
1356d77d 2749 {
adeab39b
MM
2750 if (now_seg == absolute_section)
2751 {
2752 as_bad ("space allocation too complex in absolute section");
2753 subseg_set (text_section, 0);
2754 }
2755 if (mri_common_symbol != NULL)
2756 {
2757 as_bad ("space allocation too complex in common section");
2758 mri_common_symbol = NULL;
2759 }
2760 if (!need_pass_2)
2761 p = frag_var (rs_space, 1, 1, (relax_substateT) 0,
cd924033 2762 make_expr_symbol (&exp), (offsetT) 0, (char *) 0);
1356d77d 2763 }
adeab39b
MM
2764
2765 if (p)
2766 *p = val.X_add_number;
6efd877d 2767 }
3dce804d
ILT
2768
2769 getout:
a6b200da
ILT
2770
2771 /* In MRI mode, after an odd number of bytes, we must align to an
2772 even word boundary, unless the next instruction is a dc.b, ds.b
2773 or dcb.b. */
2774 if (flag_mri && (bytes & 1) != 0)
2775 mri_pending_align = 1;
2776
3dce804d 2777 if (flag_mri)
18c9057f 2778 mri_comment_end (stop, stopc);
3dce804d 2779
6efd877d 2780 demand_empty_rest_of_line ();
cd3b81bd 2781}
fecd2382 2782
e28c40d7
ILT
2783/* This is like s_space, but the value is a floating point number with
2784 the given precision. This is for the MRI dcb.s pseudo-op and
2785 friends. */
2786
2787void
2788s_float_space (float_type)
2789 int float_type;
2790{
2791 offsetT count;
2792 int flen;
2793 char temp[MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT];
18c9057f
ILT
2794 char *stop = NULL;
2795 char stopc;
2796
2797 if (flag_mri)
2798 stop = mri_comment_field (&stopc);
e28c40d7
ILT
2799
2800 count = get_absolute_expression ();
2801
2802 SKIP_WHITESPACE ();
2803 if (*input_line_pointer != ',')
2804 {
2805 as_bad ("missing value");
18c9057f
ILT
2806 if (flag_mri)
2807 mri_comment_end (stop, stopc);
e28c40d7
ILT
2808 ignore_rest_of_line ();
2809 return;
2810 }
2811
2812 ++input_line_pointer;
2813
2814 SKIP_WHITESPACE ();
2815
2816 /* Skip any 0{letter} that may be present. Don't even check if the
2817 * letter is legal. */
2818 if (input_line_pointer[0] == '0' && isalpha (input_line_pointer[1]))
2819 input_line_pointer += 2;
2820
2821 /* Accept :xxxx, where the x's are hex digits, for a floating point
2822 with the exact digits specified. */
2823 if (input_line_pointer[0] == ':')
2824 {
2825 flen = hex_float (float_type, temp);
2826 if (flen < 0)
2827 {
18c9057f
ILT
2828 if (flag_mri)
2829 mri_comment_end (stop, stopc);
e28c40d7
ILT
2830 ignore_rest_of_line ();
2831 return;
2832 }
2833 }
2834 else
2835 {
2836 char *err;
2837
2838 err = md_atof (float_type, temp, &flen);
2839 know (flen <= MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT);
2840 know (flen > 0);
2841 if (err)
2842 {
2843 as_bad ("Bad floating literal: %s", err);
18c9057f
ILT
2844 if (flag_mri)
2845 mri_comment_end (stop, stopc);
e28c40d7
ILT
2846 ignore_rest_of_line ();
2847 return;
2848 }
2849 }
2850
2851 while (--count >= 0)
2852 {
2853 char *p;
2854
2855 p = frag_more (flen);
2856 memcpy (p, temp, (unsigned int) flen);
2857 }
2858
18c9057f
ILT
2859 if (flag_mri)
2860 mri_comment_end (stop, stopc);
2861
e28c40d7
ILT
2862 demand_empty_rest_of_line ();
2863}
2864
2865/* Handle the .struct pseudo-op, as found in MIPS assemblers. */
2866
2867void
2868s_struct (ignore)
2869 int ignore;
2870{
18c9057f
ILT
2871 char *stop = NULL;
2872 char stopc;
2873
2874 if (flag_mri)
2875 stop = mri_comment_field (&stopc);
e28c40d7
ILT
2876 abs_section_offset = get_absolute_expression ();
2877 subseg_set (absolute_section, 0);
18c9057f
ILT
2878 if (flag_mri)
2879 mri_comment_end (stop, stopc);
e28c40d7
ILT
2880 demand_empty_rest_of_line ();
2881}
2882
fecd2382 2883void
604633ae
ILT
2884s_text (ignore)
2885 int ignore;
fecd2382 2886{
6efd877d 2887 register int temp;
f8701a3f 2888
6efd877d 2889 temp = get_absolute_expression ();
9471a360 2890 subseg_set (text_section, (subsegT) temp);
6efd877d 2891 demand_empty_rest_of_line ();
80d80c64
KR
2892#ifdef OBJ_VMS
2893 const_flag &= ~IN_DEFAULT_SECTION;
2894#endif
6efd877d 2895} /* s_text() */
fecd2382 2896\f
6efd877d 2897
6efd877d
KR
2898void
2899demand_empty_rest_of_line ()
2900{
2901 SKIP_WHITESPACE ();
58d4951d 2902 if (is_end_of_line[(unsigned char) *input_line_pointer])
6efd877d
KR
2903 {
2904 input_line_pointer++;
2905 }
2906 else
2907 {
2908 ignore_rest_of_line ();
2909 }
2910 /* Return having already swallowed end-of-line. */
2911} /* Return pointing just after end-of-line. */
fecd2382
RP
2912
2913void
6efd877d 2914ignore_rest_of_line () /* For suspect lines: gives warning. */
fecd2382 2915{
58d4951d 2916 if (!is_end_of_line[(unsigned char) *input_line_pointer])
f8701a3f 2917 {
6efd877d
KR
2918 if (isprint (*input_line_pointer))
2919 as_bad ("Rest of line ignored. First ignored character is `%c'.",
f8701a3f
SC
2920 *input_line_pointer);
2921 else
6efd877d 2922 as_bad ("Rest of line ignored. First ignored character valued 0x%x.",
f8701a3f
SC
2923 *input_line_pointer);
2924 while (input_line_pointer < buffer_limit
58d4951d 2925 && !is_end_of_line[(unsigned char) *input_line_pointer])
f8701a3f 2926 {
6efd877d 2927 input_line_pointer++;
f8701a3f
SC
2928 }
2929 }
6efd877d 2930 input_line_pointer++; /* Return pointing just after end-of-line. */
58d4951d 2931 know (is_end_of_line[(unsigned char) input_line_pointer[-1]]);
fecd2382
RP
2932}
2933
2934/*
2935 * pseudo_set()
2936 *
2937 * In: Pointer to a symbol.
2938 * Input_line_pointer->expression.
2939 *
2940 * Out: Input_line_pointer->just after any whitespace after expression.
2941 * Tried to set symbol to value of expression.
2942 * Will change symbols type, value, and frag;
fecd2382
RP
2943 */
2944void
f8701a3f 2945pseudo_set (symbolP)
6efd877d 2946 symbolS *symbolP;
fecd2382 2947{
6efd877d 2948 expressionS exp;
daad3bbf 2949#if (defined (OBJ_AOUT) || defined (OBJ_BOUT)) && ! defined (BFD_ASSEMBLER)
f8701a3f 2950 int ext;
fecd2382 2951#endif /* OBJ_AOUT or OBJ_BOUT */
f8701a3f 2952
6efd877d 2953 know (symbolP); /* NULL pointer is logic error. */
daad3bbf 2954#if (defined (OBJ_AOUT) || defined (OBJ_BOUT)) && ! defined (BFD_ASSEMBLER)
6efd877d 2955 ext = S_IS_EXTERNAL (symbolP);
fecd2382 2956#endif /* OBJ_AOUT or OBJ_BOUT */
f8701a3f 2957
5ac34ac3 2958 (void) expression (&exp);
f8701a3f 2959
5ac34ac3
ILT
2960 if (exp.X_op == O_illegal)
2961 as_bad ("illegal expression; zero assumed");
2962 else if (exp.X_op == O_absent)
2963 as_bad ("missing expression; zero assumed");
2964 else if (exp.X_op == O_big)
2965 as_bad ("%s number invalid; zero assumed",
2966 exp.X_add_number > 0 ? "bignum" : "floating point");
2967 else if (exp.X_op == O_subtract
2968 && (S_GET_SEGMENT (exp.X_add_symbol)
2969 == S_GET_SEGMENT (exp.X_op_symbol))
2970 && SEG_NORMAL (S_GET_SEGMENT (exp.X_add_symbol))
2971 && exp.X_add_symbol->sy_frag == exp.X_op_symbol->sy_frag)
9471a360 2972 {
5ac34ac3
ILT
2973 exp.X_op = O_constant;
2974 exp.X_add_number = (S_GET_VALUE (exp.X_add_symbol)
2975 - S_GET_VALUE (exp.X_op_symbol));
9471a360 2976 }
5ac34ac3
ILT
2977
2978 switch (exp.X_op)
9471a360 2979 {
5ac34ac3
ILT
2980 case O_illegal:
2981 case O_absent:
2982 case O_big:
2983 exp.X_add_number = 0;
2984 /* Fall through. */
2985 case O_constant:
9471a360 2986 S_SET_SEGMENT (symbolP, absolute_section);
daad3bbf 2987#if (defined (OBJ_AOUT) || defined (OBJ_BOUT)) && ! defined (BFD_ASSEMBLER)
5ac34ac3
ILT
2988 if (ext)
2989 S_SET_EXTERNAL (symbolP);
6efd877d 2990 else
6efd877d 2991 S_CLEAR_EXTERNAL (symbolP);
fecd2382 2992#endif /* OBJ_AOUT or OBJ_BOUT */
604633ae 2993 S_SET_VALUE (symbolP, (valueT) exp.X_add_number);
6efd877d 2994 symbolP->sy_frag = &zero_address_frag;
5ac34ac3 2995 break;
f8701a3f 2996
5ac34ac3
ILT
2997 case O_register:
2998 S_SET_SEGMENT (symbolP, reg_section);
604633ae 2999 S_SET_VALUE (symbolP, (valueT) exp.X_add_number);
5ac34ac3
ILT
3000 symbolP->sy_frag = &zero_address_frag;
3001 break;
3002
3003 case O_symbol:
ef198870
KR
3004 if (S_GET_SEGMENT (exp.X_add_symbol) == undefined_section
3005 || exp.X_add_number != 0)
5ac34ac3 3006 symbolP->sy_value = exp;
6efd877d
KR
3007 else
3008 {
80d80c64
KR
3009 symbolS *s = exp.X_add_symbol;
3010
3011 S_SET_SEGMENT (symbolP, S_GET_SEGMENT (s));
daad3bbf 3012#if (defined (OBJ_AOUT) || defined (OBJ_BOUT)) && ! defined (BFD_ASSEMBLER)
5ac34ac3
ILT
3013 if (ext)
3014 S_SET_EXTERNAL (symbolP);
3015 else
3016 S_CLEAR_EXTERNAL (symbolP);
fecd2382 3017#endif /* OBJ_AOUT or OBJ_BOUT */
5ac34ac3 3018 S_SET_VALUE (symbolP,
80d80c64
KR
3019 exp.X_add_number + S_GET_VALUE (s));
3020 symbolP->sy_frag = s->sy_frag;
ef198870 3021 copy_symbol_attributes (symbolP, s);
5ac34ac3
ILT
3022 }
3023 break;
f8701a3f 3024
5ac34ac3
ILT
3025 default:
3026 /* The value is some complex expression.
3027 FIXME: Should we set the segment to anything? */
3028 symbolP->sy_value = exp;
3029 break;
f8701a3f 3030 }
fecd2382
RP
3031}
3032\f
3033/*
3034 * cons()
3035 *
3036 * CONStruct more frag of .bytes, or .words etc.
3037 * Should need_pass_2 be 1 then emit no frag(s).
80aab579 3038 * This understands EXPRESSIONS.
fecd2382
RP
3039 *
3040 * Bug (?)
3041 *
3042 * This has a split personality. We use expression() to read the
3043 * value. We can detect if the value won't fit in a byte or word.
3044 * But we can't detect if expression() discarded significant digits
3045 * in the case of a long. Not worth the crocks required to fix it.
3046 */
3047
40324362
KR
3048/* Select a parser for cons expressions. */
3049
3050/* Some targets need to parse the expression in various fancy ways.
3051 You can define TC_PARSE_CONS_EXPRESSION to do whatever you like
3052 (for example, the HPPA does this). Otherwise, you can define
3053 BITFIELD_CONS_EXPRESSIONS to permit bitfields to be specified, or
3054 REPEAT_CONS_EXPRESSIONS to permit repeat counts. If none of these
3055 are defined, which is the normal case, then only simple expressions
3056 are permitted. */
3057
1356d77d
ILT
3058static void
3059parse_mri_cons PARAMS ((expressionS *exp, unsigned int nbytes));
3060
40324362
KR
3061#ifndef TC_PARSE_CONS_EXPRESSION
3062#ifdef BITFIELD_CONS_EXPRESSIONS
3063#define TC_PARSE_CONS_EXPRESSION(EXP, NBYTES) parse_bitfield_cons (EXP, NBYTES)
3064static void
3065parse_bitfield_cons PARAMS ((expressionS *exp, unsigned int nbytes));
3066#endif
40324362
KR
3067#ifdef REPEAT_CONS_EXPRESSIONS
3068#define TC_PARSE_CONS_EXPRESSION(EXP, NBYTES) parse_repeat_cons (EXP, NBYTES)
3069static void
3070parse_repeat_cons PARAMS ((expressionS *exp, unsigned int nbytes));
3071#endif
3072
3073/* If we haven't gotten one yet, just call expression. */
3074#ifndef TC_PARSE_CONS_EXPRESSION
3075#define TC_PARSE_CONS_EXPRESSION(EXP, NBYTES) expression (EXP)
3076#endif
3077#endif
3078
6efd877d
KR
3079/* worker to do .byte etc statements */
3080/* clobbers input_line_pointer, checks */
3081/* end-of-line. */
86038ada
ILT
3082static void
3083cons_worker (nbytes, rva)
604633ae 3084 register int nbytes; /* 1=.byte, 2=.word, 4=.long */
86038ada 3085 int rva;
fecd2382 3086{
286cb27a 3087 int c;
6efd877d 3088 expressionS exp;
86038ada 3089 char *stop = NULL;
3dce804d 3090 char stopc;
f8701a3f 3091
a2a5a4fa
KR
3092#ifdef md_flush_pending_output
3093 md_flush_pending_output ();
3094#endif
3095
18c9057f
ILT
3096 if (flag_mri)
3097 stop = mri_comment_field (&stopc);
3098
40324362 3099 if (is_it_end_of_statement ())
6efd877d 3100 {
cef72a92
ILT
3101 if (flag_mri)
3102 mri_comment_end (stop, stopc);
40324362
KR
3103 demand_empty_rest_of_line ();
3104 return;
6efd877d 3105 }
40324362 3106
a69e5977
ILT
3107#ifdef md_cons_align
3108 md_cons_align (nbytes);
3109#endif
3110
286cb27a 3111 c = 0;
40324362 3112 do
6efd877d 3113 {
cef72a92 3114 if (flag_m68k_mri)
1356d77d
ILT
3115 parse_mri_cons (&exp, (unsigned int) nbytes);
3116 else
3117 TC_PARSE_CONS_EXPRESSION (&exp, (unsigned int) nbytes);
6594d6b9
KR
3118
3119 if (rva)
3120 {
3121 if (exp.X_op == O_symbol)
3122 exp.X_op = O_symbol_rva;
3123 else
3124 as_fatal ("rva without symbol");
3125 }
3126 emit_expr (&exp, (unsigned int) nbytes);
286cb27a 3127 ++c;
40324362 3128 }
18c9057f 3129 while (*input_line_pointer++ == ',');
40324362 3130
286cb27a
ILT
3131 /* In MRI mode, after an odd number of bytes, we must align to an
3132 even word boundary, unless the next instruction is a dc.b, ds.b
3133 or dcb.b. */
3134 if (flag_mri && nbytes == 1 && (c & 1) != 0)
3135 mri_pending_align = 1;
3136
40324362 3137 input_line_pointer--; /* Put terminator back into stream. */
86038ada
ILT
3138
3139 if (flag_mri)
18c9057f 3140 mri_comment_end (stop, stopc);
86038ada 3141
40324362 3142 demand_empty_rest_of_line ();
30d3a445 3143}
f8701a3f 3144
86038ada
ILT
3145
3146void
3147cons (size)
3148 int size;
3149{
3150 cons_worker (size, 0);
3151}
3152
3153void
3154s_rva (size)
3155 int size;
3156{
3157 cons_worker (size, 1);
3158}
3159
3160
40324362
KR
3161/* Put the contents of expression EXP into the object file using
3162 NBYTES bytes. If need_pass_2 is 1, this does nothing. */
f8701a3f 3163
40324362
KR
3164void
3165emit_expr (exp, nbytes)
3166 expressionS *exp;
3167 unsigned int nbytes;
3168{
5ac34ac3 3169 operatorT op;
40324362 3170 register char *p;
80aab579 3171 valueT extra_digit = 0;
f8701a3f 3172
40324362
KR
3173 /* Don't do anything if we are going to make another pass. */
3174 if (need_pass_2)
3175 return;
3176
5ac34ac3 3177 op = exp->X_op;
40324362 3178
e28c40d7
ILT
3179 /* Allow `.word 0' in the absolute section. */
3180 if (now_seg == absolute_section)
3181 {
3182 if (op != O_constant || exp->X_add_number != 0)
3183 as_bad ("attempt to store value in absolute section");
3184 abs_section_offset += nbytes;
3185 return;
3186 }
3187
80aab579
ILT
3188 /* Handle a negative bignum. */
3189 if (op == O_uminus
3190 && exp->X_add_number == 0
3191 && exp->X_add_symbol->sy_value.X_op == O_big
3192 && exp->X_add_symbol->sy_value.X_add_number > 0)
3193 {
3194 int i;
3195 unsigned long carry;
3196
3197 exp = &exp->X_add_symbol->sy_value;
3198
3199 /* Negate the bignum: one's complement each digit and add 1. */
3200 carry = 1;
3201 for (i = 0; i < exp->X_add_number; i++)
3202 {
3203 unsigned long next;
3204
3205 next = (((~ (generic_bignum[i] & LITTLENUM_MASK))
3206 & LITTLENUM_MASK)
3207 + carry);
3208 generic_bignum[i] = next & LITTLENUM_MASK;
3209 carry = next >> LITTLENUM_NUMBER_OF_BITS;
3210 }
3211
3212 /* We can ignore any carry out, because it will be handled by
3213 extra_digit if it is needed. */
3214
3215 extra_digit = (valueT) -1;
3216 op = O_big;
3217 }
3218
5ac34ac3 3219 if (op == O_absent || op == O_illegal)
6efd877d 3220 {
5ac34ac3
ILT
3221 as_warn ("zero assumed for missing expression");
3222 exp->X_add_number = 0;
3223 op = O_constant;
6efd877d 3224 }
80aab579 3225 else if (op == O_big && exp->X_add_number <= 0)
6efd877d 3226 {
80aab579 3227 as_bad ("floating point number invalid; zero assumed");
40324362 3228 exp->X_add_number = 0;
5ac34ac3 3229 op = O_constant;
40324362 3230 }
5ac34ac3 3231 else if (op == O_register)
6efd877d 3232 {
5ac34ac3
ILT
3233 as_warn ("register value used as expression");
3234 op = O_constant;
40324362 3235 }
6efd877d 3236
604633ae 3237 p = frag_more ((int) nbytes);
6efd877d 3238
40324362
KR
3239#ifndef WORKING_DOT_WORD
3240 /* If we have the difference of two symbols in a word, save it on
3241 the broken_words list. See the code in write.c. */
5ac34ac3 3242 if (op == O_subtract && nbytes == 2)
40324362
KR
3243 {
3244 struct broken_word *x;
3245
3246 x = (struct broken_word *) xmalloc (sizeof (struct broken_word));
3247 x->next_broken_word = broken_words;
3248 broken_words = x;
3249 x->frag = frag_now;
3250 x->word_goes_here = p;
3251 x->dispfrag = 0;
3252 x->add = exp->X_add_symbol;
5ac34ac3 3253 x->sub = exp->X_op_symbol;
40324362
KR
3254 x->addnum = exp->X_add_number;
3255 x->added = 0;
3256 new_broken_words++;
3257 return;
3258 }
f8701a3f 3259#endif
6efd877d 3260
80aab579
ILT
3261 /* If we have an integer, but the number of bytes is too large to
3262 pass to md_number_to_chars, handle it as a bignum. */
3263 if (op == O_constant && nbytes > sizeof (valueT))
3264 {
3265 valueT val;
3266 int gencnt;
3267
3268 if (! exp->X_unsigned && exp->X_add_number < 0)
3269 extra_digit = (valueT) -1;
3270 val = (valueT) exp->X_add_number;
3271 gencnt = 0;
3272 do
3273 {
3274 generic_bignum[gencnt] = val & LITTLENUM_MASK;
3275 val >>= LITTLENUM_NUMBER_OF_BITS;
3276 ++gencnt;
3277 }
3278 while (val != 0);
3279 op = exp->X_op = O_big;
3280 exp->X_add_number = gencnt;
3281 }
3282
5ac34ac3 3283 if (op == O_constant)
40324362 3284 {
44ce2f32
DE
3285 register valueT get;
3286 register valueT use;
3287 register valueT mask;
6468dabd 3288 valueT hibit;
44ce2f32 3289 register valueT unmask;
40324362
KR
3290
3291 /* JF << of >= number of bits in the object is undefined. In
3292 particular SPARC (Sun 4) has problems */
44ce2f32 3293 if (nbytes >= sizeof (valueT))
6468dabd
ILT
3294 {
3295 mask = 0;
3296 if (nbytes > sizeof (valueT))
3297 hibit = 0;
3298 else
3299 hibit = (valueT) 1 << (nbytes * BITS_PER_CHAR - 1);
3300 }
40324362 3301 else
6468dabd
ILT
3302 {
3303 /* Don't store these bits. */
3304 mask = ~(valueT) 0 << (BITS_PER_CHAR * nbytes);
3305 hibit = (valueT) 1 << (nbytes * BITS_PER_CHAR - 1);
3306 }
6efd877d 3307
40324362 3308 unmask = ~mask; /* Do store these bits. */
6efd877d 3309
40324362
KR
3310#ifdef NEVER
3311 "Do this mod if you want every overflow check to assume SIGNED 2's complement data.";
3312 mask = ~(unmask >> 1); /* Includes sign bit now. */
3313#endif
6efd877d 3314
40324362
KR
3315 get = exp->X_add_number;
3316 use = get & unmask;
6468dabd
ILT
3317 if ((get & mask) != 0
3318 && ((get & mask) != mask
3319 || (get & hibit) == 0))
40324362 3320 { /* Leading bits contain both 0s & 1s. */
a69e5977
ILT
3321 as_warn ("Value 0x%lx truncated to 0x%lx.",
3322 (unsigned long) get, (unsigned long) use);
40324362 3323 }
604633ae 3324 /* put bytes in right order. */
44ce2f32 3325 md_number_to_chars (p, use, (int) nbytes);
40324362 3326 }
80aab579
ILT
3327 else if (op == O_big)
3328 {
3329 int size;
3330 LITTLENUM_TYPE *nums;
3331
3332 know (nbytes % CHARS_PER_LITTLENUM == 0);
3333
3334 size = exp->X_add_number * CHARS_PER_LITTLENUM;
3335 if (nbytes < size)
3336 {
3337 as_warn ("Bignum truncated to %d bytes", nbytes);
3338 size = nbytes;
3339 }
3340
3341 if (target_big_endian)
3342 {
3343 while (nbytes > size)
3344 {
3345 md_number_to_chars (p, extra_digit, CHARS_PER_LITTLENUM);
3346 nbytes -= CHARS_PER_LITTLENUM;
3347 p += CHARS_PER_LITTLENUM;
3348 }
3349
3350 nums = generic_bignum + size / CHARS_PER_LITTLENUM;
3351 while (size > 0)
3352 {
3353 --nums;
3354 md_number_to_chars (p, (valueT) *nums, CHARS_PER_LITTLENUM);
3355 size -= CHARS_PER_LITTLENUM;
3356 p += CHARS_PER_LITTLENUM;
3357 }
3358 }
3359 else
3360 {
3361 nums = generic_bignum;
3362 while (size > 0)
3363 {
3364 md_number_to_chars (p, (valueT) *nums, CHARS_PER_LITTLENUM);
3365 ++nums;
3366 size -= CHARS_PER_LITTLENUM;
3367 p += CHARS_PER_LITTLENUM;
3368 nbytes -= CHARS_PER_LITTLENUM;
3369 }
3370
3371 while (nbytes > 0)
3372 {
3373 md_number_to_chars (p, extra_digit, CHARS_PER_LITTLENUM);
3374 nbytes -= CHARS_PER_LITTLENUM;
3375 p += CHARS_PER_LITTLENUM;
3376 }
3377 }
3378 }
40324362
KR
3379 else
3380 {
1fbfe108 3381 memset (p, 0, nbytes);
6efd877d 3382
40324362
KR
3383 /* Now we need to generate a fixS to record the symbol value.
3384 This is easy for BFD. For other targets it can be more
3385 complex. For very complex cases (currently, the HPPA and
3386 NS32K), you can define TC_CONS_FIX_NEW to do whatever you
3387 want. For simpler cases, you can define TC_CONS_RELOC to be
3388 the name of the reloc code that should be stored in the fixS.
3389 If neither is defined, the code uses NO_RELOC if it is
3390 defined, and otherwise uses 0. */
6efd877d 3391
40324362 3392#ifdef BFD_ASSEMBLER
4064305e
SS
3393#ifdef TC_CONS_FIX_NEW
3394 TC_CONS_FIX_NEW (frag_now, p - frag_now->fr_literal, nbytes, exp);
3395#else
a69e5977
ILT
3396 {
3397 bfd_reloc_code_real_type r;
3398
3399 switch (nbytes)
3400 {
3401 case 1:
3402 r = BFD_RELOC_8;
3403 break;
3404 case 2:
3405 r = BFD_RELOC_16;
3406 break;
3407 case 4:
3408 r = BFD_RELOC_32;
3409 break;
3410 case 8:
3411 r = BFD_RELOC_64;
3412 break;
3413 default:
3414 as_bad ("unsupported BFD relocation size %u", nbytes);
3415 r = BFD_RELOC_32;
3416 break;
3417 }
3418 fix_new_exp (frag_now, p - frag_now->fr_literal, (int) nbytes, exp,
3419 0, r);
3420 }
4064305e 3421#endif
40324362
KR
3422#else
3423#ifdef TC_CONS_FIX_NEW
3424 TC_CONS_FIX_NEW (frag_now, p - frag_now->fr_literal, nbytes, exp);
3425#else
3426 /* Figure out which reloc number to use. Use TC_CONS_RELOC if
3427 it is defined, otherwise use NO_RELOC if it is defined,
3428 otherwise use 0. */
3429#ifndef TC_CONS_RELOC
3430#ifdef NO_RELOC
3431#define TC_CONS_RELOC NO_RELOC
3432#else
3433#define TC_CONS_RELOC 0
3434#endif
3435#endif
80aab579 3436 fix_new_exp (frag_now, p - frag_now->fr_literal, (int) nbytes, exp, 0,
5ac34ac3 3437 TC_CONS_RELOC);
40324362
KR
3438#endif /* TC_CONS_FIX_NEW */
3439#endif /* BFD_ASSEMBLER */
3440 }
3441}
3442\f
3443#ifdef BITFIELD_CONS_EXPRESSIONS
6efd877d 3444
40324362
KR
3445/* i960 assemblers, (eg, asm960), allow bitfields after ".byte" as
3446 w:x,y:z, where w and y are bitwidths and x and y are values. They
3447 then pack them all together. We do a little better in that we allow
3448 them in words, longs, etc. and we'll pack them in target byte order
3449 for you.
6efd877d 3450
40324362
KR
3451 The rules are: pack least significat bit first, if a field doesn't
3452 entirely fit, put it in the next unit. Overflowing the bitfield is
3453 explicitly *not* even a warning. The bitwidth should be considered
3454 a "mask".
6efd877d 3455
40324362
KR
3456 To use this function the tc-XXX.h file should define
3457 BITFIELD_CONS_EXPRESSIONS. */
f8701a3f 3458
40324362
KR
3459static void
3460parse_bitfield_cons (exp, nbytes)
3461 expressionS *exp;
3462 unsigned int nbytes;
3463{
3464 unsigned int bits_available = BITS_PER_CHAR * nbytes;
3465 char *hold = input_line_pointer;
f8701a3f 3466
5ac34ac3 3467 (void) expression (exp);
f8701a3f 3468
40324362
KR
3469 if (*input_line_pointer == ':')
3470 { /* bitfields */
3471 long value = 0;
f8701a3f 3472
40324362
KR
3473 for (;;)
3474 {
3475 unsigned long width;
f8701a3f 3476
40324362
KR
3477 if (*input_line_pointer != ':')
3478 {
3479 input_line_pointer = hold;
3480 break;
3481 } /* next piece is not a bitfield */
3482
3483 /* In the general case, we can't allow
3484 full expressions with symbol
3485 differences and such. The relocation
3486 entries for symbols not defined in this
3487 assembly would require arbitrary field
3488 widths, positions, and masks which most
3489 of our current object formats don't
3490 support.
cd3b81bd 3491
40324362
KR
3492 In the specific case where a symbol
3493 *is* defined in this assembly, we
3494 *could* build fixups and track it, but
3495 this could lead to confusion for the
3496 backends. I'm lazy. I'll take any
3497 SEG_ABSOLUTE. I think that means that
3498 you can use a previous .set or
3499 .equ type symbol. xoxorich. */
3500
5ac34ac3 3501 if (exp->X_op == O_absent)
6efd877d 3502 {
5ac34ac3 3503 as_warn ("using a bit field width of zero");
40324362 3504 exp->X_add_number = 0;
5ac34ac3 3505 exp->X_op = O_constant;
40324362
KR
3506 } /* implied zero width bitfield */
3507
5ac34ac3 3508 if (exp->X_op != O_constant)
6efd877d 3509 {
40324362 3510 *input_line_pointer = '\0';
5ac34ac3 3511 as_bad ("field width \"%s\" too complex for a bitfield", hold);
40324362
KR
3512 *input_line_pointer = ':';
3513 demand_empty_rest_of_line ();
3514 return;
3515 } /* too complex */
3516
3517 if ((width = exp->X_add_number) > (BITS_PER_CHAR * nbytes))
9471a360 3518 {
80aab579 3519 as_warn ("field width %lu too big to fit in %d bytes: truncated to %d bits",
40324362
KR
3520 width, nbytes, (BITS_PER_CHAR * nbytes));
3521 width = BITS_PER_CHAR * nbytes;
3522 } /* too big */
3523
3524 if (width > bits_available)
9471a360 3525 {
40324362
KR
3526 /* FIXME-SOMEDAY: backing up and reparsing is wasteful. */
3527 input_line_pointer = hold;
3528 exp->X_add_number = value;
3529 break;
3530 } /* won't fit */
3531
3532 hold = ++input_line_pointer; /* skip ':' */
3533
5ac34ac3
ILT
3534 (void) expression (exp);
3535 if (exp->X_op != O_constant)
9471a360 3536 {
40324362
KR
3537 char cache = *input_line_pointer;
3538
3539 *input_line_pointer = '\0';
5ac34ac3 3540 as_bad ("field value \"%s\" too complex for a bitfield", hold);
40324362
KR
3541 *input_line_pointer = cache;
3542 demand_empty_rest_of_line ();
3543 return;
3544 } /* too complex */
3545
5ac34ac3
ILT
3546 value |= ((~(-1 << width) & exp->X_add_number)
3547 << ((BITS_PER_CHAR * nbytes) - bits_available));
40324362
KR
3548
3549 if ((bits_available -= width) == 0
3550 || is_it_end_of_statement ()
3551 || *input_line_pointer != ',')
3552 {
3553 break;
3554 } /* all the bitfields we're gonna get */
3555
3556 hold = ++input_line_pointer;
5ac34ac3 3557 (void) expression (exp);
40324362
KR
3558 } /* forever loop */
3559
3560 exp->X_add_number = value;
5ac34ac3 3561 exp->X_op = O_constant;
80aab579 3562 exp->X_unsigned = 1;
40324362
KR
3563 } /* if looks like a bitfield */
3564} /* parse_bitfield_cons() */
3565
3566#endif /* BITFIELD_CONS_EXPRESSIONS */
3567\f
1356d77d 3568/* Handle an MRI style string expression. */
40324362
KR
3569
3570static void
3571parse_mri_cons (exp, nbytes)
3572 expressionS *exp;
3573 unsigned int nbytes;
3574{
1356d77d
ILT
3575 if (*input_line_pointer != '\''
3576 && (input_line_pointer[1] != '\''
3577 || (*input_line_pointer != 'A'
3578 && *input_line_pointer != 'E')))
3579 TC_PARSE_CONS_EXPRESSION (exp, nbytes);
3580 else
40324362 3581 {
40324362
KR
3582 int scan = 0;
3583 unsigned int result = 0;
1356d77d
ILT
3584
3585 /* An MRI style string. Cut into as many bytes as will fit into
3586 a nbyte chunk, left justify if necessary, and separate with
3587 commas so we can try again later. */
3588 if (*input_line_pointer == 'A')
3589 ++input_line_pointer;
3590 else if (*input_line_pointer == 'E')
3591 {
3592 as_bad ("EBCDIC constants are not supported");
3593 ++input_line_pointer;
3594 }
3595
40324362
KR
3596 input_line_pointer++;
3597 for (scan = 0; scan < nbytes; scan++)
3598 {
3599 if (*input_line_pointer == '\'')
3600 {
3601 if (input_line_pointer[1] == '\'')
6efd877d 3602 {
40324362 3603 input_line_pointer++;
f8701a3f 3604 }
40324362
KR
3605 else
3606 break;
9471a360 3607 }
40324362
KR
3608 result = (result << 8) | (*input_line_pointer++);
3609 }
f8701a3f 3610
40324362
KR
3611 /* Left justify */
3612 while (scan < nbytes)
3613 {
3614 result <<= 8;
3615 scan++;
3616 }
3617 /* Create correct expression */
5ac34ac3 3618 exp->X_op = O_constant;
40324362 3619 exp->X_add_number = result;
40324362
KR
3620 /* Fake it so that we can read the next char too */
3621 if (input_line_pointer[0] != '\'' ||
3622 (input_line_pointer[0] == '\'' && input_line_pointer[1] == '\''))
3623 {
3624 input_line_pointer -= 2;
3625 input_line_pointer[0] = ',';
3626 input_line_pointer[1] = '\'';
3627 }
3628 else
3629 input_line_pointer++;
3630 }
40324362 3631}
40324362
KR
3632\f
3633#ifdef REPEAT_CONS_EXPRESSIONS
3634
3635/* Parse a repeat expression for cons. This is used by the MIPS
3636 assembler. The format is NUMBER:COUNT; NUMBER appears in the
3637 object file COUNT times.
3638
3639 To use this for a target, define REPEAT_CONS_EXPRESSIONS. */
3640
3641static void
3642parse_repeat_cons (exp, nbytes)
3643 expressionS *exp;
3644 unsigned int nbytes;
3645{
3646 expressionS count;
40324362
KR
3647 register int i;
3648
3649 expression (exp);
3650
3651 if (*input_line_pointer != ':')
3652 {
3653 /* No repeat count. */
3654 return;
3655 }
3656
3657 ++input_line_pointer;
5ac34ac3
ILT
3658 expression (&count);
3659 if (count.X_op != O_constant
40324362
KR
3660 || count.X_add_number <= 0)
3661 {
3662 as_warn ("Unresolvable or nonpositive repeat count; using 1");
3663 return;
3664 }
3665
3666 /* The cons function is going to output this expression once. So we
3667 output it count - 1 times. */
3668 for (i = count.X_add_number - 1; i > 0; i--)
3669 emit_expr (exp, nbytes);
3670}
3671
3672#endif /* REPEAT_CONS_EXPRESSIONS */
fecd2382 3673\f
e28c40d7
ILT
3674/* Parse a floating point number represented as a hex constant. This
3675 permits users to specify the exact bits they want in the floating
3676 point number. */
3677
3678static int
3679hex_float (float_type, bytes)
3680 int float_type;
3681 char *bytes;
3682{
3683 int length;
3684 int i;
3685
3686 switch (float_type)
3687 {
3688 case 'f':
3689 case 'F':
3690 case 's':
3691 case 'S':
3692 length = 4;
3693 break;
3694
3695 case 'd':
3696 case 'D':
3697 case 'r':
3698 case 'R':
3699 length = 8;
3700 break;
3701
3702 case 'x':
3703 case 'X':
3704 length = 12;
3705 break;
3706
3707 case 'p':
3708 case 'P':
3709 length = 12;
3710 break;
3711
3712 default:
3713 as_bad ("Unknown floating type type '%c'", float_type);
3714 return -1;
3715 }
3716
3717 /* It would be nice if we could go through expression to parse the
3718 hex constant, but if we get a bignum it's a pain to sort it into
3719 the buffer correctly. */
3720 i = 0;
3721 while (hex_p (*input_line_pointer) || *input_line_pointer == '_')
3722 {
3723 int d;
3724
3725 /* The MRI assembler accepts arbitrary underscores strewn about
3726 through the hex constant, so we ignore them as well. */
3727 if (*input_line_pointer == '_')
3728 {
3729 ++input_line_pointer;
3730 continue;
3731 }
3732
3733 if (i >= length)
3734 {
3735 as_warn ("Floating point constant too large");
3736 return -1;
3737 }
3738 d = hex_value (*input_line_pointer) << 4;
3739 ++input_line_pointer;
3740 while (*input_line_pointer == '_')
3741 ++input_line_pointer;
3742 if (hex_p (*input_line_pointer))
3743 {
3744 d += hex_value (*input_line_pointer);
3745 ++input_line_pointer;
3746 }
a920b693
ILT
3747 if (target_big_endian)
3748 bytes[i] = d;
3749 else
3750 bytes[length - i - 1] = d;
3751 ++i;
e28c40d7
ILT
3752 }
3753
3754 if (i < length)
a920b693
ILT
3755 {
3756 if (target_big_endian)
3757 memset (bytes + i, 0, length - i);
3758 else
3759 memset (bytes, 0, length - i);
3760 }
e28c40d7
ILT
3761
3762 return length;
3763}
3764
fecd2382
RP
3765/*
3766 * float_cons()
3767 *
3768 * CONStruct some more frag chars of .floats .ffloats etc.
3769 * Makes 0 or more new frags.
3770 * If need_pass_2 == 1, no frags are emitted.
3771 * This understands only floating literals, not expressions. Sorry.
3772 *
3773 * A floating constant is defined by atof_generic(), except it is preceded
3774 * by 0d 0f 0g or 0h. After observing the STRANGE way my BSD AS does its
3775 * reading, I decided to be incompatible. This always tries to give you
3776 * rounded bits to the precision of the pseudo-op. Former AS did premature
3777 * truncatation, restored noisy bits instead of trailing 0s AND gave you
3778 * a choice of 2 flavours of noise according to which of 2 floating-point
3779 * scanners you directed AS to use.
3780 *
3781 * In: input_line_pointer->whitespace before, or '0' of flonum.
3782 *
3783 */
3784
ba71c54d
KR
3785void
3786float_cons (float_type)
6efd877d 3787 /* Clobbers input_line-pointer, checks end-of-line. */
f8701a3f 3788 register int float_type; /* 'f':.ffloat ... 'F':.float ... */
fecd2382 3789{
6efd877d 3790 register char *p;
6efd877d
KR
3791 int length; /* Number of chars in an object. */
3792 register char *err; /* Error from scanning floating literal. */
3793 char temp[MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT];
f8701a3f 3794
6efd877d 3795 if (is_it_end_of_statement ())
f8701a3f 3796 {
1e9cf565
ILT
3797 demand_empty_rest_of_line ();
3798 return;
f8701a3f 3799 }
1e9cf565 3800
a69e5977
ILT
3801#ifdef md_flush_pending_output
3802 md_flush_pending_output ();
3803#endif
3804
1e9cf565 3805 do
f8701a3f
SC
3806 {
3807 /* input_line_pointer->1st char of a flonum (we hope!). */
6efd877d 3808 SKIP_WHITESPACE ();
1e9cf565 3809
f8701a3f
SC
3810 /* Skip any 0{letter} that may be present. Don't even check if the
3811 * letter is legal. Someone may invent a "z" format and this routine
3812 * has no use for such information. Lusers beware: you get
3813 * diagnostics if your input is ill-conditioned.
3814 */
6efd877d
KR
3815 if (input_line_pointer[0] == '0' && isalpha (input_line_pointer[1]))
3816 input_line_pointer += 2;
f8701a3f 3817
1356d77d
ILT
3818 /* Accept :xxxx, where the x's are hex digits, for a floating
3819 point with the exact digits specified. */
3820 if (input_line_pointer[0] == ':')
f8701a3f 3821 {
e28c40d7
ILT
3822 ++input_line_pointer;
3823 length = hex_float (float_type, temp);
3824 if (length < 0)
1356d77d 3825 {
1356d77d
ILT
3826 ignore_rest_of_line ();
3827 return;
3828 }
1356d77d
ILT
3829 }
3830 else
3831 {
3832 err = md_atof (float_type, temp, &length);
3833 know (length <= MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT);
3834 know (length > 0);
3835 if (err)
3836 {
3837 as_bad ("Bad floating literal: %s", err);
3838 ignore_rest_of_line ();
3839 return;
3840 }
f8701a3f 3841 }
1e9cf565
ILT
3842
3843 if (!need_pass_2)
f8701a3f 3844 {
1e9cf565
ILT
3845 int count;
3846
3847 count = 1;
3848
3849#ifdef REPEAT_CONS_EXPRESSIONS
3850 if (*input_line_pointer == ':')
3851 {
1e9cf565
ILT
3852 expressionS count_exp;
3853
3854 ++input_line_pointer;
5ac34ac3
ILT
3855 expression (&count_exp);
3856 if (count_exp.X_op != O_constant
1e9cf565
ILT
3857 || count_exp.X_add_number <= 0)
3858 {
5ac34ac3 3859 as_warn ("unresolvable or nonpositive repeat count; using 1");
1e9cf565
ILT
3860 }
3861 else
3862 count = count_exp.X_add_number;
3863 }
3864#endif
3865
3866 while (--count >= 0)
a39116f1 3867 {
f8701a3f 3868 p = frag_more (length);
604633ae 3869 memcpy (p, temp, (unsigned int) length);
a39116f1 3870 }
542e1629 3871 }
1e9cf565 3872 SKIP_WHITESPACE ();
f8701a3f 3873 }
1e9cf565
ILT
3874 while (*input_line_pointer++ == ',');
3875
3876 --input_line_pointer; /* Put terminator back into stream. */
6efd877d 3877 demand_empty_rest_of_line ();
f8701a3f 3878} /* float_cons() */
fecd2382 3879\f
cd924033
ILT
3880/* Return the size of a LEB128 value */
3881
3882static inline int
3883sizeof_sleb128 (value)
3884 offsetT value;
3885{
3886 register int size = 0;
3887 register unsigned byte;
3888
3889 do
3890 {
3891 byte = (value & 0x7f);
3892 /* Sadly, we cannot rely on typical arithmetic right shift behaviour.
3893 Fortunately, we can structure things so that the extra work reduces
3894 to a noop on systems that do things "properly". */
3895 value = (value >> 7) | ~(-(offsetT)1 >> 7);
3896 size += 1;
3897 }
3898 while (!(((value == 0) && ((byte & 0x40) == 0))
3899 || ((value == -1) && ((byte & 0x40) != 0))));
3900
3901 return size;
3902}
3903
3904static inline int
3905sizeof_uleb128 (value)
3906 valueT value;
3907{
3908 register int size = 0;
3909 register unsigned byte;
3910
3911 do
3912 {
3913 byte = (value & 0x7f);
3914 value >>= 7;
3915 size += 1;
3916 }
3917 while (value != 0);
3918
3919 return size;
3920}
3921
3922inline int
3923sizeof_leb128 (value, sign)
3924 valueT value;
3925 int sign;
3926{
3927 if (sign)
3928 return sizeof_sleb128 ((offsetT) value);
3929 else
3930 return sizeof_uleb128 (value);
3931}
3932
3933/* Output a LEB128 value. */
3934
3935static inline int
3936output_sleb128 (p, value)
3937 char *p;
3938 offsetT value;
3939{
3940 register char *orig = p;
3941 register int more;
3942
3943 do
3944 {
3945 unsigned byte = (value & 0x7f);
3946
3947 /* Sadly, we cannot rely on typical arithmetic right shift behaviour.
3948 Fortunately, we can structure things so that the extra work reduces
3949 to a noop on systems that do things "properly". */
3950 value = (value >> 7) | ~(-(offsetT)1 >> 7);
3951
3952 more = !((((value == 0) && ((byte & 0x40) == 0))
3953 || ((value == -1) && ((byte & 0x40) != 0))));
3954 if (more)
3955 byte |= 0x80;
3956
3957 *p++ = byte;
3958 }
3959 while (more);
3960
3961 return p - orig;
3962}
3963
3964static inline int
3965output_uleb128 (p, value)
3966 char *p;
3967 valueT value;
3968{
3969 char *orig = p;
3970
3971 do
3972 {
3973 unsigned byte = (value & 0x7f);
3974 value >>= 7;
3975 if (value != 0)
3976 /* More bytes to follow. */
3977 byte |= 0x80;
3978
3979 *p++ = byte;
3980 }
3981 while (value != 0);
3982
3983 return p - orig;
3984}
3985
3986inline int
3987output_leb128 (p, value, sign)
3988 char *p;
3989 valueT value;
3990 int sign;
3991{
3992 if (sign)
3993 return output_sleb128 (p, (offsetT) value);
3994 else
3995 return output_uleb128 (p, value);
3996}
3997
3998/* Do the same for bignums. We combine sizeof with output here in that
3999 we don't output for NULL values of P. It isn't really as critical as
4000 for "normal" values that this be streamlined. */
4001
4002static int
4003output_big_sleb128 (p, bignum, size)
4004 char *p;
4005 LITTLENUM_TYPE *bignum;
4006 int size;
4007{
4008 char *orig = p;
4009 valueT val;
4010 int loaded = 0;
4011 unsigned byte;
4012
4013 /* Strip leading sign extensions off the bignum. */
4014 while (size > 0 && bignum[size-1] == (LITTLENUM_TYPE)-1)
4015 size--;
4016
4017 do
4018 {
4019 if (loaded < 7 && size > 0)
4020 {
4021 val |= (*bignum << loaded);
4022 loaded += 8 * CHARS_PER_LITTLENUM;
4023 size--;
4024 bignum++;
4025 }
4026
4027 byte = val & 0x7f;
4028 loaded -= 7;
4029 val >>= 7;
4030
4031 if (size == 0)
4032 {
4033 if ((val == 0 && (byte & 0x40) == 0)
4034 || (~(val | ~(((valueT)1 << loaded) - 1)) == 0
4035 && (byte & 0x40) != 0))
4036 byte |= 0x80;
4037 }
4038
4039 if (orig)
4040 *p = byte;
4041 p++;
4042 }
4043 while (byte & 0x80);
4044
4045 return p - orig;
4046}
4047
4048static int
4049output_big_uleb128 (p, bignum, size)
4050 char *p;
4051 LITTLENUM_TYPE *bignum;
4052 int size;
4053{
4054 char *orig = p;
4055 valueT val;
4056 int loaded = 0;
4057 unsigned byte;
4058
4059 /* Strip leading zeros off the bignum. */
4060 /* XXX: Is this needed? */
4061 while (size > 0 && bignum[size-1] == 0)
4062 size--;
4063
4064 do
4065 {
4066 if (loaded < 7 && size > 0)
4067 {
4068 val |= (*bignum << loaded);
4069 loaded += 8 * CHARS_PER_LITTLENUM;
4070 size--;
4071 bignum++;
4072 }
4073
4074 byte = val & 0x7f;
4075 loaded -= 7;
4076 val >>= 7;
4077
4078 if (size > 0 || val)
4079 byte |= 0x80;
4080
4081 if (orig)
4082 *p = byte;
4083 p++;
4084 }
4085 while (byte & 0x80);
4086
4087 return p - orig;
4088}
4089
4090static inline int
4091output_big_leb128 (p, bignum, size, sign)
4092 char *p;
4093 LITTLENUM_TYPE *bignum;
4094 int size, sign;
4095{
4096 if (sign)
4097 return output_big_sleb128 (p, bignum, size);
4098 else
4099 return output_big_uleb128 (p, bignum, size);
4100}
4101
4102/* Generate the appropriate fragments for a given expression to emit a
4103 leb128 value. */
4104
4105void
4106emit_leb128_expr(exp, sign)
4107 expressionS *exp;
4108 int sign;
4109{
4110 operatorT op = exp->X_op;
4111
4112 if (op == O_absent || op == O_illegal)
4113 {
4114 as_warn ("zero assumed for missing expression");
4115 exp->X_add_number = 0;
4116 op = O_constant;
4117 }
4118 else if (op == O_big && exp->X_add_number <= 0)
4119 {
4120 as_bad ("floating point number invalid; zero assumed");
4121 exp->X_add_number = 0;
4122 op = O_constant;
4123 }
4124 else if (op == O_register)
4125 {
4126 as_warn ("register value used as expression");
4127 op = O_constant;
4128 }
4129
4130 if (op == O_constant)
4131 {
4132 /* If we've got a constant, emit the thing directly right now. */
4133
4134 valueT value = exp->X_add_number;
4135 int size;
4136 char *p;
4137
4138 size = sizeof_leb128 (value, sign);
4139 p = frag_more (size);
4140 output_leb128 (p, value, sign);
4141 }
4142 else if (op == O_big)
4143 {
4144 /* O_big is a different sort of constant. */
4145
4146 int size;
4147 char *p;
4148
4149 size = output_big_leb128 (NULL, generic_bignum, exp->X_add_number, sign);
4150 p = frag_more (size);
4151 output_big_leb128 (p, generic_bignum, exp->X_add_number, sign);
4152 }
4153 else
4154 {
4155 /* Otherwise, we have to create a variable sized fragment and
4156 resolve things later. */
4157
4158 frag_var (rs_leb128, sizeof_uleb128 (~(valueT)0), 0, sign,
4159 make_expr_symbol (exp), 0, (char *) NULL);
4160 }
4161}
4162
4163/* Parse the .sleb128 and .uleb128 pseudos. */
4164
4165void
4166s_leb128 (sign)
4167 int sign;
4168{
4169 expressionS exp;
4170
4171 do {
4172 expression (&exp);
4173 emit_leb128_expr (&exp, sign);
4174 } while (*input_line_pointer++ == ',');
4175
4176 input_line_pointer--;
4177 demand_empty_rest_of_line ();
4178}
4179\f
fecd2382
RP
4180/*
4181 * stringer()
4182 *
4183 * We read 0 or more ',' seperated, double-quoted strings.
4184 *
4185 * Caller should have checked need_pass_2 is FALSE because we don't check it.
4186 */
a39116f1
RP
4187
4188
6efd877d
KR
4189void
4190stringer (append_zero) /* Worker to do .ascii etc statements. */
4191 /* Checks end-of-line. */
f8701a3f 4192 register int append_zero; /* 0: don't append '\0', else 1 */
fecd2382 4193{
f8701a3f 4194 register unsigned int c;
6efd877d 4195
a2a5a4fa
KR
4196#ifdef md_flush_pending_output
4197 md_flush_pending_output ();
4198#endif
4199
f8701a3f
SC
4200 /*
4201 * The following awkward logic is to parse ZERO or more strings,
4202 * comma seperated. Recall a string expression includes spaces
4203 * before the opening '\"' and spaces after the closing '\"'.
4204 * We fake a leading ',' if there is (supposed to be)
4205 * a 1st, expression. We keep demanding expressions for each
4206 * ','.
4207 */
6efd877d
KR
4208 if (is_it_end_of_statement ())
4209 {
4210 c = 0; /* Skip loop. */
4211 ++input_line_pointer; /* Compensate for end of loop. */
4212 }
f8701a3f 4213 else
6efd877d
KR
4214 {
4215 c = ','; /* Do loop. */
4216 }
4217 while (c == ',' || c == '<' || c == '"')
4218 {
4219 SKIP_WHITESPACE ();
4220 switch (*input_line_pointer)
4221 {
4222 case '\"':
4223 ++input_line_pointer; /*->1st char of string. */
4224 while (is_a_char (c = next_char_of_string ()))
4225 {
4226 FRAG_APPEND_1_CHAR (c);
4227 }
4228 if (append_zero)
4229 {
4230 FRAG_APPEND_1_CHAR (0);
4231 }
4232 know (input_line_pointer[-1] == '\"');
4233 break;
4234 case '<':
4235 input_line_pointer++;
4236 c = get_single_number ();
4237 FRAG_APPEND_1_CHAR (c);
4238 if (*input_line_pointer != '>')
4239 {
4240 as_bad ("Expected <nn>");
4241 }
4242 input_line_pointer++;
4243 break;
4244 case ',':
4245 input_line_pointer++;
4246 break;
4247 }
4248 SKIP_WHITESPACE ();
4249 c = *input_line_pointer;
f8701a3f 4250 }
f8701a3f 4251
6efd877d
KR
4252 demand_empty_rest_of_line ();
4253} /* stringer() */
fecd2382 4254\f
6efd877d 4255/* FIXME-SOMEDAY: I had trouble here on characters with the
f8701a3f
SC
4256 high bits set. We'll probably also have trouble with
4257 multibyte chars, wide chars, etc. Also be careful about
4258 returning values bigger than 1 byte. xoxorich. */
fecd2382 4259
6efd877d
KR
4260unsigned int
4261next_char_of_string ()
4262{
4263 register unsigned int c;
4264
4265 c = *input_line_pointer++ & CHAR_MASK;
4266 switch (c)
4267 {
4268 case '\"':
4269 c = NOT_A_CHAR;
4270 break;
4271
a69e5977
ILT
4272 case '\n':
4273 as_warn ("Unterminated string: Newline inserted.");
4274 bump_line_counters ();
4275 break;
4276
ddb393cf 4277#ifndef NO_STRING_ESCAPES
6efd877d
KR
4278 case '\\':
4279 switch (c = *input_line_pointer++)
4280 {
4281 case 'b':
4282 c = '\b';
4283 break;
4284
4285 case 'f':
4286 c = '\f';
4287 break;
4288
4289 case 'n':
4290 c = '\n';
4291 break;
4292
4293 case 'r':
4294 c = '\r';
4295 break;
4296
4297 case 't':
4298 c = '\t';
4299 break;
4300
6efd877d
KR
4301 case 'v':
4302 c = '\013';
4303 break;
6efd877d
KR
4304
4305 case '\\':
4306 case '"':
4307 break; /* As itself. */
4308
4309 case '0':
4310 case '1':
4311 case '2':
4312 case '3':
4313 case '4':
4314 case '5':
4315 case '6':
4316 case '7':
4317 case '8':
4318 case '9':
4319 {
4320 long number;
d4c8cbd8 4321 int i;
6efd877d 4322
d4c8cbd8 4323 for (i = 0, number = 0; isdigit (c) && i < 3; c = *input_line_pointer++, i++)
6efd877d
KR
4324 {
4325 number = number * 8 + c - '0';
4326 }
4327 c = number & 0xff;
4328 }
4329 --input_line_pointer;
4330 break;
4331
d4c8cbd8
JL
4332 case 'x':
4333 case 'X':
4334 {
4335 long number;
4336
4337 number = 0;
4338 c = *input_line_pointer++;
4339 while (isxdigit (c))
4340 {
4341 if (isdigit (c))
4342 number = number * 16 + c - '0';
4343 else if (isupper (c))
4344 number = number * 16 + c - 'A' + 10;
4345 else
4346 number = number * 16 + c - 'a' + 10;
4347 c = *input_line_pointer++;
4348 }
4349 c = number & 0xff;
4350 --input_line_pointer;
4351 }
4352 break;
4353
6efd877d
KR
4354 case '\n':
4355 /* To be compatible with BSD 4.2 as: give the luser a linefeed!! */
4356 as_warn ("Unterminated string: Newline inserted.");
4357 c = '\n';
a69e5977 4358 bump_line_counters ();
6efd877d
KR
4359 break;
4360
4361 default:
4362
fecd2382 4363#ifdef ONLY_STANDARD_ESCAPES
6efd877d
KR
4364 as_bad ("Bad escaped character in string, '?' assumed");
4365 c = '?';
fecd2382 4366#endif /* ONLY_STANDARD_ESCAPES */
6efd877d
KR
4367
4368 break;
4369 } /* switch on escaped char */
4370 break;
ddb393cf 4371#endif /* ! defined (NO_STRING_ESCAPES) */
6efd877d
KR
4372
4373 default:
4374 break;
4375 } /* switch on char */
4376 return (c);
4377} /* next_char_of_string() */
fecd2382
RP
4378\f
4379static segT
f8701a3f 4380get_segmented_expression (expP)
6efd877d 4381 register expressionS *expP;
fecd2382 4382{
6efd877d 4383 register segT retval;
f8701a3f 4384
9471a360 4385 retval = expression (expP);
5ac34ac3
ILT
4386 if (expP->X_op == O_illegal
4387 || expP->X_op == O_absent
4388 || expP->X_op == O_big)
f8701a3f 4389 {
5ac34ac3
ILT
4390 as_bad ("expected address expression; zero assumed");
4391 expP->X_op = O_constant;
6efd877d 4392 expP->X_add_number = 0;
5ac34ac3 4393 retval = absolute_section;
f8701a3f 4394 }
5ac34ac3 4395 return retval;
fecd2382
RP
4396}
4397
6efd877d
KR
4398static segT
4399get_known_segmented_expression (expP)
4400 register expressionS *expP;
fecd2382 4401{
6efd877d 4402 register segT retval;
f8701a3f 4403
9471a360 4404 if ((retval = get_segmented_expression (expP)) == undefined_section)
f8701a3f 4405 {
5ac34ac3
ILT
4406 /* There is no easy way to extract the undefined symbol from the
4407 expression. */
4408 if (expP->X_add_symbol != NULL
4409 && S_GET_SEGMENT (expP->X_add_symbol) != expr_section)
4410 as_warn ("symbol \"%s\" undefined; zero assumed",
4411 S_GET_NAME (expP->X_add_symbol));
f8701a3f 4412 else
5ac34ac3
ILT
4413 as_warn ("some symbol undefined; zero assumed");
4414 retval = absolute_section;
4415 expP->X_op = O_constant;
6efd877d 4416 expP->X_add_number = 0;
f8701a3f 4417 }
5ac34ac3 4418 know (retval == absolute_section || SEG_NORMAL (retval));
f8701a3f 4419 return (retval);
fecd2382
RP
4420} /* get_known_segmented_expression() */
4421
58d4951d 4422offsetT
f8701a3f 4423get_absolute_expression ()
fecd2382 4424{
6efd877d 4425 expressionS exp;
f8701a3f 4426
5ac34ac3
ILT
4427 expression (&exp);
4428 if (exp.X_op != O_constant)
f8701a3f 4429 {
5ac34ac3 4430 if (exp.X_op != O_absent)
cd3b81bd 4431 as_bad ("bad or irreducible absolute expression; zero assumed");
6efd877d 4432 exp.X_add_number = 0;
f8701a3f 4433 }
5ac34ac3 4434 return exp.X_add_number;
fecd2382
RP
4435}
4436
6efd877d
KR
4437char /* return terminator */
4438get_absolute_expression_and_terminator (val_pointer)
4439 long *val_pointer; /* return value of expression */
fecd2382 4440{
58d4951d
ILT
4441 /* FIXME: val_pointer should probably be offsetT *. */
4442 *val_pointer = (long) get_absolute_expression ();
6efd877d 4443 return (*input_line_pointer++);
fecd2382
RP
4444}
4445\f
4446/*
4447 * demand_copy_C_string()
4448 *
4449 * Like demand_copy_string, but return NULL if the string contains any '\0's.
4450 * Give a warning if that happens.
4451 */
4452char *
f8701a3f 4453demand_copy_C_string (len_pointer)
6efd877d 4454 int *len_pointer;
fecd2382 4455{
6efd877d 4456 register char *s;
f8701a3f 4457
6efd877d 4458 if ((s = demand_copy_string (len_pointer)) != 0)
f8701a3f
SC
4459 {
4460 register int len;
4461
6594d6b9 4462 for (len = *len_pointer; len > 0; len--)
f8701a3f 4463 {
6efd877d 4464 if (*s == 0)
fecd2382 4465 {
f8701a3f
SC
4466 s = 0;
4467 len = 1;
6efd877d
KR
4468 *len_pointer = 0;
4469 as_bad ("This string may not contain \'\\0\'");
fecd2382 4470 }
f8701a3f
SC
4471 }
4472 }
6594d6b9 4473 return s;
fecd2382
RP
4474}
4475\f
4476/*
4477 * demand_copy_string()
4478 *
4479 * Demand string, but return a safe (=private) copy of the string.
4480 * Return NULL if we can't read a string here.
4481 */
6ef37255 4482char *
6efd877d
KR
4483demand_copy_string (lenP)
4484 int *lenP;
fecd2382 4485{
6efd877d
KR
4486 register unsigned int c;
4487 register int len;
4488 char *retval;
4489
4490 len = 0;
4491 SKIP_WHITESPACE ();
4492 if (*input_line_pointer == '\"')
4493 {
4494 input_line_pointer++; /* Skip opening quote. */
4495
4496 while (is_a_char (c = next_char_of_string ()))
4497 {
4498 obstack_1grow (&notes, c);
4499 len++;
fecd2382 4500 }
42ac8fa8
ILT
4501 /* JF this next line is so demand_copy_C_string will return a
4502 null terminated string. */
6efd877d
KR
4503 obstack_1grow (&notes, '\0');
4504 retval = obstack_finish (&notes);
4505 }
4506 else
4507 {
4508 as_warn ("Missing string");
4509 retval = NULL;
4510 ignore_rest_of_line ();
4511 }
4512 *lenP = len;
4513 return (retval);
4514} /* demand_copy_string() */
fecd2382
RP
4515\f
4516/*
4517 * is_it_end_of_statement()
4518 *
4519 * In: Input_line_pointer->next character.
4520 *
4521 * Do: Skip input_line_pointer over all whitespace.
4522 *
4523 * Out: 1 if input_line_pointer->end-of-line.
f8701a3f 4524*/
6efd877d
KR
4525int
4526is_it_end_of_statement ()
4527{
4528 SKIP_WHITESPACE ();
58d4951d 4529 return (is_end_of_line[(unsigned char) *input_line_pointer]);
6efd877d 4530} /* is_it_end_of_statement() */
fecd2382 4531
6efd877d 4532void
d428c89f 4533equals (sym_name, reassign)
6efd877d 4534 char *sym_name;
d428c89f 4535 int reassign;
fecd2382 4536{
6efd877d 4537 register symbolS *symbolP; /* symbol we are working with */
86038ada 4538 char *stop;
18c9057f 4539 char stopc;
f8701a3f
SC
4540
4541 input_line_pointer++;
6efd877d 4542 if (*input_line_pointer == '=')
f8701a3f
SC
4543 input_line_pointer++;
4544
6efd877d 4545 while (*input_line_pointer == ' ' || *input_line_pointer == '\t')
f8701a3f
SC
4546 input_line_pointer++;
4547
86038ada 4548 if (flag_mri)
18c9057f 4549 stop = mri_comment_field (&stopc);
86038ada 4550
6efd877d
KR
4551 if (sym_name[0] == '.' && sym_name[1] == '\0')
4552 {
4553 /* Turn '. = mumble' into a .org mumble */
4554 register segT segment;
4555 expressionS exp;
f8701a3f 4556
6efd877d
KR
4557 segment = get_known_segmented_expression (&exp);
4558 if (!need_pass_2)
e28c40d7 4559 do_org (segment, &exp, 0);
6efd877d
KR
4560 }
4561 else
4562 {
4563 symbolP = symbol_find_or_make (sym_name);
d428c89f
ILT
4564 /* Permit register names to be redefined. */
4565 if (! reassign
4566 && S_IS_DEFINED (symbolP)
4567 && S_GET_SEGMENT (symbolP) != reg_section)
4568 as_bad ("symbol `%s' already defined", S_GET_NAME (symbolP));
6efd877d
KR
4569 pseudo_set (symbolP);
4570 }
86038ada
ILT
4571
4572 if (flag_mri)
18c9057f 4573 mri_comment_end (stop, stopc);
6efd877d 4574} /* equals() */
fecd2382
RP
4575
4576/* .include -- include a file at this point. */
4577
4578/* ARGSUSED */
6efd877d
KR
4579void
4580s_include (arg)
4581 int arg;
fecd2382 4582{
f8701a3f
SC
4583 char *newbuf;
4584 char *filename;
4585 int i;
4586 FILE *try;
4587 char *path;
4588
cef72a92 4589 if (! flag_m68k_mri)
ca232972
ILT
4590 filename = demand_copy_string (&i);
4591 else
4592 {
4593 SKIP_WHITESPACE ();
4594 i = 0;
4595 while (! is_end_of_line[(unsigned char) *input_line_pointer]
4596 && *input_line_pointer != ' '
4597 && *input_line_pointer != '\t')
4598 {
4599 obstack_1grow (&notes, *input_line_pointer);
4600 ++input_line_pointer;
4601 ++i;
4602 }
4603 obstack_1grow (&notes, '\0');
4604 filename = obstack_finish (&notes);
42ac8fa8
ILT
4605 while (! is_end_of_line[(unsigned char) *input_line_pointer])
4606 ++input_line_pointer;
ca232972 4607 }
6efd877d 4608 demand_empty_rest_of_line ();
604633ae 4609 path = xmalloc ((unsigned long) i + include_dir_maxlen + 5 /* slop */ );
6efd877d
KR
4610 for (i = 0; i < include_dir_count; i++)
4611 {
4612 strcpy (path, include_dirs[i]);
4613 strcat (path, "/");
4614 strcat (path, filename);
f2889110 4615 if (0 != (try = fopen (path, "r")))
6efd877d
KR
4616 {
4617 fclose (try);
4618 goto gotit;
4619 }
4620 }
4621 free (path);
f8701a3f
SC
4622 path = filename;
4623gotit:
4624 /* malloc Storage leak when file is found on path. FIXME-SOMEDAY. */
cd924033 4625 register_dependency (path);
f8701a3f
SC
4626 newbuf = input_scrub_include_file (path, input_line_pointer);
4627 buffer_limit = input_scrub_next_buffer (&input_line_pointer);
6efd877d 4628} /* s_include() */
fecd2382 4629
6efd877d
KR
4630void
4631add_include_dir (path)
4632 char *path;
fecd2382 4633{
f8701a3f
SC
4634 int i;
4635
4636 if (include_dir_count == 0)
4637 {
6efd877d 4638 include_dirs = (char **) xmalloc (2 * sizeof (*include_dirs));
f8701a3f
SC
4639 include_dirs[0] = "."; /* Current dir */
4640 include_dir_count = 2;
4641 }
4642 else
4643 {
4644 include_dir_count++;
6efd877d
KR
4645 include_dirs = (char **) realloc (include_dirs,
4646 include_dir_count * sizeof (*include_dirs));
f8701a3f
SC
4647 }
4648
6efd877d 4649 include_dirs[include_dir_count - 1] = path; /* New one */
f8701a3f 4650
6efd877d
KR
4651 i = strlen (path);
4652 if (i > include_dir_maxlen)
4653 include_dir_maxlen = i;
4654} /* add_include_dir() */
fecd2382 4655
6efd877d
KR
4656void
4657s_ignore (arg)
4658 int arg;
fecd2382 4659{
58d4951d 4660 while (!is_end_of_line[(unsigned char) *input_line_pointer])
6efd877d
KR
4661 {
4662 ++input_line_pointer;
4663 }
4664 ++input_line_pointer;
4064305e
SS
4665}
4666
604633ae 4667
6594d6b9
KR
4668void
4669read_print_statistics (file)
4670 FILE *file;
4671{
4672 hash_print_statistics (file, "pseudo-op table", po_hash);
4673}
4674
fecd2382 4675/* end of read.c */
This page took 0.841495 seconds and 4 git commands to generate.