source: vendor/binutils/current/opcodes/xstormy16-asm.c

Last change on this file was 608, checked in by (none), 22 years ago

This commit was manufactured by cvs2svn to create branch 'GNU'.

  • Property cvs2svn:cvs-rev set to 1.1
  • Property svn:eol-style set to native
  • Property svn:executable set to *
File size: 21.1 KB
Line 
1/* Assembler interface for targets using CGEN. -*- C -*-
2 CGEN: Cpu tools GENerator
3
4THIS FILE IS MACHINE GENERATED WITH CGEN.
5- the resultant file is machine generated, cgen-asm.in isn't
6
7Copyright 1996, 1997, 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
8
9This file is part of the GNU Binutils and GDB, the GNU debugger.
10
11This program is free software; you can redistribute it and/or modify
12it under the terms of the GNU General Public License as published by
13the Free Software Foundation; either version 2, or (at your option)
14any later version.
15
16This program is distributed in the hope that it will be useful,
17but WITHOUT ANY WARRANTY; without even the implied warranty of
18MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19GNU General Public License for more details.
20
21You should have received a copy of the GNU General Public License
22along with this program; if not, write to the Free Software Foundation, Inc.,
2359 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
24
25/* ??? Eventually more and more of this stuff can go to cpu-independent files.
26 Keep that in mind. */
27
28#include "sysdep.h"
29#include <stdio.h>
30#include "ansidecl.h"
31#include "bfd.h"
32#include "symcat.h"
33#include "xstormy16-desc.h"
34#include "xstormy16-opc.h"
35#include "opintl.h"
36#include "xregex.h"
37#include "libiberty.h"
38#include "safe-ctype.h"
39
40#undef min
41#define min(a,b) ((a) < (b) ? (a) : (b))
42#undef max
43#define max(a,b) ((a) > (b) ? (a) : (b))
44
45static const char * parse_insn_normal
46 PARAMS ((CGEN_CPU_DESC, const CGEN_INSN *, const char **, CGEN_FIELDS *));
47
48
49/* -- assembler routines inserted here. */
50
51/* -- asm.c */
52static const char * parse_mem8
53 PARAMS ((CGEN_CPU_DESC, const char **, int, unsigned long *));
54static const char * parse_small_immediate
55 PARAMS ((CGEN_CPU_DESC, const char **, int, unsigned long *));
56static const char * parse_immediate16
57 PARAMS ((CGEN_CPU_DESC, const char **, int, unsigned long *));
58
59/* The machine-independent code doesn't know how to disambiguate
60 mov (foo),r3
61 and
62 mov (r2),r3
63 where 'foo' is a label. This helps it out. */
64
65static const char *
66parse_mem8 (cd, strp, opindex, valuep)
67 CGEN_CPU_DESC cd;
68 const char **strp;
69 int opindex;
70 unsigned long *valuep;
71{
72 if (**strp == '(')
73 {
74 const char *s = *strp;
75
76 if (s[1] == '-' && s[2] == '-')
77 return _("Bad register in preincrement");
78
79 while (ISALNUM (*++s))
80 ;
81 if (s[0] == '+' && s[1] == '+' && (s[2] == ')' || s[2] == ','))
82 return _("Bad register in postincrement");
83 if (s[0] == ',' || s[0] == ')')
84 return _("Bad register name");
85 }
86 else if (cgen_parse_keyword (cd, strp, & xstormy16_cgen_opval_gr_names,
87 valuep) == NULL)
88 return _("Label conflicts with register name");
89 else if (strncasecmp (*strp, "rx,", 3) == 0
90 || strncasecmp (*strp, "rxl,", 3) == 0
91 || strncasecmp (*strp, "rxh,", 3) == 0)
92 return _("Label conflicts with `Rx'");
93 else if (**strp == '#')
94 return _("Bad immediate expression");
95
96 return cgen_parse_unsigned_integer (cd, strp, opindex, valuep);
97}
98
99/* For the add and subtract instructions, there are two immediate forms,
100 one for small operands and one for large ones. We want to use
101 the small one when possible, but we do not want to generate relocs
102 of the small size. This is somewhat tricky. */
103
104static const char *
105parse_small_immediate (cd, strp, opindex, valuep)
106 CGEN_CPU_DESC cd;
107 const char **strp;
108 int opindex;
109 unsigned long *valuep;
110{
111 bfd_vma value;
112 enum cgen_parse_operand_result result;
113 const char *errmsg;
114
115 if (**strp == '@')
116 return _("No relocation for small immediate");
117
118 errmsg = (* cd->parse_operand_fn)
119 (cd, CGEN_PARSE_OPERAND_INTEGER, strp, opindex, BFD_RELOC_NONE,
120 &result, &value);
121
122 if (errmsg)
123 return errmsg;
124
125 if (result != CGEN_PARSE_OPERAND_RESULT_NUMBER)
126 return _("Small operand was not an immediate number");
127
128 *valuep = value;
129 return NULL;
130}
131
132/* Literal scan be either a normal literal, a @hi() or @lo relocation. */
133
134static const char *
135parse_immediate16 (cd, strp, opindex, valuep)
136 CGEN_CPU_DESC cd;
137 const char **strp;
138 int opindex;
139 unsigned long *valuep;
140{
141 const char *errmsg;
142 enum cgen_parse_operand_result result;
143 bfd_reloc_code_real_type code = BFD_RELOC_NONE;
144 bfd_vma value;
145
146 if (strncmp (*strp, "@hi(", 4) == 0)
147 {
148 *strp += 4;
149 code = BFD_RELOC_HI16;
150 }
151 else
152 if (strncmp (*strp, "@lo(", 4) == 0)
153 {
154 *strp += 4;
155 code = BFD_RELOC_LO16;
156 }
157
158 if (code == BFD_RELOC_NONE)
159 errmsg = cgen_parse_unsigned_integer (cd, strp, opindex, valuep);
160 else
161 {
162 errmsg = cgen_parse_address (cd, strp, opindex, code, &result, &value);
163 if ((errmsg == NULL) &&
164 (result != CGEN_PARSE_OPERAND_RESULT_QUEUED))
165 errmsg = _("Operand is not a symbol");
166
167 *valuep = value;
168 if ((code == BFD_RELOC_HI16 || code == BFD_RELOC_LO16)
169 && **strp == ')')
170 *strp += 1;
171 else
172 {
173 errmsg = _("Syntax error: No trailing ')'");
174 return errmsg;
175 }
176 }
177 return errmsg;
178}
179/* -- */
180
181const char * xstormy16_cgen_parse_operand
182 PARAMS ((CGEN_CPU_DESC, int, const char **, CGEN_FIELDS *));
183
184/* Main entry point for operand parsing.
185
186 This function is basically just a big switch statement. Earlier versions
187 used tables to look up the function to use, but
188 - if the table contains both assembler and disassembler functions then
189 the disassembler contains much of the assembler and vice-versa,
190 - there's a lot of inlining possibilities as things grow,
191 - using a switch statement avoids the function call overhead.
192
193 This function could be moved into `parse_insn_normal', but keeping it
194 separate makes clear the interface between `parse_insn_normal' and each of
195 the handlers. */
196
197const char *
198xstormy16_cgen_parse_operand (cd, opindex, strp, fields)
199 CGEN_CPU_DESC cd;
200 int opindex;
201 const char ** strp;
202 CGEN_FIELDS * fields;
203{
204 const char * errmsg = NULL;
205 /* Used by scalar operands that still need to be parsed. */
206 long junk ATTRIBUTE_UNUSED;
207
208 switch (opindex)
209 {
210 case XSTORMY16_OPERAND_RB :
211 errmsg = cgen_parse_keyword (cd, strp, & xstormy16_cgen_opval_gr_Rb_names, & fields->f_Rb);
212 break;
213 case XSTORMY16_OPERAND_RBJ :
214 errmsg = cgen_parse_keyword (cd, strp, & xstormy16_cgen_opval_gr_Rb_names, & fields->f_Rbj);
215 break;
216 case XSTORMY16_OPERAND_RD :
217 errmsg = cgen_parse_keyword (cd, strp, & xstormy16_cgen_opval_gr_names, & fields->f_Rd);
218 break;
219 case XSTORMY16_OPERAND_RDM :
220 errmsg = cgen_parse_keyword (cd, strp, & xstormy16_cgen_opval_gr_names, & fields->f_Rdm);
221 break;
222 case XSTORMY16_OPERAND_RM :
223 errmsg = cgen_parse_keyword (cd, strp, & xstormy16_cgen_opval_gr_names, & fields->f_Rm);
224 break;
225 case XSTORMY16_OPERAND_RS :
226 errmsg = cgen_parse_keyword (cd, strp, & xstormy16_cgen_opval_gr_names, & fields->f_Rs);
227 break;
228 case XSTORMY16_OPERAND_ABS24 :
229 errmsg = cgen_parse_unsigned_integer (cd, strp, XSTORMY16_OPERAND_ABS24, &fields->f_abs24);
230 break;
231 case XSTORMY16_OPERAND_BCOND2 :
232 errmsg = cgen_parse_keyword (cd, strp, & xstormy16_cgen_opval_h_branchcond, & fields->f_op2);
233 break;
234 case XSTORMY16_OPERAND_BCOND5 :
235 errmsg = cgen_parse_keyword (cd, strp, & xstormy16_cgen_opval_h_branchcond, & fields->f_op5);
236 break;
237 case XSTORMY16_OPERAND_HMEM8 :
238 errmsg = parse_mem8 (cd, strp, XSTORMY16_OPERAND_HMEM8, &fields->f_hmem8);
239 break;
240 case XSTORMY16_OPERAND_IMM12 :
241 errmsg = cgen_parse_signed_integer (cd, strp, XSTORMY16_OPERAND_IMM12, &fields->f_imm12);
242 break;
243 case XSTORMY16_OPERAND_IMM16 :
244 errmsg = parse_immediate16 (cd, strp, XSTORMY16_OPERAND_IMM16, &fields->f_imm16);
245 break;
246 case XSTORMY16_OPERAND_IMM2 :
247 errmsg = cgen_parse_unsigned_integer (cd, strp, XSTORMY16_OPERAND_IMM2, &fields->f_imm2);
248 break;
249 case XSTORMY16_OPERAND_IMM3 :
250 errmsg = cgen_parse_unsigned_integer (cd, strp, XSTORMY16_OPERAND_IMM3, &fields->f_imm3);
251 break;
252 case XSTORMY16_OPERAND_IMM3B :
253 errmsg = cgen_parse_unsigned_integer (cd, strp, XSTORMY16_OPERAND_IMM3B, &fields->f_imm3b);
254 break;
255 case XSTORMY16_OPERAND_IMM4 :
256 errmsg = parse_small_immediate (cd, strp, XSTORMY16_OPERAND_IMM4, &fields->f_imm4);
257 break;
258 case XSTORMY16_OPERAND_IMM8 :
259 errmsg = cgen_parse_unsigned_integer (cd, strp, XSTORMY16_OPERAND_IMM8, &fields->f_imm8);
260 break;
261 case XSTORMY16_OPERAND_IMM8SMALL :
262 errmsg = parse_small_immediate (cd, strp, XSTORMY16_OPERAND_IMM8SMALL, &fields->f_imm8);
263 break;
264 case XSTORMY16_OPERAND_LMEM8 :
265 errmsg = parse_mem8 (cd, strp, XSTORMY16_OPERAND_LMEM8, &fields->f_lmem8);
266 break;
267 case XSTORMY16_OPERAND_REL12 :
268 errmsg = cgen_parse_unsigned_integer (cd, strp, XSTORMY16_OPERAND_REL12, &fields->f_rel12);
269 break;
270 case XSTORMY16_OPERAND_REL12A :
271 errmsg = cgen_parse_unsigned_integer (cd, strp, XSTORMY16_OPERAND_REL12A, &fields->f_rel12a);
272 break;
273 case XSTORMY16_OPERAND_REL8_2 :
274 errmsg = cgen_parse_unsigned_integer (cd, strp, XSTORMY16_OPERAND_REL8_2, &fields->f_rel8_2);
275 break;
276 case XSTORMY16_OPERAND_REL8_4 :
277 errmsg = cgen_parse_unsigned_integer (cd, strp, XSTORMY16_OPERAND_REL8_4, &fields->f_rel8_4);
278 break;
279 case XSTORMY16_OPERAND_WS2 :
280 errmsg = cgen_parse_keyword (cd, strp, & xstormy16_cgen_opval_h_wordsize, & fields->f_op2m);
281 break;
282
283 default :
284 /* xgettext:c-format */
285 fprintf (stderr, _("Unrecognized field %d while parsing.\n"), opindex);
286 abort ();
287 }
288
289 return errmsg;
290}
291
292cgen_parse_fn * const xstormy16_cgen_parse_handlers[] =
293{
294 parse_insn_normal,
295};
296
297void
298xstormy16_cgen_init_asm (cd)
299 CGEN_CPU_DESC cd;
300{
301 xstormy16_cgen_init_opcode_table (cd);
302 xstormy16_cgen_init_ibld_table (cd);
303 cd->parse_handlers = & xstormy16_cgen_parse_handlers[0];
304 cd->parse_operand = xstormy16_cgen_parse_operand;
305}
306
307
308
309
310/* Regex construction routine.
311
312 This translates an opcode syntax string into a regex string,
313 by replacing any non-character syntax element (such as an
314 opcode) with the pattern '.*'
315
316 It then compiles the regex and stores it in the opcode, for
317 later use by xstormy16_cgen_assemble_insn
318
319 Returns NULL for success, an error message for failure. */
320
321char *
322xstormy16_cgen_build_insn_regex (insn)
323 CGEN_INSN *insn;
324{
325 CGEN_OPCODE *opc = (CGEN_OPCODE *) CGEN_INSN_OPCODE (insn);
326 const char *mnem = CGEN_INSN_MNEMONIC (insn);
327 char rxbuf[CGEN_MAX_RX_ELEMENTS];
328 char *rx = rxbuf;
329 const CGEN_SYNTAX_CHAR_TYPE *syn;
330 int reg_err;
331
332 syn = CGEN_SYNTAX_STRING (CGEN_OPCODE_SYNTAX (opc));
333
334 /* Mnemonics come first in the syntax string. */
335 if (! CGEN_SYNTAX_MNEMONIC_P (* syn))
336 return _("missing mnemonic in syntax string");
337 ++syn;
338
339 /* Generate a case sensitive regular expression that emulates case
340 insensitive matching in the "C" locale. We cannot generate a case
341 insensitive regular expression because in Turkish locales, 'i' and 'I'
342 are not equal modulo case conversion. */
343
344 /* Copy the literal mnemonic out of the insn. */
345 for (; *mnem; mnem++)
346 {
347 char c = *mnem;
348
349 if (ISALPHA (c))
350 {
351 *rx++ = '[';
352 *rx++ = TOLOWER (c);
353 *rx++ = TOUPPER (c);
354 *rx++ = ']';
355 }
356 else
357 *rx++ = c;
358 }
359
360 /* Copy any remaining literals from the syntax string into the rx. */
361 for(; * syn != 0 && rx <= rxbuf + (CGEN_MAX_RX_ELEMENTS - 7 - 4); ++syn)
362 {
363 if (CGEN_SYNTAX_CHAR_P (* syn))
364 {
365 char c = CGEN_SYNTAX_CHAR (* syn);
366
367 switch (c)
368 {
369 /* Escape any regex metacharacters in the syntax. */
370 case '.': case '[': case '\\':
371 case '*': case '^': case '$':
372
373#ifdef CGEN_ESCAPE_EXTENDED_REGEX
374 case '?': case '{': case '}':
375 case '(': case ')': case '*':
376 case '|': case '+': case ']':
377#endif
378 *rx++ = '\\';
379 *rx++ = c;
380 break;
381
382 default:
383 if (ISALPHA (c))
384 {
385 *rx++ = '[';
386 *rx++ = TOLOWER (c);
387 *rx++ = TOUPPER (c);
388 *rx++ = ']';
389 }
390 else
391 *rx++ = c;
392 break;
393 }
394 }
395 else
396 {
397 /* Replace non-syntax fields with globs. */
398 *rx++ = '.';
399 *rx++ = '*';
400 }
401 }
402
403 /* Trailing whitespace ok. */
404 * rx++ = '[';
405 * rx++ = ' ';
406 * rx++ = '\t';
407 * rx++ = ']';
408 * rx++ = '*';
409
410 /* But anchor it after that. */
411 * rx++ = '$';
412 * rx = '\0';
413
414 CGEN_INSN_RX (insn) = xmalloc (sizeof (regex_t));
415 reg_err = regcomp ((regex_t *) CGEN_INSN_RX (insn), rxbuf, REG_NOSUB);
416
417 if (reg_err == 0)
418 return NULL;
419 else
420 {
421 static char msg[80];
422
423 regerror (reg_err, (regex_t *) CGEN_INSN_RX (insn), msg, 80);
424 regfree ((regex_t *) CGEN_INSN_RX (insn));
425 free (CGEN_INSN_RX (insn));
426 (CGEN_INSN_RX (insn)) = NULL;
427 return msg;
428 }
429}
430
431
432
433/* Default insn parser.
434
435 The syntax string is scanned and operands are parsed and stored in FIELDS.
436 Relocs are queued as we go via other callbacks.
437
438 ??? Note that this is currently an all-or-nothing parser. If we fail to
439 parse the instruction, we return 0 and the caller will start over from
440 the beginning. Backtracking will be necessary in parsing subexpressions,
441 but that can be handled there. Not handling backtracking here may get
442 expensive in the case of the m68k. Deal with later.
443
444 Returns NULL for success, an error message for failure. */
445
446static const char *
447parse_insn_normal (cd, insn, strp, fields)
448 CGEN_CPU_DESC cd;
449 const CGEN_INSN *insn;
450 const char **strp;
451 CGEN_FIELDS *fields;
452{
453 /* ??? Runtime added insns not handled yet. */
454 const CGEN_SYNTAX *syntax = CGEN_INSN_SYNTAX (insn);
455 const char *str = *strp;
456 const char *errmsg;
457 const char *p;
458 const CGEN_SYNTAX_CHAR_TYPE * syn;
459#ifdef CGEN_MNEMONIC_OPERANDS
460 /* FIXME: wip */
461 int past_opcode_p;
462#endif
463
464 /* For now we assume the mnemonic is first (there are no leading operands).
465 We can parse it without needing to set up operand parsing.
466 GAS's input scrubber will ensure mnemonics are lowercase, but we may
467 not be called from GAS. */
468 p = CGEN_INSN_MNEMONIC (insn);
469 while (*p && TOLOWER (*p) == TOLOWER (*str))
470 ++p, ++str;
471
472 if (* p)
473 return _("unrecognized instruction");
474
475#ifndef CGEN_MNEMONIC_OPERANDS
476 if (* str && ! ISSPACE (* str))
477 return _("unrecognized instruction");
478#endif
479
480 CGEN_INIT_PARSE (cd);
481 cgen_init_parse_operand (cd);
482#ifdef CGEN_MNEMONIC_OPERANDS
483 past_opcode_p = 0;
484#endif
485
486 /* We don't check for (*str != '\0') here because we want to parse
487 any trailing fake arguments in the syntax string. */
488 syn = CGEN_SYNTAX_STRING (syntax);
489
490 /* Mnemonics come first for now, ensure valid string. */
491 if (! CGEN_SYNTAX_MNEMONIC_P (* syn))
492 abort ();
493
494 ++syn;
495
496 while (* syn != 0)
497 {
498 /* Non operand chars must match exactly. */
499 if (CGEN_SYNTAX_CHAR_P (* syn))
500 {
501 /* FIXME: While we allow for non-GAS callers above, we assume the
502 first char after the mnemonic part is a space. */
503 /* FIXME: We also take inappropriate advantage of the fact that
504 GAS's input scrubber will remove extraneous blanks. */
505 if (TOLOWER (*str) == TOLOWER (CGEN_SYNTAX_CHAR (* syn)))
506 {
507#ifdef CGEN_MNEMONIC_OPERANDS
508 if (CGEN_SYNTAX_CHAR(* syn) == ' ')
509 past_opcode_p = 1;
510#endif
511 ++ syn;
512 ++ str;
513 }
514 else if (*str)
515 {
516 /* Syntax char didn't match. Can't be this insn. */
517 static char msg [80];
518
519 /* xgettext:c-format */
520 sprintf (msg, _("syntax error (expected char `%c', found `%c')"),
521 CGEN_SYNTAX_CHAR(*syn), *str);
522 return msg;
523 }
524 else
525 {
526 /* Ran out of input. */
527 static char msg [80];
528
529 /* xgettext:c-format */
530 sprintf (msg, _("syntax error (expected char `%c', found end of instruction)"),
531 CGEN_SYNTAX_CHAR(*syn));
532 return msg;
533 }
534 continue;
535 }
536
537 /* We have an operand of some sort. */
538 errmsg = cd->parse_operand (cd, CGEN_SYNTAX_FIELD (*syn),
539 &str, fields);
540 if (errmsg)
541 return errmsg;
542
543 /* Done with this operand, continue with next one. */
544 ++ syn;
545 }
546
547 /* If we're at the end of the syntax string, we're done. */
548 if (* syn == 0)
549 {
550 /* FIXME: For the moment we assume a valid `str' can only contain
551 blanks now. IE: We needn't try again with a longer version of
552 the insn and it is assumed that longer versions of insns appear
553 before shorter ones (eg: lsr r2,r3,1 vs lsr r2,r3). */
554 while (ISSPACE (* str))
555 ++ str;
556
557 if (* str != '\0')
558 return _("junk at end of line"); /* FIXME: would like to include `str' */
559
560 return NULL;
561 }
562
563 /* We couldn't parse it. */
564 return _("unrecognized instruction");
565}
566
567
568/* Main entry point.
569 This routine is called for each instruction to be assembled.
570 STR points to the insn to be assembled.
571 We assume all necessary tables have been initialized.
572 The assembled instruction, less any fixups, is stored in BUF.
573 Remember that if CGEN_INT_INSN_P then BUF is an int and thus the value
574 still needs to be converted to target byte order, otherwise BUF is an array
575 of bytes in target byte order.
576 The result is a pointer to the insn's entry in the opcode table,
577 or NULL if an error occured (an error message will have already been
578 printed).
579
580 Note that when processing (non-alias) macro-insns,
581 this function recurses.
582
583 ??? It's possible to make this cpu-independent.
584 One would have to deal with a few minor things.
585 At this point in time doing so would be more of a curiosity than useful
586 [for example this file isn't _that_ big], but keeping the possibility in
587 mind helps keep the design clean. */
588
589const CGEN_INSN *
590xstormy16_cgen_assemble_insn (cd, str, fields, buf, errmsg)
591 CGEN_CPU_DESC cd;
592 const char *str;
593 CGEN_FIELDS *fields;
594 CGEN_INSN_BYTES_PTR buf;
595 char **errmsg;
596{
597 const char *start;
598 CGEN_INSN_LIST *ilist;
599 const char *parse_errmsg = NULL;
600 const char *insert_errmsg = NULL;
601 int recognized_mnemonic = 0;
602
603 /* Skip leading white space. */
604 while (ISSPACE (* str))
605 ++ str;
606
607 /* The instructions are stored in hashed lists.
608 Get the first in the list. */
609 ilist = CGEN_ASM_LOOKUP_INSN (cd, str);
610
611 /* Keep looking until we find a match. */
612 start = str;
613 for ( ; ilist != NULL ; ilist = CGEN_ASM_NEXT_INSN (ilist))
614 {
615 const CGEN_INSN *insn = ilist->insn;
616 recognized_mnemonic = 1;
617
618#ifdef CGEN_VALIDATE_INSN_SUPPORTED
619 /* Not usually needed as unsupported opcodes
620 shouldn't be in the hash lists. */
621 /* Is this insn supported by the selected cpu? */
622 if (! xstormy16_cgen_insn_supported (cd, insn))
623 continue;
624#endif
625 /* If the RELAX attribute is set, this is an insn that shouldn't be
626 chosen immediately. Instead, it is used during assembler/linker
627 relaxation if possible. */
628 if (CGEN_INSN_ATTR_VALUE (insn, CGEN_INSN_RELAX) != 0)
629 continue;
630
631 str = start;
632
633 /* Skip this insn if str doesn't look right lexically. */
634 if (CGEN_INSN_RX (insn) != NULL &&
635 regexec ((regex_t *) CGEN_INSN_RX (insn), str, 0, NULL, 0) == REG_NOMATCH)
636 continue;
637
638 /* Allow parse/insert handlers to obtain length of insn. */
639 CGEN_FIELDS_BITSIZE (fields) = CGEN_INSN_BITSIZE (insn);
640
641 parse_errmsg = CGEN_PARSE_FN (cd, insn) (cd, insn, & str, fields);
642 if (parse_errmsg != NULL)
643 continue;
644
645 /* ??? 0 is passed for `pc'. */
646 insert_errmsg = CGEN_INSERT_FN (cd, insn) (cd, insn, fields, buf,
647 (bfd_vma) 0);
648 if (insert_errmsg != NULL)
649 continue;
650
651 /* It is up to the caller to actually output the insn and any
652 queued relocs. */
653 return insn;
654 }
655
656 {
657 static char errbuf[150];
658#ifdef CGEN_VERBOSE_ASSEMBLER_ERRORS
659 const char *tmp_errmsg;
660
661 /* If requesting verbose error messages, use insert_errmsg.
662 Failing that, use parse_errmsg. */
663 tmp_errmsg = (insert_errmsg ? insert_errmsg :
664 parse_errmsg ? parse_errmsg :
665 recognized_mnemonic ?
666 _("unrecognized form of instruction") :
667 _("unrecognized instruction"));
668
669 if (strlen (start) > 50)
670 /* xgettext:c-format */
671 sprintf (errbuf, "%s `%.50s...'", tmp_errmsg, start);
672 else
673 /* xgettext:c-format */
674 sprintf (errbuf, "%s `%.50s'", tmp_errmsg, start);
675#else
676 if (strlen (start) > 50)
677 /* xgettext:c-format */
678 sprintf (errbuf, _("bad instruction `%.50s...'"), start);
679 else
680 /* xgettext:c-format */
681 sprintf (errbuf, _("bad instruction `%.50s'"), start);
682#endif
683
684 *errmsg = errbuf;
685 return NULL;
686 }
687}
688
689
690#if 0 /* This calls back to GAS which we can't do without care. */
691
692/* Record each member of OPVALS in the assembler's symbol table.
693 This lets GAS parse registers for us.
694 ??? Interesting idea but not currently used. */
695
696/* Record each member of OPVALS in the assembler's symbol table.
697 FIXME: Not currently used. */
698
699void
700xstormy16_cgen_asm_hash_keywords (cd, opvals)
701 CGEN_CPU_DESC cd;
702 CGEN_KEYWORD *opvals;
703{
704 CGEN_KEYWORD_SEARCH search = cgen_keyword_search_init (opvals, NULL);
705 const CGEN_KEYWORD_ENTRY * ke;
706
707 while ((ke = cgen_keyword_search_next (& search)) != NULL)
708 {
709#if 0 /* Unnecessary, should be done in the search routine. */
710 if (! xstormy16_cgen_opval_supported (ke))
711 continue;
712#endif
713 cgen_asm_record_register (cd, ke->name, ke->value);
714 }
715}
716
717#endif /* 0 */
Note: See TracBrowser for help on using the repository browser.