1 /* m32c opcode support. -*- C -*-
3 Copyright 2005, 2007, 2009, 2010 Free Software Foundation, Inc.
5 Contributed by Red Hat Inc; developed under contract from Renesas
7 This file is part of the GNU Binutils.
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 3 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
22 MA 02110-1301, USA. */
25 /* This file is an addendum to m32c.cpu. Heavy use of C code isn't
26 appropriate in .cpu files, so it resides here. This especially applies
27 to assembly/disassembly where parsing/printing can be quite involved.
28 Such things aren't really part of the specification of the cpu, per se,
29 so .cpu files provide the general framework and .opc files handle the
30 nitty-gritty details as necessary.
32 Each section is delimited with start and end markers.
34 <arch>-opc.h additions use: "-- opc.h"
35 <arch>-opc.c additions use: "-- opc.c"
36 <arch>-asm.c additions use: "-- asm.c"
37 <arch>-dis.c additions use: "-- dis.c"
38 <arch>-ibd.h additions use: "-- ibd.h". */
42 /* Needed for RTL's 'ext' and 'trunc' operators. */
43 #include "cgen/basic-modes.h"
44 #include "cgen/basic-ops.h"
46 /* We can't use the default hash size because many bits are used by
48 #define CGEN_DIS_HASH_SIZE 1
49 #define CGEN_DIS_HASH(buf, value) 0
50 #define CGEN_VERBOSE_ASSEMBLER_ERRORS
51 #define CGEN_VALIDATE_INSN_SUPPORTED
53 extern int m32c_cgen_insn_supported (CGEN_CPU_DESC, const CGEN_INSN *);
55 #define CGEN_ASM_HASH_SIZE 0xffff
56 #define CGEN_ASM_HASH(mnem) m32c_asm_hash ((mnem))
62 m32c_asm_hash (const char *mnem)
66 /* The length of the mnemonic for the Jcnd insns is 1. Hash jsri. */
67 if (mnem[0] == 'j' && mnem[1] != 's')
70 /* Don't hash scCND */
71 if (mnem[0] == 's' && mnem[1] == 'c')
74 /* Don't hash bmCND */
75 if (mnem[0] == 'b' && mnem[1] == 'm')
78 for (h = 0; *mnem && *mnem != ' ' && *mnem != ':'; ++mnem)
80 return h % CGEN_ASM_HASH_SIZE;
84 #include "safe-ctype.h"
86 #define MACH_M32C 5 /* Must match md_begin. */
89 m32c_cgen_isa_register (const char **strp)
92 const char *s = *strp;
93 static char * m32c_register_names [] =
95 "r0", "r1", "r2", "r3", "r0l", "r0h", "r1l", "r1h",
96 "a0", "a1", "r2r0", "r3r1", "sp", "fb", "dct0", "dct1", "flg", "svf",
97 "drc0", "drc1", "dmd0", "dmd1", "intb", "svp", "vct", "isp", "dma0",
98 "dma1", "dra0", "dra1", "dsa0", "dsa1", 0
101 for (u = 0; m32c_register_names[u]; u++)
103 int len = strlen (m32c_register_names[u]);
105 if (memcmp (m32c_register_names[u], s, len) == 0
106 && (s[len] == 0 || ! ISALNUM (s[len])))
112 #define PARSE_UNSIGNED \
115 /* Don't successfully parse literals beginning with '['. */ \
117 return "Invalid literal"; /* Anything -- will not be seen. */ \
119 errmsg = cgen_parse_unsigned_integer (cd, strp, opindex, & value);\
125 #define PARSE_SIGNED \
128 /* Don't successfully parse literals beginning with '['. */ \
130 return "Invalid literal"; /* Anything -- will not be seen. */ \
132 errmsg = cgen_parse_signed_integer (cd, strp, opindex, & value); \
139 parse_unsigned6 (CGEN_CPU_DESC cd, const char **strp,
140 int opindex, unsigned long *valuep)
142 const char *errmsg = 0;
148 return _("imm:6 immediate is out of range");
155 parse_unsigned8 (CGEN_CPU_DESC cd, const char **strp,
156 int opindex, unsigned long *valuep)
158 const char *errmsg = 0;
159 unsigned long value = 0;
162 if (strncasecmp (*strp, "%dsp8(", 6) == 0)
164 enum cgen_parse_operand_result result_type;
168 errmsg = cgen_parse_address (cd, strp, opindex, BFD_RELOC_8,
169 & result_type, & val);
171 return _("missing `)'");
175 && result_type == CGEN_PARSE_OPERAND_RESULT_NUMBER)
176 return _("%dsp8() takes a symbolic address, not a number");
183 if (strncmp (*strp, "0x0", 3) == 0
184 || (**strp == '0' && *(*strp + 1) != 'x'))
190 return _("dsp:8 immediate is out of range");
192 /* If this field may require a relocation then use larger dsp16. */
193 if (! have_zero && value == 0)
194 return _("dsp:8 immediate is out of range");
201 parse_signed4 (CGEN_CPU_DESC cd, const char **strp,
202 int opindex, signed long *valuep)
204 const char *errmsg = 0;
208 if (strncmp (*strp, "0x0", 3) == 0
209 || (**strp == '0' && *(*strp + 1) != 'x'))
214 if (value < -8 || value > 7)
215 return _("Immediate is out of range -8 to 7");
217 /* If this field may require a relocation then use larger dsp16. */
218 if (! have_zero && value == 0)
219 return _("Immediate is out of range -8 to 7");
226 parse_signed4n (CGEN_CPU_DESC cd, const char **strp,
227 int opindex, signed long *valuep)
229 const char *errmsg = 0;
233 if (strncmp (*strp, "0x0", 3) == 0
234 || (**strp == '0' && *(*strp + 1) != 'x'))
239 if (value < -7 || value > 8)
240 return _("Immediate is out of range -7 to 8");
242 /* If this field may require a relocation then use larger dsp16. */
243 if (! have_zero && value == 0)
244 return _("Immediate is out of range -7 to 8");
251 parse_signed8 (CGEN_CPU_DESC cd, const char **strp,
252 int opindex, signed long *valuep)
254 const char *errmsg = 0;
255 signed long value = 0;
257 if (strncasecmp (*strp, "%hi8(", 5) == 0)
259 enum cgen_parse_operand_result result_type;
263 errmsg = cgen_parse_address (cd, strp, opindex, BFD_RELOC_M32C_HI8,
264 & result_type, & val);
266 return _("missing `)'");
270 && result_type == CGEN_PARSE_OPERAND_RESULT_NUMBER)
280 if (value <= 255 && value > 127)
283 if (value < -128 || value > 127)
284 return _("dsp:8 immediate is out of range");
291 parse_unsigned16 (CGEN_CPU_DESC cd, const char **strp,
292 int opindex, unsigned long *valuep)
294 const char *errmsg = 0;
295 unsigned long value = 0;
298 if (strncasecmp (*strp, "%dsp16(", 7) == 0)
300 enum cgen_parse_operand_result result_type;
304 errmsg = cgen_parse_address (cd, strp, opindex, BFD_RELOC_16,
305 & result_type, & val);
307 return _("missing `)'");
311 && result_type == CGEN_PARSE_OPERAND_RESULT_NUMBER)
312 return _("%dsp16() takes a symbolic address, not a number");
319 /* Don't successfully parse literals beginning with '['. */
321 return "Invalid literal"; /* Anything -- will not be seen. */
323 /* Don't successfully parse register names. */
324 if (m32c_cgen_isa_register (strp))
325 return "Invalid literal"; /* Anything -- will not be seen. */
327 if (strncmp (*strp, "0x0", 3) == 0
328 || (**strp == '0' && *(*strp + 1) != 'x'))
331 errmsg = cgen_parse_unsigned_integer (cd, strp, opindex, & value);
336 return _("dsp:16 immediate is out of range");
338 /* If this field may require a relocation then use larger dsp24. */
339 if (cd->machs == MACH_M32C && ! have_zero && value == 0
340 && (strncmp (*strp, "[a", 2) == 0
343 return _("dsp:16 immediate is out of range");
350 parse_signed16 (CGEN_CPU_DESC cd, const char **strp,
351 int opindex, signed long *valuep)
353 const char *errmsg = 0;
354 signed long value = 0;
356 if (strncasecmp (*strp, "%lo16(", 6) == 0)
358 enum cgen_parse_operand_result result_type;
362 errmsg = cgen_parse_address (cd, strp, opindex, BFD_RELOC_LO16,
363 & result_type, & val);
365 return _("missing `)'");
369 && result_type == CGEN_PARSE_OPERAND_RESULT_NUMBER)
377 if (strncasecmp (*strp, "%hi16(", 6) == 0)
379 enum cgen_parse_operand_result result_type;
383 errmsg = cgen_parse_address (cd, strp, opindex, BFD_RELOC_HI16,
384 & result_type, & val);
386 return _("missing `)'");
390 && result_type == CGEN_PARSE_OPERAND_RESULT_NUMBER)
400 if (value <= 65535 && value > 32767)
403 if (value < -32768 || value > 32767)
404 return _("dsp:16 immediate is out of range");
411 parse_unsigned20 (CGEN_CPU_DESC cd, const char **strp,
412 int opindex, unsigned long *valuep)
414 const char *errmsg = 0;
417 /* Don't successfully parse literals beginning with '['. */
419 return "Invalid literal"; /* Anything -- will not be seen. */
421 /* Don't successfully parse register names. */
422 if (m32c_cgen_isa_register (strp))
423 return "Invalid literal"; /* Anything -- will not be seen. */
425 errmsg = cgen_parse_unsigned_integer (cd, strp, opindex, & value);
430 return _("dsp:20 immediate is out of range");
437 parse_unsigned24 (CGEN_CPU_DESC cd, const char **strp,
438 int opindex, unsigned long *valuep)
440 const char *errmsg = 0;
443 /* Don't successfully parse literals beginning with '['. */
445 return "Invalid literal"; /* Anything -- will not be seen. */
447 /* Don't successfully parse register names. */
448 if (m32c_cgen_isa_register (strp))
449 return "Invalid literal"; /* Anything -- will not be seen. */
451 errmsg = cgen_parse_unsigned_integer (cd, strp, opindex, & value);
455 if (value > 0xffffff)
456 return _("dsp:24 immediate is out of range");
462 /* This should only be used for #imm->reg. */
464 parse_signed24 (CGEN_CPU_DESC cd, const char **strp,
465 int opindex, signed long *valuep)
467 const char *errmsg = 0;
472 if (value <= 0xffffff && value > 0x7fffff)
475 if (value > 0xffffff)
476 return _("dsp:24 immediate is out of range");
483 parse_signed32 (CGEN_CPU_DESC cd, const char **strp,
484 int opindex, signed long *valuep)
486 const char *errmsg = 0;
489 errmsg = cgen_parse_signed_integer (cd, strp, opindex, & value);
498 parse_imm1_S (CGEN_CPU_DESC cd, const char **strp,
499 int opindex, signed long *valuep)
501 const char *errmsg = 0;
504 errmsg = cgen_parse_signed_integer (cd, strp, opindex, & value);
508 if (value < 1 || value > 2)
509 return _("immediate is out of range 1-2");
516 parse_imm3_S (CGEN_CPU_DESC cd, const char **strp,
517 int opindex, signed long *valuep)
519 const char *errmsg = 0;
522 errmsg = cgen_parse_signed_integer (cd, strp, opindex, & value);
526 if (value < 1 || value > 8)
527 return _("immediate is out of range 1-8");
534 parse_bit3_S (CGEN_CPU_DESC cd, const char **strp,
535 int opindex, signed long *valuep)
537 const char *errmsg = 0;
540 errmsg = cgen_parse_signed_integer (cd, strp, opindex, & value);
544 if (value < 0 || value > 7)
545 return _("immediate is out of range 0-7");
552 parse_lab_5_3 (CGEN_CPU_DESC cd,
554 int opindex ATTRIBUTE_UNUSED,
556 enum cgen_parse_operand_result *type_addr,
559 const char *errmsg = 0;
561 enum cgen_parse_operand_result op_res;
563 errmsg = cgen_parse_address (cd, strp, M32C_OPERAND_LAB_5_3,
564 opinfo, & op_res, & value);
569 if (op_res == CGEN_PARSE_OPERAND_RESULT_QUEUED)
571 /* This is a hack; the field cannot handle near-zero signed
572 offsets that CGEN wants to put in to indicate an "empty"
580 if (value < 2 || value > 9)
581 return _("immediate is out of range 2-9");
588 parse_Bitno16R (CGEN_CPU_DESC cd, const char **strp,
589 int opindex, unsigned long *valuep)
591 const char *errmsg = 0;
594 errmsg = cgen_parse_unsigned_integer (cd, strp, opindex, & value);
599 return _("Bit number for indexing general register is out of range 0-15");
606 parse_unsigned_bitbase (CGEN_CPU_DESC cd, const char **strp,
607 int opindex, unsigned long *valuep,
608 unsigned bits, int allow_syms)
610 const char *errmsg = 0;
613 const char *newp = *strp;
614 unsigned long long bitbase;
617 errmsg = cgen_parse_unsigned_integer (cd, & newp, opindex, & bit);
622 return "Missing base for bit,base:8";
626 if (strncmp (newp, "0x0", 3) == 0
627 || (newp[0] == '0' && newp[1] != 'x'))
630 errmsg = cgen_parse_unsigned_integer (cd, & newp, opindex, & base);
634 bitbase = (unsigned long long) bit + ((unsigned long long) base * 8);
636 if (bitbase >= (1ull << bits))
637 return _("bit,base is out of range");
639 /* If this field may require a relocation then use larger displacement. */
640 if (! have_zero && base == 0)
642 switch (allow_syms) {
644 return _("bit,base out of range for symbol");
648 if (strncmp (newp, "[sb]", 4) != 0)
649 return _("bit,base out of range for symbol");
660 parse_signed_bitbase (CGEN_CPU_DESC cd, const char **strp,
661 int opindex, signed long *valuep,
662 unsigned bits, int allow_syms)
664 const char *errmsg = 0;
667 const char *newp = *strp;
672 errmsg = cgen_parse_unsigned_integer (cd, & newp, opindex, & bit);
677 return "Missing base for bit,base:8";
681 if (strncmp (newp, "0x0", 3) == 0
682 || (newp[0] == '0' && newp[1] != 'x'))
685 errmsg = cgen_parse_signed_integer (cd, & newp, opindex, & base);
689 bitbase = (long long)bit + ((long long)base * 8);
691 limit = 1ll << (bits - 1);
692 if (bitbase < -limit || bitbase >= limit)
693 return _("bit,base is out of range");
695 /* If this field may require a relocation then use larger displacement. */
696 if (! have_zero && base == 0 && ! allow_syms)
697 return _("bit,base out of range for symbol");
705 parse_unsigned_bitbase8 (CGEN_CPU_DESC cd, const char **strp,
706 int opindex, unsigned long *valuep)
708 return parse_unsigned_bitbase (cd, strp, opindex, valuep, 8, 0);
712 parse_unsigned_bitbase11 (CGEN_CPU_DESC cd, const char **strp,
713 int opindex, unsigned long *valuep)
715 return parse_unsigned_bitbase (cd, strp, opindex, valuep, 11, 0);
719 parse_unsigned_bitbase16 (CGEN_CPU_DESC cd, const char **strp,
720 int opindex, unsigned long *valuep)
722 return parse_unsigned_bitbase (cd, strp, opindex, valuep, 16, 1);
726 parse_unsigned_bitbase19 (CGEN_CPU_DESC cd, const char **strp,
727 int opindex, unsigned long *valuep)
729 return parse_unsigned_bitbase (cd, strp, opindex, valuep, 19, 2);
733 parse_unsigned_bitbase27 (CGEN_CPU_DESC cd, const char **strp,
734 int opindex, unsigned long *valuep)
736 return parse_unsigned_bitbase (cd, strp, opindex, valuep, 27, 1);
740 parse_signed_bitbase8 (CGEN_CPU_DESC cd, const char **strp,
741 int opindex, signed long *valuep)
743 return parse_signed_bitbase (cd, strp, opindex, valuep, 8, 1);
747 parse_signed_bitbase11 (CGEN_CPU_DESC cd, const char **strp,
748 int opindex, signed long *valuep)
750 return parse_signed_bitbase (cd, strp, opindex, valuep, 11, 0);
754 parse_signed_bitbase19 (CGEN_CPU_DESC cd, const char **strp,
755 int opindex, signed long *valuep)
757 return parse_signed_bitbase (cd, strp, opindex, valuep, 19, 1);
760 /* Parse the suffix as :<char> or as nothing followed by a whitespace. */
763 parse_suffix (const char **strp, char suffix)
765 const char *newp = *strp;
767 if (**strp == ':' && TOLOWER (*(*strp + 1)) == suffix)
776 return "Invalid suffix"; /* Anything -- will not be seen. */
780 parse_S (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED, const char **strp,
781 int opindex ATTRIBUTE_UNUSED, signed long *valuep ATTRIBUTE_UNUSED)
783 return parse_suffix (strp, 's');
787 parse_G (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED, const char **strp,
788 int opindex ATTRIBUTE_UNUSED, signed long *valuep ATTRIBUTE_UNUSED)
790 return parse_suffix (strp, 'g');
794 parse_Q (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED, const char **strp,
795 int opindex ATTRIBUTE_UNUSED, signed long *valuep ATTRIBUTE_UNUSED)
797 return parse_suffix (strp, 'q');
801 parse_Z (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED, const char **strp,
802 int opindex ATTRIBUTE_UNUSED, signed long *valuep ATTRIBUTE_UNUSED)
804 return parse_suffix (strp, 'z');
807 /* Parse an empty suffix. Fail if the next char is ':'. */
810 parse_X (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED, const char **strp,
811 int opindex ATTRIBUTE_UNUSED, signed long *valuep ATTRIBUTE_UNUSED)
814 return "Unexpected suffix";
819 parse_r0l_r0h (CGEN_CPU_DESC cd, const char **strp,
820 int opindex ATTRIBUTE_UNUSED, signed long *valuep)
825 const char *newp = *strp;
828 errmsg = cgen_parse_keyword (cd, & newp, & m32c_cgen_opval_h_r0l_r0h, & value);
833 return _("not a valid r0l/r0h pair");
836 /* Parse the second register in the pair. */
837 if (value == 0) /* r0l */
838 errmsg = cgen_parse_keyword (cd, & newp, & m32c_cgen_opval_h_r0h, & junk);
840 errmsg = cgen_parse_keyword (cd, & newp, & m32c_cgen_opval_h_r0l, & junk);
849 /* Accept .b or .w in any case. */
852 parse_size (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED, const char **strp,
853 int opindex ATTRIBUTE_UNUSED, signed long *valuep ATTRIBUTE_UNUSED)
856 && (*(*strp + 1) == 'b' || *(*strp + 1) == 'B'
857 || *(*strp + 1) == 'w' || *(*strp + 1) == 'W'))
863 return _("Invalid size specifier");
866 /* Special check to ensure that instruction exists for given machine. */
869 m32c_cgen_insn_supported (CGEN_CPU_DESC cd,
870 const CGEN_INSN *insn)
872 int machs = CGEN_INSN_ATTR_VALUE (insn, CGEN_INSN_MACH);
873 CGEN_BITSET isas = CGEN_INSN_BITSET_ATTR_VALUE (insn, CGEN_INSN_ISA);
875 /* If attributes are absent, assume no restriction. */
879 return ((machs & cd->machs)
880 && cgen_bitset_intersect_p (& isas, cd->isas));
883 /* Parse a set of registers, R0,R1,A0,A1,SB,FB. */
886 parse_regset (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
888 int opindex ATTRIBUTE_UNUSED,
889 unsigned long *valuep,
892 const char *errmsg = 0;
896 while (**strp && **strp != ')')
898 if (**strp == 'r' || **strp == 'R')
901 regno = **strp - '0';
903 errmsg = _("Register number is not valid");
905 else if (**strp == 'a' || **strp == 'A')
908 regno = **strp - '0';
910 errmsg = _("Register number is not valid");
911 regno = **strp - '0' + 4;
914 else if (strncasecmp (*strp, "sb", 2) == 0 || strncasecmp (*strp, "SB", 2) == 0)
920 else if (strncasecmp (*strp, "fb", 2) == 0 || strncasecmp (*strp, "FB", 2) == 0)
926 if (push) /* Mask is reversed for push. */
927 *valuep |= 0x80 >> regno;
929 *valuep |= 1 << regno;
934 if (*(*strp + 1) == ')')
941 errmsg = _("Register list is not valid");
950 parse_pop_regset (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
952 int opindex ATTRIBUTE_UNUSED,
953 unsigned long *valuep)
955 return parse_regset (cd, strp, opindex, valuep, POP);
959 parse_push_regset (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
961 int opindex ATTRIBUTE_UNUSED,
962 unsigned long *valuep)
964 return parse_regset (cd, strp, opindex, valuep, PUSH);
969 #include "elf/m32c.h"
972 /* Always print the short insn format suffix as ':<char>'. */
975 print_suffix (void * dis_info, char suffix)
977 disassemble_info *info = dis_info;
979 (*info->fprintf_func) (info->stream, ":%c", suffix);
983 print_S (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
985 long value ATTRIBUTE_UNUSED,
986 unsigned int attrs ATTRIBUTE_UNUSED,
987 bfd_vma pc ATTRIBUTE_UNUSED,
988 int length ATTRIBUTE_UNUSED)
990 print_suffix (dis_info, 's');
995 print_G (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
997 long value ATTRIBUTE_UNUSED,
998 unsigned int attrs ATTRIBUTE_UNUSED,
999 bfd_vma pc ATTRIBUTE_UNUSED,
1000 int length ATTRIBUTE_UNUSED)
1002 print_suffix (dis_info, 'g');
1006 print_Q (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
1008 long value ATTRIBUTE_UNUSED,
1009 unsigned int attrs ATTRIBUTE_UNUSED,
1010 bfd_vma pc ATTRIBUTE_UNUSED,
1011 int length ATTRIBUTE_UNUSED)
1013 print_suffix (dis_info, 'q');
1017 print_Z (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
1019 long value ATTRIBUTE_UNUSED,
1020 unsigned int attrs ATTRIBUTE_UNUSED,
1021 bfd_vma pc ATTRIBUTE_UNUSED,
1022 int length ATTRIBUTE_UNUSED)
1024 print_suffix (dis_info, 'z');
1027 /* Print the empty suffix. */
1030 print_X (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
1031 void * dis_info ATTRIBUTE_UNUSED,
1032 long value ATTRIBUTE_UNUSED,
1033 unsigned int attrs ATTRIBUTE_UNUSED,
1034 bfd_vma pc ATTRIBUTE_UNUSED,
1035 int length ATTRIBUTE_UNUSED)
1041 print_r0l_r0h (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
1044 unsigned int attrs ATTRIBUTE_UNUSED,
1045 bfd_vma pc ATTRIBUTE_UNUSED,
1046 int length ATTRIBUTE_UNUSED)
1048 disassemble_info *info = dis_info;
1051 (*info->fprintf_func) (info->stream, "r0h,r0l");
1053 (*info->fprintf_func) (info->stream, "r0l,r0h");
1057 print_unsigned_bitbase (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
1059 unsigned long value,
1060 unsigned int attrs ATTRIBUTE_UNUSED,
1061 bfd_vma pc ATTRIBUTE_UNUSED,
1062 int length ATTRIBUTE_UNUSED)
1064 disassemble_info *info = dis_info;
1066 (*info->fprintf_func) (info->stream, "%ld,0x%lx", value & 0x7, value >> 3);
1070 print_signed_bitbase (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
1073 unsigned int attrs ATTRIBUTE_UNUSED,
1074 bfd_vma pc ATTRIBUTE_UNUSED,
1075 int length ATTRIBUTE_UNUSED)
1077 disassemble_info *info = dis_info;
1079 (*info->fprintf_func) (info->stream, "%ld,%ld", value & 0x7, value >> 3);
1083 print_size (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
1085 long value ATTRIBUTE_UNUSED,
1086 unsigned int attrs ATTRIBUTE_UNUSED,
1087 bfd_vma pc ATTRIBUTE_UNUSED,
1088 int length ATTRIBUTE_UNUSED)
1090 /* Always print the size as '.w'. */
1091 disassemble_info *info = dis_info;
1093 (*info->fprintf_func) (info->stream, ".w");
1099 static void print_pop_regset (CGEN_CPU_DESC, void *, long, unsigned int, bfd_vma, int);
1100 static void print_push_regset (CGEN_CPU_DESC, void *, long, unsigned int, bfd_vma, int);
1102 /* Print a set of registers, R0,R1,A0,A1,SB,FB. */
1105 print_regset (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
1108 unsigned int attrs ATTRIBUTE_UNUSED,
1109 bfd_vma pc ATTRIBUTE_UNUSED,
1110 int length ATTRIBUTE_UNUSED,
1113 static char * m16c_register_names [] =
1115 "r0", "r1", "r2", "r3", "a0", "a1", "sb", "fb"
1117 disassemble_info *info = dis_info;
1129 (*info->fprintf_func) (info->stream, "%s", m16c_register_names [0]);
1133 for (reg_index = 1; reg_index <= 7; ++reg_index)
1142 (*info->fprintf_func) (info->stream, "%s%s", comma,
1143 m16c_register_names [reg_index]);
1150 print_pop_regset (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
1153 unsigned int attrs ATTRIBUTE_UNUSED,
1154 bfd_vma pc ATTRIBUTE_UNUSED,
1155 int length ATTRIBUTE_UNUSED)
1157 print_regset (cd, dis_info, value, attrs, pc, length, POP);
1161 print_push_regset (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
1164 unsigned int attrs ATTRIBUTE_UNUSED,
1165 bfd_vma pc ATTRIBUTE_UNUSED,
1166 int length ATTRIBUTE_UNUSED)
1168 print_regset (cd, dis_info, value, attrs, pc, length, PUSH);
1172 print_signed4n (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
1175 unsigned int attrs ATTRIBUTE_UNUSED,
1176 bfd_vma pc ATTRIBUTE_UNUSED,
1177 int length ATTRIBUTE_UNUSED)
1179 disassemble_info *info = dis_info;
1181 (*info->fprintf_func) (info->stream, "%ld", -value);