ld64 with ppc
[darwin-xtools.git] / cctools / as / expr.c
blobb2b29b5b690c0939682977f041f7296db763ae83
1 /* expr.c -operands, expressions-
2 Copyright (C) 1987 Free Software Foundation, Inc.
4 This file is part of GAS, the GNU Assembler.
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 1, or (at your option)
9 any later version.
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.
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. */
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.
27 #include <ctype.h>
28 #include <stdlib.h>
29 #include <string.h>
30 #include "stuff/rnd.h"
31 #include "as.h"
32 #include "flonum.h"
33 #include "struc-symbol.h"
34 #include "expr.h"
35 #include "read.h"
36 #include "obstack.h"
37 #include "symbols.h"
38 #include "hex_value.h"
39 #include "md.h"
40 #include "messages.h"
41 #include "sections.h"
43 typedef char operator_rankT;
46 * The type operatorT is for the types of operators in expressions.
48 typedef enum {
49 O_illegal, /* (0) what we get for illegal op */
51 O_multiply, /* (1) * Ordered by rank*/
52 O_divide, /* (2) / */
53 O_modulus, /* (3) % */
55 O_add, /* (4) + */
56 O_subtract, /* (5) - */
58 O_right_shift, /* (6) >> */
59 O_left_shift, /* (7) << */
61 O_less_than, /* (8) < */
62 O_greater_than, /* (9) > */
63 O_less_than_or_equal, /* (10) <= */
64 O_greater_than_or_equal, /* (11) >= */
66 O_equal, /* (12) == */
67 O_not_equal, /* (13) != */ /* or <> */
69 O_bit_and, /* (14) & */
71 O_bit_exclusive_or, /* (15) ^ */
73 O_bit_inclusive_or, /* (16) | */
74 O_bit_or_not, /* (17) ! */
75 O_logical_and, /* (18) && */
76 O_logical_or, /* (19) || */
77 two_char_operator /* (20) encoding for two char operator */
78 } operatorT;
80 static segT expr(
81 operator_rankT rank,
82 expressionS *resultP);
84 static segT operand(
85 expressionS *expressionP);
87 static void clean_up_expression(
88 expressionS *expressionP);
90 static segT expr_part(
91 struct symbol **symbol_1_PP,
92 struct symbol *symbol_2_P);
94 static operatorT two_char_op_encoding(
95 char first_op_char);
97 static void ignore_c_ll_or_ull(
98 char c);
100 /* Build a dummy symbol to hold a complex expression. This is how we
101 build expressions up out of other expressions. The symbol is put
102 into the fake section expr_section. */
104 symbolS *
105 make_expr_symbol (expressionS *expressionP)
107 #ifdef NOTYET
108 expressionS zero;
109 #endif
110 symbolS *symbolP;
111 #ifdef NOTYET
112 struct expr_symbol_line *n;
113 #endif
115 if (expressionP->X_op == O_symbol
116 && expressionP->X_add_number == 0)
117 return expressionP->X_add_symbol;
119 #ifndef NOTYET
120 abort ();
121 #else
122 if (expressionP->X_op == O_big)
124 /* This won't work, because the actual value is stored in
125 generic_floating_point_number or generic_bignum, and we are
126 going to lose it if we haven't already. */
127 if (expressionP->X_add_number > 0)
128 as_bad (_("bignum invalid"));
129 else
130 as_bad (_("floating point number invalid"));
131 zero.X_op = O_constant;
132 zero.X_add_number = 0;
133 zero.X_unsigned = 0;
134 clean_up_expression (&zero);
135 expressionP = &zero;
138 /* Putting constant symbols in absolute_section rather than
139 expr_section is convenient for the old a.out code, for which
140 S_GET_SEGMENT does not always retrieve the value put in by
141 S_SET_SEGMENT. */
142 symbolP = symbol_create (FAKE_LABEL_NAME,
143 (expressionP->X_op == O_constant
144 ? absolute_section
145 : expr_section),
146 0, &zero_address_frag);
147 symbol_set_value_expression (symbolP, expressionP);
149 if (expressionP->X_op == O_constant)
150 resolve_symbol_value (symbolP);
152 n = (struct expr_symbol_line *) xmalloc (sizeof *n);
153 n->sym = symbolP;
154 as_where (&n->file, &n->line);
155 n->next = expr_symbol_lines;
156 expr_symbol_lines = n;
157 #endif
159 return symbolP;
162 /* Build an expression for an unsigned constant.
163 The corresponding one for signed constants is missing because
164 there's currently no need for it. One could add an unsigned_p flag
165 but that seems more clumsy. */
167 symbolS *
168 expr_build_uconstant (offsetT value)
170 expressionS e;
172 e.X_op = O_constant;
173 e.X_add_number = value;
174 e.X_unsigned = 1;
175 return make_expr_symbol (&e);
178 char *seg_name[] = {
179 "absolute",
180 "section",
181 "difference",
182 "unknown",
183 "absent",
184 "bignum/flonum",
187 #ifdef SUSPECT
188 static int seg_N_TYPE[] = {
189 N_ABS, /* absolute */
190 N_SECT, /* section */
191 -1, /* difference */
192 N_UNDF, /* unknown */
193 -1, /* absent */
194 -1 /* bignum/flonum */
196 #endif
198 segT N_TYPE_seg[] =
200 /* N_UNDF == 0, N_ABS == 2 */
201 SEG_UNKNOWN, -1, SEG_ABSOLUTE, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
202 /* N_SECT == 0xe */
203 SEG_SECT, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1
207 * SEG_BIG expressions encode either a floating point number or an integer
208 * larger than 32 bits in this manner:
209 * For a floating point number:
210 * X_add_number is < 0
211 * The result is in the global variable generic_floating_point_number.
212 * The value in X_add_number is -'c' where c is the character that
213 * introduced the constant. e.g. "0f6.9" will have -'f' as a
214 * X_add_number value.
215 * For an integer larger than 32 bits:
216 * X_add_number > 0
217 * The result is in the global variable generic_bignum.
218 * The value in X_add_number is a count of how many littlenums it
219 * took to represent the bignum.
222 /* LITTLENUM_TYPE generic_buffer [6]; JF this is a hack */
223 /* Seems atof_machine can backscan through generic_bignum and hit whatever
224 happens to be loaded before it in memory. And its way too complicated
225 for me to fix right. Thus a hack. JF: Just make generic_bignum bigger,
226 and never write into the early words, thus they'll always be zero.
227 I hate Dean's floating-point code. Bleh.
229 LITTLENUM_TYPE generic_bignum[SIZE_OF_LARGE_NUMBER + 6] = { 0 };
231 FLONUM_TYPE generic_floating_point_number = {
232 &generic_bignum[6], /* low (JF: Was 0) */
233 &generic_bignum[SIZE_OF_LARGE_NUMBER + 6 - 1],/* high JF: (added +6) */
234 0, /* leader */
235 0, /* exponent */
236 0 /* sign */
240 * op_size is indexed by an operatorT and tells the size of the operator
241 * which is used to advance the input_line_pointer over the operator.
243 static int op_size [] =
244 { 0, 1, 1, 1, 1, 1, 2, 2, 1, 1, 2, 2, 2, 2, 1, 1, 1, 1, 2, 2 };
247 * op_rank is indexed by an operatorT and tells the rank of the operator.
249 * Rank Examples
250 * 10 * / %
251 * 9 + -
252 * 8 >> <<
253 * 7 < > <= >=
254 * 6 == !=
255 * 5 &
256 * 4 ^
257 * 3 | !
258 * 2 &&
259 * 1 ||
260 * 0 operand, (expression)
262 static operator_rankT op_rank [] =
263 { 0,10,10,10, 9, 9, 8, 8, 7, 7, 7, 7, 6, 6, 5, 4, 3, 3, 2, 1 };
266 * op_encoding is indexed by a an ASCII character and maps it to an operator.
268 #define __ O_illegal
269 static const operatorT op_encoding [256] = {
270 __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __,
271 __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __,
273 __, two_char_operator, __, __, __, O_modulus, two_char_operator, __,
274 __, __, O_multiply, O_add, __, O_subtract, __, O_divide,
275 __, __, __, __, __, __, __, __,
276 __, __, __, __, two_char_operator, two_char_operator, two_char_operator, __,
277 __, __, __, __, __, __, __, __,
278 __, __, __, __, __, __, __, __,
279 __, __, __, __, __, __, __, __,
280 __, __, __, __, __, __, O_bit_exclusive_or, __,
281 __, __, __, __, __, __, __, __,
282 __, __, __, __, __, __, __, __,
283 __, __, __, __, __, __, __, __,
284 __, __, __, __, two_char_operator, __, __, __,
286 __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __,
287 __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __,
288 __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __,
289 __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __,
290 __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __,
291 __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __,
292 __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __,
293 __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __
296 segT /* Return resultP -> X_seg */
297 expression(
298 expressionS *resultP) /* deliver result here */
300 segT segment;
302 segment = expr(0, resultP);
304 /* what about caller's that just want to ignore this and print the're own
305 error message? ok I guess */
306 if(segment == SEG_DIFFSECT &&
307 resultP->X_add_symbol == NULL &&
308 (resultP->X_subtract_symbol->sy_type & N_TYPE) != N_UNDF){
309 as_warn("Subtracting symbol \"%s\"(segment\"%s\") is too "
310 "hard. Absolute segment assumed.",
311 resultP->X_subtract_symbol->sy_name,
312 seg_name[(int)N_TYPE_seg[
313 resultP->X_subtract_symbol->sy_type & N_TYPE]]);
314 segment = SEG_ABSOLUTE;
315 /* Leave exp .X_add_number alone. */
317 return(segment);
320 /* Expression parser. */
323 * We allow an empty expression, and just assume (absolute,0) silently.
324 * Unary operators and parenthetical expressions are treated as operands.
325 * As usual, Q==quantity==operand, O==operator, X==expression mnemonics.
327 * Most expressions are either register (which does not even reach here)
328 * or 1 symbol. Then "symbol+constant" and "symbol-symbol" are common.
330 * After expr(RANK,resultP) input_line_pointer -> operator of rank <= RANK.
331 * Also, we have consumed any leading or trailing spaces (operand does that)
332 * and done all intervening operators.
334 static
335 segT /* Return resultP -> X_seg */
336 expr(
337 operator_rankT rank, /* larger # is higher rank */
338 expressionS *resultP) /* deliver result here */
340 expressionS right;
341 operatorT op_left;
342 char c_left; /* 1st operator character. */
343 operatorT op_right;
344 char c_right;
346 know(rank >= 0);
348 (void)operand(resultP);
349 know(*input_line_pointer != ' '); /* Operand() gobbles spaces. */
351 c_left = *input_line_pointer; /* Potential operator character. */
352 op_left = (operatorT)op_encoding[(int)c_left];
353 if(op_left == two_char_operator)
354 op_left = two_char_op_encoding(c_left);
356 while(op_left != O_illegal && op_rank[op_left] > rank){
358 input_line_pointer += op_size[op_left];
359 /* -> after 1st character of operator. */
361 if(SEG_NONE == expr(op_rank[op_left], &right)){
362 as_warn("Missing operand value assumed absolute 0.");
363 resultP->X_add_number = 0;
364 resultP->X_subtract_symbol = NULL;
365 resultP->X_add_symbol = NULL;
366 resultP->X_seg = SEG_ABSOLUTE;
368 know(*input_line_pointer != ' ');
370 c_right = *input_line_pointer;
371 op_right = (operatorT)op_encoding[(int)c_right];
372 if(op_right == two_char_operator)
373 op_right = two_char_op_encoding(c_right);
375 /* -> after 1st character of operator. */
376 know(op_right == 0 || op_rank [op_right] <= op_rank[op_left]);
378 /* input_line_pointer -> after right-hand quantity. */
379 /* left-hand quantity in resultP */
380 /* right-hand quantity in right. */
381 /* operator in op_left. */
384 * Operations are not supported on bignums or floating-point
385 * operands.
387 if(resultP->X_seg == SEG_BIG){
388 as_warn("Left operand of %c is a %s integer 0 assumed",
389 c_left, resultP->X_add_number > 0 ? "bignum" :
390 "float");
391 resultP->X_seg = SEG_ABSOLUTE;
392 resultP->X_add_symbol = 0;
393 resultP->X_subtract_symbol = 0;
394 resultP->X_add_number = 0;
396 if(right.X_seg == SEG_BIG){
397 as_warn("Right operand of %c is a %s integer 0 assumed",
398 c_left, right.X_add_number > 0 ? "bignum" :
399 "float");
400 right.X_seg = SEG_ABSOLUTE;
401 right.X_add_symbol = 0;
402 right.X_subtract_symbol = 0;
403 right.X_add_number = 0;
405 if(op_left == O_subtract){
407 * Convert - into + by exchanging symbols and negating
408 * number. I know -infinity can't be negated in 2's
409 * complement: but then it can't be subtracted either.
410 * This trick does not cause any further inaccuracy.
412 struct symbol *symbolP;
414 right.X_add_number = - right.X_add_number;
415 symbolP = right.X_add_symbol;
416 right.X_add_symbol = right.X_subtract_symbol;
417 right.X_subtract_symbol = symbolP;
418 if(symbolP){
419 /* This is not used, as it drops in to the next if */
420 right.X_seg = SEG_DIFFSECT;
422 op_left = O_add;
424 if(op_left == O_add){
425 segT seg1;
426 segT seg2;
428 /* not SEG_NONE and not SEG_BIG */
429 know(resultP->X_seg == SEG_SECT ||
430 resultP->X_seg == SEG_UNKNOWN ||
431 resultP->X_seg == SEG_DIFFSECT ||
432 resultP->X_seg == SEG_ABSOLUTE);
433 /* not SEG_NONE and not SEG_BIG */
434 know(right.X_seg == SEG_SECT ||
435 right.X_seg == SEG_UNKNOWN ||
436 right.X_seg == SEG_DIFFSECT ||
437 right.X_seg == SEG_ABSOLUTE);
439 clean_up_expression(&right);
440 clean_up_expression(resultP);
442 /* could this just return -1 instead of SEG_PASS1? and tested in the below if
443 statement */
444 seg1 = expr_part(&resultP->X_add_symbol,
445 right.X_add_symbol);
446 seg2 = expr_part(&resultP->X_subtract_symbol,
447 right.X_subtract_symbol);
448 if((int)seg1 == -1 || (int)seg2 == -1){
449 as_warn("Can't relocate expression. Absolute 0 assumed.");
450 resultP->X_seg = SEG_ABSOLUTE;
451 resultP->X_add_number = 0;
453 else{
454 if(seg2 == SEG_ABSOLUTE){
455 if(resultP->X_seg != SEG_DIFFSECT)
456 resultP->X_seg = seg1;
458 else{
459 /* also know seg2 != -1 (SEG_PASS1) */
460 know(seg2 != SEG_ABSOLUTE);
461 /* seg2 is for the subtract symbols, since seg2 != SEG_ABSOLUTE as would be
462 returned when there is no subtract symbols then expr_part() must have
463 combined a symbol into resultP->X_subtract_symbol that is either undefined
464 or defined in a section. */
465 know(resultP->X_subtract_symbol);
467 * If we are not to use the new incompatible features
468 * then "symbol1 - symbol2" must both be in the same
469 * section and will turn out as absolute.
471 if(!flagseen['k']){
472 if(seg1 != SEG_UNKNOWN &&
473 seg1 != SEG_ABSOLUTE &&
474 seg2 != SEG_UNKNOWN &&
475 seg1 != seg2 &&
476 resultP->X_add_symbol->sy_other !=
477 resultP->X_subtract_symbol->sy_other){
478 know(seg1 == SEG_SECT);
479 know(seg2 == SEG_SECT);
480 know(resultP->X_add_symbol);
481 know(resultP->X_subtract_symbol);
482 as_warn("Expression too complex: "
483 "forgetting %s - %s",
484 resultP->X_add_symbol->sy_name,
485 resultP->X_subtract_symbol->sy_name);
486 resultP->X_seg = SEG_ABSOLUTE;
487 /* Clean_up_expression() will do the rest */
489 else{
490 /* this can result in returning an expression that is NULL - symbol and the
491 caller must deal with this being illegal. maybe this should be put in
492 expression() routine (not a macro). Note the code in cons() */
493 resultP->X_seg = SEG_DIFFSECT;
494 } /* If relocation too complex. */
496 else{
497 resultP->X_seg = SEG_DIFFSECT;
500 } /* If seg2 == SEG_ABSOLUTE. */
501 } /* If need pass 2. */
502 resultP->X_add_number += right.X_add_number;
503 clean_up_expression(resultP);
505 else{ /* Not +. */
506 if(resultP->X_seg == SEG_UNKNOWN ||
507 right.X_seg == SEG_UNKNOWN){
508 as_warn("Can't relocate expression. Absolute 0 assumed.");
509 resultP->X_seg = SEG_ABSOLUTE;
510 resultP->X_add_number = 0;
512 else{
514 * Will be SEG_ABSOLUTE. (or error)
516 try_to_make_absolute(resultP);
517 try_to_make_absolute(&right);
519 * If we have the special assembly time constant expression
520 * of the difference of two symbols defined in the same
521 * section then divided by exactly 2 mark the expression
522 * indicating this.
524 if(resultP->X_seg == SEG_DIFFSECT &&
525 right.X_seg == SEG_ABSOLUTE &&
526 op_left == O_divide &&
527 right.X_add_number == 2){
528 resultP->X_sectdiff_divide_by_two = 1;
529 goto down;
531 resultP->X_subtract_symbol = NULL;
532 resultP->X_add_symbol = NULL;
533 if(resultP->X_seg != SEG_ABSOLUTE ||
534 right.X_seg != SEG_ABSOLUTE){
535 as_warn("Relocation error. Absolute 0 assumed");
536 resultP->X_seg = SEG_ABSOLUTE;
537 resultP->X_add_number = 0;
539 else{
541 * Both are absolute so perform the operation
542 * on the constants.
544 switch(op_left){
545 case O_bit_inclusive_or:
546 resultP->X_add_number |= right.X_add_number;
547 break;
549 case O_logical_or:
550 resultP->X_add_number =
551 resultP->X_add_number || right.X_add_number;
552 break;
554 case O_modulus:
555 if(right.X_add_number){
556 resultP->X_add_number %=
557 right.X_add_number;
559 else{
560 as_warn("Division by 0. 0 assumed.");
561 resultP->X_add_number = 0;
563 break;
565 case O_bit_and:
566 resultP->X_add_number &= right.X_add_number;
567 break;
569 case O_logical_and:
570 resultP->X_add_number =
571 resultP->X_add_number && right.X_add_number;
572 break;
574 case O_multiply:
575 resultP->X_add_number *= right.X_add_number;
576 break;
578 case O_divide:
579 if(right.X_add_number){
580 resultP->X_add_number /=
581 right.X_add_number;
583 else{
584 as_warn("Division by 0. 0 assumed.");
585 resultP->X_add_number = 0;
587 break;
589 case O_left_shift:
590 resultP->X_add_number <<=
591 right.X_add_number;
592 break;
594 case O_right_shift:
595 resultP->X_add_number >>=
596 right.X_add_number;
597 break;
599 case O_bit_exclusive_or:
600 resultP->X_add_number ^= right.X_add_number;
601 break;
603 case O_bit_or_not:
604 resultP->X_add_number |=
605 ~right.X_add_number;
606 break;
608 case O_less_than:
609 resultP->X_add_number =
610 (resultP->X_add_number <
611 right.X_add_number);
612 break;
614 case O_greater_than:
615 resultP->X_add_number =
616 (resultP->X_add_number >
617 right.X_add_number);
618 break;
620 case O_less_than_or_equal:
621 resultP->X_add_number =
622 (resultP->X_add_number <=
623 right.X_add_number);
624 break;
626 case O_greater_than_or_equal:
627 resultP->X_add_number =
628 (resultP->X_add_number >=
629 right.X_add_number);
630 break;
632 case O_equal:
633 resultP->X_add_number =
634 (resultP->X_add_number ==
635 right.X_add_number);
636 break;
638 case O_not_equal:
639 resultP->X_add_number =
640 (resultP->X_add_number !=
641 right.X_add_number);
642 break;
644 default:
645 BAD_CASE( op_left );
646 break;
647 } /* switch(op_left) */
649 down: ;
650 } /* If we have to force need_pass_2 */
651 } /* If operator was + */
652 op_left = op_right;
653 } /* While next operator is >= this rank */
654 return(resultP->X_seg);
658 * Summary of operand().
660 * in: Input_line_pointer points to 1st char of operand, which may
661 * be a space.
663 * out: A expressionS. X_seg determines how to understand the rest of the
664 * expressionS.
665 * The operand may have been empty: in this case X_seg == SEG_NONE.
666 * Input_line_pointer -> (next non-blank) char after operand.
669 static
670 segT
671 operand(
672 expressionS *expressionP)
674 char c, q;
675 char *name; /* points to name of symbol */
676 struct symbol *symbolP; /* Points to symbol */
679 SKIP_WHITESPACE(); /* Leading whitespace is part of operand. */
680 c = *input_line_pointer++;/* Input_line_pointer -> past char in c. */
682 if(isdigit(c)){
683 signed_expr_t
684 number; /* offset or (absolute) value */
685 int digit; /* value of next digit in current radix */
686 /* invented for humans only, hope */
687 /* optimising compiler flushes it! */
688 int radix; /* 8, 10 or 16 */
689 /* 0 means we saw start of a floating- */
690 /* point constant. */
691 int maxdig; /* Highest permitted digit value. */
692 int too_many_digits;/* If we see >= this number of */
693 /* digits, assume it is a bignum. */
694 char *digit_2; /* -> 2nd digit of number. */
695 int small; /* TRUE if fits in 32 bits. */
696 int force_bignum; /* TRUE if number is 0xb... */
698 force_bignum = FALSE;
700 * These two initiaizations are to shut up compiler warning as the
701 * may be used with out being set. There used only if radix != 0
702 * when the number is not a floating-point number.
704 maxdig = 0;
705 too_many_digits = 0;
707 if(c == '0'){ /* non-decimal radix */
708 c = *input_line_pointer++;
709 if(c == 'x' || c=='X'){
710 c = *input_line_pointer++; /* read past "0x" or "0X" */
711 maxdig = 16;
712 radix = 16;
713 too_many_digits = 9;
716 * If we have "0b" and some hex digits then treat it as a hex
717 * number and return a bignum. This is for hex immediate
718 * bit-patterns for floating-point immediate constants.
720 else if((c == 'b' || c == 'B') &&
721 (*input_line_pointer != '\0') &&
722 strchr("0123456789abcdefABCDEF",
723 *input_line_pointer) != NULL){
724 force_bignum = TRUE;
725 c = *input_line_pointer++; /* read past "0b" or "0B" */
726 maxdig = 16;
727 radix = 16;
728 too_many_digits = 9;
730 else{
732 * If it says '0f' and the line ends or it DOESN'T look like
733 * a floating point #, its a local label ref.
735 if(c == 'f' &&
736 (*input_line_pointer == '\0' ||
737 (strchr("+-.0123456789", *input_line_pointer) == NULL &&
738 strchr(md_EXP_CHARS, *input_line_pointer) == NULL) )){
739 maxdig = 10;
740 radix = 10;
741 too_many_digits = 11;
742 c = '0';
743 input_line_pointer -= 2;
745 else if(c != '\0' && strchr(md_FLT_CHARS, c) != NULL){
746 radix = 0;/* Start of floating-point constant. */
747 /* input_line_pointer -> 1st char of number */
748 expressionP->X_add_number =
749 - (isupper(c) ? tolower(c) : c);
751 else{ /* By elimination, assume octal radix. */
752 radix = 8;
753 maxdig = 10; /* Un*x sux. Compatibility. */
754 too_many_digits = 11;
757 /* c == char after "0" or "0x" or "0X" or "0e" etc.*/
759 else{
760 maxdig = 10;
761 radix = 10;
762 too_many_digits = 11;
766 * Expressions are now evaluated as 64-bit values so the number
767 * digits allowed is twice that for 32-bit expressions.
769 too_many_digits *= 2;
771 if(radix != 0){ /* Fixed-point integer constant. */
772 /* May be bignum, or may fit in 32 bits. */
774 * Most numbers fit into 32 bits, and we want this case to be
775 * fast. So we pretend it will fit into 32 bits. If, after
776 * making up a 32 bit number, we realize that we have scanned
777 * more digits than comfortably fit into 32 bits, we re-scan the
778 * digits coding them into a bignum. For decimal and octal
779 * numbers we are conservative: some numbers may be assumed
780 * bignums when in fact they do fit into 32 bits. Numbers of
781 * any radix can have excess leading zeros: we strive to
782 * recognise this and cast them back into 32 bits. We must
783 * check that the bignum really is more than 32 bits, and
784 * change it back to a 32-bit number if it fits. The number we
785 * are looking for is expected to be positive, but if it fits
786 * into 32 bits as an unsigned number, we let it be a 32-bit
787 * number. The cavalier approach is for speed in ordinary cases.
789 digit_2 = input_line_pointer;
790 for(number = 0;
791 (digit = hex_value[(int)c]) < maxdig;
792 c = *input_line_pointer++){
793 number = number * radix + digit;
795 /* c contains character after number. */
796 /* Input_line_pointer -> char after c. */
797 small = input_line_pointer - digit_2 < too_many_digits;
798 if(force_bignum == TRUE)
799 small = FALSE;
800 if(small == FALSE){
802 * Manufacture a bignum.
804 /* -> high order littlenum of the bignum. */
805 LITTLENUM_TYPE *leader;
806 /* -> littlenum we are frobbing now. */
807 LITTLENUM_TYPE *pointer;
808 int32_t carry;
810 leader = generic_bignum;
811 generic_bignum [0] = 0;
812 /* We could just use digit_2, but lets be mnemonic. */
813 input_line_pointer = --digit_2; /* -> 1st digit. */
814 c = *input_line_pointer++;
815 for( ;
816 (carry = hex_value[(int)c]) < maxdig;
817 c = * input_line_pointer++){
818 for(pointer = generic_bignum;
819 pointer <= leader;
820 pointer++){
821 int32_t work;
823 work = carry + radix * *pointer;
824 *pointer = work & LITTLENUM_MASK;
825 carry = work >> LITTLENUM_NUMBER_OF_BITS;
827 if(carry){
828 if(leader < generic_bignum +
829 SIZE_OF_LARGE_NUMBER - 1){
830 /* Room to grow a longer bignum. */
831 *++leader = carry;
835 /* Again, C is char after number, */
836 /* input_line_pointer -> after C. */
837 /* know(BITS_PER_INT == 32); */
838 know(LITTLENUM_NUMBER_OF_BITS == 16);
839 /* Hence the constant "2" in the next line. */
840 if(leader < generic_bignum + 2 && force_bignum == FALSE)
841 { /* Will fit into 32 bits. */
842 number = ((generic_bignum[1] & LITTLENUM_MASK) <<
843 LITTLENUM_NUMBER_OF_BITS) |
844 (generic_bignum[0] & LITTLENUM_MASK);
845 small = TRUE;
847 else{
848 /* Number of littlenums in the bignum. */
849 number = leader - generic_bignum + 1;
852 if(small){
854 * Here with number, in correct radix. c is the next char.
855 * Note that unlike Un*x, we allow "011f" "0x9f" to both
856 * mean the same as the (conventional) "9f". This is simply
857 * easier than checking for strict canonical form.
859 if(c == 'b'){
861 * Backward ref to local label.
862 * Because it is backward, expect it to be DEFINED.
865 * Construct a local label.
867 name = fb_label_name((int)number, 0);
868 symbolP = symbol_table_lookup(name);
869 if((symbolP != NULL) &&
870 (symbolP->sy_type & N_TYPE) != N_UNDF){
871 /* Expected path: symbol defined. */
872 /* Local labels are never absolute. Don't waste
873 time checking absoluteness. */
874 know((symbolP->sy_type & N_TYPE) == N_SECT);
875 expressionP->X_add_symbol = symbolP;
876 expressionP->X_add_number = 0;
877 expressionP->X_seg = SEG_SECT;
879 else{ /* Either not seen or not defined. */
880 as_warn("Backw. ref to unknown label \"%lld\","
881 "0 assumed.", number);
882 expressionP->X_add_number = 0;
883 expressionP->X_seg = SEG_ABSOLUTE;
886 else if(c == 'f'){
888 * Forward reference. Expect symbol to be
889 * undefined or unknown. Undefined: seen it
890 * before. Unknown: never seen it in this pass.
891 * Construct a local label name, then an
892 * undefined symbol. Don't create a XSEG frag
893 * for it: caller may do that.
894 * Just return it as never seen before.
896 name = fb_label_name((int)number, 1);
897 symbolP = symbol_table_lookup(name);
898 if(symbolP != NULL){
899 /* We have no need to check symbol
900 properties. */
901 know((symbolP->sy_type & N_TYPE) == N_UNDF ||
902 (symbolP->sy_type & N_TYPE) == N_SECT);
904 else{
905 symbolP = symbol_new(name, N_UNDF, 0,0,0,
906 &zero_address_frag);
907 symbol_table_insert(symbolP);
909 expressionP->X_add_symbol = symbolP;
910 expressionP->X_seg = SEG_UNKNOWN;
911 expressionP->X_subtract_symbol = NULL;
912 expressionP->X_add_number = 0;
914 else{ /* a number >= 10 */
915 ignore_c_ll_or_ull(c);
916 expressionP->X_add_number = number;
917 expressionP->X_seg = SEG_ABSOLUTE;
918 input_line_pointer--; /* restore following char */
920 } /* not a small number encode returning a bignum */
921 else{
922 ignore_c_ll_or_ull(c);
923 expressionP->X_add_number = number;
924 expressionP->X_seg = SEG_BIG;
925 input_line_pointer--; /* -> char following number. */
926 } /* if (small) */
927 } /* (If integer constant) */
928 else{ /* input_line_pointer -> floating-point constant. */
930 int error_code;
932 error_code = atof_generic(&input_line_pointer, ".", md_EXP_CHARS,
933 &generic_floating_point_number);
935 if(error_code){
936 if(error_code == ERROR_EXPONENT_OVERFLOW){
937 as_bad("Bad floating-point constant: exponent overflow" );
939 else{
940 as_bad("Bad floating-point constant: unknown error "
941 "code=%d.", error_code);
944 expressionP->X_seg = SEG_BIG;
945 /* input_line_pointer -> just after constant, */
946 /* which may point to whitespace. */
947 know(expressionP->X_add_number < 0);
948 /* < 0 means "floating point". */
949 } /* if (not floating-point constant) */
951 #ifdef PPC
952 else if((c == '.' || c == '$') && !is_part_of_name(*input_line_pointer))
953 #else
954 else if(c == '.' && !is_part_of_name(*input_line_pointer))
955 #endif
958 JF: '.' is pseudo symbol with value of current location in current
959 segment. . .
961 symbolP = symbol_new("L0\001",
962 N_SECT,
963 frchain_now->frch_nsect,
965 (valueT)(obstack_next_free(&frags) -
966 frag_now->fr_literal),
967 frag_now);
968 symbol_assign_index(symbolP);
969 expressionP->X_add_number = 0;
970 expressionP->X_add_symbol = symbolP;
971 expressionP->X_seg = SEG_SECT;
973 /* here if did not begin with a digit */
974 else if(is_name_beginner(c) || c == '"'){
976 * Identifier begins here.
977 * This is kludged for speed, so code is repeated.
979 q = c;
980 if(q == '"')
981 name = input_line_pointer-- ;
982 else
983 name = -- input_line_pointer;
984 c = get_symbol_end();
985 symbolP = symbol_table_lookup(name);
986 if(symbolP != NULL){
988 * If we have an absolute symbol, then we know it's value now.
989 * Unless the symbol has an expression attached to it in which
990 * case it will have an absolute value but we do not know it
991 * now and will have to wait to evaluate after the symbols of
992 * the expression are known. This can happen with:
993 * .set x,a-b
994 * where the symbol we have now is x but the value of x is not
995 * know at this point.
997 segT seg;
999 seg = N_TYPE_seg[(int)symbolP->sy_type & N_TYPE];
1000 expressionP->X_seg = seg;
1001 if(seg == SEG_ABSOLUTE && symbolP->expression == NULL){
1002 expressionP->X_add_number =
1003 #ifndef ARCH64
1005 * For 32-bit assemblers the type n_value in a symbol
1006 * table entry is unsigned. But since we are using
1007 * this in a signed 64-bit expression we need to sign
1008 * extend this. So by casting it to a signed value and
1009 * then assigning it to the 64-bit value the expression
1010 * will be correct.
1012 (int32_t)
1013 #endif
1014 symbolP->sy_value;
1016 else{
1017 expressionP->X_add_number = 0;
1018 expressionP->X_add_symbol = symbolP;
1019 if(symbolP->expression != NULL)
1020 expressionP->X_seg = SEG_DIFFSECT;
1023 else{
1024 symbolP = symbol_new(name, N_UNDF, 0,0,0, &zero_address_frag);
1025 expressionP->X_add_symbol = symbolP;
1026 expressionP->X_add_number = 0;
1027 expressionP->X_seg = SEG_UNKNOWN;
1028 symbol_table_insert(symbolP);
1030 *input_line_pointer = c;
1031 if(q == '"')
1032 input_line_pointer[-1] = '"';
1033 expressionP->X_subtract_symbol = NULL;
1035 /* didn't begin with digit & not a name */
1036 else if (c == '('){
1037 (void)expression(expressionP);
1038 /* Expression() will pass trailing whitespace */
1039 if(*input_line_pointer++ != ')'){
1040 as_warn("Missing ')' assumed");
1041 input_line_pointer--;
1043 /* here with input_line_pointer -> char after "(...)" */
1045 /* unary operator: hope for SEG_ABSOLUTE */
1046 else if(c == '~' || c == '-' || c == '!'){
1047 switch(operand(expressionP)){
1048 case SEG_ABSOLUTE:
1049 /* input_line_pointer -> char after operand */
1050 if(c == '-' ){
1052 * Notice: '-' may overflow: no warning is given. This is
1053 * compatible with other people's assemblers.
1055 expressionP->X_add_number = - expressionP->X_add_number;
1057 else if(c == '!'){
1058 expressionP->X_add_number = ! expressionP->X_add_number;
1060 else{
1061 expressionP->X_add_number = ~ expressionP->X_add_number;
1063 break;
1064 case SEG_SECT:
1065 case SEG_UNKNOWN:
1066 if(c == '-'){ /* JF I hope this hack works */
1067 expressionP->X_subtract_symbol = expressionP->X_add_symbol;
1068 expressionP->X_add_symbol = 0;
1069 expressionP->X_seg = SEG_DIFFSECT;
1070 break;
1072 default: /* unary on non-absolute is unsuported */
1073 as_warn("Unary operator %c ignored because bad operand follows",
1075 break;
1076 /* Expression undisturbed from operand(). */
1080 * Warning: to conform to other people's assemblers NO ESCAPEMENT is
1081 * permitted for a single quote. The next character, parity errors and
1082 * all, is taken as the value of the operand. VERY KINKY.
1084 else if(c == '\''){
1085 expressionP->X_add_number = *input_line_pointer++;
1086 expressionP->X_seg = SEG_ABSOLUTE;
1088 /* can't imagine any other kind of operand */
1089 else{
1090 expressionP->X_seg = SEG_NONE;
1091 input_line_pointer--;
1094 * It is more 'efficient' to clean up the expressions when they are
1095 * created. Doing it here saves lines of code.
1097 clean_up_expression(expressionP);
1098 SKIP_WHITESPACE(); /* -> 1st char after operand. */
1099 know(*input_line_pointer != ' ');
1101 return(expressionP->X_seg);
1104 /* Internal. Simplify a struct expression for use by expr() */
1107 * In: address of a expressionS.
1108 * The X_seg field of the expressionS may only take certain values.
1109 * Now, we permit SEG_NONE to make code smaller & faster.
1110 * Elsewise we waste time special-case testing. Sigh.
1111 * Out: expressionS may have been modified:
1112 * 'foo-foo' symbol references cancelled to 0,
1113 * which changes X_seg from SEG_DIFFSECT to SEG_ABSOLUTE;
1114 * Unused fields zeroed to help expr().
1116 static
1117 void
1118 clean_up_expression(
1119 expressionS *expressionP)
1121 switch(expressionP->X_seg){
1122 case SEG_NONE:
1123 expressionP->X_add_symbol = NULL;
1124 expressionP->X_subtract_symbol = NULL;
1125 expressionP->X_add_number = 0;
1126 break;
1128 case SEG_BIG:
1129 case SEG_ABSOLUTE:
1130 expressionP->X_subtract_symbol = NULL;
1131 expressionP->X_add_symbol = NULL;
1132 break;
1134 case SEG_SECT:
1135 case SEG_UNKNOWN:
1136 expressionP->X_subtract_symbol = NULL;
1137 break;
1139 case SEG_DIFFSECT:
1141 * It does not hurt to 'cancel' NULL==NULL
1142 * when comparing symbols for 'eq'ness.
1143 * It is faster to re-cancel them to NULL
1144 * than to check for this special case.
1146 if(expressionP->X_subtract_symbol == expressionP->X_add_symbol){
1147 expressionP->X_subtract_symbol = NULL;
1148 expressionP->X_add_symbol = NULL;
1149 expressionP->X_seg = SEG_ABSOLUTE;
1151 break;
1153 default:
1154 BAD_CASE(expressionP->X_seg);
1155 break;
1160 * expr_part ()
1162 * Internal. Made a function because this code is used in 2 places.
1163 * Generate error or correct X_?????_symbol of expressionS.
1167 Combine and subsume symbol2 into symbol1 where the symbols come from
1168 expression's add or subtract symbols.
1169 The combining always occurs even if it would be an error.
1170 Either symbol maybe NULL which means there is no symbol.
1171 In that case symbol1 is set to the non NULL symbol.
1172 If both are NULL then SEG_ABSOLUTE is returned.
1173 Either symbol maybe undefined.
1174 The only combinations that are not errors are when one symbol does not exist.
1175 if one symbol is undefined and the other doesn't exist SEG_UNKNOWN is
1176 returned.
1177 For errant combinations symbol1 is set to NULL and SEG_ABSOLUTE (or -1
1178 (SEG_PASS1) when one of the symbols is undefined and the other exists)
1180 * symbol_1 += symbol_2 ... well ... sort of.
1181 * symbol_1 -= symbol_2 ... well ... sort of.
1184 static
1185 segT
1186 expr_part(
1187 struct symbol **symbol_1_PP,
1188 struct symbol *symbol_2_P)
1190 segT return_value;
1192 /* The symbols can't be N_ABS as they are in expressions and whould just have
1193 their value copied into the X_add_number part. */
1194 know( (*symbol_1_PP) == NULL ||
1195 ((*symbol_1_PP)->sy_type & N_TYPE) == N_SECT ||
1196 ((*symbol_1_PP)->sy_type & N_TYPE) == N_UNDF);
1198 know( symbol_2_P == NULL ||
1199 (symbol_2_P->sy_type & N_TYPE) == N_SECT ||
1200 (symbol_2_P->sy_type & N_TYPE) == N_UNDF);
1202 /* check to see if there is a symbol1 */
1203 if(*symbol_1_PP != NULL){
1204 /* there is a symbol1 */
1206 /* check to see if symbol1 is undefined */
1207 if(((*symbol_1_PP)->sy_type & N_TYPE) == N_UNDF){
1208 /* symbol1 is undefined */
1210 /* check to see if there is a symbol2 */
1211 if(symbol_2_P != NULL){
1212 /* symbol1 is undefined and there is a symbol2 */
1213 *symbol_1_PP = NULL;
1214 return_value = -1;
1216 else{
1217 /* symbol1 is undefined and there is no symbol2 */
1218 return_value = SEG_UNKNOWN;
1221 else{
1222 /* there is a defined symbol1 */
1224 /* check to see if there is a symbol2 */
1225 if(symbol_2_P != NULL){
1226 /* there is a symbol2 */
1228 /* check to see if symbol2 is undefined */
1229 if((symbol_2_P->sy_type & N_TYPE) == N_UNDF){
1230 /* symbol2 is undefined and symbol1 is defined */
1231 *symbol_1_PP = NULL;
1232 return_value = -1;
1234 else{
1235 /* symbol1 is defined and symbol2 is defined */
1236 /* + {symbol1} + {symbol2} or */
1237 /* - {symbol1} - {symbol2} */
1238 as_warn("Expression too complex, 2 symbols forgotten: "
1239 "\"%s\" \"%s\"", (*symbol_1_PP)->sy_name,
1240 symbol_2_P->sy_name);
1241 *symbol_1_PP = NULL;
1242 return_value = SEG_ABSOLUTE;
1245 else{
1246 /* symbol1 is defined and there is no symbol2 */
1247 return_value = N_TYPE_seg[(*symbol_1_PP)->sy_type & N_TYPE];
1251 else{
1252 /* there is no symbol1 */
1254 /* check to see if there is a symbol2 */
1255 if(symbol_2_P != NULL){
1256 /* symbol2 is defined and there is no symbol1 */
1257 *symbol_1_PP = symbol_2_P;
1258 return_value = N_TYPE_seg[(symbol_2_P)->sy_type & N_TYPE];
1260 else{
1261 /* there is no symbol1 or symbol2 */
1262 /* ??? why not SEG_UNKNOWN or SEG_NONE */
1263 return_value = SEG_ABSOLUTE;
1267 know(return_value == SEG_ABSOLUTE ||
1268 return_value == SEG_SECT ||
1269 return_value == SEG_UNKNOWN ||
1270 return_value == -1);
1271 know((*symbol_1_PP) == NULL ||
1272 ((*symbol_1_PP)->sy_type & N_TYPE) ==
1273 seg_N_TYPE[(int)return_value]);
1275 return(return_value);
1279 * DJA -- Here we make a last ditch effort to turn expressions into
1280 * absolutes. This is particularly useful for doing arithemtic
1281 * on already declared labels, for example in going through the
1282 * following table the moveq can really be evaluated.
1284 * start: .word 1
1285 * .word 2
1286 * .word 3
1287 * end:
1288 * lea start,a0
1289 * moveq #((end-start) / 2) + 1,d0
1290 * loop: cmpw d1,a0@+
1291 * dbra d0,loop
1293 segT /* Return expressionP->X_seg. */
1294 try_to_make_absolute(
1295 expressionS *expressionP) /* Deliver result here. */
1297 symbolS *add_symbol;
1298 symbolS *subtract_symbol;
1300 if(expressionP->X_seg == SEG_DIFFSECT){
1303 * The flag -dynamic is encoded as -k. If this is seen we can
1304 * use the general section difference relocation so we will leave
1305 * it at that.
1307 if(flagseen['k'])
1308 goto giveup;
1310 add_symbol = expressionP->X_add_symbol;
1311 if(add_symbol == NULL)
1312 goto giveup;
1313 if((add_symbol->sy_type & N_TYPE) != N_SECT)
1314 goto giveup;
1316 subtract_symbol = expressionP->X_subtract_symbol;
1317 if(subtract_symbol == NULL)
1318 goto giveup;
1319 if((subtract_symbol->sy_type & N_TYPE) != N_SECT)
1320 goto giveup;
1322 if(add_symbol->sy_frag == subtract_symbol->sy_frag){
1323 if(add_symbol->sy_frag != NULL &&
1324 expressionP->X_add_number +
1325 (int)add_symbol->sy_value -
1326 (int)subtract_symbol->sy_value >= 0){
1327 expressionP->X_add_number += add_symbol->sy_value -
1328 subtract_symbol->sy_value;
1329 expressionP->X_seg = SEG_ABSOLUTE;
1330 expressionP->X_add_symbol = NULL;
1331 expressionP->X_subtract_symbol = NULL;
1335 else{
1337 * This logic works only if the chain of frags can't later be
1338 * separated by scattered loading. To make sure that this can't
1339 * happen we would have to make sure all symbols associated with
1340 * frags in the chain are of the Lx form and the -L flag is not
1341 * see so they will not appear in the output (if they are not in
1342 * the output then the link editor can't separate the chain of
1343 * frags by scattered loading). Since this code does not make
1344 * sure of this it is broken. But this is a known bug in the
1345 * NeXT 3.2 and earilier releases so this code is if'ed
1346 * !flagseen['k'] which will make it compatable with 3.2 and
1347 * previous releases.
1349 if(!flagseen['k']){
1351 * Try to see if the chain of frags between the subtract
1352 * symbol and the add symbol is made up of only rs_fill and
1353 * rs_align frags and then calculate the difference. This
1354 * will always work on RISC machines since they won't have
1355 * any machine dependent frags of variable length in the
1356 * chain.
1358 uint32_t size, fail;
1359 struct frag *frag;
1361 if(add_symbol->sy_frag != NULL &&
1362 subtract_symbol->sy_frag != NULL){
1363 fail = 0;
1364 size = 0;
1365 frag = subtract_symbol->sy_frag;
1366 while(!fail && frag != NULL &&
1367 frag != add_symbol->sy_frag){
1368 if(frag->fr_type == rs_align)
1369 size = rnd(size + frag->fr_fix,
1370 1 << frag->fr_offset);
1371 else if(frag->fr_type == rs_fill)
1372 size += frag->fr_fix +
1373 frag->fr_var * frag->fr_offset;
1374 else
1375 fail = 1;
1376 frag = frag->fr_next;
1379 if(!fail && frag == add_symbol->sy_frag){
1380 expressionP->X_add_number = size +
1381 add_symbol->sy_value -
1382 subtract_symbol->sy_value;
1383 expressionP->X_seg = SEG_ABSOLUTE;
1384 expressionP->X_add_symbol = NULL;
1385 expressionP->X_subtract_symbol = NULL;
1391 giveup:
1393 return(expressionP->X_seg);
1397 * two_char_op_encoding() return the operator type for two character operators.
1398 * The first_op_char is part of a two character operator and this routine is
1399 * then used to determine the operator type looking at the second character.
1401 static
1402 operatorT
1403 two_char_op_encoding(
1404 char first_op_char)
1406 char second_op_char;
1408 second_op_char = input_line_pointer[1];
1409 switch(first_op_char){
1410 case '<':
1411 if(second_op_char == '<')
1412 return(O_left_shift);
1413 if(second_op_char == '=')
1414 return(O_less_than_or_equal);
1415 if(second_op_char == '>')
1416 return(O_not_equal);
1417 return(O_less_than);
1418 case '>':
1419 if(second_op_char == '>')
1420 return(O_right_shift);
1421 if(second_op_char == '=')
1422 return(O_greater_than_or_equal);
1423 return(O_greater_than);
1424 case '=':
1425 if(second_op_char == '=')
1426 return(O_equal);
1427 return(O_illegal);
1428 case '!':
1429 if(second_op_char == '=')
1430 return(O_not_equal);
1431 return O_not_equal;
1432 case '&':
1433 if(second_op_char == '&')
1434 return(O_logical_and);
1435 return(O_bit_and);
1436 case '|':
1437 if(second_op_char == '|')
1438 return(O_logical_or);
1439 return(O_bit_inclusive_or);
1440 default:
1441 BAD_CASE(first_op_char);
1442 return O_illegal;
1447 * get_symbol_end()
1449 * This lives here because it belongs equally in expr.c & read.c.
1450 * Expr.c is just a branch office read.c anyway, and putting it
1451 * here lessens the crowd at read.c.
1453 * Assume input_line_pointer is at start of symbol name.
1454 * Advance input_line_pointer past symbol name.
1455 * Turn that character into a '\0', returning its former value.
1456 * This allows a string compare (RMS wants symbol names to be strings)
1457 * of the symbol name.
1458 * There will always be a char following symbol name, because all good
1459 * lines end in end-of-line.
1461 char
1462 get_symbol_end(
1463 void)
1465 register char c;
1468 * Symbol names are allowed to have surrounding ""s so that names can
1469 * have any characters in them (including spacesi, colons, etc). This
1470 * is done so names like "[Foo bar:fuz:]" can be used as symbol names.
1472 if(*input_line_pointer == '"'){
1473 input_line_pointer++;
1475 c = *input_line_pointer++ ;
1476 }while(c != '"' && c != '\0' && c != '\n');
1477 if(c == '"'){
1478 *(input_line_pointer - 1) = 0;
1479 c = *input_line_pointer++;
1482 else{
1483 while(is_part_of_name(c = *input_line_pointer++))
1486 *--input_line_pointer = 0;
1487 return(c);
1490 #include <stdlib.h> /* for abort */
1492 segT S_GET_SEGMENT (symbolS *s)
1494 return s->sy_nlist.n_sect;
1498 * ignore_c_ll_or_ull
1500 * Ignores 'LL' or 'ULL' after numbers. On entrance, if 'c' is not 'U' or
1501 * 'L', we return. If 'c' is 'U' or 'L', input_line_pointer points to the
1502 * next character. On return, input_line_pointer will have been adjusted
1503 * to be after 'ULL' or 'LL' if either of them starts with c followed by
1504 * input_line_pointer. If that is not the case, input_line_pointer will
1505 * not be changed.
1507 static
1508 void
1509 ignore_c_ll_or_ull(
1510 char c)
1512 int charsRead = 0;
1513 if(c != 'U' && c != 'L'){
1514 return;
1516 if(c == 'U'){
1517 c = *input_line_pointer++;
1518 charsRead++;
1520 if(c == 'L'){
1521 c = *input_line_pointer++;
1522 charsRead++;
1524 if(c == 'L'){
1525 c = *input_line_pointer++;
1527 else{
1528 input_line_pointer -= charsRead;