2004-08-31 Robert Bowdidge <bowdidge@apple.com>
[binutils.git] / gas / config / m68k-parse.y
blobd6bb4b82d4a58c73cf090f9a064f4092ad6eb1fd
1 /* m68k.y -- bison grammar for m68k operand parsing
2 Copyright 1995, 1996, 1997, 1998, 2001, 2004 Free Software Foundation, Inc.
3 Written by Ken Raeburn and Ian Lance Taylor, Cygnus Support
5 This file is part of GAS, the GNU Assembler.
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.
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.
17 You should have received a copy of the GNU General Public License
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. */
22 /* This file holds a bison grammar to parse m68k operands. The m68k
23 has a complicated operand syntax, and gas supports two main
24 variations of it. Using a grammar is probably overkill, but at
25 least it makes clear exactly what we do support. */
29 #include "as.h"
30 #include "tc-m68k.h"
31 #include "m68k-parse.h"
32 #include "safe-ctype.h"
34 /* Remap normal yacc parser interface names (yyparse, yylex, yyerror,
35 etc), as well as gratuitously global symbol names If other parser
36 generators (bison, byacc, etc) produce additional global names that
37 conflict at link time, then those parser generators need to be
38 fixed instead of adding those names to this list. */
40 #define yymaxdepth m68k_maxdepth
41 #define yyparse m68k_parse
42 #define yylex m68k_lex
43 #define yyerror m68k_error
44 #define yylval m68k_lval
45 #define yychar m68k_char
46 #define yydebug m68k_debug
47 #define yypact m68k_pact
48 #define yyr1 m68k_r1
49 #define yyr2 m68k_r2
50 #define yydef m68k_def
51 #define yychk m68k_chk
52 #define yypgo m68k_pgo
53 #define yyact m68k_act
54 #define yyexca m68k_exca
55 #define yyerrflag m68k_errflag
56 #define yynerrs m68k_nerrs
57 #define yyps m68k_ps
58 #define yypv m68k_pv
59 #define yys m68k_s
60 #define yy_yys m68k_yys
61 #define yystate m68k_state
62 #define yytmp m68k_tmp
63 #define yyv m68k_v
64 #define yy_yyv m68k_yyv
65 #define yyval m68k_val
66 #define yylloc m68k_lloc
67 #define yyreds m68k_reds /* With YYDEBUG defined */
68 #define yytoks m68k_toks /* With YYDEBUG defined */
69 #define yylhs m68k_yylhs
70 #define yylen m68k_yylen
71 #define yydefred m68k_yydefred
72 #define yydgoto m68k_yydgoto
73 #define yysindex m68k_yysindex
74 #define yyrindex m68k_yyrindex
75 #define yygindex m68k_yygindex
76 #define yytable m68k_yytable
77 #define yycheck m68k_yycheck
79 #ifndef YYDEBUG
80 #define YYDEBUG 1
81 #endif
83 /* Internal functions. */
85 static enum m68k_register m68k_reg_parse PARAMS ((char **));
86 static int yylex PARAMS ((void));
87 static void yyerror PARAMS ((const char *));
89 /* The parser sets fields pointed to by this global variable. */
90 static struct m68k_op *op;
94 %union
96 struct m68k_indexreg indexreg;
97 enum m68k_register reg;
98 struct m68k_exp exp;
99 unsigned long mask;
100 int onereg;
101 int trailing_ampersand;
104 %token <reg> DR AR FPR FPCR LPC ZAR ZDR LZPC CREG
105 %token <indexreg> INDEXREG
106 %token <exp> EXPR
108 %type <indexreg> zireg zdireg
109 %type <reg> zadr zdr apc zapc zpc optzapc optczapc
110 %type <exp> optcexpr optexprc
111 %type <mask> reglist ireglist reglistpair
112 %type <onereg> reglistreg
113 %type <trailing_ampersand> optional_ampersand
117 /* An operand. */
119 operand:
120 generic_operand
121 | motorola_operand optional_ampersand
123 op->trailing_ampersand = $2;
125 | mit_operand optional_ampersand
127 op->trailing_ampersand = $2;
131 /* A trailing ampersand(for MAC/EMAC mask addressing). */
132 optional_ampersand:
133 /* empty */
134 { $$ = 0; }
135 | '&'
136 { $$ = 1; }
139 /* A generic operand. */
141 generic_operand:
142 '<' '<'
144 op->mode = LSH;
147 | '>' '>'
149 op->mode = RSH;
152 | DR
154 op->mode = DREG;
155 op->reg = $1;
157 | AR
159 op->mode = AREG;
160 op->reg = $1;
162 | FPR
164 op->mode = FPREG;
165 op->reg = $1;
167 | FPCR
169 op->mode = CONTROL;
170 op->reg = $1;
172 | CREG
174 op->mode = CONTROL;
175 op->reg = $1;
177 | EXPR
179 op->mode = ABSL;
180 op->disp = $1;
182 | '#' EXPR
184 op->mode = IMMED;
185 op->disp = $2;
187 | '&' EXPR
189 op->mode = IMMED;
190 op->disp = $2;
192 | reglist
194 op->mode = REGLST;
195 op->mask = $1;
199 /* An operand in Motorola syntax. This includes MRI syntax as well,
200 which may or may not be different in that it permits commutativity
201 of index and base registers, and permits an offset expression to
202 appear inside or outside of the parentheses. */
204 motorola_operand:
205 '(' AR ')'
207 op->mode = AINDR;
208 op->reg = $2;
210 | '(' AR ')' '+'
212 op->mode = AINC;
213 op->reg = $2;
215 | '-' '(' AR ')'
217 op->mode = ADEC;
218 op->reg = $3;
220 | '(' EXPR ',' zapc ')'
222 op->reg = $4;
223 op->disp = $2;
224 if (($4 >= ZADDR0 && $4 <= ZADDR7)
225 || $4 == ZPC)
226 op->mode = BASE;
227 else
228 op->mode = DISP;
230 | '(' zapc ',' EXPR ')'
232 op->reg = $2;
233 op->disp = $4;
234 if (($2 >= ZADDR0 && $2 <= ZADDR7)
235 || $2 == ZPC)
236 op->mode = BASE;
237 else
238 op->mode = DISP;
240 | EXPR '(' zapc ')'
242 op->reg = $3;
243 op->disp = $1;
244 if (($3 >= ZADDR0 && $3 <= ZADDR7)
245 || $3 == ZPC)
246 op->mode = BASE;
247 else
248 op->mode = DISP;
250 | '(' LPC ')'
252 op->mode = DISP;
253 op->reg = $2;
255 | '(' ZAR ')'
257 op->mode = BASE;
258 op->reg = $2;
260 | '(' LZPC ')'
262 op->mode = BASE;
263 op->reg = $2;
265 | '(' EXPR ',' zapc ',' zireg ')'
267 op->mode = BASE;
268 op->reg = $4;
269 op->disp = $2;
270 op->index = $6;
272 | '(' EXPR ',' zapc ',' zpc ')'
274 if ($4 == PC || $4 == ZPC)
275 yyerror (_("syntax error"));
276 op->mode = BASE;
277 op->reg = $6;
278 op->disp = $2;
279 op->index.reg = $4;
280 op->index.size = SIZE_UNSPEC;
281 op->index.scale = 1;
283 | '(' EXPR ',' zdireg optczapc ')'
285 op->mode = BASE;
286 op->reg = $5;
287 op->disp = $2;
288 op->index = $4;
290 | '(' zdireg ',' EXPR ')'
292 op->mode = BASE;
293 op->disp = $4;
294 op->index = $2;
296 | EXPR '(' zapc ',' zireg ')'
298 op->mode = BASE;
299 op->reg = $3;
300 op->disp = $1;
301 op->index = $5;
303 | '(' zapc ',' zireg ')'
305 op->mode = BASE;
306 op->reg = $2;
307 op->index = $4;
309 | EXPR '(' zapc ',' zpc ')'
311 if ($3 == PC || $3 == ZPC)
312 yyerror (_("syntax error"));
313 op->mode = BASE;
314 op->reg = $5;
315 op->disp = $1;
316 op->index.reg = $3;
317 op->index.size = SIZE_UNSPEC;
318 op->index.scale = 1;
320 | '(' zapc ',' zpc ')'
322 if ($2 == PC || $2 == ZPC)
323 yyerror (_("syntax error"));
324 op->mode = BASE;
325 op->reg = $4;
326 op->index.reg = $2;
327 op->index.size = SIZE_UNSPEC;
328 op->index.scale = 1;
330 | EXPR '(' zdireg optczapc ')'
332 op->mode = BASE;
333 op->reg = $4;
334 op->disp = $1;
335 op->index = $3;
337 | '(' zdireg optczapc ')'
339 op->mode = BASE;
340 op->reg = $3;
341 op->index = $2;
343 | '(' '[' EXPR optczapc ']' ',' zireg optcexpr ')'
345 op->mode = POST;
346 op->reg = $4;
347 op->disp = $3;
348 op->index = $7;
349 op->odisp = $8;
351 | '(' '[' EXPR optczapc ']' optcexpr ')'
353 op->mode = POST;
354 op->reg = $4;
355 op->disp = $3;
356 op->odisp = $6;
358 | '(' '[' zapc ']' ',' zireg optcexpr ')'
360 op->mode = POST;
361 op->reg = $3;
362 op->index = $6;
363 op->odisp = $7;
365 | '(' '[' zapc ']' optcexpr ')'
367 op->mode = POST;
368 op->reg = $3;
369 op->odisp = $5;
371 | '(' '[' EXPR ',' zapc ',' zireg ']' optcexpr ')'
373 op->mode = PRE;
374 op->reg = $5;
375 op->disp = $3;
376 op->index = $7;
377 op->odisp = $9;
379 | '(' '[' zapc ',' zireg ']' optcexpr ')'
381 op->mode = PRE;
382 op->reg = $3;
383 op->index = $5;
384 op->odisp = $7;
386 | '(' '[' EXPR ',' zapc ',' zpc ']' optcexpr ')'
388 if ($5 == PC || $5 == ZPC)
389 yyerror (_("syntax error"));
390 op->mode = PRE;
391 op->reg = $7;
392 op->disp = $3;
393 op->index.reg = $5;
394 op->index.size = SIZE_UNSPEC;
395 op->index.scale = 1;
396 op->odisp = $9;
398 | '(' '[' zapc ',' zpc ']' optcexpr ')'
400 if ($3 == PC || $3 == ZPC)
401 yyerror (_("syntax error"));
402 op->mode = PRE;
403 op->reg = $5;
404 op->index.reg = $3;
405 op->index.size = SIZE_UNSPEC;
406 op->index.scale = 1;
407 op->odisp = $7;
409 | '(' '[' optexprc zdireg optczapc ']' optcexpr ')'
411 op->mode = PRE;
412 op->reg = $5;
413 op->disp = $3;
414 op->index = $4;
415 op->odisp = $7;
419 /* An operand in MIT syntax. */
421 mit_operand:
422 optzapc '@'
424 /* We use optzapc to avoid a shift/reduce conflict. */
425 if ($1 < ADDR0 || $1 > ADDR7)
426 yyerror (_("syntax error"));
427 op->mode = AINDR;
428 op->reg = $1;
430 | optzapc '@' '+'
432 /* We use optzapc to avoid a shift/reduce conflict. */
433 if ($1 < ADDR0 || $1 > ADDR7)
434 yyerror (_("syntax error"));
435 op->mode = AINC;
436 op->reg = $1;
438 | optzapc '@' '-'
440 /* We use optzapc to avoid a shift/reduce conflict. */
441 if ($1 < ADDR0 || $1 > ADDR7)
442 yyerror (_("syntax error"));
443 op->mode = ADEC;
444 op->reg = $1;
446 | optzapc '@' '(' EXPR ')'
448 op->reg = $1;
449 op->disp = $4;
450 if (($1 >= ZADDR0 && $1 <= ZADDR7)
451 || $1 == ZPC)
452 op->mode = BASE;
453 else
454 op->mode = DISP;
456 | optzapc '@' '(' optexprc zireg ')'
458 op->mode = BASE;
459 op->reg = $1;
460 op->disp = $4;
461 op->index = $5;
463 | optzapc '@' '(' EXPR ')' '@' '(' optexprc zireg ')'
465 op->mode = POST;
466 op->reg = $1;
467 op->disp = $4;
468 op->index = $9;
469 op->odisp = $8;
471 | optzapc '@' '(' EXPR ')' '@' '(' EXPR ')'
473 op->mode = POST;
474 op->reg = $1;
475 op->disp = $4;
476 op->odisp = $8;
478 | optzapc '@' '(' optexprc zireg ')' '@' '(' EXPR ')'
480 op->mode = PRE;
481 op->reg = $1;
482 op->disp = $4;
483 op->index = $5;
484 op->odisp = $9;
488 /* An index register, possibly suppressed, which need not have a size
489 or scale. */
491 zireg:
492 INDEXREG
493 | zadr
495 $$.reg = $1;
496 $$.size = SIZE_UNSPEC;
497 $$.scale = 1;
501 /* A register which may be an index register, but which may not be an
502 address register. This nonterminal is used to avoid ambiguity when
503 trying to parse something like (0,d5,a6) as compared to (0,a6,d5). */
505 zdireg:
506 INDEXREG
507 | zdr
509 $$.reg = $1;
510 $$.size = SIZE_UNSPEC;
511 $$.scale = 1;
515 /* An address or data register, or a suppressed address or data
516 register. */
518 zadr:
520 | AR
521 | ZAR
524 /* A data register which may be suppressed. */
526 zdr:
528 | ZDR
531 /* Either an address register or the PC. */
533 apc:
535 | LPC
538 /* Either an address register, or the PC, or a suppressed address
539 register, or a suppressed PC. */
541 zapc:
543 | LZPC
544 | ZAR
547 /* An optional zapc. */
549 optzapc:
550 /* empty */
552 $$ = ZADDR0;
554 | zapc
557 /* The PC, optionally suppressed. */
559 zpc:
561 | LZPC
564 /* ',' zapc when it may be omitted. */
566 optczapc:
567 /* empty */
569 $$ = ZADDR0;
571 | ',' zapc
573 $$ = $2;
577 /* ',' EXPR when it may be omitted. */
579 optcexpr:
580 /* empty */
582 $$.exp.X_op = O_absent;
583 $$.size = SIZE_UNSPEC;
585 | ',' EXPR
587 $$ = $2;
591 /* EXPR ',' when it may be omitted. */
593 optexprc:
594 /* empty */
596 $$.exp.X_op = O_absent;
597 $$.size = SIZE_UNSPEC;
599 | EXPR ','
601 $$ = $1;
605 /* A register list for the movem instruction. */
607 reglist:
608 reglistpair
609 | reglistpair '/' ireglist
611 $$ = $1 | $3;
613 | reglistreg '/' ireglist
615 $$ = (1 << $1) | $3;
619 /* We use ireglist when we know we are looking at a reglist, and we
620 can safely reduce a simple register to reglistreg. If we permitted
621 reglist to reduce to reglistreg, it would be ambiguous whether a
622 plain register were a DREG/AREG/FPREG or a REGLST. */
624 ireglist:
625 reglistreg
627 $$ = 1 << $1;
629 | reglistpair
630 | reglistpair '/' ireglist
632 $$ = $1 | $3;
634 | reglistreg '/' ireglist
636 $$ = (1 << $1) | $3;
640 reglistpair:
641 reglistreg '-' reglistreg
643 if ($1 <= $3)
644 $$ = (1 << ($3 + 1)) - 1 - ((1 << $1) - 1);
645 else
646 $$ = (1 << ($1 + 1)) - 1 - ((1 << $3) - 1);
650 reglistreg:
653 $$ = $1 - DATA0;
655 | AR
657 $$ = $1 - ADDR0 + 8;
659 | FPR
661 $$ = $1 - FP0 + 16;
663 | FPCR
665 if ($1 == FPI)
666 $$ = 24;
667 else if ($1 == FPS)
668 $$ = 25;
669 else
670 $$ = 26;
676 /* The string to parse is stored here, and modified by yylex. */
678 static char *str;
680 /* The original string pointer. */
682 static char *strorig;
684 /* If *CCP could be a register, return the register number and advance
685 *CCP. Otherwise don't change *CCP, and return 0. */
687 static enum m68k_register
688 m68k_reg_parse (ccp)
689 register char **ccp;
691 char *start = *ccp;
692 char c;
693 char *p;
694 symbolS *symbolp;
696 if (flag_reg_prefix_optional)
698 if (*start == REGISTER_PREFIX)
699 start++;
700 p = start;
702 else
704 if (*start != REGISTER_PREFIX)
705 return 0;
706 p = start + 1;
709 if (! is_name_beginner (*p))
710 return 0;
712 p++;
713 while (is_part_of_name (*p) && *p != '.' && *p != ':' && *p != '*')
714 p++;
716 c = *p;
717 *p = 0;
718 symbolp = symbol_find (start);
719 *p = c;
721 if (symbolp != NULL && S_GET_SEGMENT (symbolp) == reg_section)
723 *ccp = p;
724 return S_GET_VALUE (symbolp);
727 /* In MRI mode, something like foo.bar can be equated to a register
728 name. */
729 while (flag_mri && c == '.')
731 ++p;
732 while (is_part_of_name (*p) && *p != '.' && *p != ':' && *p != '*')
733 p++;
734 c = *p;
735 *p = '\0';
736 symbolp = symbol_find (start);
737 *p = c;
738 if (symbolp != NULL && S_GET_SEGMENT (symbolp) == reg_section)
740 *ccp = p;
741 return S_GET_VALUE (symbolp);
745 return 0;
748 /* The lexer. */
750 static int
751 yylex ()
753 enum m68k_register reg;
754 char *s;
755 int parens;
756 int c = 0;
757 int tail = 0;
758 char *hold;
760 if (*str == ' ')
761 ++str;
763 if (*str == '\0')
764 return 0;
766 /* Various special characters are just returned directly. */
767 switch (*str)
769 case '@':
770 /* In MRI mode, this can be the start of an octal number. */
771 if (flag_mri)
773 if (ISDIGIT (str[1])
774 || ((str[1] == '+' || str[1] == '-')
775 && ISDIGIT (str[2])))
776 break;
778 /* Fall through. */
779 case '#':
780 case '&':
781 case ',':
782 case ')':
783 case '/':
784 case '[':
785 case ']':
786 case '<':
787 case '>':
788 return *str++;
789 case '+':
790 /* It so happens that a '+' can only appear at the end of an
791 operand, or if it is trailed by an '&'(see mac load insn).
792 If it appears anywhere else, it must be a unary. */
793 if (str[1] == '\0' || (str[1] == '&' && str[2] == '\0'))
794 return *str++;
795 break;
796 case '-':
797 /* A '-' can only appear in -(ar), rn-rn, or ar@-. If it
798 appears anywhere else, it must be a unary minus on an
799 expression, unless it it trailed by a '&'(see mac load insn). */
800 if (str[1] == '\0' || (str[1] == '&' && str[2] == '\0'))
801 return *str++;
802 s = str + 1;
803 if (*s == '(')
804 ++s;
805 if (m68k_reg_parse (&s) != 0)
806 return *str++;
807 break;
808 case '(':
809 /* A '(' can only appear in `(reg)', `(expr,...', `([', `@(', or
810 `)('. If it appears anywhere else, it must be starting an
811 expression. */
812 if (str[1] == '['
813 || (str > strorig
814 && (str[-1] == '@'
815 || str[-1] == ')')))
816 return *str++;
817 s = str + 1;
818 if (m68k_reg_parse (&s) != 0)
819 return *str++;
820 /* Check for the case of '(expr,...' by scanning ahead. If we
821 find a comma outside of balanced parentheses, we return '('.
822 If we find an unbalanced right parenthesis, then presumably
823 the '(' really starts an expression. */
824 parens = 0;
825 for (s = str + 1; *s != '\0'; s++)
827 if (*s == '(')
828 ++parens;
829 else if (*s == ')')
831 if (parens == 0)
832 break;
833 --parens;
835 else if (*s == ',' && parens == 0)
837 /* A comma can not normally appear in an expression, so
838 this is a case of '(expr,...'. */
839 return *str++;
844 /* See if it's a register. */
846 reg = m68k_reg_parse (&str);
847 if (reg != 0)
849 int ret;
851 yylval.reg = reg;
853 if (reg >= DATA0 && reg <= DATA7)
854 ret = DR;
855 else if (reg >= ADDR0 && reg <= ADDR7)
856 ret = AR;
857 else if (reg >= FP0 && reg <= FP7)
858 return FPR;
859 else if (reg == FPI
860 || reg == FPS
861 || reg == FPC)
862 return FPCR;
863 else if (reg == PC)
864 return LPC;
865 else if (reg >= ZDATA0 && reg <= ZDATA7)
866 ret = ZDR;
867 else if (reg >= ZADDR0 && reg <= ZADDR7)
868 ret = ZAR;
869 else if (reg == ZPC)
870 return LZPC;
871 else
872 return CREG;
874 /* If we get here, we have a data or address register. We
875 must check for a size or scale; if we find one, we must
876 return INDEXREG. */
878 s = str;
880 if (*s != '.' && *s != ':' && *s != '*')
881 return ret;
883 yylval.indexreg.reg = reg;
885 if (*s != '.' && *s != ':')
886 yylval.indexreg.size = SIZE_UNSPEC;
887 else
889 ++s;
890 switch (*s)
892 case 'w':
893 case 'W':
894 yylval.indexreg.size = SIZE_WORD;
895 ++s;
896 break;
897 case 'l':
898 case 'L':
899 yylval.indexreg.size = SIZE_LONG;
900 ++s;
901 break;
902 default:
903 yyerror (_("illegal size specification"));
904 yylval.indexreg.size = SIZE_UNSPEC;
905 break;
909 yylval.indexreg.scale = 1;
911 if (*s == '*' || *s == ':')
913 expressionS scale;
915 ++s;
917 hold = input_line_pointer;
918 input_line_pointer = s;
919 expression (&scale);
920 s = input_line_pointer;
921 input_line_pointer = hold;
923 if (scale.X_op != O_constant)
924 yyerror (_("scale specification must resolve to a number"));
925 else
927 switch (scale.X_add_number)
929 case 1:
930 case 2:
931 case 4:
932 case 8:
933 yylval.indexreg.scale = scale.X_add_number;
934 break;
935 default:
936 yyerror (_("invalid scale value"));
937 break;
942 str = s;
944 return INDEXREG;
947 /* It must be an expression. Before we call expression, we need to
948 look ahead to see if there is a size specification. We must do
949 that first, because otherwise foo.l will be treated as the symbol
950 foo.l, rather than as the symbol foo with a long size
951 specification. The grammar requires that all expressions end at
952 the end of the operand, or with ',', '(', ']', ')'. */
954 parens = 0;
955 for (s = str; *s != '\0'; s++)
957 if (*s == '(')
959 if (parens == 0
960 && s > str
961 && (s[-1] == ')' || ISALNUM (s[-1])))
962 break;
963 ++parens;
965 else if (*s == ')')
967 if (parens == 0)
968 break;
969 --parens;
971 else if (parens == 0
972 && (*s == ',' || *s == ']'))
973 break;
976 yylval.exp.size = SIZE_UNSPEC;
977 if (s <= str + 2
978 || (s[-2] != '.' && s[-2] != ':'))
979 tail = 0;
980 else
982 switch (s[-1])
984 case 's':
985 case 'S':
986 case 'b':
987 case 'B':
988 yylval.exp.size = SIZE_BYTE;
989 break;
990 case 'w':
991 case 'W':
992 yylval.exp.size = SIZE_WORD;
993 break;
994 case 'l':
995 case 'L':
996 yylval.exp.size = SIZE_LONG;
997 break;
998 default:
999 break;
1001 if (yylval.exp.size != SIZE_UNSPEC)
1002 tail = 2;
1005 #ifdef OBJ_ELF
1007 /* Look for @PLTPC, etc. */
1008 char *cp;
1010 yylval.exp.pic_reloc = pic_none;
1011 cp = s - tail;
1012 if (cp - 6 > str && cp[-6] == '@')
1014 if (strncmp (cp - 6, "@PLTPC", 6) == 0)
1016 yylval.exp.pic_reloc = pic_plt_pcrel;
1017 tail += 6;
1019 else if (strncmp (cp - 6, "@GOTPC", 6) == 0)
1021 yylval.exp.pic_reloc = pic_got_pcrel;
1022 tail += 6;
1025 else if (cp - 4 > str && cp[-4] == '@')
1027 if (strncmp (cp - 4, "@PLT", 4) == 0)
1029 yylval.exp.pic_reloc = pic_plt_off;
1030 tail += 4;
1032 else if (strncmp (cp - 4, "@GOT", 4) == 0)
1034 yylval.exp.pic_reloc = pic_got_off;
1035 tail += 4;
1039 #endif
1041 if (tail != 0)
1043 c = s[-tail];
1044 s[-tail] = 0;
1047 hold = input_line_pointer;
1048 input_line_pointer = str;
1049 expression (&yylval.exp.exp);
1050 str = input_line_pointer;
1051 input_line_pointer = hold;
1053 if (tail != 0)
1055 s[-tail] = c;
1056 str = s;
1059 return EXPR;
1062 /* Parse an m68k operand. This is the only function which is called
1063 from outside this file. */
1066 m68k_ip_op (s, oparg)
1067 char *s;
1068 struct m68k_op *oparg;
1070 memset (oparg, 0, sizeof *oparg);
1071 oparg->error = NULL;
1072 oparg->index.reg = ZDATA0;
1073 oparg->index.scale = 1;
1074 oparg->disp.exp.X_op = O_absent;
1075 oparg->odisp.exp.X_op = O_absent;
1077 str = strorig = s;
1078 op = oparg;
1080 return yyparse ();
1083 /* The error handler. */
1085 static void
1086 yyerror (s)
1087 const char *s;
1089 op->error = s;