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