]>
Commit | Line | Data |
---|---|---|
fecd2382 | 1 | /* expr.c -operands, expressions- |
30d0557c ILT |
2 | Copyright (C) 1987, 90, 91, 92, 93, 94, 95, 96, 1997 |
3 | Free Software Foundation, Inc. | |
2ed83a59 | 4 | |
a39116f1 | 5 | This file is part of GAS, the GNU Assembler. |
2ed83a59 | 6 | |
a39116f1 RP |
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. | |
2ed83a59 | 11 | |
a39116f1 RP |
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. | |
2ed83a59 | 16 | |
a39116f1 | 17 | You should have received a copy of the GNU General Public License |
30d0557c 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 RP |
21 | |
22 | /* | |
23 | * This is really a branch office of as-read.c. I split it out to clearly | |
24 | * distinguish the world of expressions from the world of statements. | |
25 | * (It also gives smaller files to re-compile.) | |
26 | * Here, "operand"s are of expressions, not instructions. | |
27 | */ | |
28 | ||
29 | #include <ctype.h> | |
30 | #include <string.h> | |
31 | ||
32 | #include "as.h" | |
fecd2382 RP |
33 | #include "obstack.h" |
34 | ||
d4c8cbd8 JL |
35 | static void floating_constant PARAMS ((expressionS * expressionP)); |
36 | static void integer_constant PARAMS ((int radix, expressionS * expressionP)); | |
219deb70 | 37 | static void mri_char_constant PARAMS ((expressionS *)); |
52e1cf9d | 38 | static void current_location PARAMS ((expressionS *)); |
f2f7d044 | 39 | static void clean_up_expression PARAMS ((expressionS * expressionP)); |
5ac34ac3 | 40 | |
f2f7d044 | 41 | extern const char EXP_CHARS[], FLT_CHARS[]; |
30d0557c ILT |
42 | |
43 | /* We keep a mapping of expression symbols to file positions, so that | |
44 | we can provide better error messages. */ | |
45 | ||
46 | struct expr_symbol_line | |
47 | { | |
48 | struct expr_symbol_line *next; | |
49 | symbolS *sym; | |
50 | char *file; | |
51 | unsigned int line; | |
52 | }; | |
53 | ||
54 | static struct expr_symbol_line *expr_symbol_lines; | |
5ac34ac3 ILT |
55 | \f |
56 | /* Build a dummy symbol to hold a complex expression. This is how we | |
57 | build expressions up out of other expressions. The symbol is put | |
58 | into the fake section expr_section. */ | |
59 | ||
3a762a0b | 60 | symbolS * |
5ac34ac3 ILT |
61 | make_expr_symbol (expressionP) |
62 | expressionS *expressionP; | |
63 | { | |
64 | const char *fake; | |
65 | symbolS *symbolP; | |
30d0557c | 66 | struct expr_symbol_line *n; |
fecd2382 | 67 | |
d90f530b KR |
68 | if (expressionP->X_op == O_symbol |
69 | && expressionP->X_add_number == 0) | |
70 | return expressionP->X_add_symbol; | |
71 | ||
5ac34ac3 ILT |
72 | /* FIXME: This should be something which decode_local_label_name |
73 | will handle. */ | |
d4c8cbd8 JL |
74 | fake = FAKE_LABEL_NAME; |
75 | ||
5ac34ac3 ILT |
76 | /* Putting constant symbols in absolute_section rather than |
77 | expr_section is convenient for the old a.out code, for which | |
78 | S_GET_SEGMENT does not always retrieve the value put in by | |
79 | S_SET_SEGMENT. */ | |
3a762a0b KR |
80 | symbolP = symbol_create (fake, |
81 | (expressionP->X_op == O_constant | |
82 | ? absolute_section | |
83 | : expr_section), | |
84 | 0, &zero_address_frag); | |
5ac34ac3 | 85 | symbolP->sy_value = *expressionP; |
d90f530b KR |
86 | |
87 | if (expressionP->X_op == O_constant) | |
88 | resolve_symbol_value (symbolP); | |
89 | ||
30d0557c ILT |
90 | n = (struct expr_symbol_line *) xmalloc (sizeof *n); |
91 | n->sym = symbolP; | |
92 | as_where (&n->file, &n->line); | |
93 | n->next = expr_symbol_lines; | |
94 | expr_symbol_lines = n; | |
95 | ||
5ac34ac3 ILT |
96 | return symbolP; |
97 | } | |
30d0557c ILT |
98 | |
99 | /* Return the file and line number for an expr symbol. Return | |
100 | non-zero if something was found, 0 if no information is known for | |
101 | the symbol. */ | |
102 | ||
103 | int | |
104 | expr_symbol_where (sym, pfile, pline) | |
105 | symbolS *sym; | |
106 | char **pfile; | |
107 | unsigned int *pline; | |
108 | { | |
109 | register struct expr_symbol_line *l; | |
110 | ||
111 | for (l = expr_symbol_lines; l != NULL; l = l->next) | |
112 | { | |
113 | if (l->sym == sym) | |
114 | { | |
115 | *pfile = l->file; | |
116 | *pline = l->line; | |
117 | return 1; | |
118 | } | |
119 | } | |
120 | ||
121 | return 0; | |
122 | } | |
5ac34ac3 | 123 | \f |
fecd2382 RP |
124 | /* |
125 | * Build any floating-point literal here. | |
126 | * Also build any bignum literal here. | |
127 | */ | |
128 | ||
fecd2382 RP |
129 | /* Seems atof_machine can backscan through generic_bignum and hit whatever |
130 | happens to be loaded before it in memory. And its way too complicated | |
131 | for me to fix right. Thus a hack. JF: Just make generic_bignum bigger, | |
132 | and never write into the early words, thus they'll always be zero. | |
f2f7d044 | 133 | I hate Dean's floating-point code. Bleh. */ |
2ed83a59 KR |
134 | LITTLENUM_TYPE generic_bignum[SIZE_OF_LARGE_NUMBER + 6]; |
135 | FLONUM_TYPE generic_floating_point_number = | |
fecd2382 | 136 | { |
2ed83a59 | 137 | &generic_bignum[6], /* low (JF: Was 0) */ |
351878df | 138 | &generic_bignum[SIZE_OF_LARGE_NUMBER + 6 - 1], /* high JF: (added +6) */ |
2ed83a59 KR |
139 | 0, /* leader */ |
140 | 0, /* exponent */ | |
141 | 0 /* sign */ | |
142 | }; | |
fecd2382 RP |
143 | /* If nonzero, we've been asked to assemble nan, +inf or -inf */ |
144 | int generic_floating_point_magic; | |
145 | \f | |
d4c8cbd8 | 146 | static void |
2ed83a59 KR |
147 | floating_constant (expressionP) |
148 | expressionS *expressionP; | |
c593cf41 SC |
149 | { |
150 | /* input_line_pointer->*/ | |
151 | /* floating-point constant. */ | |
152 | int error_code; | |
153 | ||
351878df KR |
154 | error_code = atof_generic (&input_line_pointer, ".", EXP_CHARS, |
155 | &generic_floating_point_number); | |
c593cf41 SC |
156 | |
157 | if (error_code) | |
c593cf41 | 158 | { |
2ed83a59 KR |
159 | if (error_code == ERROR_EXPONENT_OVERFLOW) |
160 | { | |
161 | as_bad ("bad floating-point constant: exponent overflow, probably assembling junk"); | |
162 | } | |
163 | else | |
164 | { | |
165 | as_bad ("bad floating-point constant: unknown error code=%d.", error_code); | |
166 | } | |
c593cf41 | 167 | } |
5ac34ac3 | 168 | expressionP->X_op = O_big; |
c593cf41 SC |
169 | /* input_line_pointer->just after constant, */ |
170 | /* which may point to whitespace. */ | |
2ed83a59 | 171 | expressionP->X_add_number = -1; |
c593cf41 SC |
172 | } |
173 | ||
d4c8cbd8 | 174 | static void |
2ed83a59 KR |
175 | integer_constant (radix, expressionP) |
176 | int radix; | |
177 | expressionS *expressionP; | |
c593cf41 | 178 | { |
7691379e | 179 | char *start; /* start of number. */ |
219deb70 | 180 | char *suffix = NULL; |
c593cf41 | 181 | char c; |
dae92eab KR |
182 | valueT number; /* offset or (absolute) value */ |
183 | short int digit; /* value of next digit in current radix */ | |
184 | short int maxdig = 0;/* highest permitted digit value. */ | |
185 | int too_many_digits = 0; /* if we see >= this number of */ | |
186 | char *name; /* points to name of symbol */ | |
187 | symbolS *symbolP; /* points to symbol */ | |
2ed83a59 KR |
188 | |
189 | int small; /* true if fits in 32 bits. */ | |
2ed83a59 | 190 | |
dae92eab KR |
191 | /* May be bignum, or may fit in 32 bits. */ |
192 | /* Most numbers fit into 32 bits, and we want this case to be fast. | |
193 | so we pretend it will fit into 32 bits. If, after making up a 32 | |
194 | bit number, we realise that we have scanned more digits than | |
195 | comfortably fit into 32 bits, we re-scan the digits coding them | |
196 | into a bignum. For decimal and octal numbers we are | |
197 | conservative: Some numbers may be assumed bignums when in fact | |
198 | they do fit into 32 bits. Numbers of any radix can have excess | |
199 | leading zeros: We strive to recognise this and cast them back | |
200 | into 32 bits. We must check that the bignum really is more than | |
201 | 32 bits, and change it back to a 32-bit number if it fits. The | |
202 | number we are looking for is expected to be positive, but if it | |
203 | fits into 32 bits as an unsigned number, we let it be a 32-bit | |
204 | number. The cavalier approach is for speed in ordinary cases. */ | |
58d4951d ILT |
205 | /* This has been extended for 64 bits. We blindly assume that if |
206 | you're compiling in 64-bit mode, the target is a 64-bit machine. | |
207 | This should be cleaned up. */ | |
208 | ||
209 | #ifdef BFD64 | |
210 | #define valuesize 64 | |
211 | #else /* includes non-bfd case, mostly */ | |
212 | #define valuesize 32 | |
213 | #endif | |
2ed83a59 | 214 | |
30d0557c | 215 | if (flag_m68k_mri && radix == 0) |
219deb70 ILT |
216 | { |
217 | int flt = 0; | |
218 | ||
219 | /* In MRI mode, the number may have a suffix indicating the | |
220 | radix. For that matter, it might actually be a floating | |
221 | point constant. */ | |
222 | for (suffix = input_line_pointer; isalnum (*suffix); suffix++) | |
223 | { | |
224 | if (*suffix == 'e' || *suffix == 'E') | |
225 | flt = 1; | |
226 | } | |
227 | ||
228 | if (suffix == input_line_pointer) | |
229 | { | |
230 | radix = 10; | |
231 | suffix = NULL; | |
232 | } | |
233 | else | |
234 | { | |
235 | c = *--suffix; | |
236 | if (islower (c)) | |
237 | c = toupper (c); | |
238 | if (c == 'B') | |
239 | radix = 2; | |
240 | else if (c == 'D') | |
241 | radix = 10; | |
242 | else if (c == 'O' || c == 'Q') | |
243 | radix = 8; | |
244 | else if (c == 'H') | |
245 | radix = 16; | |
246 | else if (suffix[1] == '.' || c == 'E' || flt) | |
247 | { | |
248 | floating_constant (expressionP); | |
249 | return; | |
250 | } | |
251 | else | |
252 | { | |
253 | radix = 10; | |
254 | suffix = NULL; | |
255 | } | |
256 | } | |
257 | } | |
258 | ||
2ed83a59 | 259 | switch (radix) |
f8701a3f | 260 | { |
f8701a3f SC |
261 | case 2: |
262 | maxdig = 2; | |
58d4951d | 263 | too_many_digits = valuesize + 1; |
f8701a3f SC |
264 | break; |
265 | case 8: | |
266 | maxdig = radix = 8; | |
7691379e | 267 | too_many_digits = (valuesize + 2) / 3 + 1; |
f8701a3f SC |
268 | break; |
269 | case 16: | |
f8701a3f | 270 | maxdig = radix = 16; |
7691379e | 271 | too_many_digits = (valuesize + 3) / 4 + 1; |
f8701a3f SC |
272 | break; |
273 | case 10: | |
274 | maxdig = radix = 10; | |
58d4951d | 275 | too_many_digits = (valuesize + 12) / 4; /* very rough */ |
f8701a3f | 276 | } |
58d4951d | 277 | #undef valuesize |
7691379e KR |
278 | start = input_line_pointer; |
279 | c = *input_line_pointer++; | |
58d4951d | 280 | for (number = 0; |
3a762a0b | 281 | (digit = hex_value (c)) < maxdig; |
58d4951d | 282 | c = *input_line_pointer++) |
f8701a3f SC |
283 | { |
284 | number = number * radix + digit; | |
285 | } | |
c593cf41 SC |
286 | /* c contains character after number. */ |
287 | /* input_line_pointer->char after c. */ | |
7691379e | 288 | small = (input_line_pointer - start - 1) < too_many_digits; |
2ed83a59 | 289 | if (!small) |
c593cf41 | 290 | { |
f8701a3f SC |
291 | /* |
292 | * we saw a lot of digits. manufacture a bignum the hard way. | |
293 | */ | |
2ed83a59 KR |
294 | LITTLENUM_TYPE *leader; /*->high order littlenum of the bignum. */ |
295 | LITTLENUM_TYPE *pointer; /*->littlenum we are frobbing now. */ | |
f8701a3f | 296 | long carry; |
2ed83a59 | 297 | |
f8701a3f | 298 | leader = generic_bignum; |
2ed83a59 KR |
299 | generic_bignum[0] = 0; |
300 | generic_bignum[1] = 0; | |
7691379e | 301 | input_line_pointer = start; /*->1st digit. */ |
f8701a3f | 302 | c = *input_line_pointer++; |
58d4951d | 303 | for (; |
3a762a0b | 304 | (carry = hex_value (c)) < maxdig; |
58d4951d | 305 | c = *input_line_pointer++) |
f8701a3f SC |
306 | { |
307 | for (pointer = generic_bignum; | |
308 | pointer <= leader; | |
309 | pointer++) | |
310 | { | |
311 | long work; | |
2ed83a59 KR |
312 | |
313 | work = carry + radix * *pointer; | |
f8701a3f SC |
314 | *pointer = work & LITTLENUM_MASK; |
315 | carry = work >> LITTLENUM_NUMBER_OF_BITS; | |
316 | } | |
317 | if (carry) | |
318 | { | |
319 | if (leader < generic_bignum + SIZE_OF_LARGE_NUMBER - 1) | |
351878df KR |
320 | { |
321 | /* room to grow a longer bignum. */ | |
f8701a3f SC |
322 | *++leader = carry; |
323 | } | |
324 | } | |
325 | } | |
326 | /* again, c is char after number, */ | |
327 | /* input_line_pointer->after c. */ | |
2ed83a59 | 328 | know (LITTLENUM_NUMBER_OF_BITS == 16); |
7691379e | 329 | if (leader < generic_bignum + 2) |
351878df KR |
330 | { |
331 | /* will fit into 32 bits. */ | |
f8701a3f | 332 | number = |
2ed83a59 KR |
333 | ((generic_bignum[1] & LITTLENUM_MASK) << LITTLENUM_NUMBER_OF_BITS) |
334 | | (generic_bignum[0] & LITTLENUM_MASK); | |
f8701a3f SC |
335 | small = 1; |
336 | } | |
337 | else | |
338 | { | |
2ed83a59 | 339 | number = leader - generic_bignum + 1; /* number of littlenums in the bignum. */ |
c593cf41 | 340 | } |
c593cf41 | 341 | } |
219deb70 | 342 | |
30d0557c | 343 | if (flag_m68k_mri && suffix != NULL && input_line_pointer - 1 == suffix) |
219deb70 ILT |
344 | c = *input_line_pointer++; |
345 | ||
2ed83a59 KR |
346 | if (small) |
347 | { | |
f8701a3f | 348 | /* |
2ed83a59 KR |
349 | * here with number, in correct radix. c is the next char. |
350 | * note that unlike un*x, we allow "011f" "0x9f" to | |
351 | * both mean the same as the (conventional) "9f". this is simply easier | |
352 | * than checking for strict canonical form. syntax sux! | |
f8701a3f | 353 | */ |
2ed83a59 | 354 | |
219deb70 | 355 | if (LOCAL_LABELS_FB && c == 'b') |
2ed83a59 | 356 | { |
219deb70 ILT |
357 | /* |
358 | * backward ref to local label. | |
359 | * because it is backward, expect it to be defined. | |
360 | */ | |
361 | /* Construct a local label. */ | |
362 | name = fb_label_name ((int) number, 0); | |
2ed83a59 | 363 | |
219deb70 ILT |
364 | /* seen before, or symbol is defined: ok */ |
365 | symbolP = symbol_find (name); | |
366 | if ((symbolP != NULL) && (S_IS_DEFINED (symbolP))) | |
367 | { | |
368 | /* local labels are never absolute. don't waste time | |
369 | checking absoluteness. */ | |
370 | know (SEG_NORMAL (S_GET_SEGMENT (symbolP))); | |
2ed83a59 | 371 | |
219deb70 ILT |
372 | expressionP->X_op = O_symbol; |
373 | expressionP->X_add_symbol = symbolP; | |
374 | } | |
375 | else | |
376 | { | |
377 | /* either not seen or not defined. */ | |
378 | /* @@ Should print out the original string instead of | |
379 | the parsed number. */ | |
380 | as_bad ("backw. ref to unknown label \"%d:\", 0 assumed.", | |
381 | (int) number); | |
382 | expressionP->X_op = O_constant; | |
383 | } | |
2ed83a59 | 384 | |
219deb70 ILT |
385 | expressionP->X_add_number = 0; |
386 | } /* case 'b' */ | |
387 | else if (LOCAL_LABELS_FB && c == 'f') | |
388 | { | |
389 | /* | |
390 | * forward reference. expect symbol to be undefined or | |
391 | * unknown. undefined: seen it before. unknown: never seen | |
392 | * it before. | |
393 | * construct a local label name, then an undefined symbol. | |
394 | * don't create a xseg frag for it: caller may do that. | |
395 | * just return it as never seen before. | |
396 | */ | |
397 | name = fb_label_name ((int) number, 1); | |
398 | symbolP = symbol_find_or_make (name); | |
399 | /* we have no need to check symbol properties. */ | |
c593cf41 | 400 | #ifndef many_segments |
219deb70 ILT |
401 | /* since "know" puts its arg into a "string", we |
402 | can't have newlines in the argument. */ | |
403 | know (S_GET_SEGMENT (symbolP) == undefined_section || S_GET_SEGMENT (symbolP) == text_section || S_GET_SEGMENT (symbolP) == data_section); | |
c593cf41 | 404 | #endif |
219deb70 ILT |
405 | expressionP->X_op = O_symbol; |
406 | expressionP->X_add_symbol = symbolP; | |
407 | expressionP->X_add_number = 0; | |
408 | } /* case 'f' */ | |
409 | else if (LOCAL_LABELS_DOLLAR && c == '$') | |
410 | { | |
411 | /* If the dollar label is *currently* defined, then this is just | |
412 | another reference to it. If it is not *currently* defined, | |
413 | then this is a fresh instantiation of that number, so create | |
414 | it. */ | |
2ed83a59 | 415 | |
219deb70 ILT |
416 | if (dollar_label_defined ((long) number)) |
417 | { | |
418 | name = dollar_label_name ((long) number, 0); | |
419 | symbolP = symbol_find (name); | |
420 | know (symbolP != NULL); | |
421 | } | |
422 | else | |
423 | { | |
424 | name = dollar_label_name ((long) number, 1); | |
425 | symbolP = symbol_find_or_make (name); | |
426 | } | |
2ed83a59 | 427 | |
219deb70 ILT |
428 | expressionP->X_op = O_symbol; |
429 | expressionP->X_add_symbol = symbolP; | |
430 | expressionP->X_add_number = 0; | |
431 | } /* case '$' */ | |
432 | else | |
433 | { | |
434 | expressionP->X_op = O_constant; | |
435 | #ifdef TARGET_WORD_SIZE | |
436 | /* Sign extend NUMBER. */ | |
437 | number |= (-(number >> (TARGET_WORD_SIZE - 1))) << (TARGET_WORD_SIZE - 1); | |
438 | #endif | |
439 | expressionP->X_add_number = number; | |
440 | input_line_pointer--; /* restore following character. */ | |
441 | } /* really just a number */ | |
442 | } | |
443 | else | |
444 | { | |
445 | /* not a small number */ | |
446 | expressionP->X_op = O_big; | |
447 | expressionP->X_add_number = number; /* number of littlenums */ | |
448 | input_line_pointer--; /*->char following number. */ | |
449 | } | |
450 | } | |
2ed83a59 | 451 | |
219deb70 | 452 | /* Parse an MRI multi character constant. */ |
f8701a3f | 453 | |
219deb70 ILT |
454 | static void |
455 | mri_char_constant (expressionP) | |
456 | expressionS *expressionP; | |
457 | { | |
458 | int i; | |
2ed83a59 | 459 | |
219deb70 ILT |
460 | if (*input_line_pointer == '\'' |
461 | && input_line_pointer[1] != '\'') | |
462 | { | |
463 | expressionP->X_op = O_constant; | |
464 | expressionP->X_add_number = 0; | |
465 | return; | |
466 | } | |
2ed83a59 | 467 | |
219deb70 ILT |
468 | /* In order to get the correct byte ordering, we must build the |
469 | number in reverse. */ | |
470 | for (i = SIZE_OF_LARGE_NUMBER - 1; i >= 0; i--) | |
471 | { | |
472 | int j; | |
2ed83a59 | 473 | |
219deb70 ILT |
474 | generic_bignum[i] = 0; |
475 | for (j = 0; j < CHARS_PER_LITTLENUM; j++) | |
476 | { | |
477 | if (*input_line_pointer == '\'') | |
478 | { | |
479 | if (input_line_pointer[1] != '\'') | |
480 | break; | |
481 | ++input_line_pointer; | |
482 | } | |
483 | generic_bignum[i] <<= 8; | |
484 | generic_bignum[i] += *input_line_pointer; | |
485 | ++input_line_pointer; | |
486 | } | |
2ed83a59 | 487 | |
219deb70 ILT |
488 | if (i < SIZE_OF_LARGE_NUMBER - 1) |
489 | { | |
490 | /* If there is more than one littlenum, left justify the | |
491 | last one to make it match the earlier ones. If there is | |
492 | only one, we can just use the value directly. */ | |
493 | for (; j < CHARS_PER_LITTLENUM; j++) | |
494 | generic_bignum[i] <<= 8; | |
495 | } | |
2ed83a59 | 496 | |
219deb70 ILT |
497 | if (*input_line_pointer == '\'' |
498 | && input_line_pointer[1] != '\'') | |
499 | break; | |
500 | } | |
2ed83a59 | 501 | |
219deb70 ILT |
502 | if (i < 0) |
503 | { | |
504 | as_bad ("Character constant too large"); | |
505 | i = 0; | |
506 | } | |
2ed83a59 | 507 | |
219deb70 ILT |
508 | if (i > 0) |
509 | { | |
510 | int c; | |
511 | int j; | |
2ed83a59 | 512 | |
219deb70 ILT |
513 | c = SIZE_OF_LARGE_NUMBER - i; |
514 | for (j = 0; j < c; j++) | |
515 | generic_bignum[j] = generic_bignum[i + j]; | |
516 | i = c; | |
2ed83a59 | 517 | } |
219deb70 ILT |
518 | |
519 | know (LITTLENUM_NUMBER_OF_BITS == 16); | |
520 | if (i > 2) | |
dae92eab | 521 | { |
5ac34ac3 | 522 | expressionP->X_op = O_big; |
219deb70 ILT |
523 | expressionP->X_add_number = i; |
524 | } | |
525 | else | |
526 | { | |
527 | expressionP->X_op = O_constant; | |
528 | if (i < 2) | |
529 | expressionP->X_add_number = generic_bignum[0] & LITTLENUM_MASK; | |
530 | else | |
531 | expressionP->X_add_number = | |
532 | (((generic_bignum[1] & LITTLENUM_MASK) | |
533 | << LITTLENUM_NUMBER_OF_BITS) | |
534 | | (generic_bignum[0] & LITTLENUM_MASK)); | |
dae92eab | 535 | } |
c593cf41 | 536 | |
219deb70 ILT |
537 | /* Skip the final closing quote. */ |
538 | ++input_line_pointer; | |
539 | } | |
c593cf41 | 540 | |
52e1cf9d ILT |
541 | /* Return an expression representing the current location. This |
542 | handles the magic symbol `.'. */ | |
543 | ||
544 | static void | |
545 | current_location (expressionp) | |
546 | expressionS *expressionp; | |
547 | { | |
548 | if (now_seg == absolute_section) | |
549 | { | |
550 | expressionp->X_op = O_constant; | |
551 | expressionp->X_add_number = abs_section_offset; | |
552 | } | |
553 | else | |
554 | { | |
555 | symbolS *symbolp; | |
556 | ||
557 | symbolp = symbol_new (FAKE_LABEL_NAME, now_seg, | |
558 | (valueT) frag_now_fix (), | |
559 | frag_now); | |
560 | expressionp->X_op = O_symbol; | |
561 | expressionp->X_add_symbol = symbolp; | |
562 | expressionp->X_add_number = 0; | |
563 | } | |
564 | } | |
565 | ||
fecd2382 RP |
566 | /* |
567 | * Summary of operand(). | |
568 | * | |
569 | * in: Input_line_pointer points to 1st char of operand, which may | |
570 | * be a space. | |
571 | * | |
5ac34ac3 ILT |
572 | * out: A expressionS. |
573 | * The operand may have been empty: in this case X_op == O_absent. | |
fecd2382 | 574 | * Input_line_pointer->(next non-blank) char after operand. |
fecd2382 | 575 | */ |
c593cf41 | 576 | |
fecd2382 | 577 | static segT |
c593cf41 | 578 | operand (expressionP) |
dae92eab | 579 | expressionS *expressionP; |
fecd2382 | 580 | { |
dae92eab KR |
581 | char c; |
582 | symbolS *symbolP; /* points to symbol */ | |
583 | char *name; /* points to name of symbol */ | |
58d4951d | 584 | segT segment; |
c593cf41 | 585 | |
d4c8cbd8 JL |
586 | /* All integers are regarded as unsigned unless they are negated. |
587 | This is because the only thing which cares whether a number is | |
588 | unsigned is the code in emit_expr which extends constants into | |
589 | bignums. It should only sign extend negative numbers, so that | |
590 | something like ``.quad 0x80000000'' is not sign extended even | |
591 | though it appears negative if valueT is 32 bits. */ | |
592 | expressionP->X_unsigned = 1; | |
593 | ||
c593cf41 SC |
594 | /* digits, assume it is a bignum. */ |
595 | ||
2ed83a59 KR |
596 | SKIP_WHITESPACE (); /* leading whitespace is part of operand. */ |
597 | c = *input_line_pointer++; /* input_line_pointer->past char in c. */ | |
c593cf41 SC |
598 | |
599 | switch (c) | |
fecd2382 | 600 | { |
c593cf41 SC |
601 | case '1': |
602 | case '2': | |
603 | case '3': | |
604 | case '4': | |
605 | case '5': | |
606 | case '6': | |
607 | case '7': | |
2ed83a59 KR |
608 | case '8': |
609 | case '9': | |
610 | input_line_pointer--; | |
611 | ||
30d0557c | 612 | integer_constant (flag_m68k_mri ? 0 : 10, expressionP); |
c593cf41 SC |
613 | break; |
614 | ||
2ed83a59 KR |
615 | case '0': |
616 | /* non-decimal radix */ | |
617 | ||
30d0557c | 618 | if (flag_m68k_mri) |
219deb70 ILT |
619 | { |
620 | char *s; | |
621 | ||
622 | /* Check for a hex constant. */ | |
623 | for (s = input_line_pointer; hex_p (*s); s++) | |
624 | ; | |
625 | if (*s == 'h' || *s == 'H') | |
626 | { | |
627 | --input_line_pointer; | |
628 | integer_constant (0, expressionP); | |
629 | break; | |
630 | } | |
631 | } | |
632 | ||
2ed83a59 KR |
633 | c = *input_line_pointer; |
634 | switch (c) | |
635 | { | |
30d0557c ILT |
636 | case 'o': |
637 | case 'O': | |
638 | case 'q': | |
639 | case 'Q': | |
3dce804d ILT |
640 | case '8': |
641 | case '9': | |
30d0557c | 642 | if (flag_m68k_mri) |
3dce804d ILT |
643 | { |
644 | integer_constant (0, expressionP); | |
645 | break; | |
646 | } | |
647 | /* Fall through. */ | |
2ed83a59 | 648 | default: |
219deb70 | 649 | default_case: |
2ed83a59 KR |
650 | if (c && strchr (FLT_CHARS, c)) |
651 | { | |
652 | input_line_pointer++; | |
653 | floating_constant (expressionP); | |
7691379e | 654 | expressionP->X_add_number = -(isupper (c) ? tolower (c) : c); |
2ed83a59 KR |
655 | } |
656 | else | |
657 | { | |
658 | /* The string was only zero */ | |
5ac34ac3 | 659 | expressionP->X_op = O_constant; |
2ed83a59 | 660 | expressionP->X_add_number = 0; |
2ed83a59 KR |
661 | } |
662 | ||
663 | break; | |
664 | ||
665 | case 'x': | |
666 | case 'X': | |
30d0557c | 667 | if (flag_m68k_mri) |
219deb70 | 668 | goto default_case; |
2ed83a59 KR |
669 | input_line_pointer++; |
670 | integer_constant (16, expressionP); | |
671 | break; | |
672 | ||
673 | case 'b': | |
30d0557c | 674 | if (LOCAL_LABELS_FB && ! flag_m68k_mri) |
2ed83a59 | 675 | { |
30d0557c ILT |
676 | /* This code used to check for '+' and '-' here, and, in |
677 | some conditions, fall through to call | |
678 | integer_constant. However, that didn't make sense, | |
679 | as integer_constant only accepts digits. */ | |
680 | /* Some of our code elsewhere does permit digits greater | |
681 | than the expected base; for consistency, do the same | |
682 | here. */ | |
683 | if (input_line_pointer[1] < '0' | |
684 | || input_line_pointer[1] > '9') | |
219deb70 | 685 | { |
30d0557c ILT |
686 | /* Parse this as a back reference to label 0. */ |
687 | input_line_pointer--; | |
688 | integer_constant (10, expressionP); | |
689 | break; | |
219deb70 | 690 | } |
30d0557c | 691 | /* Otherwise, parse this as a binary number. */ |
2ed83a59 | 692 | } |
30d0557c | 693 | /* Fall through. */ |
2ed83a59 KR |
694 | case 'B': |
695 | input_line_pointer++; | |
30d0557c | 696 | if (flag_m68k_mri) |
219deb70 | 697 | goto default_case; |
2ed83a59 KR |
698 | integer_constant (2, expressionP); |
699 | break; | |
700 | ||
701 | case '0': | |
702 | case '1': | |
703 | case '2': | |
704 | case '3': | |
705 | case '4': | |
706 | case '5': | |
707 | case '6': | |
708 | case '7': | |
30d0557c | 709 | integer_constant (flag_m68k_mri ? 0 : 8, expressionP); |
2ed83a59 KR |
710 | break; |
711 | ||
712 | case 'f': | |
219deb70 ILT |
713 | if (LOCAL_LABELS_FB) |
714 | { | |
715 | /* If it says "0f" and it could possibly be a floating point | |
716 | number, make it one. Otherwise, make it a local label, | |
717 | and try to deal with parsing the rest later. */ | |
718 | if (!input_line_pointer[1] | |
719 | || (is_end_of_line[0xff & input_line_pointer[1]])) | |
720 | goto is_0f_label; | |
d90f530b | 721 | { |
219deb70 ILT |
722 | char *cp = input_line_pointer + 1; |
723 | int r = atof_generic (&cp, ".", EXP_CHARS, | |
724 | &generic_floating_point_number); | |
725 | switch (r) | |
726 | { | |
727 | case 0: | |
728 | case ERROR_EXPONENT_OVERFLOW: | |
729 | if (*cp == 'f' || *cp == 'b') | |
730 | /* looks like a difference expression */ | |
731 | goto is_0f_label; | |
732 | else | |
733 | goto is_0f_float; | |
734 | default: | |
735 | as_fatal ("expr.c(operand): bad atof_generic return val %d", | |
736 | r); | |
737 | } | |
d90f530b | 738 | } |
d90f530b | 739 | |
219deb70 ILT |
740 | /* Okay, now we've sorted it out. We resume at one of these |
741 | two labels, depending on what we've decided we're probably | |
742 | looking at. */ | |
743 | is_0f_label: | |
744 | input_line_pointer--; | |
745 | integer_constant (10, expressionP); | |
746 | break; | |
747 | ||
748 | is_0f_float: | |
749 | /* fall through */ | |
750 | ; | |
751 | } | |
2ed83a59 KR |
752 | |
753 | case 'd': | |
754 | case 'D': | |
30d0557c ILT |
755 | if (flag_m68k_mri) |
756 | { | |
757 | integer_constant (0, expressionP); | |
758 | break; | |
759 | } | |
760 | /* Fall through. */ | |
2ed83a59 KR |
761 | case 'F': |
762 | case 'r': | |
763 | case 'e': | |
764 | case 'E': | |
765 | case 'g': | |
766 | case 'G': | |
2ed83a59 KR |
767 | input_line_pointer++; |
768 | floating_constant (expressionP); | |
f2f7d044 | 769 | expressionP->X_add_number = -(isupper (c) ? tolower (c) : c); |
2ed83a59 KR |
770 | break; |
771 | ||
2ed83a59 | 772 | case '$': |
219deb70 ILT |
773 | if (LOCAL_LABELS_DOLLAR) |
774 | { | |
775 | integer_constant (10, expressionP); | |
776 | break; | |
777 | } | |
778 | else | |
779 | goto default_case; | |
2ed83a59 KR |
780 | } |
781 | ||
c593cf41 | 782 | break; |
5ac34ac3 | 783 | |
2ed83a59 | 784 | case '(': |
d90f530b | 785 | case '[': |
2ed83a59 | 786 | /* didn't begin with digit & not a name */ |
58d4951d | 787 | segment = expression (expressionP); |
5ac34ac3 | 788 | /* Expression() will pass trailing whitespace */ |
219deb70 ILT |
789 | if ((c == '(' && *input_line_pointer++ != ')') |
790 | || (c == '[' && *input_line_pointer++ != ']')) | |
5ac34ac3 ILT |
791 | { |
792 | as_bad ("Missing ')' assumed"); | |
793 | input_line_pointer--; | |
794 | } | |
30d0557c | 795 | SKIP_WHITESPACE (); |
5ac34ac3 | 796 | /* here with input_line_pointer->char after "(...)" */ |
58d4951d | 797 | return segment; |
c593cf41 | 798 | |
219deb70 | 799 | case 'E': |
30d0557c | 800 | if (! flag_m68k_mri || *input_line_pointer != '\'') |
219deb70 ILT |
801 | goto de_fault; |
802 | as_bad ("EBCDIC constants are not supported"); | |
803 | /* Fall through. */ | |
804 | case 'A': | |
30d0557c | 805 | if (! flag_m68k_mri || *input_line_pointer != '\'') |
219deb70 ILT |
806 | goto de_fault; |
807 | ++input_line_pointer; | |
808 | /* Fall through. */ | |
2ed83a59 | 809 | case '\'': |
30d0557c | 810 | if (! flag_m68k_mri) |
219deb70 ILT |
811 | { |
812 | /* Warning: to conform to other people's assemblers NO | |
813 | ESCAPEMENT is permitted for a single quote. The next | |
814 | character, parity errors and all, is taken as the value | |
815 | of the operand. VERY KINKY. */ | |
816 | expressionP->X_op = O_constant; | |
817 | expressionP->X_add_number = *input_line_pointer++; | |
818 | break; | |
819 | } | |
820 | ||
821 | mri_char_constant (expressionP); | |
2ed83a59 KR |
822 | break; |
823 | ||
49864cfa | 824 | case '+': |
58d4951d | 825 | (void) operand (expressionP); |
49864cfa KR |
826 | break; |
827 | ||
219deb70 | 828 | case '"': |
30d0557c ILT |
829 | /* Double quote is the bitwise not operator in MRI mode. */ |
830 | if (! flag_m68k_mri) | |
219deb70 ILT |
831 | goto de_fault; |
832 | /* Fall through. */ | |
2ed83a59 | 833 | case '~': |
30d0557c ILT |
834 | /* ~ is permitted to start a label on the Delta. */ |
835 | if (is_name_beginner (c)) | |
836 | goto isname; | |
837 | case '!': | |
2ed83a59 | 838 | case '-': |
2ed83a59 | 839 | { |
5ac34ac3 ILT |
840 | operand (expressionP); |
841 | if (expressionP->X_op == O_constant) | |
2ed83a59 | 842 | { |
2ed83a59 KR |
843 | /* input_line_pointer -> char after operand */ |
844 | if (c == '-') | |
845 | { | |
5ac34ac3 | 846 | expressionP->X_add_number = - expressionP->X_add_number; |
d841bc49 KR |
847 | /* Notice: '-' may overflow: no warning is given. This is |
848 | compatible with other people's assemblers. Sigh. */ | |
d4c8cbd8 | 849 | expressionP->X_unsigned = 0; |
2ed83a59 | 850 | } |
30d0557c | 851 | else if (c == '~' || c == '"') |
5ac34ac3 | 852 | expressionP->X_add_number = ~ expressionP->X_add_number; |
30d0557c ILT |
853 | else |
854 | expressionP->X_add_number = ! expressionP->X_add_number; | |
f2f7d044 | 855 | } |
5ac34ac3 ILT |
856 | else if (expressionP->X_op != O_illegal |
857 | && expressionP->X_op != O_absent) | |
f2f7d044 | 858 | { |
5ac34ac3 | 859 | expressionP->X_add_symbol = make_expr_symbol (expressionP); |
2ed83a59 | 860 | if (c == '-') |
5ac34ac3 | 861 | expressionP->X_op = O_uminus; |
30d0557c | 862 | else if (c == '~' || c == '"') |
5ac34ac3 | 863 | expressionP->X_op = O_bit_not; |
30d0557c ILT |
864 | else |
865 | expressionP->X_op = O_logical_not; | |
5ac34ac3 | 866 | expressionP->X_add_number = 0; |
c593cf41 | 867 | } |
f2f7d044 | 868 | else |
5ac34ac3 ILT |
869 | as_warn ("Unary operator %c ignored because bad operand follows", |
870 | c); | |
c593cf41 | 871 | } |
2ed83a59 KR |
872 | break; |
873 | ||
d90f530b | 874 | case '$': |
219deb70 ILT |
875 | /* $ is the program counter when in MRI mode, or when DOLLAR_DOT |
876 | is defined. */ | |
877 | #ifndef DOLLAR_DOT | |
30d0557c | 878 | if (! flag_m68k_mri) |
219deb70 | 879 | goto de_fault; |
d90f530b | 880 | #endif |
30d0557c | 881 | if (flag_m68k_mri && hex_p (*input_line_pointer)) |
219deb70 ILT |
882 | { |
883 | /* In MRI mode, $ is also used as the prefix for a | |
884 | hexadecimal constant. */ | |
885 | integer_constant (16, expressionP); | |
886 | break; | |
887 | } | |
52e1cf9d ILT |
888 | |
889 | if (is_part_of_name (*input_line_pointer)) | |
890 | goto isname; | |
891 | ||
892 | current_location (expressionP); | |
893 | break; | |
894 | ||
219deb70 | 895 | case '.': |
2ed83a59 KR |
896 | if (!is_part_of_name (*input_line_pointer)) |
897 | { | |
52e1cf9d | 898 | current_location (expressionP); |
2ed83a59 | 899 | break; |
2ed83a59 | 900 | } |
3dce804d ILT |
901 | else if ((strncasecmp (input_line_pointer, "startof.", 8) == 0 |
902 | && ! is_part_of_name (input_line_pointer[8])) | |
903 | || (strncasecmp (input_line_pointer, "sizeof.", 7) == 0 | |
904 | && ! is_part_of_name (input_line_pointer[7]))) | |
905 | { | |
906 | int start; | |
907 | ||
908 | start = (input_line_pointer[1] == 't' | |
909 | || input_line_pointer[1] == 'T'); | |
910 | input_line_pointer += start ? 8 : 7; | |
911 | SKIP_WHITESPACE (); | |
912 | if (*input_line_pointer != '(') | |
913 | as_bad ("syntax error in .startof. or .sizeof."); | |
914 | else | |
915 | { | |
916 | char *buf; | |
917 | ||
918 | ++input_line_pointer; | |
919 | SKIP_WHITESPACE (); | |
920 | name = input_line_pointer; | |
921 | c = get_symbol_end (); | |
922 | ||
923 | buf = (char *) xmalloc (strlen (name) + 10); | |
924 | if (start) | |
925 | sprintf (buf, ".startof.%s", name); | |
926 | else | |
927 | sprintf (buf, ".sizeof.%s", name); | |
928 | symbolP = symbol_make (buf); | |
929 | free (buf); | |
930 | ||
931 | expressionP->X_op = O_symbol; | |
932 | expressionP->X_add_symbol = symbolP; | |
933 | expressionP->X_add_number = 0; | |
934 | ||
935 | *input_line_pointer = c; | |
936 | SKIP_WHITESPACE (); | |
937 | if (*input_line_pointer != ')') | |
938 | as_bad ("syntax error in .startof. or .sizeof."); | |
939 | else | |
940 | ++input_line_pointer; | |
941 | } | |
942 | break; | |
943 | } | |
2ed83a59 KR |
944 | else |
945 | { | |
946 | goto isname; | |
2ed83a59 KR |
947 | } |
948 | case ',': | |
949 | case '\n': | |
f2f7d044 | 950 | case '\0': |
0bd77bc4 | 951 | eol: |
2ed83a59 | 952 | /* can't imagine any other kind of operand */ |
5ac34ac3 | 953 | expressionP->X_op = O_absent; |
2ed83a59 | 954 | input_line_pointer--; |
219deb70 ILT |
955 | break; |
956 | ||
957 | case '%': | |
30d0557c | 958 | if (! flag_m68k_mri) |
219deb70 ILT |
959 | goto de_fault; |
960 | integer_constant (2, expressionP); | |
961 | break; | |
962 | ||
963 | case '@': | |
30d0557c | 964 | if (! flag_m68k_mri) |
219deb70 ILT |
965 | goto de_fault; |
966 | integer_constant (8, expressionP); | |
967 | break; | |
968 | ||
969 | case ':': | |
30d0557c | 970 | if (! flag_m68k_mri) |
219deb70 ILT |
971 | goto de_fault; |
972 | ||
973 | /* In MRI mode, this is a floating point constant represented | |
974 | using hexadecimal digits. */ | |
975 | ||
976 | ++input_line_pointer; | |
977 | integer_constant (16, expressionP); | |
2ed83a59 | 978 | break; |
0bd77bc4 | 979 | |
52e1cf9d | 980 | case '*': |
30d0557c | 981 | if (! flag_m68k_mri || is_part_of_name (*input_line_pointer)) |
52e1cf9d ILT |
982 | goto de_fault; |
983 | ||
984 | current_location (expressionP); | |
985 | break; | |
986 | ||
2ed83a59 | 987 | default: |
219deb70 | 988 | de_fault: |
58d4951d | 989 | if (is_end_of_line[(unsigned char) c]) |
0bd77bc4 | 990 | goto eol; |
2ed83a59 KR |
991 | if (is_name_beginner (c)) /* here if did not begin with a digit */ |
992 | { | |
993 | /* | |
d841bc49 KR |
994 | * Identifier begins here. |
995 | * This is kludged for speed, so code is repeated. | |
996 | */ | |
2ed83a59 KR |
997 | isname: |
998 | name = --input_line_pointer; | |
999 | c = get_symbol_end (); | |
30d0557c ILT |
1000 | |
1001 | #ifdef md_parse_name | |
1002 | /* This is a hook for the backend to parse certain names | |
1003 | specially in certain contexts. If a name always has a | |
1004 | specific value, it can often be handled by simply | |
1005 | entering it in the symbol table. */ | |
1006 | if (md_parse_name (name, expressionP)) | |
1007 | { | |
1008 | *input_line_pointer = c; | |
1009 | break; | |
1010 | } | |
1011 | #endif | |
1012 | ||
1013 | #ifdef TC_I960 | |
1014 | /* The MRI i960 assembler permits | |
1015 | lda sizeof code,g13 | |
1016 | FIXME: This should use md_parse_name. */ | |
1017 | if (flag_mri | |
1018 | && (strcasecmp (name, "sizeof") == 0 | |
1019 | || strcasecmp (name, "startof") == 0)) | |
1020 | { | |
1021 | int start; | |
1022 | char *buf; | |
1023 | ||
1024 | start = (name[1] == 't' | |
1025 | || name[1] == 'T'); | |
1026 | ||
1027 | *input_line_pointer = c; | |
1028 | SKIP_WHITESPACE (); | |
1029 | ||
1030 | name = input_line_pointer; | |
1031 | c = get_symbol_end (); | |
1032 | ||
1033 | buf = (char *) xmalloc (strlen (name) + 10); | |
1034 | if (start) | |
1035 | sprintf (buf, ".startof.%s", name); | |
1036 | else | |
1037 | sprintf (buf, ".sizeof.%s", name); | |
1038 | symbolP = symbol_make (buf); | |
1039 | free (buf); | |
1040 | ||
1041 | expressionP->X_op = O_symbol; | |
1042 | expressionP->X_add_symbol = symbolP; | |
1043 | expressionP->X_add_number = 0; | |
1044 | ||
1045 | *input_line_pointer = c; | |
1046 | SKIP_WHITESPACE (); | |
1047 | ||
1048 | break; | |
1049 | } | |
1050 | #endif | |
1051 | ||
2ed83a59 | 1052 | symbolP = symbol_find_or_make (name); |
5ac34ac3 ILT |
1053 | |
1054 | /* If we have an absolute symbol or a reg, then we know its | |
1055 | value now. */ | |
58d4951d ILT |
1056 | segment = S_GET_SEGMENT (symbolP); |
1057 | if (segment == absolute_section) | |
5ac34ac3 ILT |
1058 | { |
1059 | expressionP->X_op = O_constant; | |
1060 | expressionP->X_add_number = S_GET_VALUE (symbolP); | |
1061 | } | |
58d4951d | 1062 | else if (segment == reg_section) |
5ac34ac3 ILT |
1063 | { |
1064 | expressionP->X_op = O_register; | |
1065 | expressionP->X_add_number = S_GET_VALUE (symbolP); | |
1066 | } | |
f2f7d044 | 1067 | else |
2ed83a59 | 1068 | { |
5ac34ac3 | 1069 | expressionP->X_op = O_symbol; |
2ed83a59 | 1070 | expressionP->X_add_symbol = symbolP; |
5ac34ac3 | 1071 | expressionP->X_add_number = 0; |
2ed83a59 KR |
1072 | } |
1073 | *input_line_pointer = c; | |
2ed83a59 KR |
1074 | } |
1075 | else | |
1076 | { | |
219deb70 ILT |
1077 | /* Let the target try to parse it. Success is indicated by changing |
1078 | the X_op field to something other than O_absent and pointing | |
1079 | input_line_pointer passed the expression. If it can't parse the | |
1080 | expression, X_op and input_line_pointer should be unchanged. */ | |
1081 | expressionP->X_op = O_absent; | |
1082 | --input_line_pointer; | |
1083 | md_operand (expressionP); | |
1084 | if (expressionP->X_op == O_absent) | |
1085 | { | |
1086 | ++input_line_pointer; | |
1087 | as_bad ("Bad expression"); | |
1088 | expressionP->X_op = O_constant; | |
1089 | expressionP->X_add_number = 0; | |
1090 | } | |
2ed83a59 | 1091 | } |
219deb70 | 1092 | break; |
c593cf41 | 1093 | } |
c593cf41 | 1094 | |
c593cf41 SC |
1095 | /* |
1096 | * It is more 'efficient' to clean up the expressionS when they are created. | |
1097 | * Doing it here saves lines of code. | |
1098 | */ | |
1099 | clean_up_expression (expressionP); | |
2ed83a59 KR |
1100 | SKIP_WHITESPACE (); /*->1st char after operand. */ |
1101 | know (*input_line_pointer != ' '); | |
58d4951d | 1102 | |
009dc5e1 JL |
1103 | /* The PA port needs this information. */ |
1104 | if (expressionP->X_add_symbol) | |
1105 | expressionP->X_add_symbol->sy_used = 1; | |
1106 | ||
58d4951d ILT |
1107 | switch (expressionP->X_op) |
1108 | { | |
1109 | default: | |
1110 | return absolute_section; | |
1111 | case O_symbol: | |
1112 | return S_GET_SEGMENT (expressionP->X_add_symbol); | |
1113 | case O_register: | |
1114 | return reg_section; | |
1115 | } | |
2ed83a59 | 1116 | } /* operand() */ |
fecd2382 RP |
1117 | \f |
1118 | /* Internal. Simplify a struct expression for use by expr() */ | |
1119 | ||
1120 | /* | |
1121 | * In: address of a expressionS. | |
5ac34ac3 | 1122 | * The X_op field of the expressionS may only take certain values. |
fecd2382 RP |
1123 | * Elsewise we waste time special-case testing. Sigh. Ditto SEG_ABSENT. |
1124 | * Out: expressionS may have been modified: | |
1125 | * 'foo-foo' symbol references cancelled to 0, | |
5ac34ac3 | 1126 | * which changes X_op from O_subtract to O_constant. |
fecd2382 RP |
1127 | * Unused fields zeroed to help expr(). |
1128 | */ | |
1129 | ||
1130 | static void | |
c593cf41 | 1131 | clean_up_expression (expressionP) |
dae92eab | 1132 | expressionS *expressionP; |
fecd2382 | 1133 | { |
5ac34ac3 | 1134 | switch (expressionP->X_op) |
2ed83a59 | 1135 | { |
5ac34ac3 ILT |
1136 | case O_illegal: |
1137 | case O_absent: | |
2ed83a59 | 1138 | expressionP->X_add_number = 0; |
5ac34ac3 ILT |
1139 | /* Fall through. */ |
1140 | case O_big: | |
1141 | case O_constant: | |
1142 | case O_register: | |
2ed83a59 | 1143 | expressionP->X_add_symbol = NULL; |
5ac34ac3 ILT |
1144 | /* Fall through. */ |
1145 | case O_symbol: | |
1146 | case O_uminus: | |
1147 | case O_bit_not: | |
1148 | expressionP->X_op_symbol = NULL; | |
1149 | break; | |
1150 | case O_subtract: | |
1151 | if (expressionP->X_op_symbol == expressionP->X_add_symbol | |
1152 | || ((expressionP->X_op_symbol->sy_frag | |
1153 | == expressionP->X_add_symbol->sy_frag) | |
ffffc8fb | 1154 | && SEG_NORMAL (S_GET_SEGMENT (expressionP->X_add_symbol)) |
5ac34ac3 | 1155 | && (S_GET_VALUE (expressionP->X_op_symbol) |
49864cfa | 1156 | == S_GET_VALUE (expressionP->X_add_symbol)))) |
2ed83a59 | 1157 | { |
3a762a0b KR |
1158 | addressT diff = (S_GET_VALUE (expressionP->X_add_symbol) |
1159 | - S_GET_VALUE (expressionP->X_op_symbol)); | |
d90f530b | 1160 | |
5ac34ac3 | 1161 | expressionP->X_op = O_constant; |
2ed83a59 | 1162 | expressionP->X_add_symbol = NULL; |
5ac34ac3 | 1163 | expressionP->X_op_symbol = NULL; |
d90f530b | 1164 | expressionP->X_add_number += diff; |
fecd2382 | 1165 | } |
5ac34ac3 ILT |
1166 | break; |
1167 | default: | |
1168 | break; | |
fecd2382 | 1169 | } |
f2f7d044 | 1170 | } |
fecd2382 RP |
1171 | \f |
1172 | /* Expression parser. */ | |
1173 | ||
1174 | /* | |
1175 | * We allow an empty expression, and just assume (absolute,0) silently. | |
1176 | * Unary operators and parenthetical expressions are treated as operands. | |
1177 | * As usual, Q==quantity==operand, O==operator, X==expression mnemonics. | |
1178 | * | |
1179 | * We used to do a aho/ullman shift-reduce parser, but the logic got so | |
1180 | * warped that I flushed it and wrote a recursive-descent parser instead. | |
1181 | * Now things are stable, would anybody like to write a fast parser? | |
1182 | * Most expressions are either register (which does not even reach here) | |
1183 | * or 1 symbol. Then "symbol+constant" and "symbol-symbol" are common. | |
1184 | * So I guess it doesn't really matter how inefficient more complex expressions | |
1185 | * are parsed. | |
1186 | * | |
1187 | * After expr(RANK,resultP) input_line_pointer->operator of rank <= RANK. | |
1188 | * Also, we have consumed any leading or trailing spaces (operand does that) | |
1189 | * and done all intervening operators. | |
5ac34ac3 ILT |
1190 | * |
1191 | * This returns the segment of the result, which will be | |
1192 | * absolute_section or the segment of a symbol. | |
fecd2382 RP |
1193 | */ |
1194 | ||
49864cfa | 1195 | #undef __ |
fecd2382 RP |
1196 | #define __ O_illegal |
1197 | ||
3dce804d | 1198 | static operatorT op_encoding[256] = |
2ed83a59 KR |
1199 | { /* maps ASCII->operators */ |
1200 | ||
1201 | __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, | |
1202 | __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, | |
1203 | ||
3dce804d | 1204 | __, O_bit_or_not, __, __, __, O_modulus, O_bit_and, __, |
2ed83a59 KR |
1205 | __, __, O_multiply, O_add, __, O_subtract, __, O_divide, |
1206 | __, __, __, __, __, __, __, __, | |
219deb70 | 1207 | __, __, __, __, O_lt, __, O_gt, __, |
2ed83a59 KR |
1208 | __, __, __, __, __, __, __, __, |
1209 | __, __, __, __, __, __, __, __, | |
1210 | __, __, __, __, __, __, __, __, | |
1211 | __, __, __, __, __, __, O_bit_exclusive_or, __, | |
1212 | __, __, __, __, __, __, __, __, | |
1213 | __, __, __, __, __, __, __, __, | |
1214 | __, __, __, __, __, __, __, __, | |
1215 | __, __, __, __, O_bit_inclusive_or, __, __, __, | |
1216 | ||
1217 | __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, | |
1218 | __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, | |
1219 | __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, | |
1220 | __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, | |
1221 | __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, | |
1222 | __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, | |
1223 | __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, | |
1224 | __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __ | |
1225 | }; | |
fecd2382 RP |
1226 | |
1227 | ||
1228 | /* | |
1229 | * Rank Examples | |
1230 | * 0 operand, (expression) | |
30d0557c ILT |
1231 | * 1 || |
1232 | * 2 && | |
1233 | * 3 = <> < <= >= > | |
1234 | * 4 + - | |
1235 | * 5 used for * / % in MRI mode | |
1236 | * 6 & ^ ! | | |
1237 | * 7 * / % << >> | |
1238 | * 8 unary - unary ~ | |
fecd2382 | 1239 | */ |
219deb70 | 1240 | static operator_rankT op_rank[] = |
5ac34ac3 ILT |
1241 | { |
1242 | 0, /* O_illegal */ | |
1243 | 0, /* O_absent */ | |
1244 | 0, /* O_constant */ | |
1245 | 0, /* O_symbol */ | |
30d0557c | 1246 | 0, /* O_symbol_rva */ |
5ac34ac3 ILT |
1247 | 0, /* O_register */ |
1248 | 0, /* O_bit */ | |
30d0557c ILT |
1249 | 8, /* O_uminus */ |
1250 | 8, /* O_bit_not */ | |
1251 | 8, /* O_logical_not */ | |
1252 | 7, /* O_multiply */ | |
1253 | 7, /* O_divide */ | |
1254 | 7, /* O_modulus */ | |
1255 | 7, /* O_left_shift */ | |
1256 | 7, /* O_right_shift */ | |
1257 | 6, /* O_bit_inclusive_or */ | |
1258 | 6, /* O_bit_or_not */ | |
1259 | 6, /* O_bit_exclusive_or */ | |
1260 | 6, /* O_bit_and */ | |
1261 | 4, /* O_add */ | |
1262 | 4, /* O_subtract */ | |
1263 | 3, /* O_eq */ | |
1264 | 3, /* O_ne */ | |
1265 | 3, /* O_lt */ | |
1266 | 3, /* O_le */ | |
1267 | 3, /* O_ge */ | |
1268 | 3, /* O_gt */ | |
1269 | 2, /* O_logical_and */ | |
1270 | 1 /* O_logical_or */ | |
5ac34ac3 | 1271 | }; |
219deb70 ILT |
1272 | |
1273 | /* Initialize the expression parser. */ | |
1274 | ||
1275 | void | |
1276 | expr_begin () | |
1277 | { | |
30d0557c ILT |
1278 | /* In MRI mode for the m68k, multiplication and division have lower |
1279 | precedence than the bit wise operators. */ | |
1280 | if (flag_m68k_mri) | |
219deb70 | 1281 | { |
30d0557c ILT |
1282 | op_rank[O_multiply] = 5; |
1283 | op_rank[O_divide] = 5; | |
1284 | op_rank[O_modulus] = 5; | |
3dce804d | 1285 | op_encoding['"'] = O_bit_not; |
219deb70 | 1286 | } |
30d0557c ILT |
1287 | |
1288 | /* Verify that X_op field is wide enough. */ | |
1289 | { | |
1290 | expressionS e; | |
1291 | e.X_op = O_max; | |
1292 | assert (e.X_op == O_max); | |
1293 | } | |
219deb70 | 1294 | } |
fecd2382 | 1295 | \f |
219deb70 ILT |
1296 | /* Return the encoding for the operator at INPUT_LINE_POINTER. |
1297 | Advance INPUT_LINE_POINTER to the last character in the operator | |
1298 | (i.e., don't change it for a single character operator). */ | |
1299 | ||
1300 | static inline operatorT | |
1301 | operator () | |
1302 | { | |
1303 | int c; | |
1304 | operatorT ret; | |
1305 | ||
1306 | c = *input_line_pointer; | |
1307 | ||
1308 | switch (c) | |
1309 | { | |
1310 | default: | |
1311 | return op_encoding[c]; | |
1312 | ||
1313 | case '<': | |
1314 | switch (input_line_pointer[1]) | |
1315 | { | |
1316 | default: | |
1317 | return op_encoding[c]; | |
1318 | case '<': | |
1319 | ret = O_left_shift; | |
1320 | break; | |
1321 | case '>': | |
1322 | ret = O_ne; | |
1323 | break; | |
1324 | case '=': | |
1325 | ret = O_le; | |
1326 | break; | |
1327 | } | |
1328 | ++input_line_pointer; | |
1329 | return ret; | |
1330 | ||
1331 | case '>': | |
1332 | switch (input_line_pointer[1]) | |
1333 | { | |
1334 | default: | |
1335 | return op_encoding[c]; | |
1336 | case '>': | |
1337 | ret = O_right_shift; | |
1338 | break; | |
1339 | case '=': | |
1340 | ret = O_ge; | |
1341 | break; | |
1342 | } | |
1343 | ++input_line_pointer; | |
1344 | return ret; | |
1345 | ||
1346 | case '!': | |
1347 | /* We accept !! as equivalent to ^ for MRI compatibility. */ | |
1348 | if (input_line_pointer[1] != '!') | |
1349 | { | |
30d0557c | 1350 | if (flag_m68k_mri) |
219deb70 ILT |
1351 | return O_bit_inclusive_or; |
1352 | return op_encoding[c]; | |
1353 | } | |
1354 | ++input_line_pointer; | |
1355 | return O_bit_exclusive_or; | |
30d0557c ILT |
1356 | |
1357 | case '|': | |
1358 | if (input_line_pointer[1] != '|') | |
1359 | return op_encoding[c]; | |
1360 | ||
1361 | ++input_line_pointer; | |
1362 | return O_logical_or; | |
1363 | ||
1364 | case '&': | |
1365 | if (input_line_pointer[1] != '&') | |
1366 | return op_encoding[c]; | |
1367 | ||
1368 | ++input_line_pointer; | |
1369 | return O_logical_and; | |
219deb70 ILT |
1370 | } |
1371 | ||
1372 | /*NOTREACHED*/ | |
1373 | } | |
1374 | ||
1375 | /* Parse an expression. */ | |
1376 | ||
5ac34ac3 | 1377 | segT |
2ed83a59 | 1378 | expr (rank, resultP) |
dae92eab KR |
1379 | operator_rankT rank; /* Larger # is higher rank. */ |
1380 | expressionS *resultP; /* Deliver result here. */ | |
fecd2382 | 1381 | { |
5ac34ac3 | 1382 | segT retval; |
2ed83a59 | 1383 | expressionS right; |
dae92eab | 1384 | operatorT op_left; |
dae92eab | 1385 | operatorT op_right; |
c593cf41 | 1386 | |
2ed83a59 | 1387 | know (rank >= 0); |
5ac34ac3 ILT |
1388 | |
1389 | retval = operand (resultP); | |
1390 | ||
2ed83a59 | 1391 | know (*input_line_pointer != ' '); /* Operand() gobbles spaces. */ |
5ac34ac3 | 1392 | |
219deb70 | 1393 | op_left = operator (); |
2ed83a59 | 1394 | while (op_left != O_illegal && op_rank[(int) op_left] > rank) |
fecd2382 | 1395 | { |
5ac34ac3 ILT |
1396 | segT rightseg; |
1397 | ||
2ed83a59 | 1398 | input_line_pointer++; /*->after 1st character of operator. */ |
5ac34ac3 ILT |
1399 | |
1400 | rightseg = expr (op_rank[(int) op_left], &right); | |
1401 | if (right.X_op == O_absent) | |
fecd2382 | 1402 | { |
5ac34ac3 ILT |
1403 | as_warn ("missing operand; zero assumed"); |
1404 | right.X_op = O_constant; | |
1405 | right.X_add_number = 0; | |
d4c8cbd8 JL |
1406 | right.X_add_symbol = NULL; |
1407 | right.X_op_symbol = NULL; | |
fecd2382 | 1408 | } |
5ac34ac3 | 1409 | |
2ed83a59 | 1410 | know (*input_line_pointer != ' '); |
5ac34ac3 | 1411 | |
58d4951d ILT |
1412 | if (retval == undefined_section) |
1413 | { | |
1414 | if (SEG_NORMAL (rightseg)) | |
1415 | retval = rightseg; | |
1416 | } | |
1417 | else if (! SEG_NORMAL (retval)) | |
5ac34ac3 ILT |
1418 | retval = rightseg; |
1419 | else if (SEG_NORMAL (rightseg) | |
d4c8cbd8 JL |
1420 | && retval != rightseg |
1421 | #ifdef DIFF_EXPR_OK | |
1422 | && op_left != O_subtract | |
1423 | #endif | |
1424 | ) | |
5ac34ac3 ILT |
1425 | as_bad ("operation combines symbols in different segments"); |
1426 | ||
219deb70 | 1427 | op_right = operator (); |
5ac34ac3 ILT |
1428 | |
1429 | know (op_right == O_illegal || op_rank[(int) op_right] <= op_rank[(int) op_left]); | |
30d0557c ILT |
1430 | know ((int) op_left >= (int) O_multiply |
1431 | && (int) op_left <= (int) O_logical_or); | |
5ac34ac3 | 1432 | |
c593cf41 SC |
1433 | /* input_line_pointer->after right-hand quantity. */ |
1434 | /* left-hand quantity in resultP */ | |
1435 | /* right-hand quantity in right. */ | |
1436 | /* operator in op_left. */ | |
5ac34ac3 ILT |
1437 | |
1438 | if (resultP->X_op == O_big) | |
fecd2382 | 1439 | { |
219deb70 ILT |
1440 | as_warn ("left operand is a %s; integer 0 assumed", |
1441 | resultP->X_add_number > 0 ? "bignum" : "float"); | |
5ac34ac3 ILT |
1442 | resultP->X_op = O_constant; |
1443 | resultP->X_add_number = 0; | |
1444 | resultP->X_add_symbol = NULL; | |
1445 | resultP->X_op_symbol = NULL; | |
fecd2382 | 1446 | } |
5ac34ac3 | 1447 | if (right.X_op == O_big) |
fecd2382 | 1448 | { |
219deb70 ILT |
1449 | as_warn ("right operand is a %s; integer 0 assumed", |
1450 | right.X_add_number > 0 ? "bignum" : "float"); | |
5ac34ac3 ILT |
1451 | right.X_op = O_constant; |
1452 | right.X_add_number = 0; | |
1453 | right.X_add_symbol = NULL; | |
1454 | right.X_op_symbol = NULL; | |
1455 | } | |
1456 | ||
1457 | /* Optimize common cases. */ | |
219deb70 | 1458 | if (op_left == O_add && right.X_op == O_constant) |
5ac34ac3 ILT |
1459 | { |
1460 | /* X + constant. */ | |
1461 | resultP->X_add_number += right.X_add_number; | |
1462 | } | |
d90f530b KR |
1463 | /* This case comes up in PIC code. */ |
1464 | else if (op_left == O_subtract | |
1465 | && right.X_op == O_symbol | |
1466 | && resultP->X_op == O_symbol | |
1467 | && (right.X_add_symbol->sy_frag | |
fcacfef6 JL |
1468 | == resultP->X_add_symbol->sy_frag) |
1469 | && SEG_NORMAL (S_GET_SEGMENT (right.X_add_symbol))) | |
1470 | ||
d90f530b KR |
1471 | { |
1472 | resultP->X_add_number += right.X_add_number; | |
1473 | resultP->X_add_number += (S_GET_VALUE (resultP->X_add_symbol) | |
1474 | - S_GET_VALUE (right.X_add_symbol)); | |
1475 | resultP->X_op = O_constant; | |
1476 | resultP->X_add_symbol = 0; | |
1477 | } | |
5ac34ac3 ILT |
1478 | else if (op_left == O_subtract && right.X_op == O_constant) |
1479 | { | |
1480 | /* X - constant. */ | |
1481 | resultP->X_add_number -= right.X_add_number; | |
1482 | } | |
1483 | else if (op_left == O_add && resultP->X_op == O_constant) | |
1484 | { | |
1485 | /* Constant + X. */ | |
1486 | resultP->X_op = right.X_op; | |
1487 | resultP->X_add_symbol = right.X_add_symbol; | |
1488 | resultP->X_op_symbol = right.X_op_symbol; | |
1489 | resultP->X_add_number += right.X_add_number; | |
1490 | retval = rightseg; | |
1491 | } | |
1492 | else if (resultP->X_op == O_constant && right.X_op == O_constant) | |
1493 | { | |
1494 | /* Constant OP constant. */ | |
1495 | offsetT v = right.X_add_number; | |
1496 | if (v == 0 && (op_left == O_divide || op_left == O_modulus)) | |
fecd2382 | 1497 | { |
5ac34ac3 ILT |
1498 | as_warn ("division by zero"); |
1499 | v = 1; | |
fecd2382 | 1500 | } |
5ac34ac3 | 1501 | switch (op_left) |
fecd2382 | 1502 | { |
219deb70 | 1503 | default: abort (); |
5ac34ac3 ILT |
1504 | case O_multiply: resultP->X_add_number *= v; break; |
1505 | case O_divide: resultP->X_add_number /= v; break; | |
1506 | case O_modulus: resultP->X_add_number %= v; break; | |
1507 | case O_left_shift: resultP->X_add_number <<= v; break; | |
30d0557c ILT |
1508 | case O_right_shift: |
1509 | /* We always use unsigned shifts, to avoid relying on | |
1510 | characteristics of the compiler used to compile gas. */ | |
1511 | resultP->X_add_number = | |
1512 | (offsetT) ((valueT) resultP->X_add_number >> (valueT) v); | |
1513 | break; | |
5ac34ac3 ILT |
1514 | case O_bit_inclusive_or: resultP->X_add_number |= v; break; |
1515 | case O_bit_or_not: resultP->X_add_number |= ~v; break; | |
1516 | case O_bit_exclusive_or: resultP->X_add_number ^= v; break; | |
1517 | case O_bit_and: resultP->X_add_number &= v; break; | |
1518 | case O_add: resultP->X_add_number += v; break; | |
1519 | case O_subtract: resultP->X_add_number -= v; break; | |
219deb70 ILT |
1520 | case O_eq: |
1521 | resultP->X_add_number = | |
1522 | resultP->X_add_number == v ? ~ (offsetT) 0 : 0; | |
1523 | break; | |
1524 | case O_ne: | |
1525 | resultP->X_add_number = | |
1526 | resultP->X_add_number != v ? ~ (offsetT) 0 : 0; | |
1527 | break; | |
1528 | case O_lt: | |
1529 | resultP->X_add_number = | |
1530 | resultP->X_add_number < v ? ~ (offsetT) 0 : 0; | |
1531 | break; | |
1532 | case O_le: | |
1533 | resultP->X_add_number = | |
1534 | resultP->X_add_number <= v ? ~ (offsetT) 0 : 0; | |
1535 | break; | |
1536 | case O_ge: | |
1537 | resultP->X_add_number = | |
1538 | resultP->X_add_number >= v ? ~ (offsetT) 0 : 0; | |
1539 | break; | |
1540 | case O_gt: | |
1541 | resultP->X_add_number = | |
1542 | resultP->X_add_number > v ? ~ (offsetT) 0 : 0; | |
1543 | break; | |
30d0557c ILT |
1544 | case O_logical_and: |
1545 | resultP->X_add_number = resultP->X_add_number && v; | |
1546 | break; | |
1547 | case O_logical_or: | |
1548 | resultP->X_add_number = resultP->X_add_number || v; | |
1549 | break; | |
fecd2382 | 1550 | } |
5ac34ac3 ILT |
1551 | } |
1552 | else if (resultP->X_op == O_symbol | |
1553 | && right.X_op == O_symbol | |
1554 | && (op_left == O_add | |
1555 | || op_left == O_subtract | |
1556 | || (resultP->X_add_number == 0 | |
1557 | && right.X_add_number == 0))) | |
1558 | { | |
1559 | /* Symbol OP symbol. */ | |
1560 | resultP->X_op = op_left; | |
1561 | resultP->X_op_symbol = right.X_add_symbol; | |
c593cf41 | 1562 | if (op_left == O_add) |
5ac34ac3 ILT |
1563 | resultP->X_add_number += right.X_add_number; |
1564 | else if (op_left == O_subtract) | |
1565 | resultP->X_add_number -= right.X_add_number; | |
1566 | } | |
1567 | else | |
1568 | { | |
1569 | /* The general case. */ | |
1570 | resultP->X_add_symbol = make_expr_symbol (resultP); | |
1571 | resultP->X_op_symbol = make_expr_symbol (&right); | |
1572 | resultP->X_op = op_left; | |
1573 | resultP->X_add_number = 0; | |
d4c8cbd8 | 1574 | resultP->X_unsigned = 1; |
5ac34ac3 | 1575 | } |
351878df | 1576 | |
2ed83a59 | 1577 | op_left = op_right; |
fecd2382 | 1578 | } /* While next operator is >= this rank. */ |
5ac34ac3 | 1579 | |
009dc5e1 JL |
1580 | /* The PA port needs this information. */ |
1581 | if (resultP->X_add_symbol) | |
1582 | resultP->X_add_symbol->sy_used = 1; | |
1583 | ||
5ac34ac3 | 1584 | return resultP->X_op == O_constant ? absolute_section : retval; |
fecd2382 RP |
1585 | } |
1586 | \f | |
1587 | /* | |
1588 | * get_symbol_end() | |
1589 | * | |
1590 | * This lives here because it belongs equally in expr.c & read.c. | |
1591 | * Expr.c is just a branch office read.c anyway, and putting it | |
1592 | * here lessens the crowd at read.c. | |
1593 | * | |
1594 | * Assume input_line_pointer is at start of symbol name. | |
1595 | * Advance input_line_pointer past symbol name. | |
1596 | * Turn that character into a '\0', returning its former value. | |
1597 | * This allows a string compare (RMS wants symbol names to be strings) | |
1598 | * of the symbol name. | |
1599 | * There will always be a char following symbol name, because all good | |
1600 | * lines end in end-of-line. | |
1601 | */ | |
1602 | char | |
2ed83a59 | 1603 | get_symbol_end () |
fecd2382 | 1604 | { |
dae92eab | 1605 | char c; |
2ed83a59 | 1606 | |
3dce804d ILT |
1607 | /* We accept \001 in a name in case this is being called with a |
1608 | constructed string. */ | |
30d0557c ILT |
1609 | if (is_name_beginner (c = *input_line_pointer++) || c == '\001') |
1610 | while (is_part_of_name (c = *input_line_pointer++) | |
1611 | || c == '\001') | |
1612 | ; | |
2ed83a59 KR |
1613 | *--input_line_pointer = 0; |
1614 | return (c); | |
fecd2382 RP |
1615 | } |
1616 | ||
a39116f1 | 1617 | |
351878df | 1618 | unsigned int |
2ed83a59 | 1619 | get_single_number () |
a39116f1 | 1620 | { |
2ed83a59 KR |
1621 | expressionS exp; |
1622 | operand (&exp); | |
1623 | return exp.X_add_number; | |
1624 | ||
a39116f1 | 1625 | } |
2ed83a59 | 1626 | |
8b228fe9 | 1627 | /* end of expr.c */ |