]>
Commit | Line | Data |
---|---|---|
fecd2382 | 1 | /* expr.c -operands, expressions- |
c593cf41 | 2 | Copyright (C) 1987, 1990, 1991, 1992 Free Software Foundation, Inc. |
a39116f1 RP |
3 | |
4 | This file is part of GAS, the GNU Assembler. | |
5 | ||
6 | GAS is free software; you can redistribute it and/or modify | |
7 | it under the terms of the GNU General Public License as published by | |
8 | the Free Software Foundation; either version 2, or (at your option) | |
9 | any later version. | |
10 | ||
11 | GAS is distributed in the hope that it will be useful, | |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 | GNU General Public License for more details. | |
15 | ||
16 | You should have received a copy of the GNU General Public License | |
17 | along with GAS; see the file COPYING. If not, write to | |
18 | the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ | |
fecd2382 RP |
19 | |
20 | /* | |
21 | * This is really a branch office of as-read.c. I split it out to clearly | |
22 | * distinguish the world of expressions from the world of statements. | |
23 | * (It also gives smaller files to re-compile.) | |
24 | * Here, "operand"s are of expressions, not instructions. | |
25 | */ | |
26 | ||
27 | #include <ctype.h> | |
28 | #include <string.h> | |
29 | ||
30 | #include "as.h" | |
31 | ||
32 | #include "obstack.h" | |
33 | ||
c593cf41 | 34 | #if __STDC__ == 1 |
fecd2382 RP |
35 | static void clean_up_expression(expressionS *expressionP); |
36 | #else /* __STDC__ */ | |
37 | static void clean_up_expression(); /* Internal. */ | |
c593cf41 | 38 | #endif /* not __STDC__ */ |
fecd2382 RP |
39 | extern const char EXP_CHARS[]; /* JF hide MD floating pt stuff all the same place */ |
40 | extern const char FLT_CHARS[]; | |
41 | ||
42 | #ifdef LOCAL_LABELS_DOLLAR | |
43 | extern int local_label_defined[]; | |
44 | #endif | |
45 | ||
46 | /* | |
47 | * Build any floating-point literal here. | |
48 | * Also build any bignum literal here. | |
49 | */ | |
50 | ||
51 | /* LITTLENUM_TYPE generic_buffer [6]; */ /* JF this is a hack */ | |
52 | /* Seems atof_machine can backscan through generic_bignum and hit whatever | |
53 | happens to be loaded before it in memory. And its way too complicated | |
54 | for me to fix right. Thus a hack. JF: Just make generic_bignum bigger, | |
55 | and never write into the early words, thus they'll always be zero. | |
56 | I hate Dean's floating-point code. Bleh. | |
a39116f1 | 57 | */ |
fecd2382 RP |
58 | LITTLENUM_TYPE generic_bignum [SIZE_OF_LARGE_NUMBER+6]; |
59 | FLONUM_TYPE generic_floating_point_number = | |
60 | { | |
a39116f1 RP |
61 | & generic_bignum [6], /* low (JF: Was 0) */ |
62 | & generic_bignum [SIZE_OF_LARGE_NUMBER+6 - 1], /* high JF: (added +6) */ | |
63 | 0, /* leader */ | |
64 | 0, /* exponent */ | |
65 | 0 /* sign */ | |
66 | }; | |
fecd2382 RP |
67 | /* If nonzero, we've been asked to assemble nan, +inf or -inf */ |
68 | int generic_floating_point_magic; | |
69 | \f | |
c593cf41 SC |
70 | floating_constant(expressionP) |
71 | expressionS *expressionP; | |
72 | { | |
73 | /* input_line_pointer->*/ | |
74 | /* floating-point constant. */ | |
75 | int error_code; | |
76 | ||
77 | error_code = atof_generic | |
78 | (& input_line_pointer, ".", EXP_CHARS, | |
79 | & generic_floating_point_number); | |
80 | ||
81 | if (error_code) | |
82 | { | |
83 | if (error_code == ERROR_EXPONENT_OVERFLOW) | |
84 | { | |
85 | as_bad("bad floating-point constant: exponent overflow, probably assembling junk"); | |
86 | } | |
87 | else | |
88 | { | |
89 | as_bad("bad floating-point constant: unknown error code=%d.", error_code); | |
90 | } | |
91 | } | |
92 | expressionP->X_seg = SEG_BIG; | |
93 | /* input_line_pointer->just after constant, */ | |
94 | /* which may point to whitespace. */ | |
95 | expressionP->X_add_number =-1; | |
96 | ||
97 | } | |
98 | ||
99 | ||
100 | ||
101 | integer_constant(radix, expressionP) | |
102 | int radix; | |
103 | expressionS *expressionP; | |
104 | ||
105 | ||
106 | { | |
107 | register char * digit_2; /*->2nd digit of number. */ | |
108 | char c; | |
109 | ||
110 | register valueT number; /* offset or (absolute) value */ | |
111 | register short int digit; /* value of next digit in current radix */ | |
112 | register short int maxdig = 0; /* highest permitted digit value. */ | |
113 | register int too_many_digits = 0; /* if we see >= this number of */ | |
114 | register char *name; /* points to name of symbol */ | |
115 | register symbolS * symbolP; /* points to symbol */ | |
116 | ||
117 | int small; /* true if fits in 32 bits. */ | |
118 | extern char hex_value[]; /* in hex_value.c */ | |
119 | ||
120 | /* may be bignum, or may fit in 32 bits. */ | |
121 | /* | |
122 | * most numbers fit into 32 bits, and we want this case to be fast. | |
123 | * so we pretend it will fit into 32 bits. if, after making up a 32 | |
124 | * bit number, we realise that we have scanned more digits than | |
125 | * comfortably fit into 32 bits, we re-scan the digits coding | |
126 | * them into a bignum. for decimal and octal numbers we are conservative: some | |
127 | * numbers may be assumed bignums when in fact they do fit into 32 bits. | |
128 | * numbers of any radix can have excess leading zeros: we strive | |
129 | * to recognise this and cast them back into 32 bits. | |
130 | * we must check that the bignum really is more than 32 | |
131 | * bits, and change it back to a 32-bit number if it fits. | |
132 | * the number we are looking for is expected to be positive, but | |
133 | * if it fits into 32 bits as an unsigned number, we let it be a 32-bit | |
134 | * number. the cavalier approach is for speed in ordinary cases. | |
135 | */ | |
136 | ||
137 | switch (radix) | |
138 | { | |
139 | ||
140 | case 2: | |
141 | maxdig = 2; | |
142 | too_many_digits = 33; | |
143 | break; | |
144 | case 8: | |
145 | maxdig = radix = 8; | |
146 | too_many_digits = 11; | |
147 | break; | |
148 | case 16: | |
149 | ||
150 | ||
151 | maxdig = radix = 16; | |
152 | too_many_digits = 9; | |
153 | break; | |
154 | case 10: | |
155 | maxdig = radix = 10; | |
156 | too_many_digits = 11; | |
157 | } | |
158 | c = *input_line_pointer; | |
159 | input_line_pointer++; | |
160 | digit_2 = input_line_pointer; | |
161 | for (number=0; (digit=hex_value[c])<maxdig; c = * input_line_pointer ++) | |
162 | { | |
163 | number = number * radix + digit; | |
164 | } | |
165 | /* c contains character after number. */ | |
166 | /* input_line_pointer->char after c. */ | |
167 | small = input_line_pointer - digit_2 < too_many_digits; | |
168 | if (! small) | |
169 | { | |
170 | /* | |
171 | * we saw a lot of digits. manufacture a bignum the hard way. | |
172 | */ | |
173 | LITTLENUM_TYPE * leader; /*->high order littlenum of the bignum. */ | |
174 | LITTLENUM_TYPE * pointer; /*->littlenum we are frobbing now. */ | |
175 | long carry; | |
176 | ||
177 | leader = generic_bignum; | |
178 | generic_bignum [0] = 0; | |
179 | generic_bignum [1] = 0; | |
180 | /* we could just use digit_2, but lets be mnemonic. */ | |
181 | input_line_pointer = -- digit_2; /*->1st digit. */ | |
182 | c = *input_line_pointer ++; | |
183 | for (; (carry = hex_value [c]) < maxdig; c = * input_line_pointer ++) | |
184 | { | |
185 | for (pointer = generic_bignum; | |
186 | pointer <= leader; | |
187 | pointer ++) | |
188 | { | |
189 | long work; | |
190 | ||
191 | work = carry + radix * * pointer; | |
192 | * pointer = work & LITTLENUM_MASK; | |
193 | carry = work >> LITTLENUM_NUMBER_OF_BITS; | |
194 | } | |
195 | if (carry) | |
196 | { | |
197 | if (leader < generic_bignum + SIZE_OF_LARGE_NUMBER - 1) | |
198 | { /* room to grow a longer bignum. */ | |
199 | * ++ leader = carry; | |
200 | } | |
201 | } | |
202 | } | |
203 | /* again, c is char after number, */ | |
204 | /* input_line_pointer->after c. */ | |
205 | know(sizeof (int) * 8 == 32); | |
206 | know(LITTLENUM_NUMBER_OF_BITS == 16); | |
207 | /* hence the constant "2" in the next line. */ | |
208 | if (leader < generic_bignum + 2) | |
209 | { /* will fit into 32 bits. */ | |
210 | number = | |
211 | ((generic_bignum [1] & LITTLENUM_MASK) << LITTLENUM_NUMBER_OF_BITS) | |
212 | | (generic_bignum [0] & LITTLENUM_MASK); | |
213 | small = 1; | |
214 | } | |
215 | else | |
216 | { | |
217 | number = leader - generic_bignum + 1; /* number of littlenums in the bignum. */ | |
218 | } | |
219 | } | |
220 | if (small) | |
221 | { | |
222 | /* | |
223 | * here with number, in correct radix. c is the next char. | |
224 | * note that unlike un*x, we allow "011f" "0x9f" to | |
225 | * both mean the same as the (conventional) "9f". this is simply easier | |
226 | * than checking for strict canonical form. syntax sux! | |
227 | */ | |
228 | if (number<10) | |
229 | { | |
230 | if (0 | |
231 | #ifdef local_labels_fb | |
232 | || c=='b' | |
233 | #endif | |
234 | #ifdef local_labels_dollar | |
235 | || (c=='$' && local_label_defined[number]) | |
236 | #endif | |
237 | ) | |
238 | { | |
239 | /* | |
240 | * backward ref to local label. | |
241 | * because it is backward, expect it to be defined. | |
242 | */ | |
243 | /* | |
244 | * construct a local label. | |
245 | */ | |
246 | name = local_label_name ((int)number, 0); | |
247 | if (((symbolP = symbol_find(name)) != NULL) /* seen before */ | |
248 | && (S_IS_DEFINED(symbolP))) /* symbol is defined: ok */ | |
249 | { /* expected path: symbol defined. */ | |
250 | /* local labels are never absolute. don't waste time checking absoluteness. */ | |
251 | know(SEG_NORMAL(S_GET_SEGMENT(symbolP))); | |
252 | ||
253 | expressionP->X_add_symbol = symbolP; | |
254 | expressionP->X_add_number = 0; | |
255 | expressionP->X_seg = S_GET_SEGMENT(symbolP); | |
256 | } | |
257 | else | |
258 | { /* either not seen or not defined. */ | |
259 | as_bad("backw. ref to unknown label \"%d:\", 0 assumed.", | |
260 | number); | |
261 | expressionP->X_add_number = 0; | |
262 | expressionP->X_seg = SEG_ABSOLUTE; | |
263 | } | |
264 | } | |
265 | else | |
266 | { | |
267 | if (0 | |
268 | #ifdef local_labels_fb | |
269 | || c == 'f' | |
270 | #endif | |
271 | #ifdef local_labels_dollar | |
272 | || (c=='$' && !local_label_defined[number]) | |
273 | #endif | |
274 | ) | |
275 | { | |
276 | /* | |
277 | * forward reference. expect symbol to be undefined or | |
278 | * unknown. undefined: seen it before. unknown: never seen | |
279 | * it in this pass. | |
280 | * construct a local label name, then an undefined symbol. | |
281 | * don't create a xseg frag for it: caller may do that. | |
282 | * just return it as never seen before. | |
283 | */ | |
284 | name = local_label_name((int)number, 1); | |
285 | symbolP = symbol_find_or_make(name); | |
286 | /* we have no need to check symbol properties. */ | |
287 | #ifndef many_segments | |
288 | /* since "know" puts its arg into a "string", we | |
289 | can't have newlines in the argument. */ | |
290 | know(S_GET_SEGMENT(symbolP) == SEG_UNKNOWN || S_GET_SEGMENT(symbolP) == SEG_TEXT || S_GET_SEGMENT(symbolP) == SEG_DATA); | |
291 | #endif | |
292 | expressionP->X_add_symbol = symbolP; | |
293 | expressionP->X_seg = SEG_UNKNOWN; | |
294 | expressionP->X_subtract_symbol = NULL; | |
295 | expressionP->X_add_number = 0; | |
296 | } | |
297 | else | |
298 | { /* really a number, not a local label. */ | |
299 | expressionP->X_add_number = number; | |
300 | expressionP->X_seg = SEG_ABSOLUTE; | |
301 | input_line_pointer --; /* restore following character. */ | |
302 | } /* if (c=='f') */ | |
303 | } /* if (c=='b') */ | |
304 | } | |
305 | else | |
306 | { /* really a number. */ | |
307 | expressionP->X_add_number = number; | |
308 | expressionP->X_seg = SEG_ABSOLUTE; | |
309 | input_line_pointer --; /* restore following character. */ | |
310 | } /* if (number<10) */ | |
311 | } | |
312 | else | |
313 | { | |
314 | expressionP->X_add_number = number; | |
315 | expressionP->X_seg = SEG_BIG; | |
316 | input_line_pointer --; /*->char following number. */ | |
317 | } /* if (small) */ | |
318 | } | |
319 | ||
320 | ||
fecd2382 RP |
321 | /* |
322 | * Summary of operand(). | |
323 | * | |
324 | * in: Input_line_pointer points to 1st char of operand, which may | |
325 | * be a space. | |
326 | * | |
327 | * out: A expressionS. X_seg determines how to understand the rest of the | |
328 | * expressionS. | |
329 | * The operand may have been empty: in this case X_seg == SEG_ABSENT. | |
330 | * Input_line_pointer->(next non-blank) char after operand. | |
331 | * | |
332 | */ | |
333 | \f | |
c593cf41 SC |
334 | |
335 | ||
fecd2382 | 336 | static segT |
c593cf41 SC |
337 | operand (expressionP) |
338 | register expressionS * expressionP; | |
fecd2382 | 339 | { |
c593cf41 SC |
340 | register char c; |
341 | register symbolS * symbolP; /* points to symbol */ | |
342 | register char *name; /* points to name of symbol */ | |
343 | /* invented for humans only, hope */ | |
344 | /* optimising compiler flushes it! */ | |
345 | register short int radix; /* 2, 8, 10 or 16, 0 when floating */ | |
346 | /* 0 means we saw start of a floating- */ | |
347 | /* point constant. */ | |
348 | ||
349 | /* digits, assume it is a bignum. */ | |
350 | ||
351 | ||
352 | ||
353 | ||
354 | SKIP_WHITESPACE(); /* leading whitespace is part of operand. */ | |
355 | c = * input_line_pointer ++; /* input_line_pointer->past char in c. */ | |
356 | ||
357 | switch (c) | |
358 | { | |
359 | #ifdef MRI | |
360 | case '%': | |
361 | integer_constant(2, expressionP); | |
362 | break; | |
363 | case '@': | |
364 | integer_constant(8, expressionP); | |
365 | break; | |
366 | case '$': | |
367 | integer_constant(16, expressionP); | |
368 | break; | |
369 | #endif | |
370 | case '1': | |
371 | case '2': | |
372 | case '3': | |
373 | case '4': | |
374 | case '5': | |
375 | case '6': | |
376 | case '7': | |
377 | case '8': | |
378 | case '9': | |
379 | input_line_pointer--; | |
a39116f1 | 380 | |
c593cf41 SC |
381 | integer_constant(10, expressionP); |
382 | break; | |
383 | ||
384 | case '0': | |
385 | /* non-decimal radix */ | |
386 | ||
387 | ||
388 | c = *input_line_pointer; | |
389 | switch (c) | |
fecd2382 | 390 | { |
c593cf41 SC |
391 | |
392 | default: | |
393 | /* The string was only zero */ | |
394 | expressionP->X_add_symbol = 0; | |
395 | expressionP->X_add_number = 0; | |
396 | expressionP->X_seg = SEG_ABSOLUTE; | |
397 | break; | |
398 | ||
399 | case 'x': | |
400 | case 'X': | |
401 | input_line_pointer++; | |
402 | integer_constant(16, expressionP); | |
403 | break; | |
404 | case 'B': | |
405 | case 'b': | |
406 | input_line_pointer++; | |
407 | integer_constant(2, expressionP); | |
408 | break; | |
409 | ||
410 | case '1': | |
411 | case '2': | |
412 | case '3': | |
413 | case '4': | |
414 | case '5': | |
415 | case '6': | |
416 | case '7': | |
417 | integer_constant(8, expressionP); | |
418 | break; | |
419 | ||
420 | case 'f': | |
421 | /* if it says '0f' and the line ends or it doesn't look like | |
422 | a floating point #, its a local label ref. dtrt */ | |
423 | /* likewise for the b's. xoxorich. */ | |
424 | if ((c == 'f' || c == 'b' || c == 'b') | |
425 | && (!*input_line_pointer || | |
426 | (!strchr("+-.0123456789",*input_line_pointer) && | |
427 | !strchr(EXP_CHARS,*input_line_pointer)))) | |
428 | { | |
429 | input_line_pointer -= 2; | |
430 | integer_constant(10, expressionP); | |
431 | break; | |
432 | } | |
433 | ||
434 | case 'd': | |
435 | case 'D': | |
436 | case 'F': | |
437 | ||
438 | case 'e': | |
439 | case 'E': | |
440 | case 'g': | |
441 | case 'G': | |
442 | ||
443 | input_line_pointer++; | |
444 | floating_constant(expressionP); | |
445 | break; | |
fecd2382 | 446 | } |
c593cf41 SC |
447 | |
448 | break; | |
449 | case '(': | |
450 | /* didn't begin with digit & not a name */ | |
451 | { | |
452 | (void)expression(expressionP); | |
453 | /* Expression() will pass trailing whitespace */ | |
454 | if (* input_line_pointer ++ != ')') | |
fecd2382 | 455 | { |
c593cf41 SC |
456 | as_bad("Missing ')' assumed"); |
457 | input_line_pointer --; | |
458 | } | |
459 | /* here with input_line_pointer->char after "(...)" */ | |
460 | } | |
461 | return; | |
462 | ||
463 | ||
464 | case '\'': | |
465 | /* | |
466 | * Warning: to conform to other people's assemblers NO ESCAPEMENT is permitted | |
467 | * for a single quote. The next character, parity errors and all, is taken | |
468 | * as the value of the operand. VERY KINKY. | |
469 | */ | |
470 | expressionP->X_add_number = * input_line_pointer ++; | |
471 | expressionP->X_seg = SEG_ABSOLUTE; | |
472 | break; | |
473 | ||
474 | case '~': | |
475 | case '-': | |
476 | case '+': | |
477 | ||
478 | { | |
479 | /* unary operator: hope for SEG_ABSOLUTE */ | |
480 | switch(operand (expressionP)) { | |
481 | case SEG_ABSOLUTE: | |
482 | /* input_line_pointer -> char after operand */ | |
483 | if ( c=='-' ) | |
fecd2382 | 484 | { |
c593cf41 SC |
485 | expressionP -> X_add_number = - expressionP -> X_add_number; |
486 | /* | |
487 | * Notice: '-' may overflow: no warning is given. This is compatible | |
488 | * with other people's assemblers. Sigh. | |
489 | */ | |
fecd2382 | 490 | } |
c593cf41 | 491 | else |
fecd2382 | 492 | { |
c593cf41 | 493 | expressionP -> X_add_number = ~ expressionP -> X_add_number; |
fecd2382 | 494 | } |
c593cf41 SC |
495 | break; |
496 | ||
497 | case SEG_TEXT: | |
498 | case SEG_DATA: | |
499 | case SEG_BSS: | |
500 | case SEG_PASS1: | |
501 | case SEG_UNKNOWN: | |
502 | if(c=='-') { /* JF I hope this hack works */ | |
503 | expressionP->X_subtract_symbol=expressionP->X_add_symbol; | |
504 | expressionP->X_add_symbol=0; | |
505 | expressionP->X_seg=SEG_DIFFERENCE; | |
a39116f1 | 506 | break; |
c593cf41 SC |
507 | } |
508 | default: /* unary on non-absolute is unsuported */ | |
509 | as_warn("Unary operator %c ignored because bad operand follows", c); | |
510 | break; | |
511 | /* Expression undisturbed from operand(). */ | |
512 | } | |
513 | } | |
514 | ||
515 | ||
516 | ||
517 | break; | |
518 | ||
519 | case '.': | |
520 | if( !is_part_of_name(*input_line_pointer)) | |
fecd2382 | 521 | { |
c593cf41 SC |
522 | extern struct obstack frags; |
523 | ||
524 | /* | |
525 | JF: '.' is pseudo symbol with value of current location in current | |
526 | segment. . . | |
527 | */ | |
528 | symbolP = symbol_new("L0\001", | |
529 | now_seg, | |
530 | (valueT)(obstack_next_free(&frags)-frag_now->fr_literal), | |
531 | frag_now); | |
532 | ||
533 | expressionP->X_add_number=0; | |
534 | expressionP->X_add_symbol=symbolP; | |
535 | expressionP->X_seg = now_seg; | |
536 | break; | |
537 | ||
fecd2382 | 538 | } |
c593cf41 | 539 | else |
fecd2382 | 540 | { |
c593cf41 SC |
541 | goto isname; |
542 | ||
543 | ||
544 | } | |
545 | ||
546 | case '\n': | |
a39116f1 RP |
547 | /* can't imagine any other kind of operand */ |
548 | expressionP->X_seg = SEG_ABSENT; | |
549 | input_line_pointer --; | |
550 | md_operand (expressionP); | |
c593cf41 SC |
551 | break; |
552 | /* Fall through */ | |
553 | default: | |
554 | if (is_name_beginner(c)) /* here if did not begin with a digit */ | |
555 | { | |
556 | /* | |
557 | * Identifier begins here. | |
558 | * This is kludged for speed, so code is repeated. | |
559 | */ | |
560 | isname: | |
561 | name = -- input_line_pointer; | |
562 | c = get_symbol_end(); | |
563 | symbolP = symbol_find_or_make(name); | |
564 | /* | |
565 | * If we have an absolute symbol or a reg, then we know its value now. | |
566 | */ | |
567 | expressionP->X_seg = S_GET_SEGMENT(symbolP); | |
568 | switch (expressionP->X_seg) | |
569 | { | |
570 | case SEG_ABSOLUTE: | |
571 | case SEG_REGISTER: | |
572 | expressionP->X_add_number = S_GET_VALUE(symbolP); | |
573 | break; | |
574 | ||
575 | default: | |
576 | expressionP->X_add_number = 0; | |
577 | expressionP->X_add_symbol = symbolP; | |
578 | } | |
579 | * input_line_pointer = c; | |
580 | expressionP->X_subtract_symbol = NULL; | |
fecd2382 | 581 | } |
c593cf41 SC |
582 | else |
583 | { | |
584 | as_bad("Bad expression"); | |
585 | expressionP->X_add_number = 0; | |
586 | expressionP->X_seg = SEG_ABSOLUTE; | |
587 | ||
588 | } | |
589 | ||
590 | } | |
591 | ||
592 | ||
593 | ||
594 | ||
595 | ||
596 | ||
597 | ||
598 | /* | |
599 | * It is more 'efficient' to clean up the expressionS when they are created. | |
600 | * Doing it here saves lines of code. | |
601 | */ | |
602 | clean_up_expression (expressionP); | |
603 | SKIP_WHITESPACE(); /*->1st char after operand. */ | |
604 | know(* input_line_pointer != ' '); | |
605 | return (expressionP->X_seg); | |
fecd2382 | 606 | } /* operand() */ |
c593cf41 | 607 | |
fecd2382 RP |
608 | \f |
609 | /* Internal. Simplify a struct expression for use by expr() */ | |
610 | ||
611 | /* | |
612 | * In: address of a expressionS. | |
613 | * The X_seg field of the expressionS may only take certain values. | |
614 | * Now, we permit SEG_PASS1 to make code smaller & faster. | |
615 | * Elsewise we waste time special-case testing. Sigh. Ditto SEG_ABSENT. | |
616 | * Out: expressionS may have been modified: | |
617 | * 'foo-foo' symbol references cancelled to 0, | |
618 | * which changes X_seg from SEG_DIFFERENCE to SEG_ABSOLUTE; | |
619 | * Unused fields zeroed to help expr(). | |
620 | */ | |
621 | ||
622 | static void | |
c593cf41 SC |
623 | clean_up_expression (expressionP) |
624 | register expressionS * expressionP; | |
fecd2382 | 625 | { |
c593cf41 SC |
626 | switch (expressionP->X_seg) |
627 | { | |
628 | case SEG_ABSENT: | |
629 | case SEG_PASS1: | |
a39116f1 RP |
630 | expressionP->X_add_symbol = NULL; |
631 | expressionP->X_subtract_symbol = NULL; | |
632 | expressionP->X_add_number = 0; | |
633 | break; | |
c593cf41 SC |
634 | |
635 | case SEG_BIG: | |
636 | case SEG_ABSOLUTE: | |
a39116f1 RP |
637 | expressionP->X_subtract_symbol = NULL; |
638 | expressionP->X_add_symbol = NULL; | |
639 | break; | |
c593cf41 SC |
640 | |
641 | case SEG_UNKNOWN: | |
a39116f1 RP |
642 | expressionP->X_subtract_symbol = NULL; |
643 | break; | |
c593cf41 SC |
644 | |
645 | case SEG_DIFFERENCE: | |
a39116f1 RP |
646 | /* |
647 | * It does not hurt to 'cancel' NULL==NULL | |
648 | * when comparing symbols for 'eq'ness. | |
649 | * It is faster to re-cancel them to NULL | |
650 | * than to check for this special case. | |
651 | */ | |
652 | if (expressionP->X_subtract_symbol == expressionP->X_add_symbol | |
653 | || (expressionP->X_subtract_symbol | |
654 | && expressionP->X_add_symbol | |
655 | && expressionP->X_subtract_symbol->sy_frag==expressionP->X_add_symbol->sy_frag | |
656 | && S_GET_VALUE(expressionP->X_subtract_symbol) == S_GET_VALUE(expressionP->X_add_symbol))) { | |
657 | expressionP->X_subtract_symbol = NULL; | |
658 | expressionP->X_add_symbol = NULL; | |
659 | expressionP->X_seg = SEG_ABSOLUTE; | |
660 | } | |
661 | break; | |
c593cf41 SC |
662 | |
663 | case SEG_REGISTER: | |
a39116f1 RP |
664 | expressionP->X_add_symbol = NULL; |
665 | expressionP->X_subtract_symbol = NULL; | |
666 | break; | |
c593cf41 SC |
667 | |
668 | default: | |
a39116f1 | 669 | if (SEG_NORMAL(expressionP->X_seg)) { |
c593cf41 | 670 | expressionP->X_subtract_symbol = NULL; |
a39116f1 RP |
671 | } |
672 | else { | |
673 | BAD_CASE (expressionP->X_seg); | |
674 | } | |
675 | break; | |
c593cf41 | 676 | } |
fecd2382 RP |
677 | } /* clean_up_expression() */ |
678 | \f | |
679 | /* | |
680 | * expr_part () | |
681 | * | |
682 | * Internal. Made a function because this code is used in 2 places. | |
683 | * Generate error or correct X_?????_symbol of expressionS. | |
684 | */ | |
685 | ||
686 | /* | |
687 | * symbol_1 += symbol_2 ... well ... sort of. | |
688 | */ | |
689 | ||
690 | static segT | |
c593cf41 SC |
691 | expr_part (symbol_1_PP, symbol_2_P) |
692 | symbolS ** symbol_1_PP; | |
693 | symbolS * symbol_2_P; | |
fecd2382 | 694 | { |
a39116f1 RP |
695 | segT return_value; |
696 | #ifndef MANY_SEGMENTS | |
697 | know((* symbol_1_PP) == NULL || (S_GET_SEGMENT(*symbol_1_PP) == SEG_TEXT) || (S_GET_SEGMENT(*symbol_1_PP) == SEG_DATA) || (S_GET_SEGMENT(*symbol_1_PP) == SEG_BSS) || (!S_IS_DEFINED(* symbol_1_PP))); | |
698 | know(symbol_2_P == NULL || (S_GET_SEGMENT(symbol_2_P) == SEG_TEXT) || (S_GET_SEGMENT(symbol_2_P) == SEG_DATA) || (S_GET_SEGMENT(symbol_2_P) == SEG_BSS) || (!S_IS_DEFINED(symbol_2_P))); | |
699 | #endif | |
c593cf41 | 700 | if (* symbol_1_PP) |
fecd2382 | 701 | { |
c593cf41 | 702 | if (!S_IS_DEFINED(* symbol_1_PP)) |
fecd2382 | 703 | { |
c593cf41 | 704 | if (symbol_2_P) |
fecd2382 | 705 | { |
a39116f1 RP |
706 | return_value = SEG_PASS1; |
707 | * symbol_1_PP = NULL; | |
fecd2382 | 708 | } |
c593cf41 | 709 | else |
fecd2382 | 710 | { |
a39116f1 RP |
711 | know(!S_IS_DEFINED(* symbol_1_PP)); |
712 | return_value = SEG_UNKNOWN; | |
fecd2382 RP |
713 | } |
714 | } | |
c593cf41 | 715 | else |
fecd2382 | 716 | { |
c593cf41 | 717 | if (symbol_2_P) |
fecd2382 | 718 | { |
c593cf41 | 719 | if (!S_IS_DEFINED(symbol_2_P)) |
fecd2382 | 720 | { |
c593cf41 SC |
721 | * symbol_1_PP = NULL; |
722 | return_value = SEG_PASS1; | |
fecd2382 | 723 | } |
c593cf41 | 724 | else |
fecd2382 | 725 | { |
c593cf41 SC |
726 | /* {seg1} - {seg2} */ |
727 | as_bad("Expression too complex, 2 symbolS forgotten: \"%s\" \"%s\"", | |
728 | S_GET_NAME(* symbol_1_PP), S_GET_NAME(symbol_2_P)); | |
729 | * symbol_1_PP = NULL; | |
730 | return_value = SEG_ABSOLUTE; | |
fecd2382 RP |
731 | } |
732 | } | |
c593cf41 | 733 | else |
fecd2382 | 734 | { |
c593cf41 | 735 | return_value = S_GET_SEGMENT(* symbol_1_PP); |
fecd2382 RP |
736 | } |
737 | } | |
738 | } | |
c593cf41 | 739 | else |
fecd2382 | 740 | { /* (* symbol_1_PP) == NULL */ |
c593cf41 | 741 | if (symbol_2_P) |
fecd2382 | 742 | { |
c593cf41 SC |
743 | * symbol_1_PP = symbol_2_P; |
744 | return_value = S_GET_SEGMENT(symbol_2_P); | |
fecd2382 | 745 | } |
c593cf41 | 746 | else |
fecd2382 | 747 | { |
c593cf41 SC |
748 | * symbol_1_PP = NULL; |
749 | return_value = SEG_ABSOLUTE; | |
fecd2382 RP |
750 | } |
751 | } | |
a39116f1 | 752 | #ifndef MANY_SEGMENTS |
c593cf41 | 753 | know(return_value == SEG_ABSOLUTE || return_value == SEG_TEXT || return_value == SEG_DATA || return_value == SEG_BSS || return_value == SEG_UNKNOWN || return_value == SEG_PASS1); |
a39116f1 | 754 | #endif |
c593cf41 SC |
755 | know((*symbol_1_PP) == NULL || (S_GET_SEGMENT(*symbol_1_PP) == return_value)); |
756 | return (return_value); | |
fecd2382 RP |
757 | } /* expr_part() */ |
758 | \f | |
759 | /* Expression parser. */ | |
760 | ||
761 | /* | |
762 | * We allow an empty expression, and just assume (absolute,0) silently. | |
763 | * Unary operators and parenthetical expressions are treated as operands. | |
764 | * As usual, Q==quantity==operand, O==operator, X==expression mnemonics. | |
765 | * | |
766 | * We used to do a aho/ullman shift-reduce parser, but the logic got so | |
767 | * warped that I flushed it and wrote a recursive-descent parser instead. | |
768 | * Now things are stable, would anybody like to write a fast parser? | |
769 | * Most expressions are either register (which does not even reach here) | |
770 | * or 1 symbol. Then "symbol+constant" and "symbol-symbol" are common. | |
771 | * So I guess it doesn't really matter how inefficient more complex expressions | |
772 | * are parsed. | |
773 | * | |
774 | * After expr(RANK,resultP) input_line_pointer->operator of rank <= RANK. | |
775 | * Also, we have consumed any leading or trailing spaces (operand does that) | |
776 | * and done all intervening operators. | |
777 | */ | |
778 | ||
779 | typedef enum | |
780 | { | |
a39116f1 RP |
781 | O_illegal, /* (0) what we get for illegal op */ |
782 | ||
783 | O_multiply, /* (1) * */ | |
784 | O_divide, /* (2) / */ | |
785 | O_modulus, /* (3) % */ | |
786 | O_left_shift, /* (4) < */ | |
787 | O_right_shift, /* (5) > */ | |
788 | O_bit_inclusive_or, /* (6) | */ | |
789 | O_bit_or_not, /* (7) ! */ | |
790 | O_bit_exclusive_or, /* (8) ^ */ | |
791 | O_bit_and, /* (9) & */ | |
792 | O_add, /* (10) + */ | |
793 | O_subtract /* (11) - */ | |
794 | } | |
fecd2382 RP |
795 | operatorT; |
796 | ||
797 | #define __ O_illegal | |
798 | ||
799 | static const operatorT op_encoding [256] = { /* maps ASCII->operators */ | |
a39116f1 RP |
800 | |
801 | __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, | |
802 | __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, | |
803 | ||
804 | __, O_bit_or_not, __, __, __, O_modulus, O_bit_and, __, | |
805 | __, __, O_multiply, O_add, __, O_subtract, __, O_divide, | |
806 | __, __, __, __, __, __, __, __, | |
807 | __, __, __, __, O_left_shift, __, O_right_shift, __, | |
808 | __, __, __, __, __, __, __, __, | |
809 | __, __, __, __, __, __, __, __, | |
810 | __, __, __, __, __, __, __, __, | |
811 | __, __, __, __, __, __, O_bit_exclusive_or, __, | |
812 | __, __, __, __, __, __, __, __, | |
813 | __, __, __, __, __, __, __, __, | |
814 | __, __, __, __, __, __, __, __, | |
815 | __, __, __, __, O_bit_inclusive_or, __, __, __, | |
816 | ||
817 | __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, | |
818 | __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, | |
819 | __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, | |
820 | __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, | |
821 | __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, | |
822 | __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, | |
823 | __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, | |
824 | __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __ | |
825 | }; | |
fecd2382 RP |
826 | |
827 | ||
828 | /* | |
829 | * Rank Examples | |
830 | * 0 operand, (expression) | |
831 | * 1 + - | |
832 | * 2 & ^ ! | | |
833 | * 3 * / % << >> | |
834 | */ | |
835 | static const operator_rankT | |
c593cf41 | 836 | op_rank [] = { 0, 3, 3, 3, 3, 3, 2, 2, 2, 2, 1, 1 }; |
fecd2382 RP |
837 | \f |
838 | /* Return resultP->X_seg. */ | |
839 | segT expr(rank, resultP) | |
c593cf41 SC |
840 | register operator_rankT rank; /* Larger # is higher rank. */ |
841 | register expressionS *resultP; /* Deliver result here. */ | |
fecd2382 | 842 | { |
c593cf41 SC |
843 | expressionS right; |
844 | register operatorT op_left; | |
845 | register char c_left; /* 1st operator character. */ | |
846 | register operatorT op_right; | |
847 | register char c_right; | |
848 | ||
849 | know(rank >= 0); | |
850 | (void)operand (resultP); | |
851 | know(* input_line_pointer != ' '); /* Operand() gobbles spaces. */ | |
852 | c_left = * input_line_pointer; /* Potential operator character. */ | |
853 | op_left = op_encoding [c_left]; | |
854 | while (op_left != O_illegal && op_rank [(int) op_left] > rank) | |
fecd2382 | 855 | { |
c593cf41 SC |
856 | input_line_pointer ++; /*->after 1st character of operator. */ |
857 | /* Operators "<<" and ">>" have 2 characters. */ | |
858 | if (* input_line_pointer == c_left && (c_left == '<' || c_left == '>')) | |
fecd2382 | 859 | { |
c593cf41 | 860 | input_line_pointer ++; |
fecd2382 | 861 | } /*->after operator. */ |
c593cf41 | 862 | if (SEG_ABSENT == expr (op_rank[(int) op_left], &right)) |
fecd2382 | 863 | { |
c593cf41 SC |
864 | as_warn("Missing operand value assumed absolute 0."); |
865 | resultP->X_add_number = 0; | |
866 | resultP->X_subtract_symbol = NULL; | |
867 | resultP->X_add_symbol = NULL; | |
868 | resultP->X_seg = SEG_ABSOLUTE; | |
fecd2382 | 869 | } |
c593cf41 SC |
870 | know(* input_line_pointer != ' '); |
871 | c_right = * input_line_pointer; | |
872 | op_right = op_encoding [c_right]; | |
873 | if (* input_line_pointer == c_right && (c_right == '<' || c_right == '>')) | |
fecd2382 | 874 | { |
c593cf41 | 875 | input_line_pointer ++; |
fecd2382 | 876 | } /*->after operator. */ |
c593cf41 SC |
877 | know((int) op_right == 0 || op_rank [(int) op_right] <= op_rank[(int) op_left]); |
878 | /* input_line_pointer->after right-hand quantity. */ | |
879 | /* left-hand quantity in resultP */ | |
880 | /* right-hand quantity in right. */ | |
881 | /* operator in op_left. */ | |
882 | if (resultP->X_seg == SEG_PASS1 || right . X_seg == SEG_PASS1) | |
fecd2382 | 883 | { |
c593cf41 | 884 | resultP->X_seg = SEG_PASS1; |
fecd2382 | 885 | } |
c593cf41 | 886 | else |
fecd2382 | 887 | { |
c593cf41 | 888 | if (resultP->X_seg == SEG_BIG) |
fecd2382 | 889 | { |
c593cf41 SC |
890 | as_warn("Left operand of %c is a %s. Integer 0 assumed.", |
891 | c_left, resultP->X_add_number > 0 ? "bignum" : "float"); | |
892 | resultP->X_seg = SEG_ABSOLUTE; | |
893 | resultP->X_add_symbol = 0; | |
894 | resultP->X_subtract_symbol = 0; | |
895 | resultP->X_add_number = 0; | |
fecd2382 | 896 | } |
c593cf41 | 897 | if (right . X_seg == SEG_BIG) |
fecd2382 | 898 | { |
c593cf41 SC |
899 | as_warn("Right operand of %c is a %s. Integer 0 assumed.", |
900 | c_left, right . X_add_number > 0 ? "bignum" : "float"); | |
901 | right . X_seg = SEG_ABSOLUTE; | |
902 | right . X_add_symbol = 0; | |
903 | right . X_subtract_symbol = 0; | |
904 | right . X_add_number = 0; | |
fecd2382 | 905 | } |
c593cf41 | 906 | if (op_left == O_subtract) |
fecd2382 | 907 | { |
c593cf41 SC |
908 | /* |
909 | * Convert - into + by exchanging symbolS and negating number. | |
910 | * I know -infinity can't be negated in 2's complement: | |
911 | * but then it can't be subtracted either. This trick | |
912 | * does not cause any further inaccuracy. | |
913 | */ | |
914 | ||
915 | register symbolS * symbolP; | |
916 | ||
917 | right . X_add_number = - right . X_add_number; | |
918 | symbolP = right . X_add_symbol; | |
919 | right . X_add_symbol = right . X_subtract_symbol; | |
920 | right . X_subtract_symbol = symbolP; | |
921 | if (symbolP) | |
fecd2382 | 922 | { |
c593cf41 | 923 | right . X_seg = SEG_DIFFERENCE; |
fecd2382 | 924 | } |
c593cf41 | 925 | op_left = O_add; |
fecd2382 | 926 | } |
c593cf41 SC |
927 | \f |
928 | if (op_left == O_add) | |
fecd2382 | 929 | { |
c593cf41 SC |
930 | segT seg1; |
931 | segT seg2; | |
a39116f1 | 932 | #ifndef MANY_SEGMENTS |
c593cf41 SC |
933 | know(resultP->X_seg == SEG_DATA || resultP->X_seg == SEG_TEXT || resultP->X_seg == SEG_BSS || resultP->X_seg == SEG_UNKNOWN || resultP->X_seg == SEG_DIFFERENCE || resultP->X_seg == SEG_ABSOLUTE || resultP->X_seg == SEG_PASS1); |
934 | know(right.X_seg == SEG_DATA || right.X_seg == SEG_TEXT || right.X_seg == SEG_BSS || right.X_seg == SEG_UNKNOWN || right.X_seg == SEG_DIFFERENCE || right.X_seg == SEG_ABSOLUTE || right.X_seg == SEG_PASS1); | |
a39116f1 | 935 | #endif |
c593cf41 SC |
936 | clean_up_expression (& right); |
937 | clean_up_expression (resultP); | |
938 | ||
939 | seg1 = expr_part (& resultP->X_add_symbol, right . X_add_symbol); | |
940 | seg2 = expr_part (& resultP->X_subtract_symbol, right . X_subtract_symbol); | |
941 | if (seg1 == SEG_PASS1 || seg2 == SEG_PASS1) { | |
942 | need_pass_2 = 1; | |
943 | resultP->X_seg = SEG_PASS1; | |
944 | } else if (seg2 == SEG_ABSOLUTE) | |
945 | resultP->X_seg = seg1; | |
946 | else if (seg1 != SEG_UNKNOWN | |
947 | && seg1 != SEG_ABSOLUTE | |
948 | && seg2 != SEG_UNKNOWN | |
949 | && seg1 != seg2) { | |
950 | know(seg2 != SEG_ABSOLUTE); | |
951 | know(resultP->X_subtract_symbol); | |
a39116f1 | 952 | #ifndef MANY_SEGMENTS |
c593cf41 SC |
953 | know(seg1 == SEG_TEXT || seg1 == SEG_DATA || seg1== SEG_BSS); |
954 | know(seg2 == SEG_TEXT || seg2 == SEG_DATA || seg2== SEG_BSS); | |
a39116f1 | 955 | #endif |
c593cf41 SC |
956 | know(resultP->X_add_symbol); |
957 | know(resultP->X_subtract_symbol); | |
958 | as_bad("Expression too complex: forgetting %s - %s", | |
959 | S_GET_NAME(resultP->X_add_symbol), | |
960 | S_GET_NAME(resultP->X_subtract_symbol)); | |
961 | resultP->X_seg = SEG_ABSOLUTE; | |
962 | /* Clean_up_expression() will do the rest. */ | |
963 | } else | |
964 | resultP->X_seg = SEG_DIFFERENCE; | |
965 | ||
966 | resultP->X_add_number += right . X_add_number; | |
967 | clean_up_expression (resultP); | |
968 | } | |
969 | else | |
fecd2382 | 970 | { /* Not +. */ |
c593cf41 | 971 | if (resultP->X_seg == SEG_UNKNOWN || right . X_seg == SEG_UNKNOWN) |
fecd2382 | 972 | { |
c593cf41 SC |
973 | resultP->X_seg = SEG_PASS1; |
974 | need_pass_2 = 1; | |
fecd2382 | 975 | } |
c593cf41 | 976 | else |
fecd2382 | 977 | { |
c593cf41 SC |
978 | resultP->X_subtract_symbol = NULL; |
979 | resultP->X_add_symbol = NULL; | |
980 | /* Will be SEG_ABSOLUTE. */ | |
981 | if (resultP->X_seg != SEG_ABSOLUTE || right . X_seg != SEG_ABSOLUTE) | |
fecd2382 | 982 | { |
c593cf41 SC |
983 | as_bad("Relocation error. Absolute 0 assumed."); |
984 | resultP->X_seg = SEG_ABSOLUTE; | |
985 | resultP->X_add_number = 0; | |
fecd2382 | 986 | } |
c593cf41 | 987 | else |
fecd2382 | 988 | { |
c593cf41 | 989 | switch (op_left) |
fecd2382 RP |
990 | { |
991 | case O_bit_inclusive_or: | |
c593cf41 SC |
992 | resultP->X_add_number |= right . X_add_number; |
993 | break; | |
994 | ||
fecd2382 | 995 | case O_modulus: |
c593cf41 | 996 | if (right . X_add_number) |
fecd2382 | 997 | { |
c593cf41 | 998 | resultP->X_add_number %= right . X_add_number; |
fecd2382 | 999 | } |
c593cf41 | 1000 | else |
fecd2382 | 1001 | { |
c593cf41 SC |
1002 | as_warn("Division by 0. 0 assumed."); |
1003 | resultP->X_add_number = 0; | |
fecd2382 | 1004 | } |
c593cf41 SC |
1005 | break; |
1006 | ||
fecd2382 | 1007 | case O_bit_and: |
c593cf41 SC |
1008 | resultP->X_add_number &= right . X_add_number; |
1009 | break; | |
1010 | ||
fecd2382 | 1011 | case O_multiply: |
c593cf41 SC |
1012 | resultP->X_add_number *= right . X_add_number; |
1013 | break; | |
1014 | ||
fecd2382 | 1015 | case O_divide: |
c593cf41 | 1016 | if (right . X_add_number) |
fecd2382 | 1017 | { |
c593cf41 | 1018 | resultP->X_add_number /= right . X_add_number; |
fecd2382 | 1019 | } |
c593cf41 | 1020 | else |
fecd2382 | 1021 | { |
a39116f1 RP |
1022 | as_warn("Division by 0. 0 assumed."); |
1023 | resultP->X_add_number = 0; | |
fecd2382 | 1024 | } |
a39116f1 RP |
1025 | break; |
1026 | ||
fecd2382 | 1027 | case O_left_shift: |
a39116f1 RP |
1028 | resultP->X_add_number <<= right . X_add_number; |
1029 | break; | |
1030 | ||
fecd2382 | 1031 | case O_right_shift: |
a39116f1 RP |
1032 | resultP->X_add_number >>= right . X_add_number; |
1033 | break; | |
1034 | ||
fecd2382 | 1035 | case O_bit_exclusive_or: |
a39116f1 RP |
1036 | resultP->X_add_number ^= right . X_add_number; |
1037 | break; | |
1038 | ||
fecd2382 | 1039 | case O_bit_or_not: |
a39116f1 RP |
1040 | resultP->X_add_number |= ~ right . X_add_number; |
1041 | break; | |
1042 | ||
fecd2382 | 1043 | default: |
a39116f1 RP |
1044 | BAD_CASE(op_left); |
1045 | break; | |
fecd2382 RP |
1046 | } /* switch(operator) */ |
1047 | } | |
1048 | } /* If we have to force need_pass_2. */ | |
1049 | } /* If operator was +. */ | |
1050 | } /* If we didn't set need_pass_2. */ | |
a39116f1 | 1051 | op_left = op_right; |
fecd2382 | 1052 | } /* While next operator is >= this rank. */ |
a39116f1 | 1053 | return (resultP->X_seg); |
fecd2382 RP |
1054 | } |
1055 | \f | |
1056 | /* | |
1057 | * get_symbol_end() | |
1058 | * | |
1059 | * This lives here because it belongs equally in expr.c & read.c. | |
1060 | * Expr.c is just a branch office read.c anyway, and putting it | |
1061 | * here lessens the crowd at read.c. | |
1062 | * | |
1063 | * Assume input_line_pointer is at start of symbol name. | |
1064 | * Advance input_line_pointer past symbol name. | |
1065 | * Turn that character into a '\0', returning its former value. | |
1066 | * This allows a string compare (RMS wants symbol names to be strings) | |
1067 | * of the symbol name. | |
1068 | * There will always be a char following symbol name, because all good | |
1069 | * lines end in end-of-line. | |
1070 | */ | |
1071 | char | |
a39116f1 | 1072 | get_symbol_end() |
fecd2382 | 1073 | { |
a39116f1 RP |
1074 | register char c; |
1075 | ||
1076 | while (is_part_of_name(c = * input_line_pointer ++)) | |
1077 | ; | |
1078 | * -- input_line_pointer = 0; | |
1079 | return (c); | |
fecd2382 RP |
1080 | } |
1081 | ||
a39116f1 RP |
1082 | |
1083 | unsigned int get_single_number() | |
1084 | { | |
1085 | expressionS exp; | |
1086 | operand(&exp); | |
1087 | return exp.X_add_number; | |
1088 | ||
1089 | } | |
fecd2382 RP |
1090 | /* |
1091 | * Local Variables: | |
1092 | * comment-column: 0 | |
1093 | * fill-column: 131 | |
1094 | * End: | |
1095 | */ | |
1096 | ||
8b228fe9 | 1097 | /* end of expr.c */ |