1 /* A Bison parser, made from m68k-parse.y
2 by GNU bison 1.35. */
3
4 #define YYBISON 1 /* Identify Bison output. */
5
6 # define DR 257
7 # define AR 258
8 # define FPR 259
9 # define FPCR 260
10 # define LPC 261
11 # define ZAR 262
12 # define ZDR 263
13 # define LZPC 264
14 # define CREG 265
15 # define INDEXREG 266
16 # define EXPR 267
17
18 #line 27 "m68k-parse.y"
19
20
21 #include "as.h"
22 #include "tc-m68k.h"
23 #include "m68k-parse.h"
24 #include "safe-ctype.h"
25
26 /* Remap normal yacc parser interface names (yyparse, yylex, yyerror,
27 etc), as well as gratuitously global symbol names If other parser
28 generators (bison, byacc, etc) produce additional global names that
29 conflict at link time, then those parser generators need to be
30 fixed instead of adding those names to this list. */
31
32 #define yymaxdepth m68k_maxdepth
33 #define yyparse m68k_parse
34 #define yylex m68k_lex
35 #define yyerror m68k_error
36 #define yylval m68k_lval
37 #define yychar m68k_char
38 #define yydebug m68k_debug
39 #define yypact m68k_pact
40 #define yyr1 m68k_r1
41 #define yyr2 m68k_r2
42 #define yydef m68k_def
43 #define yychk m68k_chk
44 #define yypgo m68k_pgo
45 #define yyact m68k_act
46 #define yyexca m68k_exca
47 #define yyerrflag m68k_errflag
48 #define yynerrs m68k_nerrs
49 #define yyps m68k_ps
50 #define yypv m68k_pv
51 #define yys m68k_s
52 #define yy_yys m68k_yys
53 #define yystate m68k_state
54 #define yytmp m68k_tmp
55 #define yyv m68k_v
56 #define yy_yyv m68k_yyv
57 #define yyval m68k_val
58 #define yylloc m68k_lloc
59 #define yyreds m68k_reds /* With YYDEBUG defined */
60 #define yytoks m68k_toks /* With YYDEBUG defined */
61 #define yylhs m68k_yylhs
62 #define yylen m68k_yylen
63 #define yydefred m68k_yydefred
64 #define yydgoto m68k_yydgoto
65 #define yysindex m68k_yysindex
66 #define yyrindex m68k_yyrindex
67 #define yygindex m68k_yygindex
68 #define yytable m68k_yytable
69 #define yycheck m68k_yycheck
70
71 #ifndef YYDEBUG
72 #define YYDEBUG 1
73 #endif
74
75 /* Internal functions. */
76
77 static enum m68k_register m68k_reg_parse PARAMS ((char **));
78 static int yylex PARAMS ((void));
79 static void yyerror PARAMS ((const char *));
80
81 /* The parser sets fields pointed to by this global variable. */
82 static struct m68k_op *op;
83
84
85 #line 94 "m68k-parse.y"
86 #ifndef YYSTYPE
87 typedef union
88 {
89 struct m68k_indexreg indexreg;
90 enum m68k_register reg;
91 struct m68k_exp exp;
92 unsigned long mask;
93 int onereg;
94 } yystype;
95 # define YYSTYPE yystype
96 # define YYSTYPE_IS_TRIVIAL 1
97 #endif
98 #ifndef YYDEBUG
99 # define YYDEBUG 0
100 #endif
101
102
103
104 #define YYFINAL 173
105 #define YYFLAG -32768
106 #define YYNTBASE 25
107
108 /* YYTRANSLATE(YYLEX) -- Bison token number corresponding to YYLEX. */
109 #define YYTRANSLATE(x) ((unsigned)(x) <= 267 ? yytranslate[x] : 44)
110
111 /* YYTRANSLATE[YYLEX] -- Bison token number corresponding to YYLEX. */
112 static const char yytranslate[] =
113 {
114 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
115 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
116 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
117 2, 2, 2, 2, 2, 14, 2, 2, 15, 2,
118 16, 17, 2, 18, 20, 19, 2, 24, 2, 2,
119 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
120 2, 2, 2, 2, 23, 2, 2, 2, 2, 2,
121 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
122 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
123 2, 21, 2, 22, 2, 2, 2, 2, 2, 2,
124 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
125 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
126 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
127 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
128 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
129 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
130 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
131 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
132 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
133 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
134 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
135 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
136 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
137 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
138 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
139 2, 2, 2, 2, 2, 2, 1, 3, 4, 5,
140 6, 7, 8, 9, 10, 11, 12, 13
141 };
142
143 #if YYDEBUG
144 static const short yyprhs[] =
145 {
146 0, 0, 2, 4, 6, 8, 10, 12, 14, 16,
147 18, 21, 24, 26, 30, 35, 40, 46, 52, 57,
148 61, 65, 69, 77, 85, 92, 98, 105, 111, 118,
149 124, 130, 135, 145, 153, 162, 169, 180, 189, 200,
150 209, 218, 221, 225, 229, 235, 242, 253, 263, 274,
151 276, 278, 280, 282, 284, 286, 288, 290, 292, 294,
152 296, 298, 300, 302, 303, 305, 307, 309, 310, 313,
153 314, 317, 318, 321, 323, 327, 331, 333, 335, 339,
154 343, 347, 349, 351, 353
155 };
156 static const short yyrhs[] =
157 {
158 26, 0, 27, 0, 28, 0, 3, 0, 4, 0,
159 5, 0, 6, 0, 11, 0, 13, 0, 14, 13,
160 0, 15, 13, 0, 40, 0, 16, 4, 17, 0,
161 16, 4, 17, 18, 0, 19, 16, 4, 17, 0,
162 16, 13, 20, 34, 17, 0, 16, 34, 20, 13,
163 17, 0, 13, 16, 34, 17, 0, 16, 7, 17,
164 0, 16, 8, 17, 0, 16, 10, 17, 0, 16,
165 13, 20, 34, 20, 29, 17, 0, 16, 13, 20,
166 34, 20, 36, 17, 0, 16, 13, 20, 30, 37,
167 17, 0, 16, 30, 20, 13, 17, 0, 13, 16,
168 34, 20, 29, 17, 0, 16, 34, 20, 29, 17,
169 0, 13, 16, 34, 20, 36, 17, 0, 16, 34,
170 20, 36, 17, 0, 13, 16, 30, 37, 17, 0,
171 16, 30, 37, 17, 0, 16, 21, 13, 37, 22,
172 20, 29, 38, 17, 0, 16, 21, 13, 37, 22,
173 38, 17, 0, 16, 21, 34, 22, 20, 29, 38,
174 17, 0, 16, 21, 34, 22, 38, 17, 0, 16,
175 21, 13, 20, 34, 20, 29, 22, 38, 17, 0,
176 16, 21, 34, 20, 29, 22, 38, 17, 0, 16,
177 21, 13, 20, 34, 20, 36, 22, 38, 17, 0,
178 16, 21, 34, 20, 36, 22, 38, 17, 0, 16,
179 21, 39, 30, 37, 22, 38, 17, 0, 35, 23,
180 0, 35, 23, 18, 0, 35, 23, 19, 0, 35,
181 23, 16, 13, 17, 0, 35, 23, 16, 39, 29,
182 17, 0, 35, 23, 16, 13, 17, 23, 16, 39,
183 29, 17, 0, 35, 23, 16, 13, 17, 23, 16,
184 13, 17, 0, 35, 23, 16, 39, 29, 17, 23,
185 16, 13, 17, 0, 12, 0, 31, 0, 12, 0,
186 32, 0, 32, 0, 4, 0, 8, 0, 3, 0,
187 9, 0, 4, 0, 7, 0, 33, 0, 10, 0,
188 8, 0, 0, 34, 0, 7, 0, 10, 0, 0,
189 20, 34, 0, 0, 20, 13, 0, 0, 13, 20,
190 0, 42, 0, 42, 24, 41, 0, 43, 24, 41,
191 0, 43, 0, 42, 0, 42, 24, 41, 0, 43,
192 24, 41, 0, 43, 19, 43, 0, 3, 0, 4,
193 0, 5, 0, 6, 0
194 };
195
196 #endif
197
198 #if YYDEBUG
199 /* YYRLINE[YYN] -- source line where rule number YYN was defined. */
200 static const short yyrline[] =
201 {
202 0, 117, 119, 120, 125, 131, 136, 141, 146, 151,
203 156, 161, 166, 178, 184, 189, 194, 204, 214, 224,
204 229, 234, 239, 246, 257, 264, 270, 277, 283, 294,
205 304, 311, 317, 325, 332, 339, 345, 353, 360, 372,
206 383, 395, 404, 412, 420, 430, 437, 445, 452, 465,
207 467, 479, 481, 492, 494, 495, 500, 502, 507, 509,
208 515, 517, 518, 523, 528, 533, 535, 540, 545, 553,
209 559, 567, 573, 581, 583, 587, 598, 603, 604, 608,
210 614, 624, 629, 633, 637
211 };
212 #endif
213
214
215 #if (YYDEBUG) || defined YYERROR_VERBOSE
216
217 /* YYTNAME[TOKEN_NUM] -- String name of the token TOKEN_NUM. */
218 static const char *const yytname[] =
219 {
220 "$", "error", "$undefined.", "DR", "AR", "FPR", "FPCR", "LPC", "ZAR",
221 "ZDR", "LZPC", "CREG", "INDEXREG", "EXPR", "'#'", "'&'", "'('", "')'",
222 "'+'", "'-'", "','", "'['", "']'", "'@'", "'/'", "operand",
223 "generic_operand", "motorola_operand", "mit_operand", "zireg", "zdireg",
224 "zadr", "zdr", "apc", "zapc", "optzapc", "zpc", "optczapc", "optcexpr",
225 "optexprc", "reglist", "ireglist", "reglistpair", "reglistreg", 0
226 };
227 #endif
228
229 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
230 static const short yyr1[] =
231 {
232 0, 25, 25, 25, 26, 26, 26, 26, 26, 26,
233 26, 26, 26, 27, 27, 27, 27, 27, 27, 27,
234 27, 27, 27, 27, 27, 27, 27, 27, 27, 27,
235 27, 27, 27, 27, 27, 27, 27, 27, 27, 27,
236 27, 28, 28, 28, 28, 28, 28, 28, 28, 29,
237 29, 30, 30, 31, 31, 31, 32, 32, 33, 33,
238 34, 34, 34, 35, 35, 36, 36, 37, 37, 38,
239 38, 39, 39, 40, 40, 40, 41, 41, 41, 41,
240 42, 43, 43, 43, 43
241 };
242
243 /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
244 static const short yyr2[] =
245 {
246 0, 1, 1, 1, 1, 1, 1, 1, 1, 1,
247 2, 2, 1, 3, 4, 4, 5, 5, 4, 3,
248 3, 3, 7, 7, 6, 5, 6, 5, 6, 5,
249 5, 4, 9, 7, 8, 6, 10, 8, 10, 8,
250 8, 2, 3, 3, 5, 6, 10, 9, 10, 1,
251 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
252 1, 1, 1, 0, 1, 1, 1, 0, 2, 0,
253 2, 0, 2, 1, 3, 3, 1, 1, 3, 3,
254 3, 1, 1, 1, 1
255 };
256
257 /* YYDEFACT[S] -- default rule to reduce with in state S when YYTABLE
258 doesn't specify something else to do. Zero means the default is an
259 error. */
260 static const short yydefact[] =
261 {
262 63, 81, 82, 83, 84, 59, 62, 61, 8, 9,
263 0, 0, 0, 0, 1, 2, 3, 60, 64, 0,
264 12, 73, 0, 0, 10, 11, 56, 58, 59, 62,
265 57, 61, 51, 0, 71, 67, 52, 0, 0, 41,
266 0, 0, 0, 58, 67, 0, 13, 19, 20, 21,
267 0, 67, 0, 0, 0, 0, 0, 0, 71, 42,
268 43, 81, 82, 83, 84, 74, 77, 76, 80, 75,
269 0, 0, 18, 0, 14, 67, 0, 72, 0, 0,
270 69, 67, 0, 68, 31, 54, 65, 55, 66, 49,
271 0, 0, 50, 53, 0, 15, 0, 0, 0, 0,
272 30, 0, 0, 0, 16, 0, 68, 69, 0, 0,
273 0, 0, 0, 25, 17, 27, 29, 44, 72, 0,
274 78, 79, 26, 28, 24, 0, 0, 0, 0, 0,
275 69, 69, 70, 69, 35, 69, 0, 45, 22, 23,
276 0, 0, 69, 33, 0, 0, 0, 0, 0, 71,
277 0, 69, 69, 0, 37, 39, 34, 40, 0, 0,
278 0, 0, 0, 32, 47, 0, 0, 36, 38, 46,
279 48, 0, 0, 0
280 };
281
282 static const short yydefgoto[] =
283 {
284 171, 14, 15, 16, 91, 35, 92, 93, 17, 83,
285 19, 94, 55, 111, 53, 20, 65, 66, 67
286 };
287
288 static const short yypact[] =
289 {
290 89, 10, 11, 19, 23,-32768,-32768,-32768,-32768, 13,
291 -4, 22, 57, 36,-32768,-32768,-32768,-32768,-32768, 18,
292 -32768, 33, -2, 114,-32768,-32768,-32768, 46, 62, 66,
293 -32768, 67,-32768, 68, 131, 69,-32768, 70, 105, 147,
294 156, 156, 156,-32768, 94, 25, 101,-32768,-32768,-32768,
295 114, 100, 53, 9, 138, 108, 103, 112, 117,-32768,
296 -32768,-32768,-32768,-32768,-32768,-32768, 119, 12,-32768,-32768,
297 64, 130,-32768, 124,-32768, 94, 81, 64, 135, 124,
298 132, 94, 150,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
299 151, 152,-32768,-32768, 153,-32768, 120, 146, 156, 156,
300 -32768, 154, 155, 157,-32768, 124, 144, 158, 159, 160,
301 73, 162, 161,-32768,-32768,-32768,-32768, 163,-32768, 167,
302 -32768,-32768,-32768,-32768,-32768, 168, 170, 124, 73, 171,
303 169, 169,-32768, 169,-32768, 169, 164, 172,-32768,-32768,
304 174, 175, 169,-32768, 177, 176, 181, 182, 183, 178,
305 185, 169, 169, 186,-32768,-32768,-32768,-32768, 136, 146,
306 179, 187, 188,-32768,-32768, 189, 190,-32768,-32768,-32768,
307 -32768, 173, 194,-32768
308 };
309
310 static const short yypgoto[] =
311 {
312 -32768,-32768,-32768,-32768, -72, 1,-32768, -7,-32768, 3,
313 -32768, -65, -31, -103, -58,-32768, -40, 202, 6
314 };
315
316
317 #define YYLAST 207
318
319
320 static const short yytable[] =
321 {
322 97, 101, 69, 18, 129, 36, 22, 108, 102, 24,
323 -4, -5, 26, 71, 109, 37, 36, 41, 30, -6,
324 78, 32, 42, -7, 44, 119, 45, 145, 146, 23,
325 147, 41, 148, 125, -58, 25, 99, 52, 133, 153,
326 126, 39, 72, 36, 103, 73, 36, 68, 161, 162,
327 112, 75, 38, 76, 81, 140, 142, 40, 120, 121,
328 26, 27, 141, 46, 28, 29, 30, 31, 43, 32,
329 33, 5, 6, 79, 7, 80, 26, 85, 34, 47,
330 106, 87, 30, 48, 49, 89, 132, 165, 50, 54,
331 56, 159, 1, 2, 3, 4, 5, 6, 104, 7,
332 8, 105, 9, 10, 11, 12, 26, 85, 13, 57,
333 86, 87, 30, 88, 70, 89, 90, 26, 43, 74,
334 77, 5, 6, 30, 7, 84, 32, 26, 85, 95,
335 96, 86, 87, 30, 88, 43, 89, 117, 5, 6,
336 118, 7, 43, 98, 51, 5, 6, 100, 7, 26,
337 85, 82, 110, 164, 87, 30, 118, 107, 89, 61,
338 62, 63, 64, 58, 127, 59, 60, 113, 114, 115,
339 116, 122, 123, 172, 124, 0, 0, 0, 128, 134,
340 149, 130, 131, 135, 137, 138, 136, 139, 143, 144,
341 132, 158, 166, 154, 173, 150, 151, 152, 155, 156,
342 157, 160, 21, 163, 167, 168, 169, 170
343 };
344
345 static const short yycheck[] =
346 {
347 58, 73, 42, 0, 107, 12, 0, 79, 73, 13,
348 0, 0, 3, 44, 79, 12, 23, 19, 9, 0,
349 51, 12, 24, 0, 23, 97, 23, 130, 131, 16,
350 133, 19, 135, 105, 23, 13, 24, 34, 110, 142,
351 105, 23, 17, 50, 75, 20, 53, 41, 151, 152,
352 81, 50, 16, 50, 53, 127, 128, 24, 98, 99,
353 3, 4, 127, 17, 7, 8, 9, 10, 4, 12,
354 13, 7, 8, 20, 10, 22, 3, 4, 21, 17,
355 77, 8, 9, 17, 17, 12, 13, 159, 20, 20,
356 20, 149, 3, 4, 5, 6, 7, 8, 17, 10,
357 11, 20, 13, 14, 15, 16, 3, 4, 19, 4,
358 7, 8, 9, 10, 20, 12, 13, 3, 4, 18,
359 20, 7, 8, 9, 10, 17, 12, 3, 4, 17,
360 13, 7, 8, 9, 10, 4, 12, 17, 7, 8,
361 20, 10, 4, 24, 13, 7, 8, 17, 10, 3,
362 4, 13, 20, 17, 8, 9, 20, 22, 12, 3,
363 4, 5, 6, 16, 20, 18, 19, 17, 17, 17,
364 17, 17, 17, 0, 17, -1, -1, -1, 20, 17,
365 16, 22, 22, 22, 17, 17, 23, 17, 17, 20,
366 13, 13, 13, 17, 0, 23, 22, 22, 17, 17,
367 17, 16, 0, 17, 17, 17, 17, 17
368 };
369 /* -*-C-*- Note some compilers choke on comments on `#line' lines. */
370 #line 3 "/usr/share/bison-1.35/bison.simple"
371
372 /* Skeleton output parser for bison,
373
374 Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002 Free Software
375 Foundation, Inc.
376
377 This program is free software; you can redistribute it and/or modify
378 it under the terms of the GNU General Public License as published by
379 the Free Software Foundation; either version 2, or (at your option)
380 any later version.
381
382 This program is distributed in the hope that it will be useful,
383 but WITHOUT ANY WARRANTY; without even the implied warranty of
384 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
385 GNU General Public License for more details.
386
387 You should have received a copy of the GNU General Public License
388 along with this program; if not, write to the Free Software
389 Foundation, Inc., 59 Temple Place - Suite 330,
390 Boston, MA 02111-1307, USA. */
391
392 /* As a special exception, when this file is copied by Bison into a
393 Bison output file, you may use that output file without restriction.
394 This special exception was added by the Free Software Foundation
395 in version 1.24 of Bison. */
396
397 /* This is the parser code that is written into each bison parser when
398 the %semantic_parser declaration is not specified in the grammar.
399 It was written by Richard Stallman by simplifying the hairy parser
400 used when %semantic_parser is specified. */
401
402 /* All symbols defined below should begin with yy or YY, to avoid
403 infringing on user name space. This should be done even for local
404 variables, as they might otherwise be expanded by user macros.
405 There are some unavoidable exceptions within include files to
406 define necessary library symbols; they are noted "INFRINGES ON
407 USER NAME SPACE" below. */
408
409 #if ! defined (yyoverflow) || defined (YYERROR_VERBOSE)
410
411 /* The parser invokes alloca or malloc; define the necessary symbols. */
412
413 # if YYSTACK_USE_ALLOCA
414 # define YYSTACK_ALLOC alloca
415 # else
416 # ifndef YYSTACK_USE_ALLOCA
417 # if defined (alloca) || defined (_ALLOCA_H)
418 # define YYSTACK_ALLOC alloca
419 # else
420 # ifdef __GNUC__
421 # define YYSTACK_ALLOC __builtin_alloca
422 # endif
423 # endif
424 # endif
425 # endif
426
427 # ifdef YYSTACK_ALLOC
428 /* Pacify GCC's `empty if-body' warning. */
429 # define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
430 # else
431 # if defined (__STDC__) || defined (__cplusplus)
432 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
433 # define YYSIZE_T size_t
434 # endif
435 # define YYSTACK_ALLOC malloc
436 # define YYSTACK_FREE free
437 # endif
438 #endif /* ! defined (yyoverflow) || defined (YYERROR_VERBOSE) */
439
440
441 #if (! defined (yyoverflow) \
442 && (! defined (__cplusplus) \
443 || (YYLTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
444
445 /* A type that is properly aligned for any stack member. */
446 union yyalloc
447 {
448 short yyss;
449 YYSTYPE yyvs;
450 # if YYLSP_NEEDED
451 YYLTYPE yyls;
452 # endif
453 };
454
455 /* The size of the maximum gap between one aligned stack and the next. */
456 # define YYSTACK_GAP_MAX (sizeof (union yyalloc) - 1)
457
458 /* The size of an array large to enough to hold all stacks, each with
459 N elements. */
460 # if YYLSP_NEEDED
461 # define YYSTACK_BYTES(N) \
462 ((N) * (sizeof (short) + sizeof (YYSTYPE) + sizeof (YYLTYPE)) \
463 + 2 * YYSTACK_GAP_MAX)
464 # else
465 # define YYSTACK_BYTES(N) \
466 ((N) * (sizeof (short) + sizeof (YYSTYPE)) \
467 + YYSTACK_GAP_MAX)
468 # endif
469
470 /* Copy COUNT objects from FROM to TO. The source and destination do
471 not overlap. */
472 # ifndef YYCOPY
473 # if 1 < __GNUC__
474 # define YYCOPY(To, From, Count) \
475 __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
476 # else
477 # define YYCOPY(To, From, Count) \
478 do \
479 { \
480 register YYSIZE_T yyi; \
481 for (yyi = 0; yyi < (Count); yyi++) \
482 (To)[yyi] = (From)[yyi]; \
483 } \
484 while (0)
485 # endif
486 # endif
487
488 /* Relocate STACK from its old location to the new one. The
489 local variables YYSIZE and YYSTACKSIZE give the old and new number of
490 elements in the stack, and YYPTR gives the new location of the
491 stack. Advance YYPTR to a properly aligned location for the next
492 stack. */
493 # define YYSTACK_RELOCATE(Stack) \
494 do \
495 { \
496 YYSIZE_T yynewbytes; \
497 YYCOPY (&yyptr->Stack, Stack, yysize); \
498 Stack = &yyptr->Stack; \
499 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAX; \
500 yyptr += yynewbytes / sizeof (*yyptr); \
501 } \
502 while (0)
503
504 #endif
505
506
507 #if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__)
508 # define YYSIZE_T __SIZE_TYPE__
509 #endif
510 #if ! defined (YYSIZE_T) && defined (size_t)
511 # define YYSIZE_T size_t
512 #endif
513 #if ! defined (YYSIZE_T)
514 # if defined (__STDC__) || defined (__cplusplus)
515 # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
516 # define YYSIZE_T size_t
517 # endif
518 #endif
519 #if ! defined (YYSIZE_T)
520 # define YYSIZE_T unsigned int
521 #endif
522
523 #define yyerrok (yyerrstatus = 0)
524 #define yyclearin (yychar = YYEMPTY)
525 #define YYEMPTY -2
526 #define YYEOF 0
527 #define YYACCEPT goto yyacceptlab
528 #define YYABORT goto yyabortlab
529 #define YYERROR goto yyerrlab1
530 /* Like YYERROR except do call yyerror. This remains here temporarily
531 to ease the transition to the new meaning of YYERROR, for GCC.
532 Once GCC version 2 has supplanted version 1, this can go. */
533 #define YYFAIL goto yyerrlab
534 #define YYRECOVERING() (!!yyerrstatus)
535 #define YYBACKUP(Token, Value) \
536 do \
537 if (yychar == YYEMPTY && yylen == 1) \
538 { \
539 yychar = (Token); \
540 yylval = (Value); \
541 yychar1 = YYTRANSLATE (yychar); \
542 YYPOPSTACK; \
543 goto yybackup; \
544 } \
545 else \
546 { \
547 yyerror ("syntax error: cannot back up"); \
548 YYERROR; \
549 } \
550 while (0)
551
552 #define YYTERROR 1
553 #define YYERRCODE 256
554
555
556 /* YYLLOC_DEFAULT -- Compute the default location (before the actions
557 are run).
558
559 When YYLLOC_DEFAULT is run, CURRENT is set the location of the
560 first token. By default, to implement support for ranges, extend
561 its range to the last symbol. */
562
563 #ifndef YYLLOC_DEFAULT
564 # define YYLLOC_DEFAULT(Current, Rhs, N) \
565 Current.last_line = Rhs[N].last_line; \
566 Current.last_column = Rhs[N].last_column;
567 #endif
568
569
570 /* YYLEX -- calling `yylex' with the right arguments. */
571
572 #if YYPURE
573 # if YYLSP_NEEDED
574 # ifdef YYLEX_PARAM
575 # define YYLEX yylex (&yylval, &yylloc, YYLEX_PARAM)
576 # else
577 # define YYLEX yylex (&yylval, &yylloc)
578 # endif
579 # else /* !YYLSP_NEEDED */
580 # ifdef YYLEX_PARAM
581 # define YYLEX yylex (&yylval, YYLEX_PARAM)
582 # else
583 # define YYLEX yylex (&yylval)
584 # endif
585 # endif /* !YYLSP_NEEDED */
586 #else /* !YYPURE */
587 # define YYLEX yylex ()
588 #endif /* !YYPURE */
589
590
591 /* Enable debugging if requested. */
592 #if YYDEBUG
593
594 # ifndef YYFPRINTF
595 # include <stdio.h> /* INFRINGES ON USER NAME SPACE */
596 # define YYFPRINTF fprintf
597 # endif
598
599 # define YYDPRINTF(Args) \
600 do { \
601 if (yydebug) \
602 YYFPRINTF Args; \
603 } while (0)
604 /* Nonzero means print parse trace. It is left uninitialized so that
605 multiple parsers can coexist. */
606 int yydebug;
607 #else /* !YYDEBUG */
608 # define YYDPRINTF(Args)
609 #endif /* !YYDEBUG */
610
611 /* YYINITDEPTH -- initial size of the parser's stacks. */
612 #ifndef YYINITDEPTH
613 # define YYINITDEPTH 200
614 #endif
615
616 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
617 if the built-in stack extension method is used).
618
619 Do not make this value too large; the results are undefined if
620 SIZE_MAX < YYSTACK_BYTES (YYMAXDEPTH)
621 evaluated with infinite-precision integer arithmetic. */
622
623 #if YYMAXDEPTH == 0
624 # undef YYMAXDEPTH
625 #endif
626
627 #ifndef YYMAXDEPTH
628 # define YYMAXDEPTH 10000
629 #endif
630
631 #ifdef YYERROR_VERBOSE
632
633 # ifndef yystrlen
634 # if defined (__GLIBC__) && defined (_STRING_H)
635 # define yystrlen strlen
636 # else
637 /* Return the length of YYSTR. */
638 static YYSIZE_T
639 # if defined (__STDC__) || defined (__cplusplus)
yystrlen(const char * yystr)640 yystrlen (const char *yystr)
641 # else
642 yystrlen (yystr)
643 const char *yystr;
644 # endif
645 {
646 register const char *yys = yystr;
647
648 while (*yys++ != '\0')
649 continue;
650
651 return yys - yystr - 1;
652 }
653 # endif
654 # endif
655
656 # ifndef yystpcpy
657 # if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE)
658 # define yystpcpy stpcpy
659 # else
660 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
661 YYDEST. */
662 static char *
663 # if defined (__STDC__) || defined (__cplusplus)
yystpcpy(char * yydest,const char * yysrc)664 yystpcpy (char *yydest, const char *yysrc)
665 # else
666 yystpcpy (yydest, yysrc)
667 char *yydest;
668 const char *yysrc;
669 # endif
670 {
671 register char *yyd = yydest;
672 register const char *yys = yysrc;
673
674 while ((*yyd++ = *yys++) != '\0')
675 continue;
676
677 return yyd - 1;
678 }
679 # endif
680 # endif
681 #endif
682
683 #line 315 "/usr/share/bison-1.35/bison.simple"
684
685
686 /* The user can define YYPARSE_PARAM as the name of an argument to be passed
687 into yyparse. The argument should have type void *.
688 It should actually point to an object.
689 Grammar actions can access the variable by casting it
690 to the proper pointer type. */
691
692 #ifdef YYPARSE_PARAM
693 # if defined (__STDC__) || defined (__cplusplus)
694 # define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
695 # define YYPARSE_PARAM_DECL
696 # else
697 # define YYPARSE_PARAM_ARG YYPARSE_PARAM
698 # define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
699 # endif
700 #else /* !YYPARSE_PARAM */
701 # define YYPARSE_PARAM_ARG
702 # define YYPARSE_PARAM_DECL
703 #endif /* !YYPARSE_PARAM */
704
705 /* Prevent warning if -Wstrict-prototypes. */
706 #ifdef __GNUC__
707 # ifdef YYPARSE_PARAM
708 int yyparse (void *);
709 # else
710 int yyparse (void);
711 # endif
712 #endif
713
714 /* YY_DECL_VARIABLES -- depending whether we use a pure parser,
715 variables are global, or local to YYPARSE. */
716
717 #define YY_DECL_NON_LSP_VARIABLES \
718 /* The lookahead symbol. */ \
719 int yychar; \
720 \
721 /* The semantic value of the lookahead symbol. */ \
722 YYSTYPE yylval; \
723 \
724 /* Number of parse errors so far. */ \
725 int yynerrs;
726
727 #if YYLSP_NEEDED
728 # define YY_DECL_VARIABLES \
729 YY_DECL_NON_LSP_VARIABLES \
730 \
731 /* Location data for the lookahead symbol. */ \
732 YYLTYPE yylloc;
733 #else
734 # define YY_DECL_VARIABLES \
735 YY_DECL_NON_LSP_VARIABLES
736 #endif
737
738
739 /* If nonreentrant, generate the variables here. */
740
741 #if !YYPURE
742 YY_DECL_VARIABLES
743 #endif /* !YYPURE */
744
745 int
yyparse(YYPARSE_PARAM_ARG)746 yyparse (YYPARSE_PARAM_ARG)
747 YYPARSE_PARAM_DECL
748 {
749 /* If reentrant, generate the variables here. */
750 #if YYPURE
751 YY_DECL_VARIABLES
752 #endif /* !YYPURE */
753
754 register int yystate;
755 register int yyn;
756 int yyresult;
757 /* Number of tokens to shift before error messages enabled. */
758 int yyerrstatus;
759 /* Lookahead token as an internal (translated) token number. */
760 int yychar1 = 0;
761
762 /* Three stacks and their tools:
763 `yyss': related to states,
764 `yyvs': related to semantic values,
765 `yyls': related to locations.
766
767 Refer to the stacks thru separate pointers, to allow yyoverflow
768 to reallocate them elsewhere. */
769
770 /* The state stack. */
771 short yyssa[YYINITDEPTH];
772 short *yyss = yyssa;
773 register short *yyssp;
774
775 /* The semantic value stack. */
776 YYSTYPE yyvsa[YYINITDEPTH];
777 YYSTYPE *yyvs = yyvsa;
778 register YYSTYPE *yyvsp;
779
780 #if YYLSP_NEEDED
781 /* The location stack. */
782 YYLTYPE yylsa[YYINITDEPTH];
783 YYLTYPE *yyls = yylsa;
784 YYLTYPE *yylsp;
785 #endif
786
787 #if YYLSP_NEEDED
788 # define YYPOPSTACK (yyvsp--, yyssp--, yylsp--)
789 #else
790 # define YYPOPSTACK (yyvsp--, yyssp--)
791 #endif
792
793 YYSIZE_T yystacksize = YYINITDEPTH;
794
795
796 /* The variables used to return semantic value and location from the
797 action routines. */
798 YYSTYPE yyval;
799 #if YYLSP_NEEDED
800 YYLTYPE yyloc;
801 #endif
802
803 /* When reducing, the number of symbols on the RHS of the reduced
804 rule. */
805 int yylen;
806
807 YYDPRINTF ((stderr, "Starting parse\n"));
808
809 yystate = 0;
810 yyerrstatus = 0;
811 yynerrs = 0;
812 yychar = YYEMPTY; /* Cause a token to be read. */
813
814 /* Initialize stack pointers.
815 Waste one element of value and location stack
816 so that they stay on the same level as the state stack.
817 The wasted elements are never initialized. */
818
819 yyssp = yyss;
820 yyvsp = yyvs;
821 #if YYLSP_NEEDED
822 yylsp = yyls;
823 #endif
824 goto yysetstate;
825
826 /*------------------------------------------------------------.
827 | yynewstate -- Push a new state, which is found in yystate. |
828 `------------------------------------------------------------*/
829 yynewstate:
830 /* In all cases, when you get here, the value and location stacks
831 have just been pushed. so pushing a state here evens the stacks.
832 */
833 yyssp++;
834
835 yysetstate:
836 *yyssp = yystate;
837
838 if (yyssp >= yyss + yystacksize - 1)
839 {
840 /* Get the current used size of the three stacks, in elements. */
841 YYSIZE_T yysize = yyssp - yyss + 1;
842
843 #ifdef yyoverflow
844 {
845 /* Give user a chance to reallocate the stack. Use copies of
846 these so that the &'s don't force the real ones into
847 memory. */
848 YYSTYPE *yyvs1 = yyvs;
849 short *yyss1 = yyss;
850
851 /* Each stack pointer address is followed by the size of the
852 data in use in that stack, in bytes. */
853 # if YYLSP_NEEDED
854 YYLTYPE *yyls1 = yyls;
855 /* This used to be a conditional around just the two extra args,
856 but that might be undefined if yyoverflow is a macro. */
857 yyoverflow ("parser stack overflow",
858 &yyss1, yysize * sizeof (*yyssp),
859 &yyvs1, yysize * sizeof (*yyvsp),
860 &yyls1, yysize * sizeof (*yylsp),
861 &yystacksize);
862 yyls = yyls1;
863 # else
864 yyoverflow ("parser stack overflow",
865 &yyss1, yysize * sizeof (*yyssp),
866 &yyvs1, yysize * sizeof (*yyvsp),
867 &yystacksize);
868 # endif
869 yyss = yyss1;
870 yyvs = yyvs1;
871 }
872 #else /* no yyoverflow */
873 # ifndef YYSTACK_RELOCATE
874 goto yyoverflowlab;
875 # else
876 /* Extend the stack our own way. */
877 if (yystacksize >= YYMAXDEPTH)
878 goto yyoverflowlab;
879 yystacksize *= 2;
880 if (yystacksize > YYMAXDEPTH)
881 yystacksize = YYMAXDEPTH;
882
883 {
884 short *yyss1 = yyss;
885 union yyalloc *yyptr =
886 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
887 if (! yyptr)
888 goto yyoverflowlab;
889 YYSTACK_RELOCATE (yyss);
890 YYSTACK_RELOCATE (yyvs);
891 # if YYLSP_NEEDED
892 YYSTACK_RELOCATE (yyls);
893 # endif
894 # undef YYSTACK_RELOCATE
895 if (yyss1 != yyssa)
896 YYSTACK_FREE (yyss1);
897 }
898 # endif
899 #endif /* no yyoverflow */
900
901 yyssp = yyss + yysize - 1;
902 yyvsp = yyvs + yysize - 1;
903 #if YYLSP_NEEDED
904 yylsp = yyls + yysize - 1;
905 #endif
906
907 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
908 (unsigned long int) yystacksize));
909
910 if (yyssp >= yyss + yystacksize - 1)
911 YYABORT;
912 }
913
914 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
915
916 goto yybackup;
917
918
919 /*-----------.
920 | yybackup. |
921 `-----------*/
922 yybackup:
923
924 /* Do appropriate processing given the current state. */
925 /* Read a lookahead token if we need one and don't already have one. */
926 /* yyresume: */
927
928 /* First try to decide what to do without reference to lookahead token. */
929
930 yyn = yypact[yystate];
931 if (yyn == YYFLAG)
932 goto yydefault;
933
934 /* Not known => get a lookahead token if don't already have one. */
935
936 /* yychar is either YYEMPTY or YYEOF
937 or a valid token in external form. */
938
939 if (yychar == YYEMPTY)
940 {
941 YYDPRINTF ((stderr, "Reading a token: "));
942 yychar = YYLEX;
943 }
944
945 /* Convert token to internal form (in yychar1) for indexing tables with */
946
947 if (yychar <= 0) /* This means end of input. */
948 {
949 yychar1 = 0;
950 yychar = YYEOF; /* Don't call YYLEX any more */
951
952 YYDPRINTF ((stderr, "Now at end of input.\n"));
953 }
954 else
955 {
956 yychar1 = YYTRANSLATE (yychar);
957
958 #if YYDEBUG
959 /* We have to keep this `#if YYDEBUG', since we use variables
960 which are defined only if `YYDEBUG' is set. */
961 if (yydebug)
962 {
963 YYFPRINTF (stderr, "Next token is %d (%s",
964 yychar, yytname[yychar1]);
965 /* Give the individual parser a way to print the precise
966 meaning of a token, for further debugging info. */
967 # ifdef YYPRINT
968 YYPRINT (stderr, yychar, yylval);
969 # endif
970 YYFPRINTF (stderr, ")\n");
971 }
972 #endif
973 }
974
975 yyn += yychar1;
976 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
977 goto yydefault;
978
979 yyn = yytable[yyn];
980
981 /* yyn is what to do for this token type in this state.
982 Negative => reduce, -yyn is rule number.
983 Positive => shift, yyn is new state.
984 New state is final state => don't bother to shift,
985 just return success.
986 0, or most negative number => error. */
987
988 if (yyn < 0)
989 {
990 if (yyn == YYFLAG)
991 goto yyerrlab;
992 yyn = -yyn;
993 goto yyreduce;
994 }
995 else if (yyn == 0)
996 goto yyerrlab;
997
998 if (yyn == YYFINAL)
999 YYACCEPT;
1000
1001 /* Shift the lookahead token. */
1002 YYDPRINTF ((stderr, "Shifting token %d (%s), ",
1003 yychar, yytname[yychar1]));
1004
1005 /* Discard the token being shifted unless it is eof. */
1006 if (yychar != YYEOF)
1007 yychar = YYEMPTY;
1008
1009 *++yyvsp = yylval;
1010 #if YYLSP_NEEDED
1011 *++yylsp = yylloc;
1012 #endif
1013
1014 /* Count tokens shifted since error; after three, turn off error
1015 status. */
1016 if (yyerrstatus)
1017 yyerrstatus--;
1018
1019 yystate = yyn;
1020 goto yynewstate;
1021
1022
1023 /*-----------------------------------------------------------.
1024 | yydefault -- do the default action for the current state. |
1025 `-----------------------------------------------------------*/
1026 yydefault:
1027 yyn = yydefact[yystate];
1028 if (yyn == 0)
1029 goto yyerrlab;
1030 goto yyreduce;
1031
1032
1033 /*-----------------------------.
1034 | yyreduce -- Do a reduction. |
1035 `-----------------------------*/
1036 yyreduce:
1037 /* yyn is the number of a rule to reduce with. */
1038 yylen = yyr2[yyn];
1039
1040 /* If YYLEN is nonzero, implement the default value of the action:
1041 `$$ = $1'.
1042
1043 Otherwise, the following line sets YYVAL to the semantic value of
1044 the lookahead token. This behavior is undocumented and Bison
1045 users should not rely upon it. Assigning to YYVAL
1046 unconditionally makes the parser a bit smaller, and it avoids a
1047 GCC warning that YYVAL may be used uninitialized. */
1048 yyval = yyvsp[1-yylen];
1049
1050 #if YYLSP_NEEDED
1051 /* Similarly for the default location. Let the user run additional
1052 commands if for instance locations are ranges. */
1053 yyloc = yylsp[1-yylen];
1054 YYLLOC_DEFAULT (yyloc, (yylsp - yylen), yylen);
1055 #endif
1056
1057 #if YYDEBUG
1058 /* We have to keep this `#if YYDEBUG', since we use variables which
1059 are defined only if `YYDEBUG' is set. */
1060 if (yydebug)
1061 {
1062 int yyi;
1063
1064 YYFPRINTF (stderr, "Reducing via rule %d (line %d), ",
1065 yyn, yyrline[yyn]);
1066
1067 /* Print the symbols being reduced, and their result. */
1068 for (yyi = yyprhs[yyn]; yyrhs[yyi] > 0; yyi++)
1069 YYFPRINTF (stderr, "%s ", yytname[yyrhs[yyi]]);
1070 YYFPRINTF (stderr, " -> %s\n", yytname[yyr1[yyn]]);
1071 }
1072 #endif
1073
1074 switch (yyn) {
1075
1076 case 4:
1077 #line 127 "m68k-parse.y"
1078 {
1079 op->mode = DREG;
1080 op->reg = yyvsp[0].reg;
1081 }
1082 break;
1083 case 5:
1084 #line 132 "m68k-parse.y"
1085 {
1086 op->mode = AREG;
1087 op->reg = yyvsp[0].reg;
1088 }
1089 break;
1090 case 6:
1091 #line 137 "m68k-parse.y"
1092 {
1093 op->mode = FPREG;
1094 op->reg = yyvsp[0].reg;
1095 }
1096 break;
1097 case 7:
1098 #line 142 "m68k-parse.y"
1099 {
1100 op->mode = CONTROL;
1101 op->reg = yyvsp[0].reg;
1102 }
1103 break;
1104 case 8:
1105 #line 147 "m68k-parse.y"
1106 {
1107 op->mode = CONTROL;
1108 op->reg = yyvsp[0].reg;
1109 }
1110 break;
1111 case 9:
1112 #line 152 "m68k-parse.y"
1113 {
1114 op->mode = ABSL;
1115 op->disp = yyvsp[0].exp;
1116 }
1117 break;
1118 case 10:
1119 #line 157 "m68k-parse.y"
1120 {
1121 op->mode = IMMED;
1122 op->disp = yyvsp[0].exp;
1123 }
1124 break;
1125 case 11:
1126 #line 162 "m68k-parse.y"
1127 {
1128 op->mode = IMMED;
1129 op->disp = yyvsp[0].exp;
1130 }
1131 break;
1132 case 12:
1133 #line 167 "m68k-parse.y"
1134 {
1135 op->mode = REGLST;
1136 op->mask = yyvsp[0].mask;
1137 }
1138 break;
1139 case 13:
1140 #line 180 "m68k-parse.y"
1141 {
1142 op->mode = AINDR;
1143 op->reg = yyvsp[-1].reg;
1144 }
1145 break;
1146 case 14:
1147 #line 185 "m68k-parse.y"
1148 {
1149 op->mode = AINC;
1150 op->reg = yyvsp[-2].reg;
1151 }
1152 break;
1153 case 15:
1154 #line 190 "m68k-parse.y"
1155 {
1156 op->mode = ADEC;
1157 op->reg = yyvsp[-1].reg;
1158 }
1159 break;
1160 case 16:
1161 #line 195 "m68k-parse.y"
1162 {
1163 op->reg = yyvsp[-1].reg;
1164 op->disp = yyvsp[-3].exp;
1165 if ((yyvsp[-1].reg >= ZADDR0 && yyvsp[-1].reg <= ZADDR7)
1166 || yyvsp[-1].reg == ZPC)
1167 op->mode = BASE;
1168 else
1169 op->mode = DISP;
1170 }
1171 break;
1172 case 17:
1173 #line 205 "m68k-parse.y"
1174 {
1175 op->reg = yyvsp[-3].reg;
1176 op->disp = yyvsp[-1].exp;
1177 if ((yyvsp[-3].reg >= ZADDR0 && yyvsp[-3].reg <= ZADDR7)
1178 || yyvsp[-3].reg == ZPC)
1179 op->mode = BASE;
1180 else
1181 op->mode = DISP;
1182 }
1183 break;
1184 case 18:
1185 #line 215 "m68k-parse.y"
1186 {
1187 op->reg = yyvsp[-1].reg;
1188 op->disp = yyvsp[-3].exp;
1189 if ((yyvsp[-1].reg >= ZADDR0 && yyvsp[-1].reg <= ZADDR7)
1190 || yyvsp[-1].reg == ZPC)
1191 op->mode = BASE;
1192 else
1193 op->mode = DISP;
1194 }
1195 break;
1196 case 19:
1197 #line 225 "m68k-parse.y"
1198 {
1199 op->mode = DISP;
1200 op->reg = yyvsp[-1].reg;
1201 }
1202 break;
1203 case 20:
1204 #line 230 "m68k-parse.y"
1205 {
1206 op->mode = BASE;
1207 op->reg = yyvsp[-1].reg;
1208 }
1209 break;
1210 case 21:
1211 #line 235 "m68k-parse.y"
1212 {
1213 op->mode = BASE;
1214 op->reg = yyvsp[-1].reg;
1215 }
1216 break;
1217 case 22:
1218 #line 240 "m68k-parse.y"
1219 {
1220 op->mode = BASE;
1221 op->reg = yyvsp[-3].reg;
1222 op->disp = yyvsp[-5].exp;
1223 op->index = yyvsp[-1].indexreg;
1224 }
1225 break;
1226 case 23:
1227 #line 247 "m68k-parse.y"
1228 {
1229 if (yyvsp[-3].reg == PC || yyvsp[-3].reg == ZPC)
1230 yyerror (_("syntax error"));
1231 op->mode = BASE;
1232 op->reg = yyvsp[-1].reg;
1233 op->disp = yyvsp[-5].exp;
1234 op->index.reg = yyvsp[-3].reg;
1235 op->index.size = SIZE_UNSPEC;
1236 op->index.scale = 1;
1237 }
1238 break;
1239 case 24:
1240 #line 258 "m68k-parse.y"
1241 {
1242 op->mode = BASE;
1243 op->reg = yyvsp[-1].reg;
1244 op->disp = yyvsp[-4].exp;
1245 op->index = yyvsp[-2].indexreg;
1246 }
1247 break;
1248 case 25:
1249 #line 265 "m68k-parse.y"
1250 {
1251 op->mode = BASE;
1252 op->disp = yyvsp[-1].exp;
1253 op->index = yyvsp[-3].indexreg;
1254 }
1255 break;
1256 case 26:
1257 #line 271 "m68k-parse.y"
1258 {
1259 op->mode = BASE;
1260 op->reg = yyvsp[-3].reg;
1261 op->disp = yyvsp[-5].exp;
1262 op->index = yyvsp[-1].indexreg;
1263 }
1264 break;
1265 case 27:
1266 #line 278 "m68k-parse.y"
1267 {
1268 op->mode = BASE;
1269 op->reg = yyvsp[-3].reg;
1270 op->index = yyvsp[-1].indexreg;
1271 }
1272 break;
1273 case 28:
1274 #line 284 "m68k-parse.y"
1275 {
1276 if (yyvsp[-3].reg == PC || yyvsp[-3].reg == ZPC)
1277 yyerror (_("syntax error"));
1278 op->mode = BASE;
1279 op->reg = yyvsp[-1].reg;
1280 op->disp = yyvsp[-5].exp;
1281 op->index.reg = yyvsp[-3].reg;
1282 op->index.size = SIZE_UNSPEC;
1283 op->index.scale = 1;
1284 }
1285 break;
1286 case 29:
1287 #line 295 "m68k-parse.y"
1288 {
1289 if (yyvsp[-3].reg == PC || yyvsp[-3].reg == ZPC)
1290 yyerror (_("syntax error"));
1291 op->mode = BASE;
1292 op->reg = yyvsp[-1].reg;
1293 op->index.reg = yyvsp[-3].reg;
1294 op->index.size = SIZE_UNSPEC;
1295 op->index.scale = 1;
1296 }
1297 break;
1298 case 30:
1299 #line 305 "m68k-parse.y"
1300 {
1301 op->mode = BASE;
1302 op->reg = yyvsp[-1].reg;
1303 op->disp = yyvsp[-4].exp;
1304 op->index = yyvsp[-2].indexreg;
1305 }
1306 break;
1307 case 31:
1308 #line 312 "m68k-parse.y"
1309 {
1310 op->mode = BASE;
1311 op->reg = yyvsp[-1].reg;
1312 op->index = yyvsp[-2].indexreg;
1313 }
1314 break;
1315 case 32:
1316 #line 318 "m68k-parse.y"
1317 {
1318 op->mode = POST;
1319 op->reg = yyvsp[-5].reg;
1320 op->disp = yyvsp[-6].exp;
1321 op->index = yyvsp[-2].indexreg;
1322 op->odisp = yyvsp[-1].exp;
1323 }
1324 break;
1325 case 33:
1326 #line 326 "m68k-parse.y"
1327 {
1328 op->mode = POST;
1329 op->reg = yyvsp[-3].reg;
1330 op->disp = yyvsp[-4].exp;
1331 op->odisp = yyvsp[-1].exp;
1332 }
1333 break;
1334 case 34:
1335 #line 333 "m68k-parse.y"
1336 {
1337 op->mode = POST;
1338 op->reg = yyvsp[-5].reg;
1339 op->index = yyvsp[-2].indexreg;
1340 op->odisp = yyvsp[-1].exp;
1341 }
1342 break;
1343 case 35:
1344 #line 340 "m68k-parse.y"
1345 {
1346 op->mode = POST;
1347 op->reg = yyvsp[-3].reg;
1348 op->odisp = yyvsp[-1].exp;
1349 }
1350 break;
1351 case 36:
1352 #line 346 "m68k-parse.y"
1353 {
1354 op->mode = PRE;
1355 op->reg = yyvsp[-5].reg;
1356 op->disp = yyvsp[-7].exp;
1357 op->index = yyvsp[-3].indexreg;
1358 op->odisp = yyvsp[-1].exp;
1359 }
1360 break;
1361 case 37:
1362 #line 354 "m68k-parse.y"
1363 {
1364 op->mode = PRE;
1365 op->reg = yyvsp[-5].reg;
1366 op->index = yyvsp[-3].indexreg;
1367 op->odisp = yyvsp[-1].exp;
1368 }
1369 break;
1370 case 38:
1371 #line 361 "m68k-parse.y"
1372 {
1373 if (yyvsp[-5].reg == PC || yyvsp[-5].reg == ZPC)
1374 yyerror (_("syntax error"));
1375 op->mode = PRE;
1376 op->reg = yyvsp[-3].reg;
1377 op->disp = yyvsp[-7].exp;
1378 op->index.reg = yyvsp[-5].reg;
1379 op->index.size = SIZE_UNSPEC;
1380 op->index.scale = 1;
1381 op->odisp = yyvsp[-1].exp;
1382 }
1383 break;
1384 case 39:
1385 #line 373 "m68k-parse.y"
1386 {
1387 if (yyvsp[-5].reg == PC || yyvsp[-5].reg == ZPC)
1388 yyerror (_("syntax error"));
1389 op->mode = PRE;
1390 op->reg = yyvsp[-3].reg;
1391 op->index.reg = yyvsp[-5].reg;
1392 op->index.size = SIZE_UNSPEC;
1393 op->index.scale = 1;
1394 op->odisp = yyvsp[-1].exp;
1395 }
1396 break;
1397 case 40:
1398 #line 384 "m68k-parse.y"
1399 {
1400 op->mode = PRE;
1401 op->reg = yyvsp[-3].reg;
1402 op->disp = yyvsp[-5].exp;
1403 op->index = yyvsp[-4].indexreg;
1404 op->odisp = yyvsp[-1].exp;
1405 }
1406 break;
1407 case 41:
1408 #line 397 "m68k-parse.y"
1409 {
1410 /* We use optzapc to avoid a shift/reduce conflict. */
1411 if (yyvsp[-1].reg < ADDR0 || yyvsp[-1].reg > ADDR7)
1412 yyerror (_("syntax error"));
1413 op->mode = AINDR;
1414 op->reg = yyvsp[-1].reg;
1415 }
1416 break;
1417 case 42:
1418 #line 405 "m68k-parse.y"
1419 {
1420 /* We use optzapc to avoid a shift/reduce conflict. */
1421 if (yyvsp[-2].reg < ADDR0 || yyvsp[-2].reg > ADDR7)
1422 yyerror (_("syntax error"));
1423 op->mode = AINC;
1424 op->reg = yyvsp[-2].reg;
1425 }
1426 break;
1427 case 43:
1428 #line 413 "m68k-parse.y"
1429 {
1430 /* We use optzapc to avoid a shift/reduce conflict. */
1431 if (yyvsp[-2].reg < ADDR0 || yyvsp[-2].reg > ADDR7)
1432 yyerror (_("syntax error"));
1433 op->mode = ADEC;
1434 op->reg = yyvsp[-2].reg;
1435 }
1436 break;
1437 case 44:
1438 #line 421 "m68k-parse.y"
1439 {
1440 op->reg = yyvsp[-4].reg;
1441 op->disp = yyvsp[-1].exp;
1442 if ((yyvsp[-4].reg >= ZADDR0 && yyvsp[-4].reg <= ZADDR7)
1443 || yyvsp[-4].reg == ZPC)
1444 op->mode = BASE;
1445 else
1446 op->mode = DISP;
1447 }
1448 break;
1449 case 45:
1450 #line 431 "m68k-parse.y"
1451 {
1452 op->mode = BASE;
1453 op->reg = yyvsp[-5].reg;
1454 op->disp = yyvsp[-2].exp;
1455 op->index = yyvsp[-1].indexreg;
1456 }
1457 break;
1458 case 46:
1459 #line 438 "m68k-parse.y"
1460 {
1461 op->mode = POST;
1462 op->reg = yyvsp[-9].reg;
1463 op->disp = yyvsp[-6].exp;
1464 op->index = yyvsp[-1].indexreg;
1465 op->odisp = yyvsp[-2].exp;
1466 }
1467 break;
1468 case 47:
1469 #line 446 "m68k-parse.y"
1470 {
1471 op->mode = POST;
1472 op->reg = yyvsp[-8].reg;
1473 op->disp = yyvsp[-5].exp;
1474 op->odisp = yyvsp[-1].exp;
1475 }
1476 break;
1477 case 48:
1478 #line 453 "m68k-parse.y"
1479 {
1480 op->mode = PRE;
1481 op->reg = yyvsp[-9].reg;
1482 op->disp = yyvsp[-6].exp;
1483 op->index = yyvsp[-5].indexreg;
1484 op->odisp = yyvsp[-1].exp;
1485 }
1486 break;
1487 case 50:
1488 #line 468 "m68k-parse.y"
1489 {
1490 yyval.indexreg.reg = yyvsp[0].reg;
1491 yyval.indexreg.size = SIZE_UNSPEC;
1492 yyval.indexreg.scale = 1;
1493 }
1494 break;
1495 case 52:
1496 #line 482 "m68k-parse.y"
1497 {
1498 yyval.indexreg.reg = yyvsp[0].reg;
1499 yyval.indexreg.size = SIZE_UNSPEC;
1500 yyval.indexreg.scale = 1;
1501 }
1502 break;
1503 case 63:
1504 #line 525 "m68k-parse.y"
1505 {
1506 yyval.reg = ZADDR0;
1507 }
1508 break;
1509 case 67:
1510 #line 542 "m68k-parse.y"
1511 {
1512 yyval.reg = ZADDR0;
1513 }
1514 break;
1515 case 68:
1516 #line 546 "m68k-parse.y"
1517 {
1518 yyval.reg = yyvsp[0].reg;
1519 }
1520 break;
1521 case 69:
1522 #line 555 "m68k-parse.y"
1523 {
1524 yyval.exp.exp.X_op = O_absent;
1525 yyval.exp.size = SIZE_UNSPEC;
1526 }
1527 break;
1528 case 70:
1529 #line 560 "m68k-parse.y"
1530 {
1531 yyval.exp = yyvsp[0].exp;
1532 }
1533 break;
1534 case 71:
1535 #line 569 "m68k-parse.y"
1536 {
1537 yyval.exp.exp.X_op = O_absent;
1538 yyval.exp.size = SIZE_UNSPEC;
1539 }
1540 break;
1541 case 72:
1542 #line 574 "m68k-parse.y"
1543 {
1544 yyval.exp = yyvsp[-1].exp;
1545 }
1546 break;
1547 case 74:
1548 #line 584 "m68k-parse.y"
1549 {
1550 yyval.mask = yyvsp[-2].mask | yyvsp[0].mask;
1551 }
1552 break;
1553 case 75:
1554 #line 588 "m68k-parse.y"
1555 {
1556 yyval.mask = (1 << yyvsp[-2].onereg) | yyvsp[0].mask;
1557 }
1558 break;
1559 case 76:
1560 #line 600 "m68k-parse.y"
1561 {
1562 yyval.mask = 1 << yyvsp[0].onereg;
1563 }
1564 break;
1565 case 78:
1566 #line 605 "m68k-parse.y"
1567 {
1568 yyval.mask = yyvsp[-2].mask | yyvsp[0].mask;
1569 }
1570 break;
1571 case 79:
1572 #line 609 "m68k-parse.y"
1573 {
1574 yyval.mask = (1 << yyvsp[-2].onereg) | yyvsp[0].mask;
1575 }
1576 break;
1577 case 80:
1578 #line 616 "m68k-parse.y"
1579 {
1580 if (yyvsp[-2].onereg <= yyvsp[0].onereg)
1581 yyval.mask = (1 << (yyvsp[0].onereg + 1)) - 1 - ((1 << yyvsp[-2].onereg) - 1);
1582 else
1583 yyval.mask = (1 << (yyvsp[-2].onereg + 1)) - 1 - ((1 << yyvsp[0].onereg) - 1);
1584 }
1585 break;
1586 case 81:
1587 #line 626 "m68k-parse.y"
1588 {
1589 yyval.onereg = yyvsp[0].reg - DATA0;
1590 }
1591 break;
1592 case 82:
1593 #line 630 "m68k-parse.y"
1594 {
1595 yyval.onereg = yyvsp[0].reg - ADDR0 + 8;
1596 }
1597 break;
1598 case 83:
1599 #line 634 "m68k-parse.y"
1600 {
1601 yyval.onereg = yyvsp[0].reg - FP0 + 16;
1602 }
1603 break;
1604 case 84:
1605 #line 638 "m68k-parse.y"
1606 {
1607 if (yyvsp[0].reg == FPI)
1608 yyval.onereg = 24;
1609 else if (yyvsp[0].reg == FPS)
1610 yyval.onereg = 25;
1611 else
1612 yyval.onereg = 26;
1613 }
1614 break;
1615 }
1616
1617 #line 705 "/usr/share/bison-1.35/bison.simple"
1618
1619
1620 yyvsp -= yylen;
1621 yyssp -= yylen;
1622 #if YYLSP_NEEDED
1623 yylsp -= yylen;
1624 #endif
1625
1626 #if YYDEBUG
1627 if (yydebug)
1628 {
1629 short *yyssp1 = yyss - 1;
1630 YYFPRINTF (stderr, "state stack now");
1631 while (yyssp1 != yyssp)
1632 YYFPRINTF (stderr, " %d", *++yyssp1);
1633 YYFPRINTF (stderr, "\n");
1634 }
1635 #endif
1636
1637 *++yyvsp = yyval;
1638 #if YYLSP_NEEDED
1639 *++yylsp = yyloc;
1640 #endif
1641
1642 /* Now `shift' the result of the reduction. Determine what state
1643 that goes to, based on the state we popped back to and the rule
1644 number reduced by. */
1645
1646 yyn = yyr1[yyn];
1647
1648 yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
1649 if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
1650 yystate = yytable[yystate];
1651 else
1652 yystate = yydefgoto[yyn - YYNTBASE];
1653
1654 goto yynewstate;
1655
1656
1657 /*------------------------------------.
1658 | yyerrlab -- here on detecting error |
1659 `------------------------------------*/
1660 yyerrlab:
1661 /* If not already recovering from an error, report this error. */
1662 if (!yyerrstatus)
1663 {
1664 ++yynerrs;
1665
1666 #ifdef YYERROR_VERBOSE
1667 yyn = yypact[yystate];
1668
1669 if (yyn > YYFLAG && yyn < YYLAST)
1670 {
1671 YYSIZE_T yysize = 0;
1672 char *yymsg;
1673 int yyx, yycount;
1674
1675 yycount = 0;
1676 /* Start YYX at -YYN if negative to avoid negative indexes in
1677 YYCHECK. */
1678 for (yyx = yyn < 0 ? -yyn : 0;
1679 yyx < (int) (sizeof (yytname) / sizeof (char *)); yyx++)
1680 if (yycheck[yyx + yyn] == yyx)
1681 yysize += yystrlen (yytname[yyx]) + 15, yycount++;
1682 yysize += yystrlen ("parse error, unexpected ") + 1;
1683 yysize += yystrlen (yytname[YYTRANSLATE (yychar)]);
1684 yymsg = (char *) YYSTACK_ALLOC (yysize);
1685 if (yymsg != 0)
1686 {
1687 char *yyp = yystpcpy (yymsg, "parse error, unexpected ");
1688 yyp = yystpcpy (yyp, yytname[YYTRANSLATE (yychar)]);
1689
1690 if (yycount < 5)
1691 {
1692 yycount = 0;
1693 for (yyx = yyn < 0 ? -yyn : 0;
1694 yyx < (int) (sizeof (yytname) / sizeof (char *));
1695 yyx++)
1696 if (yycheck[yyx + yyn] == yyx)
1697 {
1698 const char *yyq = ! yycount ? ", expecting " : " or ";
1699 yyp = yystpcpy (yyp, yyq);
1700 yyp = yystpcpy (yyp, yytname[yyx]);
1701 yycount++;
1702 }
1703 }
1704 yyerror (yymsg);
1705 YYSTACK_FREE (yymsg);
1706 }
1707 else
1708 yyerror ("parse error; also virtual memory exhausted");
1709 }
1710 else
1711 #endif /* defined (YYERROR_VERBOSE) */
1712 yyerror ("parse error");
1713 }
1714 goto yyerrlab1;
1715
1716
1717 /*--------------------------------------------------.
1718 | yyerrlab1 -- error raised explicitly by an action |
1719 `--------------------------------------------------*/
1720 yyerrlab1:
1721 if (yyerrstatus == 3)
1722 {
1723 /* If just tried and failed to reuse lookahead token after an
1724 error, discard it. */
1725
1726 /* return failure if at end of input */
1727 if (yychar == YYEOF)
1728 YYABORT;
1729 YYDPRINTF ((stderr, "Discarding token %d (%s).\n",
1730 yychar, yytname[yychar1]));
1731 yychar = YYEMPTY;
1732 }
1733
1734 /* Else will try to reuse lookahead token after shifting the error
1735 token. */
1736
1737 yyerrstatus = 3; /* Each real token shifted decrements this */
1738
1739 goto yyerrhandle;
1740
1741
1742 /*-------------------------------------------------------------------.
1743 | yyerrdefault -- current state does not do anything special for the |
1744 | error token. |
1745 `-------------------------------------------------------------------*/
1746 yyerrdefault:
1747 #if 0
1748 /* This is wrong; only states that explicitly want error tokens
1749 should shift them. */
1750
1751 /* If its default is to accept any token, ok. Otherwise pop it. */
1752 yyn = yydefact[yystate];
1753 if (yyn)
1754 goto yydefault;
1755 #endif
1756
1757
1758 /*---------------------------------------------------------------.
1759 | yyerrpop -- pop the current state because it cannot handle the |
1760 | error token |
1761 `---------------------------------------------------------------*/
1762 yyerrpop:
1763 if (yyssp == yyss)
1764 YYABORT;
1765 yyvsp--;
1766 yystate = *--yyssp;
1767 #if YYLSP_NEEDED
1768 yylsp--;
1769 #endif
1770
1771 #if YYDEBUG
1772 if (yydebug)
1773 {
1774 short *yyssp1 = yyss - 1;
1775 YYFPRINTF (stderr, "Error: state stack now");
1776 while (yyssp1 != yyssp)
1777 YYFPRINTF (stderr, " %d", *++yyssp1);
1778 YYFPRINTF (stderr, "\n");
1779 }
1780 #endif
1781
1782 /*--------------.
1783 | yyerrhandle. |
1784 `--------------*/
1785 yyerrhandle:
1786 yyn = yypact[yystate];
1787 if (yyn == YYFLAG)
1788 goto yyerrdefault;
1789
1790 yyn += YYTERROR;
1791 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
1792 goto yyerrdefault;
1793
1794 yyn = yytable[yyn];
1795 if (yyn < 0)
1796 {
1797 if (yyn == YYFLAG)
1798 goto yyerrpop;
1799 yyn = -yyn;
1800 goto yyreduce;
1801 }
1802 else if (yyn == 0)
1803 goto yyerrpop;
1804
1805 if (yyn == YYFINAL)
1806 YYACCEPT;
1807
1808 YYDPRINTF ((stderr, "Shifting error token, "));
1809
1810 *++yyvsp = yylval;
1811 #if YYLSP_NEEDED
1812 *++yylsp = yylloc;
1813 #endif
1814
1815 yystate = yyn;
1816 goto yynewstate;
1817
1818
1819 /*-------------------------------------.
1820 | yyacceptlab -- YYACCEPT comes here. |
1821 `-------------------------------------*/
1822 yyacceptlab:
1823 yyresult = 0;
1824 goto yyreturn;
1825
1826 /*-----------------------------------.
1827 | yyabortlab -- YYABORT comes here. |
1828 `-----------------------------------*/
1829 yyabortlab:
1830 yyresult = 1;
1831 goto yyreturn;
1832
1833 /*---------------------------------------------.
1834 | yyoverflowab -- parser overflow comes here. |
1835 `---------------------------------------------*/
1836 yyoverflowlab:
1837 yyerror ("parser stack overflow");
1838 yyresult = 2;
1839 /* Fall through. */
1840
1841 yyreturn:
1842 #ifndef yyoverflow
1843 if (yyss != yyssa)
1844 YYSTACK_FREE (yyss);
1845 #endif
1846 return yyresult;
1847 }
1848 #line 648 "m68k-parse.y"
1849
1850
1851 /* The string to parse is stored here, and modified by yylex. */
1852
1853 static char *str;
1854
1855 /* The original string pointer. */
1856
1857 static char *strorig;
1858
1859 /* If *CCP could be a register, return the register number and advance
1860 *CCP. Otherwise don't change *CCP, and return 0. */
1861
1862 static enum m68k_register
m68k_reg_parse(ccp)1863 m68k_reg_parse (ccp)
1864 register char **ccp;
1865 {
1866 char *start = *ccp;
1867 char c;
1868 char *p;
1869 symbolS *symbolp;
1870
1871 if (flag_reg_prefix_optional)
1872 {
1873 if (*start == REGISTER_PREFIX)
1874 start++;
1875 p = start;
1876 }
1877 else
1878 {
1879 if (*start != REGISTER_PREFIX)
1880 return 0;
1881 p = start + 1;
1882 }
1883
1884 if (! is_name_beginner (*p))
1885 return 0;
1886
1887 p++;
1888 while (is_part_of_name (*p) && *p != '.' && *p != ':' && *p != '*')
1889 p++;
1890
1891 c = *p;
1892 *p = 0;
1893 symbolp = symbol_find (start);
1894 *p = c;
1895
1896 if (symbolp != NULL && S_GET_SEGMENT (symbolp) == reg_section)
1897 {
1898 *ccp = p;
1899 return S_GET_VALUE (symbolp);
1900 }
1901
1902 /* In MRI mode, something like foo.bar can be equated to a register
1903 name. */
1904 while (flag_mri && c == '.')
1905 {
1906 ++p;
1907 while (is_part_of_name (*p) && *p != '.' && *p != ':' && *p != '*')
1908 p++;
1909 c = *p;
1910 *p = '\0';
1911 symbolp = symbol_find (start);
1912 *p = c;
1913 if (symbolp != NULL && S_GET_SEGMENT (symbolp) == reg_section)
1914 {
1915 *ccp = p;
1916 return S_GET_VALUE (symbolp);
1917 }
1918 }
1919
1920 return 0;
1921 }
1922
1923 /* The lexer. */
1924
1925 static int
yylex()1926 yylex ()
1927 {
1928 enum m68k_register reg;
1929 char *s;
1930 int parens;
1931 int c = 0;
1932 int tail = 0;
1933 char *hold;
1934
1935 if (*str == ' ')
1936 ++str;
1937
1938 if (*str == '\0')
1939 return 0;
1940
1941 /* Various special characters are just returned directly. */
1942 switch (*str)
1943 {
1944 case '@':
1945 /* In MRI mode, this can be the start of an octal number. */
1946 if (flag_mri)
1947 {
1948 if (ISDIGIT (str[1])
1949 || ((str[1] == '+' || str[1] == '-')
1950 && ISDIGIT (str[2])))
1951 break;
1952 }
1953 /* Fall through. */
1954 case '#':
1955 case '&':
1956 case ',':
1957 case ')':
1958 case '/':
1959 case '[':
1960 case ']':
1961 return *str++;
1962 case '+':
1963 /* It so happens that a '+' can only appear at the end of an
1964 operand. If it appears anywhere else, it must be a unary
1965 plus on an expression. */
1966 if (str[1] == '\0')
1967 return *str++;
1968 break;
1969 case '-':
1970 /* A '-' can only appear in -(ar), rn-rn, or ar@-. If it
1971 appears anywhere else, it must be a unary minus on an
1972 expression. */
1973 if (str[1] == '\0')
1974 return *str++;
1975 s = str + 1;
1976 if (*s == '(')
1977 ++s;
1978 if (m68k_reg_parse (&s) != 0)
1979 return *str++;
1980 break;
1981 case '(':
1982 /* A '(' can only appear in `(reg)', `(expr,...', `([', `@(', or
1983 `)('. If it appears anywhere else, it must be starting an
1984 expression. */
1985 if (str[1] == '['
1986 || (str > strorig
1987 && (str[-1] == '@'
1988 || str[-1] == ')')))
1989 return *str++;
1990 s = str + 1;
1991 if (m68k_reg_parse (&s) != 0)
1992 return *str++;
1993 /* Check for the case of '(expr,...' by scanning ahead. If we
1994 find a comma outside of balanced parentheses, we return '('.
1995 If we find an unbalanced right parenthesis, then presumably
1996 the '(' really starts an expression. */
1997 parens = 0;
1998 for (s = str + 1; *s != '\0'; s++)
1999 {
2000 if (*s == '(')
2001 ++parens;
2002 else if (*s == ')')
2003 {
2004 if (parens == 0)
2005 break;
2006 --parens;
2007 }
2008 else if (*s == ',' && parens == 0)
2009 {
2010 /* A comma can not normally appear in an expression, so
2011 this is a case of '(expr,...'. */
2012 return *str++;
2013 }
2014 }
2015 }
2016
2017 /* See if it's a register. */
2018
2019 reg = m68k_reg_parse (&str);
2020 if (reg != 0)
2021 {
2022 int ret;
2023
2024 yylval.reg = reg;
2025
2026 if (reg >= DATA0 && reg <= DATA7)
2027 ret = DR;
2028 else if (reg >= ADDR0 && reg <= ADDR7)
2029 ret = AR;
2030 else if (reg >= FP0 && reg <= FP7)
2031 return FPR;
2032 else if (reg == FPI
2033 || reg == FPS
2034 || reg == FPC)
2035 return FPCR;
2036 else if (reg == PC)
2037 return LPC;
2038 else if (reg >= ZDATA0 && reg <= ZDATA7)
2039 ret = ZDR;
2040 else if (reg >= ZADDR0 && reg <= ZADDR7)
2041 ret = ZAR;
2042 else if (reg == ZPC)
2043 return LZPC;
2044 else
2045 return CREG;
2046
2047 /* If we get here, we have a data or address register. We
2048 must check for a size or scale; if we find one, we must
2049 return INDEXREG. */
2050
2051 s = str;
2052
2053 if (*s != '.' && *s != ':' && *s != '*')
2054 return ret;
2055
2056 yylval.indexreg.reg = reg;
2057
2058 if (*s != '.' && *s != ':')
2059 yylval.indexreg.size = SIZE_UNSPEC;
2060 else
2061 {
2062 ++s;
2063 switch (*s)
2064 {
2065 case 'w':
2066 case 'W':
2067 yylval.indexreg.size = SIZE_WORD;
2068 ++s;
2069 break;
2070 case 'l':
2071 case 'L':
2072 yylval.indexreg.size = SIZE_LONG;
2073 ++s;
2074 break;
2075 default:
2076 yyerror (_("illegal size specification"));
2077 yylval.indexreg.size = SIZE_UNSPEC;
2078 break;
2079 }
2080 }
2081
2082 yylval.indexreg.scale = 1;
2083
2084 if (*s == '*' || *s == ':')
2085 {
2086 expressionS scale;
2087
2088 ++s;
2089
2090 hold = input_line_pointer;
2091 input_line_pointer = s;
2092 expression (&scale);
2093 s = input_line_pointer;
2094 input_line_pointer = hold;
2095
2096 if (scale.X_op != O_constant)
2097 yyerror (_("scale specification must resolve to a number"));
2098 else
2099 {
2100 switch (scale.X_add_number)
2101 {
2102 case 1:
2103 case 2:
2104 case 4:
2105 case 8:
2106 yylval.indexreg.scale = scale.X_add_number;
2107 break;
2108 default:
2109 yyerror (_("invalid scale value"));
2110 break;
2111 }
2112 }
2113 }
2114
2115 str = s;
2116
2117 return INDEXREG;
2118 }
2119
2120 /* It must be an expression. Before we call expression, we need to
2121 look ahead to see if there is a size specification. We must do
2122 that first, because otherwise foo.l will be treated as the symbol
2123 foo.l, rather than as the symbol foo with a long size
2124 specification. The grammar requires that all expressions end at
2125 the end of the operand, or with ',', '(', ']', ')'. */
2126
2127 parens = 0;
2128 for (s = str; *s != '\0'; s++)
2129 {
2130 if (*s == '(')
2131 {
2132 if (parens == 0
2133 && s > str
2134 && (s[-1] == ')' || ISALNUM (s[-1])))
2135 break;
2136 ++parens;
2137 }
2138 else if (*s == ')')
2139 {
2140 if (parens == 0)
2141 break;
2142 --parens;
2143 }
2144 else if (parens == 0
2145 && (*s == ',' || *s == ']'))
2146 break;
2147 }
2148
2149 yylval.exp.size = SIZE_UNSPEC;
2150 if (s <= str + 2
2151 || (s[-2] != '.' && s[-2] != ':'))
2152 tail = 0;
2153 else
2154 {
2155 switch (s[-1])
2156 {
2157 case 's':
2158 case 'S':
2159 case 'b':
2160 case 'B':
2161 yylval.exp.size = SIZE_BYTE;
2162 break;
2163 case 'w':
2164 case 'W':
2165 yylval.exp.size = SIZE_WORD;
2166 break;
2167 case 'l':
2168 case 'L':
2169 yylval.exp.size = SIZE_LONG;
2170 break;
2171 default:
2172 break;
2173 }
2174 if (yylval.exp.size != SIZE_UNSPEC)
2175 tail = 2;
2176 }
2177
2178 #ifdef OBJ_ELF
2179 {
2180 /* Look for @PLTPC, etc. */
2181 char *cp;
2182
2183 yylval.exp.pic_reloc = pic_none;
2184 cp = s - tail;
2185 if (cp - 6 > str && cp[-6] == '@')
2186 {
2187 if (strncmp (cp - 6, "@PLTPC", 6) == 0)
2188 {
2189 yylval.exp.pic_reloc = pic_plt_pcrel;
2190 tail += 6;
2191 }
2192 else if (strncmp (cp - 6, "@GOTPC", 6) == 0)
2193 {
2194 yylval.exp.pic_reloc = pic_got_pcrel;
2195 tail += 6;
2196 }
2197 }
2198 else if (cp - 4 > str && cp[-4] == '@')
2199 {
2200 if (strncmp (cp - 4, "@PLT", 4) == 0)
2201 {
2202 yylval.exp.pic_reloc = pic_plt_off;
2203 tail += 4;
2204 }
2205 else if (strncmp (cp - 4, "@GOT", 4) == 0)
2206 {
2207 yylval.exp.pic_reloc = pic_got_off;
2208 tail += 4;
2209 }
2210 }
2211 }
2212 #endif
2213
2214 if (tail != 0)
2215 {
2216 c = s[-tail];
2217 s[-tail] = 0;
2218 }
2219
2220 hold = input_line_pointer;
2221 input_line_pointer = str;
2222 expression (&yylval.exp.exp);
2223 str = input_line_pointer;
2224 input_line_pointer = hold;
2225
2226 if (tail != 0)
2227 {
2228 s[-tail] = c;
2229 str = s;
2230 }
2231
2232 return EXPR;
2233 }
2234
2235 /* Parse an m68k operand. This is the only function which is called
2236 from outside this file. */
2237
2238 int
m68k_ip_op(s,oparg)2239 m68k_ip_op (s, oparg)
2240 char *s;
2241 struct m68k_op *oparg;
2242 {
2243 memset (oparg, 0, sizeof *oparg);
2244 oparg->error = NULL;
2245 oparg->index.reg = ZDATA0;
2246 oparg->index.scale = 1;
2247 oparg->disp.exp.X_op = O_absent;
2248 oparg->odisp.exp.X_op = O_absent;
2249
2250 str = strorig = s;
2251 op = oparg;
2252
2253 return yyparse ();
2254 }
2255
2256 /* The error handler. */
2257
2258 static void
yyerror(s)2259 yyerror (s)
2260 const char *s;
2261 {
2262 op->error = s;
2263 }
2264