Statistics
| Branch: | Revision:

root / cris-dis.c @ c16b5a2c

History | View | Annotate | Download (80.4 kB)

1 450d4ff5 ths
/* Disassembler code for CRIS.
2 450d4ff5 ths
   Copyright 2000, 2001, 2002, 2004, 2005, 2006 Free Software Foundation, Inc.
3 450d4ff5 ths
   Contributed by Axis Communications AB, Lund, Sweden.
4 450d4ff5 ths
   Written by Hans-Peter Nilsson.
5 450d4ff5 ths

6 450d4ff5 ths
   This file is part of the GNU binutils and GDB, the GNU debugger.
7 450d4ff5 ths

8 450d4ff5 ths
   This program is free software; you can redistribute it and/or modify it
9 450d4ff5 ths
   under the terms of the GNU General Public License as published by the
10 450d4ff5 ths
   Free Software Foundation; either version 2, or (at your option) any later
11 450d4ff5 ths
   version.
12 450d4ff5 ths

13 450d4ff5 ths
   This program is distributed in the hope that it will be useful, but WITHOUT
14 450d4ff5 ths
   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 450d4ff5 ths
   FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
16 450d4ff5 ths
   more details.
17 450d4ff5 ths

18 450d4ff5 ths
   You should have received a copy of the GNU General Public License
19 450d4ff5 ths
   along with this program; if not, write to the Free Software
20 450d4ff5 ths
   Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
21 450d4ff5 ths
   MA 02110-1301, USA.  */
22 450d4ff5 ths
23 450d4ff5 ths
#include "dis-asm.h"
24 450d4ff5 ths
//#include "sysdep.h"
25 450d4ff5 ths
#include "target-cris/opcode-cris.h"
26 450d4ff5 ths
//#include "libiberty.h"
27 450d4ff5 ths
 
28 450d4ff5 ths
29 1eec614b aliguori
void *qemu_malloc(size_t len); /* can't include qemu-common.h here */
30 1eec614b aliguori
31 450d4ff5 ths
#define FALSE 0
32 450d4ff5 ths
#define TRUE 1
33 450d4ff5 ths
#define CONST_STRNEQ(STR1,STR2) (strncmp ((STR1), (STR2), sizeof (STR2) - 1) == 0)
34 450d4ff5 ths
35 450d4ff5 ths
/* cris-opc.c -- Table of opcodes for the CRIS processor.
36 450d4ff5 ths
   Copyright 2000, 2001, 2004 Free Software Foundation, Inc.
37 450d4ff5 ths
   Contributed by Axis Communications AB, Lund, Sweden.
38 450d4ff5 ths
   Originally written for GAS 1.38.1 by Mikael Asker.
39 450d4ff5 ths
   Reorganized by Hans-Peter Nilsson.
40 450d4ff5 ths

41 450d4ff5 ths
This file is part of GAS, GDB and the GNU binutils.
42 450d4ff5 ths

43 450d4ff5 ths
GAS, GDB, and GNU binutils is free software; you can redistribute it
44 450d4ff5 ths
and/or modify it under the terms of the GNU General Public License as
45 450d4ff5 ths
published by the Free Software Foundation; either version 2, or (at your
46 450d4ff5 ths
option) any later version.
47 450d4ff5 ths

48 450d4ff5 ths
GAS, GDB, and GNU binutils are distributed in the hope that they will be
49 450d4ff5 ths
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
50 450d4ff5 ths
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
51 450d4ff5 ths
GNU General Public License for more details.
52 450d4ff5 ths

53 450d4ff5 ths
You should have received a copy of the GNU General Public License
54 450d4ff5 ths
along with this program; if not, write to the Free Software
55 450d4ff5 ths
Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.  */
56 450d4ff5 ths
57 450d4ff5 ths
#ifndef NULL
58 450d4ff5 ths
#define NULL (0)
59 450d4ff5 ths
#endif
60 450d4ff5 ths
61 450d4ff5 ths
/* This table isn't used for CRISv32 and the size of immediate operands.  */
62 450d4ff5 ths
const struct cris_spec_reg
63 450d4ff5 ths
cris_spec_regs[] =
64 450d4ff5 ths
{
65 450d4ff5 ths
  {"bz",  0,  1, cris_ver_v32p,           NULL},
66 450d4ff5 ths
  {"p0",  0,  1, 0,                   NULL},
67 450d4ff5 ths
  {"vr",  1,  1, 0,                   NULL},
68 450d4ff5 ths
  {"p1",  1,  1, 0,                   NULL},
69 450d4ff5 ths
  {"pid", 2,  1, cris_ver_v32p,    NULL},
70 450d4ff5 ths
  {"p2",  2,  1, cris_ver_v32p,           NULL},
71 450d4ff5 ths
  {"p2",  2,  1, cris_ver_warning, NULL},
72 450d4ff5 ths
  {"srs", 3,  1, cris_ver_v32p,    NULL},
73 450d4ff5 ths
  {"p3",  3,  1, cris_ver_v32p,           NULL},
74 450d4ff5 ths
  {"p3",  3,  1, cris_ver_warning, NULL},
75 450d4ff5 ths
  {"wz",  4,  2, cris_ver_v32p,           NULL},
76 450d4ff5 ths
  {"p4",  4,  2, 0,                   NULL},
77 450d4ff5 ths
  {"ccr", 5,  2, cris_ver_v0_10,   NULL},
78 450d4ff5 ths
  {"exs", 5,  4, cris_ver_v32p,           NULL},
79 450d4ff5 ths
  {"p5",  5,  2, cris_ver_v0_10,   NULL},
80 450d4ff5 ths
  {"p5",  5,  4, cris_ver_v32p,           NULL},
81 450d4ff5 ths
  {"dcr0",6,  2, cris_ver_v0_3,           NULL},
82 450d4ff5 ths
  {"eda", 6,  4, cris_ver_v32p,           NULL},
83 450d4ff5 ths
  {"p6",  6,  2, cris_ver_v0_3,           NULL},
84 450d4ff5 ths
  {"p6",  6,  4, cris_ver_v32p,           NULL},
85 450d4ff5 ths
  {"dcr1/mof", 7, 4, cris_ver_v10p,
86 450d4ff5 ths
   "Register `dcr1/mof' with ambiguous size specified.  Guessing 4 bytes"},
87 450d4ff5 ths
  {"dcr1/mof", 7, 2, cris_ver_v0_3,
88 450d4ff5 ths
   "Register `dcr1/mof' with ambiguous size specified.  Guessing 2 bytes"},
89 450d4ff5 ths
  {"mof", 7,  4, cris_ver_v10p,           NULL},
90 450d4ff5 ths
  {"dcr1",7,  2, cris_ver_v0_3,           NULL},
91 450d4ff5 ths
  {"p7",  7,  4, cris_ver_v10p,           NULL},
92 450d4ff5 ths
  {"p7",  7,  2, cris_ver_v0_3,           NULL},
93 450d4ff5 ths
  {"dz",  8,  4, cris_ver_v32p,           NULL},
94 450d4ff5 ths
  {"p8",  8,  4, 0,                   NULL},
95 450d4ff5 ths
  {"ibr", 9,  4, cris_ver_v0_10,   NULL},
96 450d4ff5 ths
  {"ebp", 9,  4, cris_ver_v32p,           NULL},
97 450d4ff5 ths
  {"p9",  9,  4, 0,                   NULL},
98 450d4ff5 ths
  {"irp", 10, 4, cris_ver_v0_10,   NULL},
99 450d4ff5 ths
  {"erp", 10, 4, cris_ver_v32p,           NULL},
100 450d4ff5 ths
  {"p10", 10, 4, 0,                   NULL},
101 450d4ff5 ths
  {"srp", 11, 4, 0,                   NULL},
102 450d4ff5 ths
  {"p11", 11, 4, 0,                   NULL},
103 450d4ff5 ths
  /* For disassembly use only.  Accept at assembly with a warning.  */
104 450d4ff5 ths
  {"bar/dtp0", 12, 4, cris_ver_warning,
105 450d4ff5 ths
   "Ambiguous register `bar/dtp0' specified"},
106 450d4ff5 ths
  {"nrp", 12, 4, cris_ver_v32p,           NULL},
107 450d4ff5 ths
  {"bar", 12, 4, cris_ver_v8_10,   NULL},
108 450d4ff5 ths
  {"dtp0",12, 4, cris_ver_v0_3,           NULL},
109 450d4ff5 ths
  {"p12", 12, 4, 0,                   NULL},
110 450d4ff5 ths
  /* For disassembly use only.  Accept at assembly with a warning.  */
111 450d4ff5 ths
  {"dccr/dtp1",13, 4, cris_ver_warning,
112 450d4ff5 ths
   "Ambiguous register `dccr/dtp1' specified"},
113 450d4ff5 ths
  {"ccs", 13, 4, cris_ver_v32p,           NULL},
114 450d4ff5 ths
  {"dccr",13, 4, cris_ver_v8_10,   NULL},
115 450d4ff5 ths
  {"dtp1",13, 4, cris_ver_v0_3,           NULL},
116 450d4ff5 ths
  {"p13", 13, 4, 0,                   NULL},
117 450d4ff5 ths
  {"brp", 14, 4, cris_ver_v3_10,   NULL},
118 450d4ff5 ths
  {"usp", 14, 4, cris_ver_v32p,           NULL},
119 450d4ff5 ths
  {"p14", 14, 4, cris_ver_v3p,           NULL},
120 450d4ff5 ths
  {"usp", 15, 4, cris_ver_v10,           NULL},
121 450d4ff5 ths
  {"spc", 15, 4, cris_ver_v32p,           NULL},
122 450d4ff5 ths
  {"p15", 15, 4, cris_ver_v10p,           NULL},
123 450d4ff5 ths
  {NULL, 0, 0, cris_ver_version_all, NULL}
124 450d4ff5 ths
};
125 450d4ff5 ths
126 450d4ff5 ths
/* Add version specifiers to this table when necessary.
127 450d4ff5 ths
   The (now) regular coding of register names suggests a simpler
128 450d4ff5 ths
   implementation.  */
129 450d4ff5 ths
const struct cris_support_reg cris_support_regs[] =
130 450d4ff5 ths
{
131 450d4ff5 ths
  {"s0", 0},
132 450d4ff5 ths
  {"s1", 1},
133 450d4ff5 ths
  {"s2", 2},
134 450d4ff5 ths
  {"s3", 3},
135 450d4ff5 ths
  {"s4", 4},
136 450d4ff5 ths
  {"s5", 5},
137 450d4ff5 ths
  {"s6", 6},
138 450d4ff5 ths
  {"s7", 7},
139 450d4ff5 ths
  {"s8", 8},
140 450d4ff5 ths
  {"s9", 9},
141 450d4ff5 ths
  {"s10", 10},
142 450d4ff5 ths
  {"s11", 11},
143 450d4ff5 ths
  {"s12", 12},
144 450d4ff5 ths
  {"s13", 13},
145 450d4ff5 ths
  {"s14", 14},
146 450d4ff5 ths
  {"s15", 15},
147 450d4ff5 ths
  {NULL, 0}
148 450d4ff5 ths
};
149 450d4ff5 ths
150 450d4ff5 ths
/* All CRIS opcodes are 16 bits.
151 450d4ff5 ths

152 450d4ff5 ths
   - The match component is a mask saying which bits must match a
153 450d4ff5 ths
     particular opcode in order for an instruction to be an instance
154 450d4ff5 ths
     of that opcode.
155 450d4ff5 ths

156 450d4ff5 ths
   - The args component is a string containing characters symbolically
157 450d4ff5 ths
     matching the operands of an instruction.  Used for both assembly
158 450d4ff5 ths
     and disassembly.
159 450d4ff5 ths

160 450d4ff5 ths
     Operand-matching characters:
161 450d4ff5 ths
     [ ] , space
162 450d4ff5 ths
        Verbatim.
163 450d4ff5 ths
     A        The string "ACR" (case-insensitive).
164 450d4ff5 ths
     B        Not really an operand.  It causes a "BDAP -size,SP" prefix to be
165 450d4ff5 ths
        output for the PUSH alias-instructions and recognizes a push-
166 450d4ff5 ths
        prefix at disassembly.  This letter isn't recognized for v32.
167 450d4ff5 ths
        Must be followed by a R or P letter.
168 450d4ff5 ths
     !        Non-match pattern, will not match if there's a prefix insn.
169 450d4ff5 ths
     b        Non-matching operand, used for branches with 16-bit
170 450d4ff5 ths
        displacement. Only recognized by the disassembler.
171 450d4ff5 ths
     c        5-bit unsigned immediate in bits <4:0>.
172 450d4ff5 ths
     C        4-bit unsigned immediate in bits <3:0>.
173 450d4ff5 ths
     d  At assembly, optionally (as in put other cases before this one)
174 450d4ff5 ths
        ".d" or ".D" at the start of the operands, followed by one space
175 450d4ff5 ths
        character.  At disassembly, nothing.
176 450d4ff5 ths
     D        General register in bits <15:12> and <3:0>.
177 450d4ff5 ths
     f        List of flags in bits <15:12> and <3:0>.
178 450d4ff5 ths
     i        6-bit signed immediate in bits <5:0>.
179 450d4ff5 ths
     I        6-bit unsigned immediate in bits <5:0>.
180 450d4ff5 ths
     M        Size modifier (B, W or D) for CLEAR instructions.
181 450d4ff5 ths
     m        Size modifier (B, W or D) in bits <5:4>
182 450d4ff5 ths
     N  A 32-bit dword, like in the difference between s and y.
183 450d4ff5 ths
        This has no effect on bits in the opcode.  Can also be expressed
184 450d4ff5 ths
        as "[pc+]" in input.
185 450d4ff5 ths
     n  As N, but PC-relative (to the start of the instruction).
186 450d4ff5 ths
     o        [-128..127] word offset in bits <7:1> and <0>.  Used by 8-bit
187 450d4ff5 ths
        branch instructions.
188 450d4ff5 ths
     O        [-128..127] offset in bits <7:0>.  Also matches a comma and a
189 450d4ff5 ths
        general register after the expression, in bits <15:12>.  Used
190 450d4ff5 ths
        only for the BDAP prefix insn (in v32 the ADDOQ insn; same opcode).
191 450d4ff5 ths
     P        Special register in bits <15:12>.
192 450d4ff5 ths
     p        Indicates that the insn is a prefix insn.  Must be first
193 450d4ff5 ths
        character.
194 450d4ff5 ths
     Q  As O, but don't relax; force an 8-bit offset.
195 450d4ff5 ths
     R        General register in bits <15:12>.
196 450d4ff5 ths
     r        General register in bits <3:0>.
197 450d4ff5 ths
     S        Source operand in bit <10> and a prefix; a 3-operand prefix
198 450d4ff5 ths
        without side-effect.
199 450d4ff5 ths
     s        Source operand in bits <10> and <3:0>, optionally with a
200 450d4ff5 ths
        side-effect prefix, except [pc] (the name, not R15 as in ACR)
201 450d4ff5 ths
        isn't allowed for v32 and higher.
202 450d4ff5 ths
     T  Support register in bits <15:12>.
203 450d4ff5 ths
     u  4-bit (PC-relative) unsigned immediate word offset in bits <3:0>.
204 450d4ff5 ths
     U  Relaxes to either u or n, instruction is assumed LAPCQ or LAPC.
205 450d4ff5 ths
        Not recognized at disassembly.
206 450d4ff5 ths
     x        Register-dot-modifier, for example "r5.w" in bits <15:12> and <5:4>.
207 450d4ff5 ths
     y        Like 's' but do not allow an integer at assembly.
208 450d4ff5 ths
     Y        The difference s-y; only an integer is allowed.
209 450d4ff5 ths
     z        Size modifier (B or W) in bit <4>.  */
210 450d4ff5 ths
211 450d4ff5 ths
212 450d4ff5 ths
/* Please note the order of the opcodes in this table is significant.
213 450d4ff5 ths
   The assembler requires that all instances of the same mnemonic must
214 450d4ff5 ths
   be consecutive.  If they aren't, the assembler might not recognize
215 450d4ff5 ths
   them, or may indicate an internal error.
216 450d4ff5 ths

217 450d4ff5 ths
   The disassembler should not normally care about the order of the
218 450d4ff5 ths
   opcodes, but will prefer an earlier alternative if the "match-score"
219 450d4ff5 ths
   (see cris-dis.c) is computed as equal.
220 450d4ff5 ths

221 450d4ff5 ths
   It should not be significant for proper execution that this table is
222 450d4ff5 ths
   in alphabetical order, but please follow that convention for an easy
223 450d4ff5 ths
   overview.  */
224 450d4ff5 ths
225 450d4ff5 ths
const struct cris_opcode
226 450d4ff5 ths
cris_opcodes[] =
227 450d4ff5 ths
{
228 450d4ff5 ths
  {"abs",     0x06B0, 0x0940,                  "r,R",     0, SIZE_NONE,     0,
229 450d4ff5 ths
   cris_abs_op},
230 450d4ff5 ths
231 450d4ff5 ths
  {"add",     0x0600, 0x09c0,                  "m r,R",   0, SIZE_NONE,     0,
232 450d4ff5 ths
   cris_reg_mode_add_sub_cmp_and_or_move_op},
233 450d4ff5 ths
234 450d4ff5 ths
  {"add",     0x0A00, 0x01c0,                  "m s,R",   0, SIZE_FIELD,    0,
235 450d4ff5 ths
   cris_none_reg_mode_add_sub_cmp_and_or_move_op},
236 450d4ff5 ths
237 450d4ff5 ths
  {"add",     0x0A00, 0x01c0,                  "m S,D",   0, SIZE_NONE,
238 450d4ff5 ths
   cris_ver_v0_10,
239 450d4ff5 ths
   cris_none_reg_mode_add_sub_cmp_and_or_move_op},
240 450d4ff5 ths
241 450d4ff5 ths
  {"add",     0x0a00, 0x05c0,                  "m S,R,r", 0, SIZE_NONE,
242 450d4ff5 ths
   cris_ver_v0_10,
243 450d4ff5 ths
   cris_three_operand_add_sub_cmp_and_or_op},
244 450d4ff5 ths
245 450d4ff5 ths
  {"add",     0x0A00, 0x01c0,                  "m s,R",   0, SIZE_FIELD,
246 450d4ff5 ths
   cris_ver_v32p,
247 450d4ff5 ths
   cris_none_reg_mode_add_sub_cmp_and_or_move_op},
248 450d4ff5 ths
249 450d4ff5 ths
  {"addc",    0x0570, 0x0A80,                  "r,R",     0, SIZE_FIX_32,
250 450d4ff5 ths
   cris_ver_v32p,
251 450d4ff5 ths
   cris_not_implemented_op},
252 450d4ff5 ths
253 450d4ff5 ths
  {"addc",    0x09A0, 0x0250,                  "s,R",     0, SIZE_FIX_32,
254 450d4ff5 ths
   cris_ver_v32p,
255 450d4ff5 ths
   cris_not_implemented_op},
256 450d4ff5 ths
257 450d4ff5 ths
  {"addi",    0x0540, 0x0A80,                  "x,r,A",   0, SIZE_NONE,
258 450d4ff5 ths
   cris_ver_v32p,
259 450d4ff5 ths
   cris_addi_op},
260 450d4ff5 ths
261 450d4ff5 ths
  {"addi",    0x0500, 0x0Ac0,                  "x,r",     0, SIZE_NONE,     0,
262 450d4ff5 ths
   cris_addi_op},
263 450d4ff5 ths
264 450d4ff5 ths
  /* This collates after "addo", but we want to disassemble as "addoq",
265 450d4ff5 ths
     not "addo".  */
266 450d4ff5 ths
  {"addoq",   0x0100, 0x0E00,                  "Q,A",     0, SIZE_NONE,
267 450d4ff5 ths
   cris_ver_v32p,
268 450d4ff5 ths
   cris_not_implemented_op},
269 450d4ff5 ths
270 450d4ff5 ths
  {"addo",    0x0940, 0x0280,                  "m s,R,A", 0, SIZE_FIELD_SIGNED,
271 450d4ff5 ths
   cris_ver_v32p,
272 450d4ff5 ths
   cris_not_implemented_op},
273 450d4ff5 ths
274 450d4ff5 ths
  /* This must be located after the insn above, lest we misinterpret
275 450d4ff5 ths
     "addo.b -1,r0,acr" as "addo .b-1,r0,acr".  FIXME: Sounds like a
276 450d4ff5 ths
     parser bug.  */
277 450d4ff5 ths
  {"addo",   0x0100, 0x0E00,                  "O,A",     0, SIZE_NONE,
278 450d4ff5 ths
   cris_ver_v32p,
279 450d4ff5 ths
   cris_not_implemented_op},
280 450d4ff5 ths
281 450d4ff5 ths
  {"addq",    0x0200, 0x0Dc0,                  "I,R",     0, SIZE_NONE,     0,
282 450d4ff5 ths
   cris_quick_mode_add_sub_op},
283 450d4ff5 ths
284 450d4ff5 ths
  {"adds",    0x0420, 0x0Bc0,                  "z r,R",   0, SIZE_NONE,     0,
285 450d4ff5 ths
   cris_reg_mode_add_sub_cmp_and_or_move_op},
286 450d4ff5 ths
287 450d4ff5 ths
  /* FIXME: SIZE_FIELD_SIGNED and all necessary changes.  */
288 450d4ff5 ths
  {"adds",    0x0820, 0x03c0,                  "z s,R",   0, SIZE_FIELD,    0,
289 450d4ff5 ths
   cris_none_reg_mode_add_sub_cmp_and_or_move_op},
290 450d4ff5 ths
291 450d4ff5 ths
  {"adds",    0x0820, 0x03c0,                  "z S,D",   0, SIZE_NONE,
292 450d4ff5 ths
   cris_ver_v0_10,
293 450d4ff5 ths
   cris_none_reg_mode_add_sub_cmp_and_or_move_op},
294 450d4ff5 ths
295 450d4ff5 ths
  {"adds",    0x0820, 0x07c0,                  "z S,R,r", 0, SIZE_NONE,
296 450d4ff5 ths
   cris_ver_v0_10,
297 450d4ff5 ths
   cris_three_operand_add_sub_cmp_and_or_op},
298 450d4ff5 ths
299 450d4ff5 ths
  {"addu",    0x0400, 0x0be0,                  "z r,R",   0, SIZE_NONE,     0,
300 450d4ff5 ths
   cris_reg_mode_add_sub_cmp_and_or_move_op},
301 450d4ff5 ths
302 450d4ff5 ths
  /* FIXME: SIZE_FIELD_UNSIGNED and all necessary changes.  */
303 450d4ff5 ths
  {"addu",    0x0800, 0x03e0,                  "z s,R",   0, SIZE_FIELD,    0,
304 450d4ff5 ths
   cris_none_reg_mode_add_sub_cmp_and_or_move_op},
305 450d4ff5 ths
306 450d4ff5 ths
  {"addu",    0x0800, 0x03e0,                  "z S,D",   0, SIZE_NONE,
307 450d4ff5 ths
   cris_ver_v0_10,
308 450d4ff5 ths
   cris_none_reg_mode_add_sub_cmp_and_or_move_op},
309 450d4ff5 ths
310 450d4ff5 ths
  {"addu",    0x0800, 0x07e0,                  "z S,R,r", 0, SIZE_NONE,
311 450d4ff5 ths
   cris_ver_v0_10,
312 450d4ff5 ths
   cris_three_operand_add_sub_cmp_and_or_op},
313 450d4ff5 ths
314 450d4ff5 ths
  {"and",     0x0700, 0x08C0,                  "m r,R",   0, SIZE_NONE,     0,
315 450d4ff5 ths
   cris_reg_mode_add_sub_cmp_and_or_move_op},
316 450d4ff5 ths
317 450d4ff5 ths
  {"and",     0x0B00, 0x00C0,                  "m s,R",   0, SIZE_FIELD,    0,
318 450d4ff5 ths
   cris_none_reg_mode_add_sub_cmp_and_or_move_op},
319 450d4ff5 ths
320 450d4ff5 ths
  {"and",     0x0B00, 0x00C0,                  "m S,D",   0, SIZE_NONE,
321 450d4ff5 ths
   cris_ver_v0_10,
322 450d4ff5 ths
   cris_none_reg_mode_add_sub_cmp_and_or_move_op},
323 450d4ff5 ths
324 450d4ff5 ths
  {"and",     0x0B00, 0x04C0,                  "m S,R,r", 0, SIZE_NONE,
325 450d4ff5 ths
   cris_ver_v0_10,
326 450d4ff5 ths
   cris_three_operand_add_sub_cmp_and_or_op},
327 450d4ff5 ths
328 450d4ff5 ths
  {"andq",    0x0300, 0x0CC0,                  "i,R",     0, SIZE_NONE,     0,
329 450d4ff5 ths
   cris_quick_mode_and_cmp_move_or_op},
330 450d4ff5 ths
331 450d4ff5 ths
  {"asr",     0x0780, 0x0840,                  "m r,R",   0, SIZE_NONE,     0,
332 450d4ff5 ths
   cris_asr_op},
333 450d4ff5 ths
334 450d4ff5 ths
  {"asrq",    0x03a0, 0x0c40,                  "c,R",     0, SIZE_NONE,     0,
335 450d4ff5 ths
   cris_asrq_op},
336 450d4ff5 ths
337 450d4ff5 ths
  {"ax",      0x15B0, 0xEA4F,                  "",             0, SIZE_NONE,     0,
338 450d4ff5 ths
   cris_ax_ei_setf_op},
339 450d4ff5 ths
340 450d4ff5 ths
  /* FIXME: Should use branch #defines.  */
341 450d4ff5 ths
  {"b",              0x0dff, 0x0200,                  "b",             1, SIZE_NONE,     0,
342 450d4ff5 ths
   cris_sixteen_bit_offset_branch_op},
343 450d4ff5 ths
344 450d4ff5 ths
  {"ba",
345 450d4ff5 ths
   BA_QUICK_OPCODE,
346 450d4ff5 ths
   0x0F00+(0xF-CC_A)*0x1000,                  "o",             1, SIZE_NONE,     0,
347 450d4ff5 ths
   cris_eight_bit_offset_branch_op},
348 450d4ff5 ths
349 450d4ff5 ths
  /* Needs to come after the usual "ba o", which might be relaxed to
350 450d4ff5 ths
     this one.  */
351 450d4ff5 ths
  {"ba",     BA_DWORD_OPCODE,
352 450d4ff5 ths
   0xffff & (~BA_DWORD_OPCODE),                  "n",             0, SIZE_FIX_32,
353 450d4ff5 ths
   cris_ver_v32p,
354 450d4ff5 ths
   cris_none_reg_mode_jump_op},
355 450d4ff5 ths
356 450d4ff5 ths
  {"bas",     0x0EBF, 0x0140,                  "n,P",     0, SIZE_FIX_32,
357 450d4ff5 ths
   cris_ver_v32p,
358 450d4ff5 ths
   cris_none_reg_mode_jump_op},
359 450d4ff5 ths
360 450d4ff5 ths
  {"basc",     0x0EFF, 0x0100,                  "n,P",     0, SIZE_FIX_32,
361 450d4ff5 ths
   cris_ver_v32p,
362 450d4ff5 ths
   cris_none_reg_mode_jump_op},
363 450d4ff5 ths
364 450d4ff5 ths
  {"bcc",
365 450d4ff5 ths
   BRANCH_QUICK_OPCODE+CC_CC*0x1000,
366 450d4ff5 ths
   0x0f00+(0xF-CC_CC)*0x1000,                  "o",             1, SIZE_NONE,     0,
367 450d4ff5 ths
   cris_eight_bit_offset_branch_op},
368 450d4ff5 ths
369 450d4ff5 ths
  {"bcs",
370 450d4ff5 ths
   BRANCH_QUICK_OPCODE+CC_CS*0x1000,
371 450d4ff5 ths
   0x0f00+(0xF-CC_CS)*0x1000,                  "o",             1, SIZE_NONE,     0,
372 450d4ff5 ths
   cris_eight_bit_offset_branch_op},
373 450d4ff5 ths
374 450d4ff5 ths
  {"bdap",
375 450d4ff5 ths
   BDAP_INDIR_OPCODE, BDAP_INDIR_Z_BITS,  "pm s,R",  0, SIZE_FIELD_SIGNED,
376 450d4ff5 ths
   cris_ver_v0_10,
377 450d4ff5 ths
   cris_bdap_prefix},
378 450d4ff5 ths
379 450d4ff5 ths
  {"bdap",
380 450d4ff5 ths
   BDAP_QUICK_OPCODE, BDAP_QUICK_Z_BITS,  "pO",             0, SIZE_NONE,
381 450d4ff5 ths
   cris_ver_v0_10,
382 450d4ff5 ths
   cris_quick_mode_bdap_prefix},
383 450d4ff5 ths
384 450d4ff5 ths
  {"beq",
385 450d4ff5 ths
   BRANCH_QUICK_OPCODE+CC_EQ*0x1000,
386 450d4ff5 ths
   0x0f00+(0xF-CC_EQ)*0x1000,                  "o",             1, SIZE_NONE,     0,
387 450d4ff5 ths
   cris_eight_bit_offset_branch_op},
388 450d4ff5 ths
389 450d4ff5 ths
  /* This is deliberately put before "bext" to trump it, even though not
390 450d4ff5 ths
     in alphabetical order, since we don't do excluding version checks
391 450d4ff5 ths
     for v0..v10.  */
392 450d4ff5 ths
  {"bwf",
393 450d4ff5 ths
   BRANCH_QUICK_OPCODE+CC_EXT*0x1000,
394 450d4ff5 ths
   0x0f00+(0xF-CC_EXT)*0x1000,                  "o",             1, SIZE_NONE,
395 450d4ff5 ths
   cris_ver_v10,
396 450d4ff5 ths
   cris_eight_bit_offset_branch_op},
397 450d4ff5 ths
398 450d4ff5 ths
  {"bext",
399 450d4ff5 ths
   BRANCH_QUICK_OPCODE+CC_EXT*0x1000,
400 450d4ff5 ths
   0x0f00+(0xF-CC_EXT)*0x1000,                  "o",             1, SIZE_NONE,
401 450d4ff5 ths
   cris_ver_v0_3,
402 450d4ff5 ths
   cris_eight_bit_offset_branch_op},
403 450d4ff5 ths
404 450d4ff5 ths
  {"bge",
405 450d4ff5 ths
   BRANCH_QUICK_OPCODE+CC_GE*0x1000,
406 450d4ff5 ths
   0x0f00+(0xF-CC_GE)*0x1000,                  "o",             1, SIZE_NONE,     0,
407 450d4ff5 ths
   cris_eight_bit_offset_branch_op},
408 450d4ff5 ths
409 450d4ff5 ths
  {"bgt",
410 450d4ff5 ths
   BRANCH_QUICK_OPCODE+CC_GT*0x1000,
411 450d4ff5 ths
   0x0f00+(0xF-CC_GT)*0x1000,                  "o",             1, SIZE_NONE,     0,
412 450d4ff5 ths
   cris_eight_bit_offset_branch_op},
413 450d4ff5 ths
414 450d4ff5 ths
  {"bhi",
415 450d4ff5 ths
   BRANCH_QUICK_OPCODE+CC_HI*0x1000,
416 450d4ff5 ths
   0x0f00+(0xF-CC_HI)*0x1000,                  "o",             1, SIZE_NONE,     0,
417 450d4ff5 ths
   cris_eight_bit_offset_branch_op},
418 450d4ff5 ths
419 450d4ff5 ths
  {"bhs",
420 450d4ff5 ths
   BRANCH_QUICK_OPCODE+CC_HS*0x1000,
421 450d4ff5 ths
   0x0f00+(0xF-CC_HS)*0x1000,                  "o",             1, SIZE_NONE,     0,
422 450d4ff5 ths
   cris_eight_bit_offset_branch_op},
423 450d4ff5 ths
424 450d4ff5 ths
  {"biap", BIAP_OPCODE, BIAP_Z_BITS,          "pm r,R",  0, SIZE_NONE,
425 450d4ff5 ths
   cris_ver_v0_10,
426 450d4ff5 ths
   cris_biap_prefix},
427 450d4ff5 ths
428 450d4ff5 ths
  {"ble",
429 450d4ff5 ths
   BRANCH_QUICK_OPCODE+CC_LE*0x1000,
430 450d4ff5 ths
   0x0f00+(0xF-CC_LE)*0x1000,                  "o",             1, SIZE_NONE,     0,
431 450d4ff5 ths
   cris_eight_bit_offset_branch_op},
432 450d4ff5 ths
433 450d4ff5 ths
  {"blo",
434 450d4ff5 ths
   BRANCH_QUICK_OPCODE+CC_LO*0x1000,
435 450d4ff5 ths
   0x0f00+(0xF-CC_LO)*0x1000,                  "o",             1, SIZE_NONE,     0,
436 450d4ff5 ths
   cris_eight_bit_offset_branch_op},
437 450d4ff5 ths
438 450d4ff5 ths
  {"bls",
439 450d4ff5 ths
   BRANCH_QUICK_OPCODE+CC_LS*0x1000,
440 450d4ff5 ths
   0x0f00+(0xF-CC_LS)*0x1000,                  "o",             1, SIZE_NONE,     0,
441 450d4ff5 ths
   cris_eight_bit_offset_branch_op},
442 450d4ff5 ths
443 450d4ff5 ths
  {"blt",
444 450d4ff5 ths
   BRANCH_QUICK_OPCODE+CC_LT*0x1000,
445 450d4ff5 ths
   0x0f00+(0xF-CC_LT)*0x1000,                  "o",             1, SIZE_NONE,     0,
446 450d4ff5 ths
   cris_eight_bit_offset_branch_op},
447 450d4ff5 ths
448 450d4ff5 ths
  {"bmi",
449 450d4ff5 ths
   BRANCH_QUICK_OPCODE+CC_MI*0x1000,
450 450d4ff5 ths
   0x0f00+(0xF-CC_MI)*0x1000,                  "o",             1, SIZE_NONE,     0,
451 450d4ff5 ths
   cris_eight_bit_offset_branch_op},
452 450d4ff5 ths
453 450d4ff5 ths
  {"bmod",    0x0ab0, 0x0140,                  "s,R",     0, SIZE_FIX_32,
454 450d4ff5 ths
   cris_ver_sim_v0_10,
455 450d4ff5 ths
   cris_not_implemented_op},
456 450d4ff5 ths
457 450d4ff5 ths
  {"bmod",    0x0ab0, 0x0140,                  "S,D",     0, SIZE_NONE,
458 450d4ff5 ths
   cris_ver_sim_v0_10,
459 450d4ff5 ths
   cris_not_implemented_op},
460 450d4ff5 ths
461 450d4ff5 ths
  {"bmod",    0x0ab0, 0x0540,                  "S,R,r",   0, SIZE_NONE,
462 450d4ff5 ths
   cris_ver_sim_v0_10,
463 450d4ff5 ths
   cris_not_implemented_op},
464 450d4ff5 ths
465 450d4ff5 ths
  {"bne",
466 450d4ff5 ths
   BRANCH_QUICK_OPCODE+CC_NE*0x1000,
467 450d4ff5 ths
   0x0f00+(0xF-CC_NE)*0x1000,                  "o",             1, SIZE_NONE,     0,
468 450d4ff5 ths
   cris_eight_bit_offset_branch_op},
469 450d4ff5 ths
470 450d4ff5 ths
  {"bound",   0x05c0, 0x0A00,                  "m r,R",   0, SIZE_NONE,     0,
471 450d4ff5 ths
   cris_two_operand_bound_op},
472 450d4ff5 ths
  /* FIXME: SIZE_FIELD_UNSIGNED and all necessary changes.  */
473 450d4ff5 ths
  {"bound",   0x09c0, 0x0200,                  "m s,R",   0, SIZE_FIELD,
474 450d4ff5 ths
   cris_ver_v0_10,
475 450d4ff5 ths
   cris_two_operand_bound_op},
476 450d4ff5 ths
  /* FIXME: SIZE_FIELD_UNSIGNED and all necessary changes.  */
477 450d4ff5 ths
  {"bound",   0x0dcf, 0x0200,                  "m Y,R",   0, SIZE_FIELD,    0,
478 450d4ff5 ths
   cris_two_operand_bound_op},
479 450d4ff5 ths
  {"bound",   0x09c0, 0x0200,                  "m S,D",   0, SIZE_NONE,
480 450d4ff5 ths
   cris_ver_v0_10,
481 450d4ff5 ths
   cris_two_operand_bound_op},
482 450d4ff5 ths
  {"bound",   0x09c0, 0x0600,                  "m S,R,r", 0, SIZE_NONE,
483 450d4ff5 ths
   cris_ver_v0_10,
484 450d4ff5 ths
   cris_three_operand_bound_op},
485 450d4ff5 ths
486 450d4ff5 ths
  {"bpl",
487 450d4ff5 ths
   BRANCH_QUICK_OPCODE+CC_PL*0x1000,
488 450d4ff5 ths
   0x0f00+(0xF-CC_PL)*0x1000,                  "o",             1, SIZE_NONE,     0,
489 450d4ff5 ths
   cris_eight_bit_offset_branch_op},
490 450d4ff5 ths
491 450d4ff5 ths
  {"break",   0xe930, 0x16c0,                  "C",             0, SIZE_NONE,
492 450d4ff5 ths
   cris_ver_v3p,
493 450d4ff5 ths
   cris_break_op},
494 450d4ff5 ths
495 450d4ff5 ths
  {"bsb",
496 450d4ff5 ths
   BRANCH_QUICK_OPCODE+CC_EXT*0x1000,
497 450d4ff5 ths
   0x0f00+(0xF-CC_EXT)*0x1000,                  "o",             1, SIZE_NONE,
498 450d4ff5 ths
   cris_ver_v32p,
499 450d4ff5 ths
   cris_eight_bit_offset_branch_op},
500 450d4ff5 ths
501 450d4ff5 ths
  {"bsr",     0xBEBF, 0x4140,                  "n",             0, SIZE_FIX_32,
502 450d4ff5 ths
   cris_ver_v32p,
503 450d4ff5 ths
   cris_none_reg_mode_jump_op},
504 450d4ff5 ths
505 450d4ff5 ths
  {"bsrc",     0xBEFF, 0x4100,                  "n",             0, SIZE_FIX_32,
506 450d4ff5 ths
   cris_ver_v32p,
507 450d4ff5 ths
   cris_none_reg_mode_jump_op},
508 450d4ff5 ths
509 450d4ff5 ths
  {"bstore",  0x0af0, 0x0100,                  "s,R",     0, SIZE_FIX_32,
510 450d4ff5 ths
   cris_ver_warning,
511 450d4ff5 ths
   cris_not_implemented_op},
512 450d4ff5 ths
513 450d4ff5 ths
  {"bstore",  0x0af0, 0x0100,                  "S,D",     0, SIZE_NONE,
514 450d4ff5 ths
   cris_ver_warning,
515 450d4ff5 ths
   cris_not_implemented_op},
516 450d4ff5 ths
517 450d4ff5 ths
  {"bstore",  0x0af0, 0x0500,                  "S,R,r",   0, SIZE_NONE,
518 450d4ff5 ths
   cris_ver_warning,
519 450d4ff5 ths
   cris_not_implemented_op},
520 450d4ff5 ths
521 450d4ff5 ths
  {"btst",    0x04F0, 0x0B00,                  "r,R",     0, SIZE_NONE,     0,
522 450d4ff5 ths
   cris_btst_nop_op},
523 450d4ff5 ths
  {"btstq",   0x0380, 0x0C60,                  "c,R",     0, SIZE_NONE,     0,
524 450d4ff5 ths
   cris_btst_nop_op},
525 450d4ff5 ths
526 450d4ff5 ths
  {"bvc",
527 450d4ff5 ths
   BRANCH_QUICK_OPCODE+CC_VC*0x1000,
528 450d4ff5 ths
   0x0f00+(0xF-CC_VC)*0x1000,                  "o",             1, SIZE_NONE,     0,
529 450d4ff5 ths
   cris_eight_bit_offset_branch_op},
530 450d4ff5 ths
531 450d4ff5 ths
  {"bvs",
532 450d4ff5 ths
   BRANCH_QUICK_OPCODE+CC_VS*0x1000,
533 450d4ff5 ths
   0x0f00+(0xF-CC_VS)*0x1000,                  "o",             1, SIZE_NONE,     0,
534 450d4ff5 ths
   cris_eight_bit_offset_branch_op},
535 450d4ff5 ths
536 450d4ff5 ths
  {"clear",   0x0670, 0x3980,                  "M r",     0, SIZE_NONE,     0,
537 450d4ff5 ths
   cris_reg_mode_clear_op},
538 450d4ff5 ths
539 450d4ff5 ths
  {"clear",   0x0A70, 0x3180,                  "M y",     0, SIZE_NONE,     0,
540 450d4ff5 ths
   cris_none_reg_mode_clear_test_op},
541 450d4ff5 ths
542 450d4ff5 ths
  {"clear",   0x0A70, 0x3180,                  "M S",     0, SIZE_NONE,
543 450d4ff5 ths
   cris_ver_v0_10,
544 450d4ff5 ths
   cris_none_reg_mode_clear_test_op},
545 450d4ff5 ths
546 450d4ff5 ths
  {"clearf",  0x05F0, 0x0A00,                  "f",             0, SIZE_NONE,     0,
547 450d4ff5 ths
   cris_clearf_di_op},
548 450d4ff5 ths
549 450d4ff5 ths
  {"cmp",     0x06C0, 0x0900,                  "m r,R",   0, SIZE_NONE,     0,
550 450d4ff5 ths
   cris_reg_mode_add_sub_cmp_and_or_move_op},
551 450d4ff5 ths
552 450d4ff5 ths
  {"cmp",     0x0Ac0, 0x0100,                  "m s,R",   0, SIZE_FIELD,    0,
553 450d4ff5 ths
   cris_none_reg_mode_add_sub_cmp_and_or_move_op},
554 450d4ff5 ths
555 450d4ff5 ths
  {"cmp",     0x0Ac0, 0x0100,                  "m S,D",   0, SIZE_NONE,
556 450d4ff5 ths
   cris_ver_v0_10,
557 450d4ff5 ths
   cris_none_reg_mode_add_sub_cmp_and_or_move_op},
558 450d4ff5 ths
559 450d4ff5 ths
  {"cmpq",    0x02C0, 0x0D00,                  "i,R",     0, SIZE_NONE,     0,
560 450d4ff5 ths
   cris_quick_mode_and_cmp_move_or_op},
561 450d4ff5 ths
562 450d4ff5 ths
  /* FIXME: SIZE_FIELD_SIGNED and all necessary changes.  */
563 450d4ff5 ths
  {"cmps",    0x08e0, 0x0300,                  "z s,R",   0, SIZE_FIELD,    0,
564 450d4ff5 ths
   cris_none_reg_mode_add_sub_cmp_and_or_move_op},
565 450d4ff5 ths
566 450d4ff5 ths
  {"cmps",    0x08e0, 0x0300,                  "z S,D",   0, SIZE_NONE,
567 450d4ff5 ths
   cris_ver_v0_10,
568 450d4ff5 ths
   cris_none_reg_mode_add_sub_cmp_and_or_move_op},
569 450d4ff5 ths
570 450d4ff5 ths
  /* FIXME: SIZE_FIELD_UNSIGNED and all necessary changes.  */
571 450d4ff5 ths
  {"cmpu",    0x08c0, 0x0320,                  "z s,R" ,  0, SIZE_FIELD,    0,
572 450d4ff5 ths
   cris_none_reg_mode_add_sub_cmp_and_or_move_op},
573 450d4ff5 ths
574 450d4ff5 ths
  {"cmpu",    0x08c0, 0x0320,                  "z S,D",   0, SIZE_NONE,
575 450d4ff5 ths
   cris_ver_v0_10,
576 450d4ff5 ths
   cris_none_reg_mode_add_sub_cmp_and_or_move_op},
577 450d4ff5 ths
578 450d4ff5 ths
  {"di",      0x25F0, 0xDA0F,                  "",             0, SIZE_NONE,     0,
579 450d4ff5 ths
   cris_clearf_di_op},
580 450d4ff5 ths
581 450d4ff5 ths
  {"dip",     DIP_OPCODE, DIP_Z_BITS,          "ps",             0, SIZE_FIX_32,
582 450d4ff5 ths
   cris_ver_v0_10,
583 450d4ff5 ths
   cris_dip_prefix},
584 450d4ff5 ths
585 450d4ff5 ths
  {"div",     0x0980, 0x0640,                  "m R,r",   0, SIZE_FIELD,    0,
586 450d4ff5 ths
   cris_not_implemented_op},
587 450d4ff5 ths
588 450d4ff5 ths
  {"dstep",   0x06f0, 0x0900,                  "r,R",     0, SIZE_NONE,     0,
589 450d4ff5 ths
   cris_dstep_logshift_mstep_neg_not_op},
590 450d4ff5 ths
591 450d4ff5 ths
  {"ei",      0x25B0, 0xDA4F,                  "",             0, SIZE_NONE,     0,
592 450d4ff5 ths
   cris_ax_ei_setf_op},
593 450d4ff5 ths
594 450d4ff5 ths
  {"fidxd",    0x0ab0, 0xf540,                  "[r]",     0, SIZE_NONE,
595 450d4ff5 ths
   cris_ver_v32p,
596 450d4ff5 ths
   cris_not_implemented_op},
597 450d4ff5 ths
598 450d4ff5 ths
  {"fidxi",    0x0d30, 0xF2C0,                  "[r]",     0, SIZE_NONE,
599 450d4ff5 ths
   cris_ver_v32p,
600 450d4ff5 ths
   cris_not_implemented_op},
601 450d4ff5 ths
602 450d4ff5 ths
  {"ftagd",    0x1AB0, 0xE540,                  "[r]",     0, SIZE_NONE,
603 450d4ff5 ths
   cris_ver_v32p,
604 450d4ff5 ths
   cris_not_implemented_op},
605 450d4ff5 ths
606 450d4ff5 ths
  {"ftagi",    0x1D30, 0xE2C0,                  "[r]",     0, SIZE_NONE,
607 450d4ff5 ths
   cris_ver_v32p,
608 450d4ff5 ths
   cris_not_implemented_op},
609 450d4ff5 ths
610 450d4ff5 ths
  {"halt",    0xF930, 0x06CF,                  "",             0, SIZE_NONE,
611 450d4ff5 ths
   cris_ver_v32p,
612 450d4ff5 ths
   cris_not_implemented_op},
613 450d4ff5 ths
614 450d4ff5 ths
  {"jas",    0x09B0, 0x0640,                  "r,P",     0, SIZE_NONE,
615 450d4ff5 ths
   cris_ver_v32p,
616 450d4ff5 ths
   cris_reg_mode_jump_op},
617 450d4ff5 ths
618 450d4ff5 ths
  {"jas",    0x0DBF, 0x0240,                  "N,P",     0, SIZE_FIX_32,
619 450d4ff5 ths
   cris_ver_v32p,
620 450d4ff5 ths
   cris_reg_mode_jump_op},
621 450d4ff5 ths
622 450d4ff5 ths
  {"jasc",    0x0B30, 0x04C0,                  "r,P",     0, SIZE_NONE,
623 450d4ff5 ths
   cris_ver_v32p,
624 450d4ff5 ths
   cris_reg_mode_jump_op},
625 450d4ff5 ths
626 450d4ff5 ths
  {"jasc",    0x0F3F, 0x00C0,                  "N,P",     0, SIZE_FIX_32,
627 450d4ff5 ths
   cris_ver_v32p,
628 450d4ff5 ths
   cris_reg_mode_jump_op},
629 450d4ff5 ths
630 450d4ff5 ths
  {"jbrc",    0x69b0, 0x9640,                  "r",             0, SIZE_NONE,
631 450d4ff5 ths
   cris_ver_v8_10,
632 450d4ff5 ths
   cris_reg_mode_jump_op},
633 450d4ff5 ths
634 450d4ff5 ths
  {"jbrc",    0x6930, 0x92c0,                  "s",             0, SIZE_FIX_32,
635 450d4ff5 ths
   cris_ver_v8_10,
636 450d4ff5 ths
   cris_none_reg_mode_jump_op},
637 450d4ff5 ths
638 450d4ff5 ths
  {"jbrc",    0x6930, 0x92c0,                  "S",             0, SIZE_NONE,
639 450d4ff5 ths
   cris_ver_v8_10,
640 450d4ff5 ths
   cris_none_reg_mode_jump_op},
641 450d4ff5 ths
642 450d4ff5 ths
  {"jir",     0xA9b0, 0x5640,                  "r",             0, SIZE_NONE,
643 450d4ff5 ths
   cris_ver_v8_10,
644 450d4ff5 ths
   cris_reg_mode_jump_op},
645 450d4ff5 ths
646 450d4ff5 ths
  {"jir",     0xA930, 0x52c0,                  "s",             0, SIZE_FIX_32,
647 450d4ff5 ths
   cris_ver_v8_10,
648 450d4ff5 ths
   cris_none_reg_mode_jump_op},
649 450d4ff5 ths
650 450d4ff5 ths
  {"jir",     0xA930, 0x52c0,                  "S",             0, SIZE_NONE,
651 450d4ff5 ths
   cris_ver_v8_10,
652 450d4ff5 ths
   cris_none_reg_mode_jump_op},
653 450d4ff5 ths
654 450d4ff5 ths
  {"jirc",    0x29b0, 0xd640,                  "r",             0, SIZE_NONE,
655 450d4ff5 ths
   cris_ver_v8_10,
656 450d4ff5 ths
   cris_reg_mode_jump_op},
657 450d4ff5 ths
658 450d4ff5 ths
  {"jirc",    0x2930, 0xd2c0,                  "s",             0, SIZE_FIX_32,
659 450d4ff5 ths
   cris_ver_v8_10,
660 450d4ff5 ths
   cris_none_reg_mode_jump_op},
661 450d4ff5 ths
662 450d4ff5 ths
  {"jirc",    0x2930, 0xd2c0,                  "S",             0, SIZE_NONE,
663 450d4ff5 ths
   cris_ver_v8_10,
664 450d4ff5 ths
   cris_none_reg_mode_jump_op},
665 450d4ff5 ths
666 450d4ff5 ths
  {"jsr",     0xB9b0, 0x4640,                  "r",             0, SIZE_NONE,     0,
667 450d4ff5 ths
   cris_reg_mode_jump_op},
668 450d4ff5 ths
669 450d4ff5 ths
  {"jsr",     0xB930, 0x42c0,                  "s",             0, SIZE_FIX_32,
670 450d4ff5 ths
   cris_ver_v0_10,
671 450d4ff5 ths
   cris_none_reg_mode_jump_op},
672 450d4ff5 ths
673 450d4ff5 ths
  {"jsr",     0xBDBF, 0x4240,                  "N",             0, SIZE_FIX_32,
674 450d4ff5 ths
   cris_ver_v32p,
675 450d4ff5 ths
   cris_none_reg_mode_jump_op},
676 450d4ff5 ths
677 450d4ff5 ths
  {"jsr",     0xB930, 0x42c0,                  "S",             0, SIZE_NONE,
678 450d4ff5 ths
   cris_ver_v0_10,
679 450d4ff5 ths
   cris_none_reg_mode_jump_op},
680 450d4ff5 ths
681 450d4ff5 ths
  {"jsrc",    0x39b0, 0xc640,                  "r",             0, SIZE_NONE,
682 450d4ff5 ths
   cris_ver_v8_10,
683 450d4ff5 ths
   cris_reg_mode_jump_op},
684 450d4ff5 ths
685 450d4ff5 ths
  {"jsrc",    0x3930, 0xc2c0,                  "s",             0, SIZE_FIX_32,
686 450d4ff5 ths
   cris_ver_v8_10,
687 450d4ff5 ths
   cris_none_reg_mode_jump_op},
688 450d4ff5 ths
689 450d4ff5 ths
  {"jsrc",    0x3930, 0xc2c0,                  "S",             0, SIZE_NONE,
690 450d4ff5 ths
   cris_ver_v8_10,
691 450d4ff5 ths
   cris_none_reg_mode_jump_op},
692 450d4ff5 ths
693 450d4ff5 ths
  {"jsrc",    0xBB30, 0x44C0,                  "r",       0, SIZE_NONE,
694 450d4ff5 ths
   cris_ver_v32p,
695 450d4ff5 ths
   cris_reg_mode_jump_op},
696 450d4ff5 ths
697 450d4ff5 ths
  {"jsrc",    0xBF3F, 0x40C0,                  "N",             0, SIZE_FIX_32,
698 450d4ff5 ths
   cris_ver_v32p,
699 450d4ff5 ths
   cris_reg_mode_jump_op},
700 450d4ff5 ths
701 450d4ff5 ths
  {"jump",    0x09b0, 0xF640,                  "r",             0, SIZE_NONE,     0,
702 450d4ff5 ths
   cris_reg_mode_jump_op},
703 450d4ff5 ths
704 450d4ff5 ths
  {"jump",
705 450d4ff5 ths
   JUMP_INDIR_OPCODE, JUMP_INDIR_Z_BITS,  "s",             0, SIZE_FIX_32,
706 450d4ff5 ths
   cris_ver_v0_10,
707 450d4ff5 ths
   cris_none_reg_mode_jump_op},
708 450d4ff5 ths
709 450d4ff5 ths
  {"jump",
710 450d4ff5 ths
   JUMP_INDIR_OPCODE, JUMP_INDIR_Z_BITS,  "S",             0, SIZE_NONE,
711 450d4ff5 ths
   cris_ver_v0_10,
712 450d4ff5 ths
   cris_none_reg_mode_jump_op},
713 450d4ff5 ths
714 450d4ff5 ths
  {"jump",    0x09F0, 0x060F,                  "P",             0, SIZE_NONE,
715 450d4ff5 ths
   cris_ver_v32p,
716 450d4ff5 ths
   cris_none_reg_mode_jump_op},
717 450d4ff5 ths
718 450d4ff5 ths
  {"jump",
719 450d4ff5 ths
   JUMP_PC_INCR_OPCODE_V32,
720 450d4ff5 ths
   (0xffff & ~JUMP_PC_INCR_OPCODE_V32),          "N",             0, SIZE_FIX_32,
721 450d4ff5 ths
   cris_ver_v32p,
722 450d4ff5 ths
   cris_none_reg_mode_jump_op},
723 450d4ff5 ths
724 450d4ff5 ths
  {"jmpu",    0x8930, 0x72c0,                  "s",             0, SIZE_FIX_32,
725 450d4ff5 ths
   cris_ver_v10,
726 450d4ff5 ths
   cris_none_reg_mode_jump_op},
727 450d4ff5 ths
728 450d4ff5 ths
  {"jmpu",    0x8930, 0x72c0,                   "S",             0, SIZE_NONE,
729 450d4ff5 ths
   cris_ver_v10,
730 450d4ff5 ths
   cris_none_reg_mode_jump_op},
731 450d4ff5 ths
732 450d4ff5 ths
  {"lapc",    0x0970, 0x0680,                  "U,R",    0, SIZE_NONE,
733 450d4ff5 ths
   cris_ver_v32p,
734 450d4ff5 ths
   cris_not_implemented_op},
735 450d4ff5 ths
736 450d4ff5 ths
  {"lapc",    0x0D7F, 0x0280,                  "dn,R",    0, SIZE_FIX_32,
737 450d4ff5 ths
   cris_ver_v32p,
738 450d4ff5 ths
   cris_not_implemented_op},
739 450d4ff5 ths
740 450d4ff5 ths
  {"lapcq",   0x0970, 0x0680,                  "u,R",     0, SIZE_NONE,
741 450d4ff5 ths
   cris_ver_v32p,
742 450d4ff5 ths
   cris_addi_op},
743 450d4ff5 ths
744 450d4ff5 ths
  {"lsl",     0x04C0, 0x0B00,                  "m r,R",   0, SIZE_NONE,     0,
745 450d4ff5 ths
   cris_dstep_logshift_mstep_neg_not_op},
746 450d4ff5 ths
747 450d4ff5 ths
  {"lslq",    0x03c0, 0x0C20,                  "c,R",     0, SIZE_NONE,     0,
748 450d4ff5 ths
   cris_dstep_logshift_mstep_neg_not_op},
749 450d4ff5 ths
750 450d4ff5 ths
  {"lsr",     0x07C0, 0x0800,                  "m r,R",   0, SIZE_NONE,     0,
751 450d4ff5 ths
   cris_dstep_logshift_mstep_neg_not_op},
752 450d4ff5 ths
753 450d4ff5 ths
  {"lsrq",    0x03e0, 0x0C00,                  "c,R",     0, SIZE_NONE,     0,
754 450d4ff5 ths
   cris_dstep_logshift_mstep_neg_not_op},
755 450d4ff5 ths
756 450d4ff5 ths
  {"lz",      0x0730, 0x08C0,                  "r,R",     0, SIZE_NONE,
757 450d4ff5 ths
   cris_ver_v3p,
758 450d4ff5 ths
   cris_not_implemented_op},
759 450d4ff5 ths
760 450d4ff5 ths
  {"mcp",      0x07f0, 0x0800,                  "P,r",     0, SIZE_NONE,
761 450d4ff5 ths
   cris_ver_v32p,
762 450d4ff5 ths
   cris_not_implemented_op},
763 450d4ff5 ths
764 450d4ff5 ths
  {"move",    0x0640, 0x0980,                  "m r,R",   0, SIZE_NONE,     0,
765 450d4ff5 ths
   cris_reg_mode_add_sub_cmp_and_or_move_op},
766 450d4ff5 ths
767 450d4ff5 ths
  {"move",    0x0A40, 0x0180,                  "m s,R",   0, SIZE_FIELD,    0,
768 450d4ff5 ths
   cris_none_reg_mode_add_sub_cmp_and_or_move_op},
769 450d4ff5 ths
770 450d4ff5 ths
  {"move",    0x0A40, 0x0180,                  "m S,D",   0, SIZE_NONE,
771 450d4ff5 ths
   cris_ver_v0_10,
772 450d4ff5 ths
   cris_none_reg_mode_add_sub_cmp_and_or_move_op},
773 450d4ff5 ths
774 450d4ff5 ths
  {"move",    0x0630, 0x09c0,                  "r,P",     0, SIZE_NONE,     0,
775 450d4ff5 ths
   cris_move_to_preg_op},
776 450d4ff5 ths
777 450d4ff5 ths
  {"move",    0x0670, 0x0980,                  "P,r",     0, SIZE_NONE,     0,
778 450d4ff5 ths
   cris_reg_mode_move_from_preg_op},
779 450d4ff5 ths
780 450d4ff5 ths
  {"move",    0x0BC0, 0x0000,                  "m R,y",   0, SIZE_FIELD,    0,
781 450d4ff5 ths
   cris_none_reg_mode_add_sub_cmp_and_or_move_op},
782 450d4ff5 ths
783 450d4ff5 ths
  {"move",    0x0BC0, 0x0000,                  "m D,S",   0, SIZE_NONE,
784 450d4ff5 ths
   cris_ver_v0_10,
785 450d4ff5 ths
   cris_none_reg_mode_add_sub_cmp_and_or_move_op},
786 450d4ff5 ths
787 450d4ff5 ths
  {"move",
788 450d4ff5 ths
   MOVE_M_TO_PREG_OPCODE, MOVE_M_TO_PREG_ZBITS,
789 450d4ff5 ths
   "s,P",   0, SIZE_SPEC_REG, 0,
790 450d4ff5 ths
   cris_move_to_preg_op},
791 450d4ff5 ths
792 450d4ff5 ths
  {"move",    0x0A30, 0x01c0,                  "S,P",     0, SIZE_NONE,
793 450d4ff5 ths
   cris_ver_v0_10,
794 450d4ff5 ths
   cris_move_to_preg_op},
795 450d4ff5 ths
796 450d4ff5 ths
  {"move",    0x0A70, 0x0180,                  "P,y",     0, SIZE_SPEC_REG, 0,
797 450d4ff5 ths
   cris_none_reg_mode_move_from_preg_op},
798 450d4ff5 ths
799 450d4ff5 ths
  {"move",    0x0A70, 0x0180,                  "P,S",     0, SIZE_NONE,
800 450d4ff5 ths
   cris_ver_v0_10,
801 450d4ff5 ths
   cris_none_reg_mode_move_from_preg_op},
802 450d4ff5 ths
803 450d4ff5 ths
  {"move",    0x0B70, 0x0480,                  "r,T",     0, SIZE_NONE,
804 450d4ff5 ths
   cris_ver_v32p,
805 450d4ff5 ths
   cris_not_implemented_op},
806 450d4ff5 ths
807 450d4ff5 ths
  {"move",    0x0F70, 0x0080,                  "T,r",     0, SIZE_NONE,
808 450d4ff5 ths
   cris_ver_v32p,
809 450d4ff5 ths
   cris_not_implemented_op},
810 450d4ff5 ths
811 450d4ff5 ths
  {"movem",   0x0BF0, 0x0000,                  "R,y",     0, SIZE_FIX_32,   0,
812 450d4ff5 ths
   cris_move_reg_to_mem_movem_op},
813 450d4ff5 ths
814 450d4ff5 ths
  {"movem",   0x0BF0, 0x0000,                  "D,S",     0, SIZE_NONE,
815 450d4ff5 ths
   cris_ver_v0_10,
816 450d4ff5 ths
   cris_move_reg_to_mem_movem_op},
817 450d4ff5 ths
818 450d4ff5 ths
  {"movem",   0x0BB0, 0x0040,                  "s,R",     0, SIZE_FIX_32,   0,
819 450d4ff5 ths
   cris_move_mem_to_reg_movem_op},
820 450d4ff5 ths
821 450d4ff5 ths
  {"movem",   0x0BB0, 0x0040,                  "S,D",     0, SIZE_NONE,
822 450d4ff5 ths
   cris_ver_v0_10,
823 450d4ff5 ths
   cris_move_mem_to_reg_movem_op},
824 450d4ff5 ths
825 450d4ff5 ths
  {"moveq",   0x0240, 0x0D80,                  "i,R",     0, SIZE_NONE,     0,
826 450d4ff5 ths
   cris_quick_mode_and_cmp_move_or_op},
827 450d4ff5 ths
828 450d4ff5 ths
  {"movs",    0x0460, 0x0B80,                  "z r,R",   0, SIZE_NONE,     0,
829 450d4ff5 ths
   cris_reg_mode_add_sub_cmp_and_or_move_op},
830 450d4ff5 ths
831 450d4ff5 ths
  /* FIXME: SIZE_FIELD_SIGNED and all necessary changes.  */
832 450d4ff5 ths
  {"movs",    0x0860, 0x0380,                  "z s,R",   0, SIZE_FIELD,    0,
833 450d4ff5 ths
   cris_none_reg_mode_add_sub_cmp_and_or_move_op},
834 450d4ff5 ths
835 450d4ff5 ths
  {"movs",    0x0860, 0x0380,                  "z S,D",   0, SIZE_NONE,
836 450d4ff5 ths
   cris_ver_v0_10,
837 450d4ff5 ths
   cris_none_reg_mode_add_sub_cmp_and_or_move_op},
838 450d4ff5 ths
839 450d4ff5 ths
  {"movu",    0x0440, 0x0Ba0,                  "z r,R",   0, SIZE_NONE,     0,
840 450d4ff5 ths
   cris_reg_mode_add_sub_cmp_and_or_move_op},
841 450d4ff5 ths
842 450d4ff5 ths
  /* FIXME: SIZE_FIELD_UNSIGNED and all necessary changes.  */
843 450d4ff5 ths
  {"movu",    0x0840, 0x03a0,                  "z s,R",   0, SIZE_FIELD,    0,
844 450d4ff5 ths
   cris_none_reg_mode_add_sub_cmp_and_or_move_op},
845 450d4ff5 ths
846 450d4ff5 ths
  {"movu",    0x0840, 0x03a0,                  "z S,D",   0, SIZE_NONE,
847 450d4ff5 ths
   cris_ver_v0_10,
848 450d4ff5 ths
   cris_none_reg_mode_add_sub_cmp_and_or_move_op},
849 450d4ff5 ths
850 450d4ff5 ths
  {"mstep",   0x07f0, 0x0800,                  "r,R",     0, SIZE_NONE,
851 450d4ff5 ths
   cris_ver_v0_10,
852 450d4ff5 ths
   cris_dstep_logshift_mstep_neg_not_op},
853 450d4ff5 ths
854 450d4ff5 ths
  {"muls",    0x0d00, 0x02c0,                  "m r,R",   0, SIZE_NONE,
855 450d4ff5 ths
   cris_ver_v10p,
856 450d4ff5 ths
   cris_muls_op},
857 450d4ff5 ths
858 450d4ff5 ths
  {"mulu",    0x0900, 0x06c0,                  "m r,R",   0, SIZE_NONE,
859 450d4ff5 ths
   cris_ver_v10p,
860 450d4ff5 ths
   cris_mulu_op},
861 450d4ff5 ths
862 450d4ff5 ths
  {"neg",     0x0580, 0x0A40,                  "m r,R",   0, SIZE_NONE,     0,
863 450d4ff5 ths
   cris_dstep_logshift_mstep_neg_not_op},
864 450d4ff5 ths
865 450d4ff5 ths
  {"nop",     NOP_OPCODE, NOP_Z_BITS,          "",             0, SIZE_NONE,
866 450d4ff5 ths
   cris_ver_v0_10,
867 450d4ff5 ths
   cris_btst_nop_op},
868 450d4ff5 ths
869 450d4ff5 ths
  {"nop",     NOP_OPCODE_V32, NOP_Z_BITS_V32, "",    0, SIZE_NONE,
870 450d4ff5 ths
   cris_ver_v32p,
871 450d4ff5 ths
   cris_btst_nop_op},
872 450d4ff5 ths
873 450d4ff5 ths
  {"not",     0x8770, 0x7880,                  "r",             0, SIZE_NONE,     0,
874 450d4ff5 ths
   cris_dstep_logshift_mstep_neg_not_op},
875 450d4ff5 ths
876 450d4ff5 ths
  {"or",      0x0740, 0x0880,                  "m r,R",   0, SIZE_NONE,     0,
877 450d4ff5 ths
   cris_reg_mode_add_sub_cmp_and_or_move_op},
878 450d4ff5 ths
879 450d4ff5 ths
  {"or",      0x0B40, 0x0080,                  "m s,R",   0, SIZE_FIELD,    0,
880 450d4ff5 ths
   cris_none_reg_mode_add_sub_cmp_and_or_move_op},
881 450d4ff5 ths
882 450d4ff5 ths
  {"or",      0x0B40, 0x0080,                  "m S,D",   0, SIZE_NONE,
883 450d4ff5 ths
   cris_ver_v0_10,
884 450d4ff5 ths
   cris_none_reg_mode_add_sub_cmp_and_or_move_op},
885 450d4ff5 ths
886 450d4ff5 ths
  {"or",      0x0B40, 0x0480,                  "m S,R,r", 0, SIZE_NONE,
887 450d4ff5 ths
   cris_ver_v0_10,
888 450d4ff5 ths
   cris_three_operand_add_sub_cmp_and_or_op},
889 450d4ff5 ths
890 450d4ff5 ths
  {"orq",     0x0340, 0x0C80,                  "i,R",     0, SIZE_NONE,     0,
891 450d4ff5 ths
   cris_quick_mode_and_cmp_move_or_op},
892 450d4ff5 ths
893 450d4ff5 ths
  {"pop",     0x0E6E, 0x0191,                  "!R",             0, SIZE_NONE,
894 450d4ff5 ths
   cris_ver_v0_10,
895 450d4ff5 ths
   cris_none_reg_mode_add_sub_cmp_and_or_move_op},
896 450d4ff5 ths
897 450d4ff5 ths
  {"pop",     0x0e3e, 0x01c1,                  "!P",             0, SIZE_NONE,
898 450d4ff5 ths
   cris_ver_v0_10,
899 450d4ff5 ths
   cris_none_reg_mode_move_from_preg_op},
900 450d4ff5 ths
901 450d4ff5 ths
  {"push",    0x0FEE, 0x0011,                  "BR",             0, SIZE_NONE,
902 450d4ff5 ths
   cris_ver_v0_10,
903 450d4ff5 ths
   cris_none_reg_mode_add_sub_cmp_and_or_move_op},
904 450d4ff5 ths
905 450d4ff5 ths
  {"push",    0x0E7E, 0x0181,                  "BP",             0, SIZE_NONE,
906 450d4ff5 ths
   cris_ver_v0_10,
907 450d4ff5 ths
   cris_move_to_preg_op},
908 450d4ff5 ths
909 450d4ff5 ths
  {"rbf",     0x3b30, 0xc0c0,                  "y",             0, SIZE_NONE,
910 450d4ff5 ths
   cris_ver_v10,
911 450d4ff5 ths
   cris_not_implemented_op},
912 450d4ff5 ths
913 450d4ff5 ths
  {"rbf",     0x3b30, 0xc0c0,                  "S",             0, SIZE_NONE,
914 450d4ff5 ths
   cris_ver_v10,
915 450d4ff5 ths
   cris_not_implemented_op},
916 450d4ff5 ths
917 450d4ff5 ths
  {"rfe",     0x2930, 0xD6CF,                  "",             0, SIZE_NONE,
918 450d4ff5 ths
   cris_ver_v32p,
919 450d4ff5 ths
   cris_not_implemented_op},
920 450d4ff5 ths
921 450d4ff5 ths
  {"rfg",     0x4930, 0xB6CF,                  "",             0, SIZE_NONE,
922 450d4ff5 ths
   cris_ver_v32p,
923 450d4ff5 ths
   cris_not_implemented_op},
924 450d4ff5 ths
925 450d4ff5 ths
  {"rfn",     0x5930, 0xA6CF,                  "",             0, SIZE_NONE,
926 450d4ff5 ths
   cris_ver_v32p,
927 450d4ff5 ths
   cris_not_implemented_op},
928 450d4ff5 ths
929 450d4ff5 ths
  {"ret",     0xB67F, 0x4980,                  "",             1, SIZE_NONE,
930 450d4ff5 ths
   cris_ver_v0_10,
931 450d4ff5 ths
   cris_reg_mode_move_from_preg_op},
932 450d4ff5 ths
933 450d4ff5 ths
  {"ret",     0xB9F0, 0x460F,                  "",             1, SIZE_NONE,
934 450d4ff5 ths
   cris_ver_v32p,
935 450d4ff5 ths
   cris_reg_mode_move_from_preg_op},
936 450d4ff5 ths
937 450d4ff5 ths
  {"retb",    0xe67f, 0x1980,                  "",             1, SIZE_NONE,
938 450d4ff5 ths
   cris_ver_v0_10,
939 450d4ff5 ths
   cris_reg_mode_move_from_preg_op},
940 450d4ff5 ths
941 450d4ff5 ths
  {"rete",     0xA9F0, 0x560F,                  "",             1, SIZE_NONE,
942 450d4ff5 ths
   cris_ver_v32p,
943 450d4ff5 ths
   cris_reg_mode_move_from_preg_op},
944 450d4ff5 ths
945 450d4ff5 ths
  {"reti",    0xA67F, 0x5980,                  "",             1, SIZE_NONE,
946 450d4ff5 ths
   cris_ver_v0_10,
947 450d4ff5 ths
   cris_reg_mode_move_from_preg_op},
948 450d4ff5 ths
949 450d4ff5 ths
  {"retn",     0xC9F0, 0x360F,                  "",             1, SIZE_NONE,
950 450d4ff5 ths
   cris_ver_v32p,
951 450d4ff5 ths
   cris_reg_mode_move_from_preg_op},
952 450d4ff5 ths
953 450d4ff5 ths
  {"sbfs",    0x3b70, 0xc080,                  "y",             0, SIZE_NONE,
954 450d4ff5 ths
   cris_ver_v10,
955 450d4ff5 ths
   cris_not_implemented_op},
956 450d4ff5 ths
957 450d4ff5 ths
  {"sbfs",    0x3b70, 0xc080,                  "S",             0, SIZE_NONE,
958 450d4ff5 ths
   cris_ver_v10,
959 450d4ff5 ths
   cris_not_implemented_op},
960 450d4ff5 ths
961 450d4ff5 ths
  {"sa",
962 450d4ff5 ths
   0x0530+CC_A*0x1000,
963 450d4ff5 ths
   0x0AC0+(0xf-CC_A)*0x1000,                  "r",             0, SIZE_NONE,     0,
964 450d4ff5 ths
   cris_scc_op},
965 450d4ff5 ths
966 450d4ff5 ths
  {"ssb",
967 450d4ff5 ths
   0x0530+CC_EXT*0x1000,
968 450d4ff5 ths
   0x0AC0+(0xf-CC_EXT)*0x1000,                  "r",             0, SIZE_NONE,
969 450d4ff5 ths
   cris_ver_v32p,
970 450d4ff5 ths
   cris_scc_op},
971 450d4ff5 ths
972 450d4ff5 ths
  {"scc",
973 450d4ff5 ths
   0x0530+CC_CC*0x1000,
974 450d4ff5 ths
   0x0AC0+(0xf-CC_CC)*0x1000,                  "r",             0, SIZE_NONE,     0,
975 450d4ff5 ths
   cris_scc_op},
976 450d4ff5 ths
977 450d4ff5 ths
  {"scs",
978 450d4ff5 ths
   0x0530+CC_CS*0x1000,
979 450d4ff5 ths
   0x0AC0+(0xf-CC_CS)*0x1000,                  "r",             0, SIZE_NONE,     0,
980 450d4ff5 ths
   cris_scc_op},
981 450d4ff5 ths
982 450d4ff5 ths
  {"seq",
983 450d4ff5 ths
   0x0530+CC_EQ*0x1000,
984 450d4ff5 ths
   0x0AC0+(0xf-CC_EQ)*0x1000,                  "r",             0, SIZE_NONE,     0,
985 450d4ff5 ths
   cris_scc_op},
986 450d4ff5 ths
987 450d4ff5 ths
  {"setf",    0x05b0, 0x0A40,                  "f",             0, SIZE_NONE,     0,
988 450d4ff5 ths
   cris_ax_ei_setf_op},
989 450d4ff5 ths
990 450d4ff5 ths
  {"sfe",    0x3930, 0xC6CF,                  "",             0, SIZE_NONE,
991 450d4ff5 ths
   cris_ver_v32p,
992 450d4ff5 ths
   cris_not_implemented_op},
993 450d4ff5 ths
994 450d4ff5 ths
  /* Need to have "swf" in front of "sext" so it is the one displayed in
995 450d4ff5 ths
     disassembly.  */
996 450d4ff5 ths
  {"swf",
997 450d4ff5 ths
   0x0530+CC_EXT*0x1000,
998 450d4ff5 ths
   0x0AC0+(0xf-CC_EXT)*0x1000,                  "r",             0, SIZE_NONE,
999 450d4ff5 ths
   cris_ver_v10,
1000 450d4ff5 ths
   cris_scc_op},
1001 450d4ff5 ths
1002 450d4ff5 ths
  {"sext",
1003 450d4ff5 ths
   0x0530+CC_EXT*0x1000,
1004 450d4ff5 ths
   0x0AC0+(0xf-CC_EXT)*0x1000,                  "r",             0, SIZE_NONE,
1005 450d4ff5 ths
   cris_ver_v0_3,
1006 450d4ff5 ths
   cris_scc_op},
1007 450d4ff5 ths
1008 450d4ff5 ths
  {"sge",
1009 450d4ff5 ths
   0x0530+CC_GE*0x1000,
1010 450d4ff5 ths
   0x0AC0+(0xf-CC_GE)*0x1000,                  "r",             0, SIZE_NONE,     0,
1011 450d4ff5 ths
   cris_scc_op},
1012 450d4ff5 ths
1013 450d4ff5 ths
  {"sgt",
1014 450d4ff5 ths
   0x0530+CC_GT*0x1000,
1015 450d4ff5 ths
   0x0AC0+(0xf-CC_GT)*0x1000,                  "r",             0, SIZE_NONE,     0,
1016 450d4ff5 ths
   cris_scc_op},
1017 450d4ff5 ths
1018 450d4ff5 ths
  {"shi",
1019 450d4ff5 ths
   0x0530+CC_HI*0x1000,
1020 450d4ff5 ths
   0x0AC0+(0xf-CC_HI)*0x1000,                  "r",             0, SIZE_NONE,     0,
1021 450d4ff5 ths
   cris_scc_op},
1022 450d4ff5 ths
1023 450d4ff5 ths
  {"shs",
1024 450d4ff5 ths
   0x0530+CC_HS*0x1000,
1025 450d4ff5 ths
   0x0AC0+(0xf-CC_HS)*0x1000,                  "r",             0, SIZE_NONE,     0,
1026 450d4ff5 ths
   cris_scc_op},
1027 450d4ff5 ths
1028 450d4ff5 ths
  {"sle",
1029 450d4ff5 ths
   0x0530+CC_LE*0x1000,
1030 450d4ff5 ths
   0x0AC0+(0xf-CC_LE)*0x1000,                  "r",             0, SIZE_NONE,     0,
1031 450d4ff5 ths
   cris_scc_op},
1032 450d4ff5 ths
1033 450d4ff5 ths
  {"slo",
1034 450d4ff5 ths
   0x0530+CC_LO*0x1000,
1035 450d4ff5 ths
   0x0AC0+(0xf-CC_LO)*0x1000,                  "r",             0, SIZE_NONE,     0,
1036 450d4ff5 ths
   cris_scc_op},
1037 450d4ff5 ths
1038 450d4ff5 ths
  {"sls",
1039 450d4ff5 ths
   0x0530+CC_LS*0x1000,
1040 450d4ff5 ths
   0x0AC0+(0xf-CC_LS)*0x1000,                  "r",             0, SIZE_NONE,     0,
1041 450d4ff5 ths
   cris_scc_op},
1042 450d4ff5 ths
1043 450d4ff5 ths
  {"slt",
1044 450d4ff5 ths
   0x0530+CC_LT*0x1000,
1045 450d4ff5 ths
   0x0AC0+(0xf-CC_LT)*0x1000,                  "r",             0, SIZE_NONE,     0,
1046 450d4ff5 ths
   cris_scc_op},
1047 450d4ff5 ths
1048 450d4ff5 ths
  {"smi",
1049 450d4ff5 ths
   0x0530+CC_MI*0x1000,
1050 450d4ff5 ths
   0x0AC0+(0xf-CC_MI)*0x1000,                  "r",             0, SIZE_NONE,     0,
1051 450d4ff5 ths
   cris_scc_op},
1052 450d4ff5 ths
1053 450d4ff5 ths
  {"sne",
1054 450d4ff5 ths
   0x0530+CC_NE*0x1000,
1055 450d4ff5 ths
   0x0AC0+(0xf-CC_NE)*0x1000,                  "r",             0, SIZE_NONE,     0,
1056 450d4ff5 ths
   cris_scc_op},
1057 450d4ff5 ths
1058 450d4ff5 ths
  {"spl",
1059 450d4ff5 ths
   0x0530+CC_PL*0x1000,
1060 450d4ff5 ths
   0x0AC0+(0xf-CC_PL)*0x1000,                  "r",             0, SIZE_NONE,     0,
1061 450d4ff5 ths
   cris_scc_op},
1062 450d4ff5 ths
1063 450d4ff5 ths
  {"sub",     0x0680, 0x0940,                  "m r,R",   0, SIZE_NONE,     0,
1064 450d4ff5 ths
   cris_reg_mode_add_sub_cmp_and_or_move_op},
1065 450d4ff5 ths
1066 450d4ff5 ths
  {"sub",     0x0a80, 0x0140,                  "m s,R",   0, SIZE_FIELD,    0,
1067 450d4ff5 ths
   cris_none_reg_mode_add_sub_cmp_and_or_move_op},
1068 450d4ff5 ths
1069 450d4ff5 ths
  {"sub",     0x0a80, 0x0140,                  "m S,D",   0, SIZE_NONE,
1070 450d4ff5 ths
   cris_ver_v0_10,
1071 450d4ff5 ths
   cris_none_reg_mode_add_sub_cmp_and_or_move_op},
1072 450d4ff5 ths
1073 450d4ff5 ths
  {"sub",     0x0a80, 0x0540,                  "m S,R,r", 0, SIZE_NONE,
1074 450d4ff5 ths
   cris_ver_v0_10,
1075 450d4ff5 ths
   cris_three_operand_add_sub_cmp_and_or_op},
1076 450d4ff5 ths
1077 450d4ff5 ths
  {"subq",    0x0280, 0x0d40,                  "I,R",     0, SIZE_NONE,     0,
1078 450d4ff5 ths
   cris_quick_mode_add_sub_op},
1079 450d4ff5 ths
1080 450d4ff5 ths
  {"subs",    0x04a0, 0x0b40,                  "z r,R",   0, SIZE_NONE,     0,
1081 450d4ff5 ths
   cris_reg_mode_add_sub_cmp_and_or_move_op},
1082 450d4ff5 ths
1083 450d4ff5 ths
  /* FIXME: SIZE_FIELD_SIGNED and all necessary changes.  */
1084 450d4ff5 ths
  {"subs",    0x08a0, 0x0340,                  "z s,R",   0, SIZE_FIELD,    0,
1085 450d4ff5 ths
   cris_none_reg_mode_add_sub_cmp_and_or_move_op},
1086 450d4ff5 ths
1087 450d4ff5 ths
  {"subs",    0x08a0, 0x0340,                  "z S,D",   0, SIZE_NONE,
1088 450d4ff5 ths
   cris_ver_v0_10,
1089 450d4ff5 ths
   cris_none_reg_mode_add_sub_cmp_and_or_move_op},
1090 450d4ff5 ths
1091 450d4ff5 ths
  {"subs",    0x08a0, 0x0740,                  "z S,R,r", 0, SIZE_NONE,
1092 450d4ff5 ths
   cris_ver_v0_10,
1093 450d4ff5 ths
   cris_three_operand_add_sub_cmp_and_or_op},
1094 450d4ff5 ths
1095 450d4ff5 ths
  {"subu",    0x0480, 0x0b60,                  "z r,R",   0, SIZE_NONE,     0,
1096 450d4ff5 ths
   cris_reg_mode_add_sub_cmp_and_or_move_op},
1097 450d4ff5 ths
1098 450d4ff5 ths
  /* FIXME: SIZE_FIELD_UNSIGNED and all necessary changes.  */
1099 450d4ff5 ths
  {"subu",    0x0880, 0x0360,                  "z s,R",   0, SIZE_FIELD,    0,
1100 450d4ff5 ths
   cris_none_reg_mode_add_sub_cmp_and_or_move_op},
1101 450d4ff5 ths
1102 450d4ff5 ths
  {"subu",    0x0880, 0x0360,                  "z S,D",   0, SIZE_NONE,
1103 450d4ff5 ths
   cris_ver_v0_10,
1104 450d4ff5 ths
   cris_none_reg_mode_add_sub_cmp_and_or_move_op},
1105 450d4ff5 ths
1106 450d4ff5 ths
  {"subu",    0x0880, 0x0760,                  "z S,R,r", 0, SIZE_NONE,
1107 450d4ff5 ths
   cris_ver_v0_10,
1108 450d4ff5 ths
   cris_three_operand_add_sub_cmp_and_or_op},
1109 450d4ff5 ths
1110 450d4ff5 ths
  {"svc",
1111 450d4ff5 ths
   0x0530+CC_VC*0x1000,
1112 450d4ff5 ths
   0x0AC0+(0xf-CC_VC)*0x1000,                  "r",             0, SIZE_NONE,     0,
1113 450d4ff5 ths
   cris_scc_op},
1114 450d4ff5 ths
1115 450d4ff5 ths
  {"svs",
1116 450d4ff5 ths
   0x0530+CC_VS*0x1000,
1117 450d4ff5 ths
   0x0AC0+(0xf-CC_VS)*0x1000,                  "r",             0, SIZE_NONE,     0,
1118 450d4ff5 ths
   cris_scc_op},
1119 450d4ff5 ths
1120 450d4ff5 ths
  /* The insn "swapn" is the same as "not" and will be disassembled as
1121 450d4ff5 ths
     such, but the swap* family of mnmonics are generally v8-and-higher
1122 450d4ff5 ths
     only, so count it in.  */
1123 450d4ff5 ths
  {"swapn",   0x8770, 0x7880,                  "r",             0, SIZE_NONE,
1124 450d4ff5 ths
   cris_ver_v8p,
1125 450d4ff5 ths
   cris_not_implemented_op},
1126 450d4ff5 ths
1127 450d4ff5 ths
  {"swapw",   0x4770, 0xb880,                  "r",             0, SIZE_NONE,
1128 450d4ff5 ths
   cris_ver_v8p,
1129 450d4ff5 ths
   cris_not_implemented_op},
1130 450d4ff5 ths
1131 450d4ff5 ths
  {"swapnw",  0xc770, 0x3880,                  "r",             0, SIZE_NONE,
1132 450d4ff5 ths
   cris_ver_v8p,
1133 450d4ff5 ths
   cris_not_implemented_op},
1134 450d4ff5 ths
1135 450d4ff5 ths
  {"swapb",   0x2770, 0xd880,                  "r",             0, SIZE_NONE,
1136 450d4ff5 ths
   cris_ver_v8p,
1137 450d4ff5 ths
   cris_not_implemented_op},
1138 450d4ff5 ths
1139 450d4ff5 ths
  {"swapnb",  0xA770, 0x5880,                  "r",             0, SIZE_NONE,
1140 450d4ff5 ths
   cris_ver_v8p,
1141 450d4ff5 ths
   cris_not_implemented_op},
1142 450d4ff5 ths
1143 450d4ff5 ths
  {"swapwb",  0x6770, 0x9880,                  "r",             0, SIZE_NONE,
1144 450d4ff5 ths
   cris_ver_v8p,
1145 450d4ff5 ths
   cris_not_implemented_op},
1146 450d4ff5 ths
1147 450d4ff5 ths
  {"swapnwb", 0xE770, 0x1880,                  "r",             0, SIZE_NONE,
1148 450d4ff5 ths
   cris_ver_v8p,
1149 450d4ff5 ths
   cris_not_implemented_op},
1150 450d4ff5 ths
1151 450d4ff5 ths
  {"swapr",   0x1770, 0xe880,                  "r",             0, SIZE_NONE,
1152 450d4ff5 ths
   cris_ver_v8p,
1153 450d4ff5 ths
   cris_not_implemented_op},
1154 450d4ff5 ths
1155 450d4ff5 ths
  {"swapnr",  0x9770, 0x6880,                  "r",             0, SIZE_NONE,
1156 450d4ff5 ths
   cris_ver_v8p,
1157 450d4ff5 ths
   cris_not_implemented_op},
1158 450d4ff5 ths
1159 450d4ff5 ths
  {"swapwr",  0x5770, 0xa880,                  "r",             0, SIZE_NONE,
1160 450d4ff5 ths
   cris_ver_v8p,
1161 450d4ff5 ths
   cris_not_implemented_op},
1162 450d4ff5 ths
1163 450d4ff5 ths
  {"swapnwr", 0xd770, 0x2880,                  "r",             0, SIZE_NONE,
1164 450d4ff5 ths
   cris_ver_v8p,
1165 450d4ff5 ths
   cris_not_implemented_op},
1166 450d4ff5 ths
1167 450d4ff5 ths
  {"swapbr",  0x3770, 0xc880,                  "r",             0, SIZE_NONE,
1168 450d4ff5 ths
   cris_ver_v8p,
1169 450d4ff5 ths
   cris_not_implemented_op},
1170 450d4ff5 ths
1171 450d4ff5 ths
  {"swapnbr", 0xb770, 0x4880,                  "r",             0, SIZE_NONE,
1172 450d4ff5 ths
   cris_ver_v8p,
1173 450d4ff5 ths
   cris_not_implemented_op},
1174 450d4ff5 ths
1175 450d4ff5 ths
  {"swapwbr", 0x7770, 0x8880,                  "r",             0, SIZE_NONE,
1176 450d4ff5 ths
   cris_ver_v8p,
1177 450d4ff5 ths
   cris_not_implemented_op},
1178 450d4ff5 ths
1179 450d4ff5 ths
  {"swapnwbr", 0xf770, 0x0880,                  "r",             0, SIZE_NONE,
1180 450d4ff5 ths
   cris_ver_v8p,
1181 450d4ff5 ths
   cris_not_implemented_op},
1182 450d4ff5 ths
1183 450d4ff5 ths
  {"test",    0x0640, 0x0980,                  "m D",     0, SIZE_NONE,
1184 450d4ff5 ths
   cris_ver_v0_10,
1185 450d4ff5 ths
   cris_reg_mode_test_op},
1186 450d4ff5 ths
1187 450d4ff5 ths
  {"test",    0x0b80, 0xf040,                  "m y",     0, SIZE_FIELD,    0,
1188 450d4ff5 ths
   cris_none_reg_mode_clear_test_op},
1189 450d4ff5 ths
1190 450d4ff5 ths
  {"test",    0x0b80, 0xf040,                  "m S",     0, SIZE_NONE,
1191 450d4ff5 ths
   cris_ver_v0_10,
1192 450d4ff5 ths
   cris_none_reg_mode_clear_test_op},
1193 450d4ff5 ths
1194 450d4ff5 ths
  {"xor",     0x07B0, 0x0840,                  "r,R",     0, SIZE_NONE,     0,
1195 450d4ff5 ths
   cris_xor_op},
1196 450d4ff5 ths
1197 450d4ff5 ths
  {NULL, 0, 0, NULL, 0, 0, 0, cris_not_implemented_op}
1198 450d4ff5 ths
};
1199 450d4ff5 ths
1200 450d4ff5 ths
/* Condition-names, indexed by the CC_* numbers as found in cris.h. */
1201 450d4ff5 ths
const char * const
1202 450d4ff5 ths
cris_cc_strings[] =
1203 450d4ff5 ths
{
1204 450d4ff5 ths
  "hs",
1205 450d4ff5 ths
  "lo",
1206 450d4ff5 ths
  "ne",
1207 450d4ff5 ths
  "eq",
1208 450d4ff5 ths
  "vc",
1209 450d4ff5 ths
  "vs",
1210 450d4ff5 ths
  "pl",
1211 450d4ff5 ths
  "mi",
1212 450d4ff5 ths
  "ls",
1213 450d4ff5 ths
  "hi",
1214 450d4ff5 ths
  "ge",
1215 450d4ff5 ths
  "lt",
1216 450d4ff5 ths
  "gt",
1217 450d4ff5 ths
  "le",
1218 450d4ff5 ths
  "a",
1219 450d4ff5 ths
  /* This is a placeholder.  In v0, this would be "ext".  In v32, this
1220 450d4ff5 ths
     is "sb".  See cris_conds15.  */
1221 450d4ff5 ths
  "wf"
1222 450d4ff5 ths
};
1223 450d4ff5 ths
1224 450d4ff5 ths
/* Different names and semantics for condition 1111 (0xf).  */
1225 450d4ff5 ths
const struct cris_cond15 cris_cond15s[] =
1226 450d4ff5 ths
{
1227 450d4ff5 ths
  /* FIXME: In what version did condition "ext" disappear?  */
1228 450d4ff5 ths
  {"ext", cris_ver_v0_3},
1229 450d4ff5 ths
  {"wf", cris_ver_v10},
1230 450d4ff5 ths
  {"sb", cris_ver_v32p},
1231 450d4ff5 ths
  {NULL, 0}
1232 450d4ff5 ths
};
1233 450d4ff5 ths
1234 450d4ff5 ths
1235 450d4ff5 ths
/*
1236 450d4ff5 ths
 * Local variables:
1237 450d4ff5 ths
 * eval: (c-set-style "gnu")
1238 450d4ff5 ths
 * indent-tabs-mode: t
1239 450d4ff5 ths
 * End:
1240 450d4ff5 ths
 */
1241 450d4ff5 ths
1242 450d4ff5 ths
1243 450d4ff5 ths
/* No instruction will be disassembled longer than this.  In theory, and
1244 450d4ff5 ths
   in silicon, address prefixes can be cascaded.  In practice, cascading
1245 450d4ff5 ths
   is not used by GCC, and not supported by the assembler.  */
1246 450d4ff5 ths
#ifndef MAX_BYTES_PER_CRIS_INSN
1247 450d4ff5 ths
#define MAX_BYTES_PER_CRIS_INSN 8
1248 450d4ff5 ths
#endif
1249 450d4ff5 ths
1250 450d4ff5 ths
/* Whether or not to decode prefixes, folding it into the following
1251 450d4ff5 ths
   instruction.  FIXME: Make this optional later.  */
1252 450d4ff5 ths
#ifndef PARSE_PREFIX
1253 450d4ff5 ths
#define PARSE_PREFIX 1
1254 450d4ff5 ths
#endif
1255 450d4ff5 ths
1256 450d4ff5 ths
/* Sometimes we prefix all registers with this character.  */
1257 450d4ff5 ths
#define REGISTER_PREFIX_CHAR '$'
1258 450d4ff5 ths
1259 450d4ff5 ths
/* Whether or not to trace the following sequence:
1260 450d4ff5 ths
   sub* X,r%d
1261 450d4ff5 ths
   bound* Y,r%d
1262 450d4ff5 ths
   adds.w [pc+r%d.w],pc
1263 450d4ff5 ths

1264 450d4ff5 ths
   This is the assembly form of a switch-statement in C.
1265 450d4ff5 ths
   The "sub is optional.  If there is none, then X will be zero.
1266 450d4ff5 ths
   X is the value of the first case,
1267 450d4ff5 ths
   Y is the number of cases (including default).
1268 450d4ff5 ths

1269 450d4ff5 ths
   This results in case offsets printed on the form:
1270 450d4ff5 ths
    case N: -> case_address
1271 450d4ff5 ths
   where N is an estimation on the corresponding 'case' operand in C,
1272 450d4ff5 ths
   and case_address is where execution of that case continues after the
1273 450d4ff5 ths
   sequence presented above.
1274 450d4ff5 ths

1275 450d4ff5 ths
   The old style of output was to print the offsets as instructions,
1276 450d4ff5 ths
   which made it hard to follow "case"-constructs in the disassembly,
1277 450d4ff5 ths
   and caused a lot of annoying warnings about undefined instructions.
1278 450d4ff5 ths

1279 450d4ff5 ths
   FIXME: Make this optional later.  */
1280 450d4ff5 ths
#ifndef TRACE_CASE
1281 450d4ff5 ths
#define TRACE_CASE (disdata->trace_case)
1282 450d4ff5 ths
#endif
1283 450d4ff5 ths
1284 450d4ff5 ths
enum cris_disass_family
1285 450d4ff5 ths
 { cris_dis_v0_v10, cris_dis_common_v10_v32, cris_dis_v32 };
1286 450d4ff5 ths
1287 450d4ff5 ths
/* Stored in the disasm_info->private_data member.  */
1288 450d4ff5 ths
struct cris_disasm_data
1289 450d4ff5 ths
{
1290 450d4ff5 ths
  /* Whether to print something less confusing if we find something
1291 450d4ff5 ths
     matching a switch-construct.  */
1292 450d4ff5 ths
  bfd_boolean trace_case;
1293 450d4ff5 ths
1294 450d4ff5 ths
  /* Whether this code is flagged as crisv32.  FIXME: Should be an enum
1295 450d4ff5 ths
     that includes "compatible".  */
1296 450d4ff5 ths
  enum cris_disass_family distype;
1297 450d4ff5 ths
};
1298 450d4ff5 ths
1299 450d4ff5 ths
/* Value of first element in switch.  */
1300 450d4ff5 ths
static long case_offset = 0;
1301 450d4ff5 ths
1302 450d4ff5 ths
/* How many more case-offsets to print.  */
1303 450d4ff5 ths
static long case_offset_counter = 0;
1304 450d4ff5 ths
1305 450d4ff5 ths
/* Number of case offsets.  */
1306 450d4ff5 ths
static long no_of_case_offsets = 0;
1307 450d4ff5 ths
1308 450d4ff5 ths
/* Candidate for next case_offset.  */
1309 450d4ff5 ths
static long last_immediate = 0;
1310 450d4ff5 ths
1311 450d4ff5 ths
static int cris_constraint
1312 450d4ff5 ths
  (const char *, unsigned, unsigned, struct cris_disasm_data *);
1313 450d4ff5 ths
1314 450d4ff5 ths
/* Parse disassembler options and store state in info.  FIXME: For the
1315 450d4ff5 ths
   time being, we abuse static variables.  */
1316 450d4ff5 ths
1317 450d4ff5 ths
static bfd_boolean
1318 450d4ff5 ths
cris_parse_disassembler_options (disassemble_info *info,
1319 450d4ff5 ths
                                 enum cris_disass_family distype)
1320 450d4ff5 ths
{
1321 450d4ff5 ths
  struct cris_disasm_data *disdata;
1322 450d4ff5 ths
1323 450d4ff5 ths
  info->private_data = calloc (1, sizeof (struct cris_disasm_data));
1324 450d4ff5 ths
  disdata = (struct cris_disasm_data *) info->private_data;
1325 450d4ff5 ths
  if (disdata == NULL)
1326 450d4ff5 ths
    return FALSE;
1327 450d4ff5 ths
1328 450d4ff5 ths
  /* Default true.  */
1329 450d4ff5 ths
  disdata->trace_case
1330 450d4ff5 ths
    = (info->disassembler_options == NULL
1331 450d4ff5 ths
       || (strcmp (info->disassembler_options, "nocase") != 0));
1332 450d4ff5 ths
1333 450d4ff5 ths
  disdata->distype = distype;
1334 450d4ff5 ths
  return TRUE;
1335 450d4ff5 ths
}
1336 450d4ff5 ths
1337 450d4ff5 ths
static const struct cris_spec_reg *
1338 450d4ff5 ths
spec_reg_info (unsigned int sreg, enum cris_disass_family distype)
1339 450d4ff5 ths
{
1340 450d4ff5 ths
  int i;
1341 450d4ff5 ths
1342 450d4ff5 ths
  for (i = 0; cris_spec_regs[i].name != NULL; i++)
1343 450d4ff5 ths
    {
1344 450d4ff5 ths
      if (cris_spec_regs[i].number == sreg)
1345 450d4ff5 ths
        {
1346 450d4ff5 ths
          if (distype == cris_dis_v32)
1347 450d4ff5 ths
            switch (cris_spec_regs[i].applicable_version)
1348 450d4ff5 ths
              {
1349 450d4ff5 ths
              case cris_ver_warning:
1350 450d4ff5 ths
              case cris_ver_version_all:
1351 450d4ff5 ths
              case cris_ver_v3p:
1352 450d4ff5 ths
              case cris_ver_v8p:
1353 450d4ff5 ths
              case cris_ver_v10p:
1354 450d4ff5 ths
              case cris_ver_v32p:
1355 450d4ff5 ths
                /* No ambiguous sizes or register names with CRISv32.  */
1356 450d4ff5 ths
                if (cris_spec_regs[i].warning == NULL)
1357 450d4ff5 ths
                  return &cris_spec_regs[i];
1358 450d4ff5 ths
              default:
1359 450d4ff5 ths
                ;
1360 450d4ff5 ths
              }
1361 450d4ff5 ths
          else if (cris_spec_regs[i].applicable_version != cris_ver_v32p)
1362 450d4ff5 ths
            return &cris_spec_regs[i];
1363 450d4ff5 ths
        }
1364 450d4ff5 ths
    }
1365 450d4ff5 ths
1366 450d4ff5 ths
  return NULL;
1367 450d4ff5 ths
}
1368 450d4ff5 ths
1369 450d4ff5 ths
/* Return the number of bits in the argument.  */
1370 450d4ff5 ths
1371 450d4ff5 ths
static int
1372 450d4ff5 ths
number_of_bits (unsigned int val)
1373 450d4ff5 ths
{
1374 450d4ff5 ths
  int bits;
1375 450d4ff5 ths
1376 450d4ff5 ths
  for (bits = 0; val != 0; val &= val - 1)
1377 450d4ff5 ths
    bits++;
1378 450d4ff5 ths
1379 450d4ff5 ths
  return bits;
1380 450d4ff5 ths
}
1381 450d4ff5 ths
1382 450d4ff5 ths
/* Get an entry in the opcode-table.  */
1383 450d4ff5 ths
1384 450d4ff5 ths
static const struct cris_opcode *
1385 450d4ff5 ths
get_opcode_entry (unsigned int insn,
1386 450d4ff5 ths
                  unsigned int prefix_insn,
1387 450d4ff5 ths
                  struct cris_disasm_data *disdata)
1388 450d4ff5 ths
{
1389 450d4ff5 ths
  /* For non-prefixed insns, we keep a table of pointers, indexed by the
1390 450d4ff5 ths
     insn code.  Each entry is initialized when found to be NULL.  */
1391 450d4ff5 ths
  static const struct cris_opcode **opc_table = NULL;
1392 450d4ff5 ths
1393 450d4ff5 ths
  const struct cris_opcode *max_matchedp = NULL;
1394 450d4ff5 ths
  const struct cris_opcode **prefix_opc_table = NULL;
1395 450d4ff5 ths
1396 450d4ff5 ths
  /* We hold a table for each prefix that need to be handled differently.  */
1397 450d4ff5 ths
  static const struct cris_opcode **dip_prefixes = NULL;
1398 450d4ff5 ths
  static const struct cris_opcode **bdapq_m1_prefixes = NULL;
1399 450d4ff5 ths
  static const struct cris_opcode **bdapq_m2_prefixes = NULL;
1400 450d4ff5 ths
  static const struct cris_opcode **bdapq_m4_prefixes = NULL;
1401 450d4ff5 ths
  static const struct cris_opcode **rest_prefixes = NULL;
1402 450d4ff5 ths
1403 450d4ff5 ths
  /* Allocate and clear the opcode-table.  */
1404 450d4ff5 ths
  if (opc_table == NULL)
1405 450d4ff5 ths
    {
1406 1eec614b aliguori
      opc_table = qemu_malloc (65536 * sizeof (opc_table[0]));
1407 450d4ff5 ths
1408 450d4ff5 ths
      memset (opc_table, 0, 65536 * sizeof (const struct cris_opcode *));
1409 450d4ff5 ths
1410 450d4ff5 ths
      dip_prefixes
1411 1eec614b aliguori
        = qemu_malloc (65536 * sizeof (const struct cris_opcode **));
1412 450d4ff5 ths
1413 450d4ff5 ths
      memset (dip_prefixes, 0, 65536 * sizeof (dip_prefixes[0]));
1414 450d4ff5 ths
1415 450d4ff5 ths
      bdapq_m1_prefixes
1416 1eec614b aliguori
        = qemu_malloc (65536 * sizeof (const struct cris_opcode **));
1417 450d4ff5 ths
1418 450d4ff5 ths
      memset (bdapq_m1_prefixes, 0, 65536 * sizeof (bdapq_m1_prefixes[0]));
1419 450d4ff5 ths
1420 450d4ff5 ths
      bdapq_m2_prefixes
1421 1eec614b aliguori
        = qemu_malloc (65536 * sizeof (const struct cris_opcode **));
1422 450d4ff5 ths
1423 450d4ff5 ths
      memset (bdapq_m2_prefixes, 0, 65536 * sizeof (bdapq_m2_prefixes[0]));
1424 450d4ff5 ths
1425 450d4ff5 ths
      bdapq_m4_prefixes
1426 1eec614b aliguori
        = qemu_malloc (65536 * sizeof (const struct cris_opcode **));
1427 450d4ff5 ths
1428 450d4ff5 ths
      memset (bdapq_m4_prefixes, 0, 65536 * sizeof (bdapq_m4_prefixes[0]));
1429 450d4ff5 ths
1430 450d4ff5 ths
      rest_prefixes
1431 1eec614b aliguori
        = qemu_malloc (65536 * sizeof (const struct cris_opcode **));
1432 450d4ff5 ths
1433 450d4ff5 ths
      memset (rest_prefixes, 0, 65536 * sizeof (rest_prefixes[0]));
1434 450d4ff5 ths
    }
1435 450d4ff5 ths
1436 450d4ff5 ths
  /* Get the right table if this is a prefix.
1437 450d4ff5 ths
     This code is connected to cris_constraints in that it knows what
1438 450d4ff5 ths
     prefixes play a role in recognition of patterns; the necessary
1439 450d4ff5 ths
     state is reflected by which table is used.  If constraints
1440 450d4ff5 ths
     involving match or non-match of prefix insns are changed, then this
1441 450d4ff5 ths
     probably needs changing too.  */
1442 450d4ff5 ths
  if (prefix_insn != NO_CRIS_PREFIX)
1443 450d4ff5 ths
    {
1444 450d4ff5 ths
      const struct cris_opcode *popcodep
1445 450d4ff5 ths
        = (opc_table[prefix_insn] != NULL
1446 450d4ff5 ths
           ? opc_table[prefix_insn]
1447 450d4ff5 ths
           : get_opcode_entry (prefix_insn, NO_CRIS_PREFIX, disdata));
1448 450d4ff5 ths
1449 450d4ff5 ths
      if (popcodep == NULL)
1450 450d4ff5 ths
        return NULL;
1451 450d4ff5 ths
1452 450d4ff5 ths
      if (popcodep->match == BDAP_QUICK_OPCODE)
1453 450d4ff5 ths
        {
1454 450d4ff5 ths
          /* Since some offsets are recognized with "push" macros, we
1455 450d4ff5 ths
             have to have different tables for them.  */
1456 450d4ff5 ths
          int offset = (prefix_insn & 255);
1457 450d4ff5 ths
1458 450d4ff5 ths
          if (offset > 127)
1459 450d4ff5 ths
            offset -= 256;
1460 450d4ff5 ths
1461 450d4ff5 ths
          switch (offset)
1462 450d4ff5 ths
            {
1463 450d4ff5 ths
            case -4:
1464 450d4ff5 ths
              prefix_opc_table = bdapq_m4_prefixes;
1465 450d4ff5 ths
              break;
1466 450d4ff5 ths
1467 450d4ff5 ths
            case -2:
1468 450d4ff5 ths
              prefix_opc_table = bdapq_m2_prefixes;
1469 450d4ff5 ths
              break;
1470 450d4ff5 ths
1471 450d4ff5 ths
            case -1:
1472 450d4ff5 ths
              prefix_opc_table = bdapq_m1_prefixes;
1473 450d4ff5 ths
              break;
1474 450d4ff5 ths
1475 450d4ff5 ths
            default:
1476 450d4ff5 ths
              prefix_opc_table = rest_prefixes;
1477 450d4ff5 ths
              break;
1478 450d4ff5 ths
            }
1479 450d4ff5 ths
        }
1480 450d4ff5 ths
      else if (popcodep->match == DIP_OPCODE)
1481 450d4ff5 ths
        /* We don't allow postincrement when the prefix is DIP, so use a
1482 450d4ff5 ths
           different table for DIP.  */
1483 450d4ff5 ths
        prefix_opc_table = dip_prefixes;
1484 450d4ff5 ths
      else
1485 450d4ff5 ths
        prefix_opc_table = rest_prefixes;
1486 450d4ff5 ths
    }
1487 450d4ff5 ths
1488 450d4ff5 ths
  if (prefix_insn != NO_CRIS_PREFIX
1489 450d4ff5 ths
      && prefix_opc_table[insn] != NULL)
1490 450d4ff5 ths
    max_matchedp = prefix_opc_table[insn];
1491 450d4ff5 ths
  else if (prefix_insn == NO_CRIS_PREFIX && opc_table[insn] != NULL)
1492 450d4ff5 ths
    max_matchedp = opc_table[insn];
1493 450d4ff5 ths
  else
1494 450d4ff5 ths
    {
1495 450d4ff5 ths
      const struct cris_opcode *opcodep;
1496 450d4ff5 ths
      int max_level_of_match = -1;
1497 450d4ff5 ths
1498 450d4ff5 ths
      for (opcodep = cris_opcodes;
1499 450d4ff5 ths
           opcodep->name != NULL;
1500 450d4ff5 ths
           opcodep++)
1501 450d4ff5 ths
        {
1502 450d4ff5 ths
          int level_of_match;
1503 450d4ff5 ths
1504 450d4ff5 ths
          if (disdata->distype == cris_dis_v32)
1505 450d4ff5 ths
            {
1506 450d4ff5 ths
              switch (opcodep->applicable_version)
1507 450d4ff5 ths
                {
1508 450d4ff5 ths
                case cris_ver_version_all:
1509 450d4ff5 ths
                  break;
1510 450d4ff5 ths
1511 450d4ff5 ths
                case cris_ver_v0_3:
1512 450d4ff5 ths
                case cris_ver_v0_10:
1513 450d4ff5 ths
                case cris_ver_v3_10:
1514 450d4ff5 ths
                case cris_ver_sim_v0_10:
1515 450d4ff5 ths
                case cris_ver_v8_10:
1516 450d4ff5 ths
                case cris_ver_v10:
1517 450d4ff5 ths
                case cris_ver_warning:
1518 450d4ff5 ths
                  continue;
1519 450d4ff5 ths
1520 450d4ff5 ths
                case cris_ver_v3p:
1521 450d4ff5 ths
                case cris_ver_v8p:
1522 450d4ff5 ths
                case cris_ver_v10p:
1523 450d4ff5 ths
                case cris_ver_v32p:
1524 450d4ff5 ths
                  break;
1525 450d4ff5 ths
1526 450d4ff5 ths
                case cris_ver_v8:
1527 450d4ff5 ths
                  abort ();
1528 450d4ff5 ths
                default:
1529 450d4ff5 ths
                  abort ();
1530 450d4ff5 ths
                }
1531 450d4ff5 ths
            }
1532 450d4ff5 ths
          else
1533 450d4ff5 ths
            {
1534 450d4ff5 ths
              switch (opcodep->applicable_version)
1535 450d4ff5 ths
                {
1536 450d4ff5 ths
                case cris_ver_version_all:
1537 450d4ff5 ths
                case cris_ver_v0_3:
1538 450d4ff5 ths
                case cris_ver_v3p:
1539 450d4ff5 ths
                case cris_ver_v0_10:
1540 450d4ff5 ths
                case cris_ver_v8p:
1541 450d4ff5 ths
                case cris_ver_v8_10:
1542 450d4ff5 ths
                case cris_ver_v10:
1543 450d4ff5 ths
                case cris_ver_sim_v0_10:
1544 450d4ff5 ths
                case cris_ver_v10p:
1545 450d4ff5 ths
                case cris_ver_warning:
1546 450d4ff5 ths
                  break;
1547 450d4ff5 ths
1548 450d4ff5 ths
                case cris_ver_v32p:
1549 450d4ff5 ths
                  continue;
1550 450d4ff5 ths
1551 450d4ff5 ths
                case cris_ver_v8:
1552 450d4ff5 ths
                  abort ();
1553 450d4ff5 ths
                default:
1554 450d4ff5 ths
                  abort ();
1555 450d4ff5 ths
                }
1556 450d4ff5 ths
            }
1557 450d4ff5 ths
1558 450d4ff5 ths
          /* We give a double lead for bits matching the template in
1559 450d4ff5 ths
             cris_opcodes.  Not even, because then "move p8,r10" would
1560 450d4ff5 ths
             be given 2 bits lead over "clear.d r10".  When there's a
1561 450d4ff5 ths
             tie, the first entry in the table wins.  This is
1562 450d4ff5 ths
             deliberate, to avoid a more complicated recognition
1563 450d4ff5 ths
             formula.  */
1564 450d4ff5 ths
          if ((opcodep->match & insn) == opcodep->match
1565 450d4ff5 ths
              && (opcodep->lose & insn) == 0
1566 450d4ff5 ths
              && ((level_of_match
1567 450d4ff5 ths
                   = cris_constraint (opcodep->args,
1568 450d4ff5 ths
                                      insn,
1569 450d4ff5 ths
                                      prefix_insn,
1570 450d4ff5 ths
                                      disdata))
1571 450d4ff5 ths
                  >= 0)
1572 450d4ff5 ths
              && ((level_of_match
1573 450d4ff5 ths
                   += 2 * number_of_bits (opcodep->match
1574 450d4ff5 ths
                                          | opcodep->lose))
1575 450d4ff5 ths
                          > max_level_of_match))
1576 450d4ff5 ths
                    {
1577 450d4ff5 ths
                      max_matchedp = opcodep;
1578 450d4ff5 ths
                      max_level_of_match = level_of_match;
1579 450d4ff5 ths
1580 450d4ff5 ths
                      /* If there was a full match, never mind looking
1581 450d4ff5 ths
                         further.  */
1582 450d4ff5 ths
                      if (level_of_match >= 2 * 16)
1583 450d4ff5 ths
                        break;
1584 450d4ff5 ths
                    }
1585 450d4ff5 ths
                }
1586 450d4ff5 ths
      /* Fill in the new entry.
1587 450d4ff5 ths

1588 450d4ff5 ths
         If there are changes to the opcode-table involving prefixes, and
1589 450d4ff5 ths
         disassembly then does not work correctly, try removing the
1590 450d4ff5 ths
         else-clause below that fills in the prefix-table.  If that
1591 450d4ff5 ths
         helps, you need to change the prefix_opc_table setting above, or
1592 450d4ff5 ths
         something related.  */
1593 450d4ff5 ths
      if (prefix_insn == NO_CRIS_PREFIX)
1594 450d4ff5 ths
        opc_table[insn] = max_matchedp;
1595 450d4ff5 ths
      else
1596 450d4ff5 ths
        prefix_opc_table[insn] = max_matchedp;
1597 450d4ff5 ths
    }
1598 450d4ff5 ths
1599 450d4ff5 ths
  return max_matchedp;
1600 450d4ff5 ths
}
1601 450d4ff5 ths
1602 450d4ff5 ths
/* Return -1 if the constraints of a bitwise-matched instruction say
1603 450d4ff5 ths
   that there is no match.  Otherwise return a nonnegative number
1604 450d4ff5 ths
   indicating the confidence in the match (higher is better).  */
1605 450d4ff5 ths
1606 450d4ff5 ths
static int
1607 450d4ff5 ths
cris_constraint (const char *cs,
1608 450d4ff5 ths
                 unsigned int insn,
1609 450d4ff5 ths
                 unsigned int prefix_insn,
1610 450d4ff5 ths
                 struct cris_disasm_data *disdata)
1611 450d4ff5 ths
{
1612 450d4ff5 ths
  int retval = 0;
1613 450d4ff5 ths
  int tmp;
1614 450d4ff5 ths
  int prefix_ok = 0;
1615 450d4ff5 ths
  const char *s;
1616 450d4ff5 ths
1617 450d4ff5 ths
  for (s = cs; *s; s++)
1618 450d4ff5 ths
    switch (*s)
1619 450d4ff5 ths
      {
1620 450d4ff5 ths
      case '!':
1621 450d4ff5 ths
        /* Do not recognize "pop" if there's a prefix and then only for
1622 450d4ff5 ths
           v0..v10.  */
1623 450d4ff5 ths
        if (prefix_insn != NO_CRIS_PREFIX
1624 450d4ff5 ths
            || disdata->distype != cris_dis_v0_v10)
1625 450d4ff5 ths
          return -1;
1626 450d4ff5 ths
        break;
1627 450d4ff5 ths
1628 450d4ff5 ths
      case 'U':
1629 450d4ff5 ths
        /* Not recognized at disassembly.  */
1630 450d4ff5 ths
        return -1;
1631 450d4ff5 ths
1632 450d4ff5 ths
      case 'M':
1633 450d4ff5 ths
        /* Size modifier for "clear", i.e. special register 0, 4 or 8.
1634 450d4ff5 ths
           Check that it is one of them.  Only special register 12 could
1635 450d4ff5 ths
           be mismatched, but checking for matches is more logical than
1636 450d4ff5 ths
           checking for mismatches when there are only a few cases.  */
1637 450d4ff5 ths
        tmp = ((insn >> 12) & 0xf);
1638 450d4ff5 ths
        if (tmp != 0 && tmp != 4 && tmp != 8)
1639 450d4ff5 ths
          return -1;
1640 450d4ff5 ths
        break;
1641 450d4ff5 ths
1642 450d4ff5 ths
      case 'm':
1643 450d4ff5 ths
        if ((insn & 0x30) == 0x30)
1644 450d4ff5 ths
          return -1;
1645 450d4ff5 ths
        break;
1646 450d4ff5 ths
1647 450d4ff5 ths
      case 'S':
1648 450d4ff5 ths
        /* A prefix operand without side-effect.  */
1649 450d4ff5 ths
        if (prefix_insn != NO_CRIS_PREFIX && (insn & 0x400) == 0)
1650 450d4ff5 ths
          {
1651 450d4ff5 ths
            prefix_ok = 1;
1652 450d4ff5 ths
            break;
1653 450d4ff5 ths
          }
1654 450d4ff5 ths
        else
1655 450d4ff5 ths
          return -1;
1656 450d4ff5 ths
1657 450d4ff5 ths
      case 's':
1658 450d4ff5 ths
      case 'y':
1659 450d4ff5 ths
      case 'Y':
1660 450d4ff5 ths
        /* If this is a prefixed insn with postincrement (side-effect),
1661 450d4ff5 ths
           the prefix must not be DIP.  */
1662 450d4ff5 ths
        if (prefix_insn != NO_CRIS_PREFIX)
1663 450d4ff5 ths
          {
1664 450d4ff5 ths
            if (insn & 0x400)
1665 450d4ff5 ths
              {
1666 450d4ff5 ths
                const struct cris_opcode *prefix_opcodep
1667 450d4ff5 ths
                  = get_opcode_entry (prefix_insn, NO_CRIS_PREFIX, disdata);
1668 450d4ff5 ths
1669 450d4ff5 ths
                if (prefix_opcodep->match == DIP_OPCODE)
1670 450d4ff5 ths
                  return -1;
1671 450d4ff5 ths
              }
1672 450d4ff5 ths
1673 450d4ff5 ths
            prefix_ok = 1;
1674 450d4ff5 ths
          }
1675 450d4ff5 ths
        break;
1676 450d4ff5 ths
1677 450d4ff5 ths
      case 'B':
1678 450d4ff5 ths
        /* If we don't fall through, then the prefix is ok.  */
1679 450d4ff5 ths
        prefix_ok = 1;
1680 450d4ff5 ths
1681 450d4ff5 ths
        /* A "push" prefix.  Check for valid "push" size.
1682 450d4ff5 ths
           In case of special register, it may be != 4.  */
1683 450d4ff5 ths
        if (prefix_insn != NO_CRIS_PREFIX)
1684 450d4ff5 ths
          {
1685 450d4ff5 ths
            /* Match the prefix insn to BDAPQ.  */
1686 450d4ff5 ths
            const struct cris_opcode *prefix_opcodep
1687 450d4ff5 ths
              = get_opcode_entry (prefix_insn, NO_CRIS_PREFIX, disdata);
1688 450d4ff5 ths
1689 450d4ff5 ths
            if (prefix_opcodep->match == BDAP_QUICK_OPCODE)
1690 450d4ff5 ths
              {
1691 450d4ff5 ths
                int pushsize = (prefix_insn & 255);
1692 450d4ff5 ths
1693 450d4ff5 ths
                if (pushsize > 127)
1694 450d4ff5 ths
                  pushsize -= 256;
1695 450d4ff5 ths
1696 450d4ff5 ths
                if (s[1] == 'P')
1697 450d4ff5 ths
                  {
1698 450d4ff5 ths
                    unsigned int spec_reg = (insn >> 12) & 15;
1699 450d4ff5 ths
                    const struct cris_spec_reg *sregp
1700 450d4ff5 ths
                      = spec_reg_info (spec_reg, disdata->distype);
1701 450d4ff5 ths
1702 450d4ff5 ths
                    /* For a special-register, the "prefix size" must
1703 450d4ff5 ths
                       match the size of the register.  */
1704 450d4ff5 ths
                    if (sregp && sregp->reg_size == (unsigned int) -pushsize)
1705 450d4ff5 ths
                      break;
1706 450d4ff5 ths
                  }
1707 450d4ff5 ths
                else if (s[1] == 'R')
1708 450d4ff5 ths
                  {
1709 450d4ff5 ths
                    if ((insn & 0x30) == 0x20 && pushsize == -4)
1710 450d4ff5 ths
                      break;
1711 450d4ff5 ths
                  }
1712 450d4ff5 ths
                /* FIXME:  Should abort here; next constraint letter
1713 450d4ff5 ths
                   *must* be 'P' or 'R'.  */
1714 450d4ff5 ths
              }
1715 450d4ff5 ths
          }
1716 450d4ff5 ths
        return -1;
1717 450d4ff5 ths
1718 450d4ff5 ths
      case 'D':
1719 450d4ff5 ths
        retval = (((insn >> 12) & 15) == (insn & 15));
1720 450d4ff5 ths
        if (!retval)
1721 450d4ff5 ths
          return -1;
1722 450d4ff5 ths
        else
1723 450d4ff5 ths
          retval += 4;
1724 450d4ff5 ths
        break;
1725 450d4ff5 ths
1726 450d4ff5 ths
      case 'P':
1727 450d4ff5 ths
        {
1728 450d4ff5 ths
          const struct cris_spec_reg *sregp
1729 450d4ff5 ths
            = spec_reg_info ((insn >> 12) & 15, disdata->distype);
1730 450d4ff5 ths
1731 450d4ff5 ths
          /* Since we match four bits, we will give a value of 4-1 = 3
1732 450d4ff5 ths
             in a match.  If there is a corresponding exact match of a
1733 450d4ff5 ths
             special register in another pattern, it will get a value of
1734 450d4ff5 ths
             4, which will be higher.  This should be correct in that an
1735 450d4ff5 ths
             exact pattern would match better than a general pattern.
1736 450d4ff5 ths

1737 450d4ff5 ths
             Note that there is a reason for not returning zero; the
1738 450d4ff5 ths
             pattern for "clear" is partly  matched in the bit-pattern
1739 450d4ff5 ths
             (the two lower bits must be zero), while the bit-pattern
1740 450d4ff5 ths
             for a move from a special register is matched in the
1741 450d4ff5 ths
             register constraint.  */
1742 450d4ff5 ths
1743 450d4ff5 ths
          if (sregp != NULL)
1744 450d4ff5 ths
            {
1745 450d4ff5 ths
              retval += 3;
1746 450d4ff5 ths
              break;
1747 450d4ff5 ths
            }
1748 450d4ff5 ths
          else
1749 450d4ff5 ths
            return -1;
1750 450d4ff5 ths
        }
1751 450d4ff5 ths
      }
1752 450d4ff5 ths
1753 450d4ff5 ths
  if (prefix_insn != NO_CRIS_PREFIX && ! prefix_ok)
1754 450d4ff5 ths
    return -1;
1755 450d4ff5 ths
1756 450d4ff5 ths
  return retval;
1757 450d4ff5 ths
}
1758 450d4ff5 ths
1759 450d4ff5 ths
/* Format number as hex with a leading "0x" into outbuffer.  */
1760 450d4ff5 ths
1761 450d4ff5 ths
static char *
1762 450d4ff5 ths
format_hex (unsigned long number,
1763 450d4ff5 ths
            char *outbuffer,
1764 450d4ff5 ths
            struct cris_disasm_data *disdata)
1765 450d4ff5 ths
{
1766 450d4ff5 ths
  /* Truncate negative numbers on >32-bit hosts.  */
1767 450d4ff5 ths
  number &= 0xffffffff;
1768 450d4ff5 ths
1769 450d4ff5 ths
  sprintf (outbuffer, "0x%lx", number);
1770 450d4ff5 ths
1771 450d4ff5 ths
  /* Save this value for the "case" support.  */
1772 450d4ff5 ths
  if (TRACE_CASE)
1773 450d4ff5 ths
    last_immediate = number;
1774 450d4ff5 ths
1775 450d4ff5 ths
  return outbuffer + strlen (outbuffer);
1776 450d4ff5 ths
}
1777 450d4ff5 ths
1778 450d4ff5 ths
/* Format number as decimal into outbuffer.  Parameter signedp says
1779 450d4ff5 ths
   whether the number should be formatted as signed (!= 0) or
1780 450d4ff5 ths
   unsigned (== 0).  */
1781 450d4ff5 ths
1782 450d4ff5 ths
static char *
1783 450d4ff5 ths
format_dec (long number, char *outbuffer, int signedp)
1784 450d4ff5 ths
{
1785 450d4ff5 ths
  last_immediate = number;
1786 450d4ff5 ths
  sprintf (outbuffer, signedp ? "%ld" : "%lu", number);
1787 450d4ff5 ths
1788 450d4ff5 ths
  return outbuffer + strlen (outbuffer);
1789 450d4ff5 ths
}
1790 450d4ff5 ths
1791 450d4ff5 ths
/* Format the name of the general register regno into outbuffer.  */
1792 450d4ff5 ths
1793 450d4ff5 ths
static char *
1794 450d4ff5 ths
format_reg (struct cris_disasm_data *disdata,
1795 450d4ff5 ths
            int regno,
1796 450d4ff5 ths
            char *outbuffer_start,
1797 450d4ff5 ths
            bfd_boolean with_reg_prefix)
1798 450d4ff5 ths
{
1799 450d4ff5 ths
  char *outbuffer = outbuffer_start;
1800 450d4ff5 ths
1801 450d4ff5 ths
  if (with_reg_prefix)
1802 450d4ff5 ths
    *outbuffer++ = REGISTER_PREFIX_CHAR;
1803 450d4ff5 ths
1804 450d4ff5 ths
  switch (regno)
1805 450d4ff5 ths
    {
1806 450d4ff5 ths
    case 15:
1807 450d4ff5 ths
      /* For v32, there is no context in which we output PC.  */
1808 450d4ff5 ths
      if (disdata->distype == cris_dis_v32)
1809 450d4ff5 ths
        strcpy (outbuffer, "acr");
1810 450d4ff5 ths
      else
1811 450d4ff5 ths
        strcpy (outbuffer, "pc");
1812 450d4ff5 ths
      break;
1813 450d4ff5 ths
1814 450d4ff5 ths
    case 14:
1815 450d4ff5 ths
      strcpy (outbuffer, "sp");
1816 450d4ff5 ths
      break;
1817 450d4ff5 ths
1818 450d4ff5 ths
    default:
1819 450d4ff5 ths
      sprintf (outbuffer, "r%d", regno);
1820 450d4ff5 ths
      break;
1821 450d4ff5 ths
    }
1822 450d4ff5 ths
1823 450d4ff5 ths
  return outbuffer_start + strlen (outbuffer_start);
1824 450d4ff5 ths
}
1825 450d4ff5 ths
1826 450d4ff5 ths
/* Format the name of a support register into outbuffer.  */
1827 450d4ff5 ths
1828 450d4ff5 ths
static char *
1829 450d4ff5 ths
format_sup_reg (unsigned int regno,
1830 450d4ff5 ths
                char *outbuffer_start,
1831 450d4ff5 ths
                bfd_boolean with_reg_prefix)
1832 450d4ff5 ths
{
1833 450d4ff5 ths
  char *outbuffer = outbuffer_start;
1834 450d4ff5 ths
  int i;
1835 450d4ff5 ths
1836 450d4ff5 ths
  if (with_reg_prefix)
1837 450d4ff5 ths
    *outbuffer++ = REGISTER_PREFIX_CHAR;
1838 450d4ff5 ths
1839 450d4ff5 ths
  for (i = 0; cris_support_regs[i].name != NULL; i++)
1840 450d4ff5 ths
    if (cris_support_regs[i].number == regno)
1841 450d4ff5 ths
      {
1842 450d4ff5 ths
        sprintf (outbuffer, "%s", cris_support_regs[i].name);
1843 450d4ff5 ths
        return outbuffer_start + strlen (outbuffer_start);
1844 450d4ff5 ths
      }
1845 450d4ff5 ths
1846 450d4ff5 ths
  /* There's supposed to be register names covering all numbers, though
1847 450d4ff5 ths
     some may be generic names.  */
1848 450d4ff5 ths
  sprintf (outbuffer, "format_sup_reg-BUG");
1849 450d4ff5 ths
  return outbuffer_start + strlen (outbuffer_start);
1850 450d4ff5 ths
}
1851 450d4ff5 ths
1852 450d4ff5 ths
/* Return the length of an instruction.  */
1853 450d4ff5 ths
1854 450d4ff5 ths
static unsigned
1855 450d4ff5 ths
bytes_to_skip (unsigned int insn,
1856 450d4ff5 ths
               const struct cris_opcode *matchedp,
1857 450d4ff5 ths
               enum cris_disass_family distype,
1858 450d4ff5 ths
               const struct cris_opcode *prefix_matchedp)
1859 450d4ff5 ths
{
1860 450d4ff5 ths
  /* Each insn is a word plus "immediate" operands.  */
1861 450d4ff5 ths
  unsigned to_skip = 2;
1862 450d4ff5 ths
  const char *template = matchedp->args;
1863 450d4ff5 ths
  const char *s;
1864 450d4ff5 ths
1865 450d4ff5 ths
  for (s = template; *s; s++)
1866 450d4ff5 ths
    if ((*s == 's' || *s == 'N' || *s == 'Y')
1867 450d4ff5 ths
        && (insn & 0x400) && (insn & 15) == 15
1868 450d4ff5 ths
        && prefix_matchedp == NULL)
1869 450d4ff5 ths
      {
1870 450d4ff5 ths
        /* Immediate via [pc+], so we have to check the size of the
1871 450d4ff5 ths
           operand.  */
1872 450d4ff5 ths
        int mode_size = 1 << ((insn >> 4) & (*template == 'z' ? 1 : 3));
1873 450d4ff5 ths
1874 450d4ff5 ths
        if (matchedp->imm_oprnd_size == SIZE_FIX_32)
1875 450d4ff5 ths
          to_skip += 4;
1876 450d4ff5 ths
        else if (matchedp->imm_oprnd_size == SIZE_SPEC_REG)
1877 450d4ff5 ths
          {
1878 450d4ff5 ths
            const struct cris_spec_reg *sregp
1879 450d4ff5 ths
              = spec_reg_info ((insn >> 12) & 15, distype);
1880 450d4ff5 ths
1881 450d4ff5 ths
            /* FIXME: Improve error handling; should have been caught
1882 450d4ff5 ths
               earlier.  */
1883 450d4ff5 ths
            if (sregp == NULL)
1884 450d4ff5 ths
              return 2;
1885 450d4ff5 ths
1886 450d4ff5 ths
            /* PC is incremented by two, not one, for a byte.  Except on
1887 450d4ff5 ths
               CRISv32, where constants are always DWORD-size for
1888 450d4ff5 ths
               special registers.  */
1889 450d4ff5 ths
            to_skip +=
1890 450d4ff5 ths
              distype == cris_dis_v32 ? 4 : (sregp->reg_size + 1) & ~1;
1891 450d4ff5 ths
          }
1892 450d4ff5 ths
        else
1893 450d4ff5 ths
          to_skip += (mode_size + 1) & ~1;
1894 450d4ff5 ths
      }
1895 450d4ff5 ths
    else if (*s == 'n')
1896 450d4ff5 ths
      to_skip += 4;
1897 450d4ff5 ths
    else if (*s == 'b')
1898 450d4ff5 ths
      to_skip += 2;
1899 450d4ff5 ths
1900 450d4ff5 ths
  return to_skip;
1901 450d4ff5 ths
}
1902 450d4ff5 ths
1903 450d4ff5 ths
/* Print condition code flags.  */
1904 450d4ff5 ths
1905 450d4ff5 ths
static char *
1906 450d4ff5 ths
print_flags (struct cris_disasm_data *disdata, unsigned int insn, char *cp)
1907 450d4ff5 ths
{
1908 450d4ff5 ths
  /* Use the v8 (Etrax 100) flag definitions for disassembly.
1909 450d4ff5 ths
     The differences with v0 (Etrax 1..4) vs. Svinto are:
1910 450d4ff5 ths
      v0 'd' <=> v8 'm'
1911 450d4ff5 ths
      v0 'e' <=> v8 'b'.
1912 450d4ff5 ths
     FIXME: Emit v0..v3 flag names somehow.  */
1913 450d4ff5 ths
  static const char v8_fnames[] = "cvznxibm";
1914 450d4ff5 ths
  static const char v32_fnames[] = "cvznxiup";
1915 450d4ff5 ths
  const char *fnames
1916 450d4ff5 ths
    = disdata->distype == cris_dis_v32 ? v32_fnames : v8_fnames;
1917 450d4ff5 ths
1918 450d4ff5 ths
  unsigned char flagbits = (((insn >> 8) & 0xf0) | (insn & 15));
1919 450d4ff5 ths
  int i;
1920 450d4ff5 ths
1921 450d4ff5 ths
  for (i = 0; i < 8; i++)
1922 450d4ff5 ths
    if (flagbits & (1 << i))
1923 450d4ff5 ths
      *cp++ = fnames[i];
1924 450d4ff5 ths
1925 450d4ff5 ths
  return cp;
1926 450d4ff5 ths
}
1927 450d4ff5 ths
1928 450d4ff5 ths
/* Print out an insn with its operands, and update the info->insn_type
1929 450d4ff5 ths
   fields.  The prefix_opcodep and the rest hold a prefix insn that is
1930 450d4ff5 ths
   supposed to be output as an address mode.  */
1931 450d4ff5 ths
1932 450d4ff5 ths
static void
1933 450d4ff5 ths
print_with_operands (const struct cris_opcode *opcodep,
1934 450d4ff5 ths
                     unsigned int insn,
1935 450d4ff5 ths
                     unsigned char *buffer,
1936 450d4ff5 ths
                     bfd_vma addr,
1937 450d4ff5 ths
                     disassemble_info *info,
1938 450d4ff5 ths
                     /* If a prefix insn was before this insn (and is supposed
1939 450d4ff5 ths
                        to be output as an address), here is a description of
1940 450d4ff5 ths
                        it.  */
1941 450d4ff5 ths
                     const struct cris_opcode *prefix_opcodep,
1942 450d4ff5 ths
                     unsigned int prefix_insn,
1943 450d4ff5 ths
                     unsigned char *prefix_buffer,
1944 450d4ff5 ths
                     bfd_boolean with_reg_prefix)
1945 450d4ff5 ths
{
1946 450d4ff5 ths
  /* Get a buffer of somewhat reasonable size where we store
1947 450d4ff5 ths
     intermediate parts of the insn.  */
1948 450d4ff5 ths
  char temp[sizeof (".d [$r13=$r12-2147483648],$r10") * 2];
1949 450d4ff5 ths
  char *tp = temp;
1950 450d4ff5 ths
  static const char mode_char[] = "bwd?";
1951 450d4ff5 ths
  const char *s;
1952 450d4ff5 ths
  const char *cs;
1953 450d4ff5 ths
  struct cris_disasm_data *disdata
1954 450d4ff5 ths
    = (struct cris_disasm_data *) info->private_data;
1955 450d4ff5 ths
1956 450d4ff5 ths
  /* Print out the name first thing we do.  */
1957 450d4ff5 ths
  (*info->fprintf_func) (info->stream, "%s", opcodep->name);
1958 450d4ff5 ths
1959 450d4ff5 ths
  cs = opcodep->args;
1960 450d4ff5 ths
  s = cs;
1961 450d4ff5 ths
1962 450d4ff5 ths
  /* Ignore any prefix indicator.  */
1963 450d4ff5 ths
  if (*s == 'p')
1964 450d4ff5 ths
    s++;
1965 450d4ff5 ths
1966 450d4ff5 ths
  if (*s == 'm' || *s == 'M' || *s == 'z')
1967 450d4ff5 ths
    {
1968 450d4ff5 ths
      *tp++ = '.';
1969 450d4ff5 ths
1970 450d4ff5 ths
      /* Get the size-letter.  */
1971 450d4ff5 ths
      *tp++ = *s == 'M'
1972 450d4ff5 ths
        ? (insn & 0x8000 ? 'd'
1973 450d4ff5 ths
           : insn & 0x4000 ? 'w' : 'b')
1974 450d4ff5 ths
        : mode_char[(insn >> 4) & (*s == 'z' ? 1 : 3)];
1975 450d4ff5 ths
1976 450d4ff5 ths
      /* Ignore the size and the space character that follows.  */
1977 450d4ff5 ths
      s += 2;
1978 450d4ff5 ths
    }
1979 450d4ff5 ths
1980 450d4ff5 ths
  /* Add a space if this isn't a long-branch, because for those will add
1981 450d4ff5 ths
     the condition part of the name later.  */
1982 450d4ff5 ths
  if (opcodep->match != (BRANCH_PC_LOW + BRANCH_INCR_HIGH * 256))
1983 450d4ff5 ths
    *tp++ = ' ';
1984 450d4ff5 ths
1985 450d4ff5 ths
  /* Fill in the insn-type if deducible from the name (and there's no
1986 450d4ff5 ths
     better way).  */
1987 450d4ff5 ths
  if (opcodep->name[0] == 'j')
1988 450d4ff5 ths
    {
1989 450d4ff5 ths
      if (CONST_STRNEQ (opcodep->name, "jsr"))
1990 450d4ff5 ths
        /* It's "jsr" or "jsrc".  */
1991 450d4ff5 ths
        info->insn_type = dis_jsr;
1992 450d4ff5 ths
      else
1993 450d4ff5 ths
        /* Any other jump-type insn is considered a branch.  */
1994 450d4ff5 ths
        info->insn_type = dis_branch;
1995 450d4ff5 ths
    }
1996 450d4ff5 ths
1997 450d4ff5 ths
  /* We might know some more fields right now.  */
1998 450d4ff5 ths
  info->branch_delay_insns = opcodep->delayed;
1999 450d4ff5 ths
2000 450d4ff5 ths
  /* Handle operands.  */
2001 450d4ff5 ths
  for (; *s; s++)
2002 450d4ff5 ths
    {
2003 450d4ff5 ths
    switch (*s)
2004 450d4ff5 ths
      {
2005 450d4ff5 ths
      case 'T':
2006 450d4ff5 ths
        tp = format_sup_reg ((insn >> 12) & 15, tp, with_reg_prefix);
2007 450d4ff5 ths
        break;
2008 450d4ff5 ths
2009 450d4ff5 ths
      case 'A':
2010 450d4ff5 ths
        if (with_reg_prefix)
2011 450d4ff5 ths
          *tp++ = REGISTER_PREFIX_CHAR;
2012 450d4ff5 ths
        *tp++ = 'a';
2013 450d4ff5 ths
        *tp++ = 'c';
2014 450d4ff5 ths
        *tp++ = 'r';
2015 450d4ff5 ths
        break;
2016 450d4ff5 ths
2017 450d4ff5 ths
      case '[':
2018 450d4ff5 ths
      case ']':
2019 450d4ff5 ths
      case ',':
2020 450d4ff5 ths
        *tp++ = *s;
2021 450d4ff5 ths
        break;
2022 450d4ff5 ths
2023 450d4ff5 ths
      case '!':
2024 450d4ff5 ths
        /* Ignore at this point; used at earlier stages to avoid
2025 450d4ff5 ths
           recognition if there's a prefix at something that in other
2026 450d4ff5 ths
           ways looks like a "pop".  */
2027 450d4ff5 ths
        break;
2028 450d4ff5 ths
2029 450d4ff5 ths
      case 'd':
2030 450d4ff5 ths
        /* Ignore.  This is an optional ".d " on the large one of
2031 450d4ff5 ths
           relaxable insns.  */
2032 450d4ff5 ths
        break;
2033 450d4ff5 ths
2034 450d4ff5 ths
      case 'B':
2035 450d4ff5 ths
        /* This was the prefix that made this a "push".  We've already
2036 450d4ff5 ths
           handled it by recognizing it, so signal that the prefix is
2037 450d4ff5 ths
           handled by setting it to NULL.  */
2038 450d4ff5 ths
        prefix_opcodep = NULL;
2039 450d4ff5 ths
        break;
2040 450d4ff5 ths
2041 450d4ff5 ths
      case 'D':
2042 450d4ff5 ths
      case 'r':
2043 450d4ff5 ths
        tp = format_reg (disdata, insn & 15, tp, with_reg_prefix);
2044 450d4ff5 ths
        break;
2045 450d4ff5 ths
2046 450d4ff5 ths
      case 'R':
2047 450d4ff5 ths
        tp = format_reg (disdata, (insn >> 12) & 15, tp, with_reg_prefix);
2048 450d4ff5 ths
        break;
2049 450d4ff5 ths
2050 450d4ff5 ths
      case 'n':
2051 450d4ff5 ths
        {
2052 450d4ff5 ths
          /* Like N but pc-relative to the start of the insn.  */
2053 450d4ff5 ths
          unsigned long number
2054 450d4ff5 ths
            = (buffer[2] + buffer[3] * 256 + buffer[4] * 65536
2055 450d4ff5 ths
               + buffer[5] * 0x1000000 + addr);
2056 450d4ff5 ths
2057 450d4ff5 ths
          /* Finish off and output previous formatted bytes.  */
2058 450d4ff5 ths
          *tp = 0;
2059 450d4ff5 ths
          if (temp[0])
2060 450d4ff5 ths
            (*info->fprintf_func) (info->stream, "%s", temp);
2061 450d4ff5 ths
          tp = temp;
2062 450d4ff5 ths
2063 450d4ff5 ths
          (*info->print_address_func) ((bfd_vma) number, info);
2064 450d4ff5 ths
        }
2065 450d4ff5 ths
        break;
2066 450d4ff5 ths
2067 450d4ff5 ths
      case 'u':
2068 450d4ff5 ths
        {
2069 450d4ff5 ths
          /* Like n but the offset is bits <3:0> in the instruction.  */
2070 450d4ff5 ths
          unsigned long number = (buffer[0] & 0xf) * 2 + addr;
2071 450d4ff5 ths
2072 450d4ff5 ths
          /* Finish off and output previous formatted bytes.  */
2073 450d4ff5 ths
          *tp = 0;
2074 450d4ff5 ths
          if (temp[0])
2075 450d4ff5 ths
            (*info->fprintf_func) (info->stream, "%s", temp);
2076 450d4ff5 ths
          tp = temp;
2077 450d4ff5 ths
2078 450d4ff5 ths
          (*info->print_address_func) ((bfd_vma) number, info);
2079 450d4ff5 ths
        }
2080 450d4ff5 ths
        break;
2081 450d4ff5 ths
2082 450d4ff5 ths
      case 'N':
2083 450d4ff5 ths
      case 'y':
2084 450d4ff5 ths
      case 'Y':
2085 450d4ff5 ths
      case 'S':
2086 450d4ff5 ths
      case 's':
2087 450d4ff5 ths
        /* Any "normal" memory operand.  */
2088 450d4ff5 ths
        if ((insn & 0x400) && (insn & 15) == 15 && prefix_opcodep == NULL)
2089 450d4ff5 ths
          {
2090 450d4ff5 ths
            /* We're looking at [pc+], i.e. we need to output an immediate
2091 450d4ff5 ths
               number, where the size can depend on different things.  */
2092 450d4ff5 ths
            long number;
2093 450d4ff5 ths
            int signedp
2094 450d4ff5 ths
              = ((*cs == 'z' && (insn & 0x20))
2095 450d4ff5 ths
                 || opcodep->match == BDAP_QUICK_OPCODE);
2096 450d4ff5 ths
            int nbytes;
2097 450d4ff5 ths
2098 450d4ff5 ths
            if (opcodep->imm_oprnd_size == SIZE_FIX_32)
2099 450d4ff5 ths
              nbytes = 4;
2100 450d4ff5 ths
            else if (opcodep->imm_oprnd_size == SIZE_SPEC_REG)
2101 450d4ff5 ths
              {
2102 450d4ff5 ths
                const struct cris_spec_reg *sregp
2103 450d4ff5 ths
                  = spec_reg_info ((insn >> 12) & 15, disdata->distype);
2104 450d4ff5 ths
2105 450d4ff5 ths
                /* A NULL return should have been as a non-match earlier,
2106 450d4ff5 ths
                   so catch it as an internal error in the error-case
2107 450d4ff5 ths
                   below.  */
2108 450d4ff5 ths
                if (sregp == NULL)
2109 450d4ff5 ths
                  /* Whatever non-valid size.  */
2110 450d4ff5 ths
                  nbytes = 42;
2111 450d4ff5 ths
                else
2112 450d4ff5 ths
                  /* PC is always incremented by a multiple of two.
2113 450d4ff5 ths
                     For CRISv32, immediates are always 4 bytes for
2114 450d4ff5 ths
                     special registers.  */
2115 450d4ff5 ths
                  nbytes = disdata->distype == cris_dis_v32
2116 450d4ff5 ths
                    ? 4 : (sregp->reg_size + 1) & ~1;
2117 450d4ff5 ths
              }
2118 450d4ff5 ths
            else
2119 450d4ff5 ths
              {
2120 450d4ff5 ths
                int mode_size = 1 << ((insn >> 4) & (*cs == 'z' ? 1 : 3));
2121 450d4ff5 ths
2122 450d4ff5 ths
                if (mode_size == 1)
2123 450d4ff5 ths
                  nbytes = 2;
2124 450d4ff5 ths
                else
2125 450d4ff5 ths
                  nbytes = mode_size;
2126 450d4ff5 ths
              }
2127 450d4ff5 ths
2128 450d4ff5 ths
            switch (nbytes)
2129 450d4ff5 ths
              {
2130 450d4ff5 ths
              case 1:
2131 450d4ff5 ths
                number = buffer[2];
2132 450d4ff5 ths
                if (signedp && number > 127)
2133 450d4ff5 ths
                  number -= 256;
2134 450d4ff5 ths
                break;
2135 450d4ff5 ths
2136 450d4ff5 ths
              case 2:
2137 450d4ff5 ths
                number = buffer[2] + buffer[3] * 256;
2138 450d4ff5 ths
                if (signedp && number > 32767)
2139 450d4ff5 ths
                  number -= 65536;
2140 450d4ff5 ths
                break;
2141 450d4ff5 ths
2142 450d4ff5 ths
              case 4:
2143 450d4ff5 ths
                number
2144 450d4ff5 ths
                  = buffer[2] + buffer[3] * 256 + buffer[4] * 65536
2145 450d4ff5 ths
                  + buffer[5] * 0x1000000;
2146 450d4ff5 ths
                break;
2147 450d4ff5 ths
2148 450d4ff5 ths
              default:
2149 450d4ff5 ths
                strcpy (tp, "bug");
2150 450d4ff5 ths
                tp += 3;
2151 450d4ff5 ths
                number = 42;
2152 450d4ff5 ths
              }
2153 450d4ff5 ths
2154 450d4ff5 ths
            if ((*cs == 'z' && (insn & 0x20))
2155 450d4ff5 ths
                || (opcodep->match == BDAP_QUICK_OPCODE
2156 450d4ff5 ths
                    && (nbytes <= 2 || buffer[1 + nbytes] == 0)))
2157 450d4ff5 ths
              tp = format_dec (number, tp, signedp);
2158 450d4ff5 ths
            else
2159 450d4ff5 ths
              {
2160 450d4ff5 ths
                unsigned int highbyte = (number >> 24) & 0xff;
2161 450d4ff5 ths
2162 450d4ff5 ths
                /* Either output this as an address or as a number.  If it's
2163 450d4ff5 ths
                   a dword with the same high-byte as the address of the
2164 450d4ff5 ths
                   insn, assume it's an address, and also if it's a non-zero
2165 450d4ff5 ths
                   non-0xff high-byte.  If this is a jsr or a jump, then
2166 450d4ff5 ths
                   it's definitely an address.  */
2167 450d4ff5 ths
                if (nbytes == 4
2168 450d4ff5 ths
                    && (highbyte == ((addr >> 24) & 0xff)
2169 450d4ff5 ths
                        || (highbyte != 0 && highbyte != 0xff)
2170 450d4ff5 ths
                        || info->insn_type == dis_branch
2171 450d4ff5 ths
                        || info->insn_type == dis_jsr))
2172 450d4ff5 ths
                  {
2173 450d4ff5 ths
                    /* Finish off and output previous formatted bytes.  */
2174 450d4ff5 ths
                    *tp = 0;
2175 450d4ff5 ths
                    tp = temp;
2176 450d4ff5 ths
                    if (temp[0])
2177 450d4ff5 ths
                      (*info->fprintf_func) (info->stream, "%s", temp);
2178 450d4ff5 ths
2179 450d4ff5 ths
                    (*info->print_address_func) ((bfd_vma) number, info);
2180 450d4ff5 ths
2181 450d4ff5 ths
                    info->target = number;
2182 450d4ff5 ths
                  }
2183 450d4ff5 ths
                else
2184 450d4ff5 ths
                  tp = format_hex (number, tp, disdata);
2185 450d4ff5 ths
              }
2186 450d4ff5 ths
          }
2187 450d4ff5 ths
        else
2188 450d4ff5 ths
          {
2189 450d4ff5 ths
            /* Not an immediate number.  Then this is a (possibly
2190 450d4ff5 ths
               prefixed) memory operand.  */
2191 450d4ff5 ths
            if (info->insn_type != dis_nonbranch)
2192 450d4ff5 ths
              {
2193 450d4ff5 ths
                int mode_size
2194 450d4ff5 ths
                  = 1 << ((insn >> 4)
2195 450d4ff5 ths
                          & (opcodep->args[0] == 'z' ? 1 : 3));
2196 450d4ff5 ths
                int size;
2197 450d4ff5 ths
                info->insn_type = dis_dref;
2198 450d4ff5 ths
                info->flags |= CRIS_DIS_FLAG_MEMREF;
2199 450d4ff5 ths
2200 450d4ff5 ths
                if (opcodep->imm_oprnd_size == SIZE_FIX_32)
2201 450d4ff5 ths
                  size = 4;
2202 450d4ff5 ths
                else if (opcodep->imm_oprnd_size == SIZE_SPEC_REG)
2203 450d4ff5 ths
                  {
2204 450d4ff5 ths
                    const struct cris_spec_reg *sregp
2205 450d4ff5 ths
                      = spec_reg_info ((insn >> 12) & 15, disdata->distype);
2206 450d4ff5 ths
2207 450d4ff5 ths
                    /* FIXME: Improve error handling; should have been caught
2208 450d4ff5 ths
                       earlier.  */
2209 450d4ff5 ths
                    if (sregp == NULL)
2210 450d4ff5 ths
                      size = 4;
2211 450d4ff5 ths
                    else
2212 450d4ff5 ths
                      size = sregp->reg_size;
2213 450d4ff5 ths
                  }
2214 450d4ff5 ths
                else
2215 450d4ff5 ths
                  size = mode_size;
2216 450d4ff5 ths
2217 450d4ff5 ths
                info->data_size = size;
2218 450d4ff5 ths
              }
2219 450d4ff5 ths
2220 450d4ff5 ths
            *tp++ = '[';
2221 450d4ff5 ths
2222 450d4ff5 ths
            if (prefix_opcodep
2223 450d4ff5 ths
                /* We don't match dip with a postincremented field
2224 450d4ff5 ths
                   as a side-effect address mode.  */
2225 450d4ff5 ths
                && ((insn & 0x400) == 0
2226 450d4ff5 ths
                    || prefix_opcodep->match != DIP_OPCODE))
2227 450d4ff5 ths
              {
2228 450d4ff5 ths
                if (insn & 0x400)
2229 450d4ff5 ths
                  {
2230 450d4ff5 ths
                    tp = format_reg (disdata, insn & 15, tp, with_reg_prefix);
2231 450d4ff5 ths
                    *tp++ = '=';
2232 450d4ff5 ths
                  }
2233 450d4ff5 ths
2234 450d4ff5 ths
2235 450d4ff5 ths
                /* We mainly ignore the prefix format string when the
2236 450d4ff5 ths
                   address-mode syntax is output.  */
2237 450d4ff5 ths
                switch (prefix_opcodep->match)
2238 450d4ff5 ths
                  {
2239 450d4ff5 ths
                  case DIP_OPCODE:
2240 450d4ff5 ths
                    /* It's [r], [r+] or [pc+].  */
2241 450d4ff5 ths
                    if ((prefix_insn & 0x400) && (prefix_insn & 15) == 15)
2242 450d4ff5 ths
                      {
2243 450d4ff5 ths
                        /* It's [pc+].  This cannot possibly be anything
2244 450d4ff5 ths
                           but an address.  */
2245 450d4ff5 ths
                        unsigned long number
2246 450d4ff5 ths
                          = prefix_buffer[2] + prefix_buffer[3] * 256
2247 450d4ff5 ths
                          + prefix_buffer[4] * 65536
2248 450d4ff5 ths
                          + prefix_buffer[5] * 0x1000000;
2249 450d4ff5 ths
2250 450d4ff5 ths
                        info->target = (bfd_vma) number;
2251 450d4ff5 ths
2252 450d4ff5 ths
                        /* Finish off and output previous formatted
2253 450d4ff5 ths
                           data.  */
2254 450d4ff5 ths
                        *tp = 0;
2255 450d4ff5 ths
                        tp = temp;
2256 450d4ff5 ths
                        if (temp[0])
2257 450d4ff5 ths
                          (*info->fprintf_func) (info->stream, "%s", temp);
2258 450d4ff5 ths
2259 450d4ff5 ths
                        (*info->print_address_func) ((bfd_vma) number, info);
2260 450d4ff5 ths
                      }
2261 450d4ff5 ths
                    else
2262 450d4ff5 ths
                      {
2263 450d4ff5 ths
                        /* For a memref in an address, we use target2.
2264 450d4ff5 ths
                           In this case, target is zero.  */
2265 450d4ff5 ths
                        info->flags
2266 450d4ff5 ths
                          |= (CRIS_DIS_FLAG_MEM_TARGET2_IS_REG
2267 450d4ff5 ths
                              | CRIS_DIS_FLAG_MEM_TARGET2_MEM);
2268 450d4ff5 ths
2269 450d4ff5 ths
                        info->target2 = prefix_insn & 15;
2270 450d4ff5 ths
2271 450d4ff5 ths
                        *tp++ = '[';
2272 450d4ff5 ths
                        tp = format_reg (disdata, prefix_insn & 15, tp,
2273 450d4ff5 ths
                                         with_reg_prefix);
2274 450d4ff5 ths
                        if (prefix_insn & 0x400)
2275 450d4ff5 ths
                          *tp++ = '+';
2276 450d4ff5 ths
                        *tp++ = ']';
2277 450d4ff5 ths
                      }
2278 450d4ff5 ths
                    break;
2279 450d4ff5 ths
2280 450d4ff5 ths
                  case BDAP_QUICK_OPCODE:
2281 450d4ff5 ths
                    {
2282 450d4ff5 ths
                      int number;
2283 450d4ff5 ths
2284 450d4ff5 ths
                      number = prefix_buffer[0];
2285 450d4ff5 ths
                      if (number > 127)
2286 450d4ff5 ths
                        number -= 256;
2287 450d4ff5 ths
2288 450d4ff5 ths
                      /* Output "reg+num" or, if num < 0, "reg-num".  */
2289 450d4ff5 ths
                      tp = format_reg (disdata, (prefix_insn >> 12) & 15, tp,
2290 450d4ff5 ths
                                       with_reg_prefix);
2291 450d4ff5 ths
                      if (number >= 0)
2292 450d4ff5 ths
                        *tp++ = '+';
2293 450d4ff5 ths
                      tp = format_dec (number, tp, 1);
2294 450d4ff5 ths
2295 450d4ff5 ths
                      info->flags |= CRIS_DIS_FLAG_MEM_TARGET_IS_REG;
2296 450d4ff5 ths
                      info->target = (prefix_insn >> 12) & 15;
2297 450d4ff5 ths
                      info->target2 = (bfd_vma) number;
2298 450d4ff5 ths
                      break;
2299 450d4ff5 ths
                    }
2300 450d4ff5 ths
2301 450d4ff5 ths
                  case BIAP_OPCODE:
2302 450d4ff5 ths
                    /* Output "r+R.m".  */
2303 450d4ff5 ths
                    tp = format_reg (disdata, prefix_insn & 15, tp,
2304 450d4ff5 ths
                                     with_reg_prefix);
2305 450d4ff5 ths
                    *tp++ = '+';
2306 450d4ff5 ths
                    tp = format_reg (disdata, (prefix_insn >> 12) & 15, tp,
2307 450d4ff5 ths
                                     with_reg_prefix);
2308 450d4ff5 ths
                    *tp++ = '.';
2309 450d4ff5 ths
                    *tp++ = mode_char[(prefix_insn >> 4) & 3];
2310 450d4ff5 ths
2311 450d4ff5 ths
                    info->flags
2312 450d4ff5 ths
                      |= (CRIS_DIS_FLAG_MEM_TARGET2_IS_REG
2313 450d4ff5 ths
                          | CRIS_DIS_FLAG_MEM_TARGET_IS_REG
2314 450d4ff5 ths
2315 450d4ff5 ths
                          | ((prefix_insn & 0x8000)
2316 450d4ff5 ths
                             ? CRIS_DIS_FLAG_MEM_TARGET2_MULT4
2317 450d4ff5 ths
                             : ((prefix_insn & 0x8000)
2318 450d4ff5 ths
                                ? CRIS_DIS_FLAG_MEM_TARGET2_MULT2 : 0)));
2319 450d4ff5 ths
2320 450d4ff5 ths
                    /* Is it the casejump?  It's a "adds.w [pc+r%d.w],pc".  */
2321 450d4ff5 ths
                    if (insn == 0xf83f && (prefix_insn & ~0xf000) == 0x55f)
2322 450d4ff5 ths
                      /* Then start interpreting data as offsets.  */
2323 450d4ff5 ths
                      case_offset_counter = no_of_case_offsets;
2324 450d4ff5 ths
                    break;
2325 450d4ff5 ths
2326 450d4ff5 ths
                  case BDAP_INDIR_OPCODE:
2327 450d4ff5 ths
                    /* Output "r+s.m", or, if "s" is [pc+], "r+s" or
2328 450d4ff5 ths
                       "r-s".  */
2329 450d4ff5 ths
                    tp = format_reg (disdata, (prefix_insn >> 12) & 15, tp,
2330 450d4ff5 ths
                                     with_reg_prefix);
2331 450d4ff5 ths
2332 450d4ff5 ths
                    if ((prefix_insn & 0x400) && (prefix_insn & 15) == 15)
2333 450d4ff5 ths
                      {
2334 450d4ff5 ths
                        long number;
2335 450d4ff5 ths
                        unsigned int nbytes;
2336 450d4ff5 ths
2337 450d4ff5 ths
                        /* It's a value.  Get its size.  */
2338 450d4ff5 ths
                        int mode_size = 1 << ((prefix_insn >> 4) & 3);
2339 450d4ff5 ths
2340 450d4ff5 ths
                        if (mode_size == 1)
2341 450d4ff5 ths
                          nbytes = 2;
2342 450d4ff5 ths
                        else
2343 450d4ff5 ths
                          nbytes = mode_size;
2344 450d4ff5 ths
2345 450d4ff5 ths
                        switch (nbytes)
2346 450d4ff5 ths
                          {
2347 450d4ff5 ths
                          case 1:
2348 450d4ff5 ths
                            number = prefix_buffer[2];
2349 450d4ff5 ths
                            if (number > 127)
2350 450d4ff5 ths
                              number -= 256;
2351 450d4ff5 ths
                            break;
2352 450d4ff5 ths
2353 450d4ff5 ths
                          case 2:
2354 450d4ff5 ths
                            number = prefix_buffer[2] + prefix_buffer[3] * 256;
2355 450d4ff5 ths
                            if (number > 32767)
2356 450d4ff5 ths
                              number -= 65536;
2357 450d4ff5 ths
                            break;
2358 450d4ff5 ths
2359 450d4ff5 ths
                          case 4:
2360 450d4ff5 ths
                            number
2361 450d4ff5 ths
                              = prefix_buffer[2] + prefix_buffer[3] * 256
2362 450d4ff5 ths
                              + prefix_buffer[4] * 65536
2363 450d4ff5 ths
                              + prefix_buffer[5] * 0x1000000;
2364 450d4ff5 ths
                            break;
2365 450d4ff5 ths
2366 450d4ff5 ths
                          default:
2367 450d4ff5 ths
                            strcpy (tp, "bug");
2368 450d4ff5 ths
                            tp += 3;
2369 450d4ff5 ths
                            number = 42;
2370 450d4ff5 ths
                          }
2371 450d4ff5 ths
2372 450d4ff5 ths
                        info->flags |= CRIS_DIS_FLAG_MEM_TARGET_IS_REG;
2373 450d4ff5 ths
                        info->target2 = (bfd_vma) number;
2374 450d4ff5 ths
2375 450d4ff5 ths
                        /* If the size is dword, then assume it's an
2376 450d4ff5 ths
                           address.  */
2377 450d4ff5 ths
                        if (nbytes == 4)
2378 450d4ff5 ths
                          {
2379 450d4ff5 ths
                            /* Finish off and output previous formatted
2380 450d4ff5 ths
                               bytes.  */
2381 450d4ff5 ths
                            *tp++ = '+';
2382 450d4ff5 ths
                            *tp = 0;
2383 450d4ff5 ths
                            tp = temp;
2384 450d4ff5 ths
                            (*info->fprintf_func) (info->stream, "%s", temp);
2385 450d4ff5 ths
2386 450d4ff5 ths
                            (*info->print_address_func) ((bfd_vma) number, info);
2387 450d4ff5 ths
                          }
2388 450d4ff5 ths
                        else
2389 450d4ff5 ths
                          {
2390 450d4ff5 ths
                            if (number >= 0)
2391 450d4ff5 ths
                              *tp++ = '+';
2392 450d4ff5 ths
                            tp = format_dec (number, tp, 1);
2393 450d4ff5 ths
                          }
2394 450d4ff5 ths
                      }
2395 450d4ff5 ths
                    else
2396 450d4ff5 ths
                      {
2397 450d4ff5 ths
                        /* Output "r+[R].m" or "r+[R+].m".  */
2398 450d4ff5 ths
                        *tp++ = '+';
2399 450d4ff5 ths
                        *tp++ = '[';
2400 450d4ff5 ths
                        tp = format_reg (disdata, prefix_insn & 15, tp,
2401 450d4ff5 ths
                                         with_reg_prefix);
2402 450d4ff5 ths
                        if (prefix_insn & 0x400)
2403 450d4ff5 ths
                          *tp++ = '+';
2404 450d4ff5 ths
                        *tp++ = ']';
2405 450d4ff5 ths
                        *tp++ = '.';
2406 450d4ff5 ths
                        *tp++ = mode_char[(prefix_insn >> 4) & 3];
2407 450d4ff5 ths
2408 450d4ff5 ths
                        info->flags
2409 450d4ff5 ths
                          |= (CRIS_DIS_FLAG_MEM_TARGET2_IS_REG
2410 450d4ff5 ths
                              | CRIS_DIS_FLAG_MEM_TARGET2_MEM
2411 450d4ff5 ths
                              | CRIS_DIS_FLAG_MEM_TARGET_IS_REG
2412 450d4ff5 ths
2413 450d4ff5 ths
                              | (((prefix_insn >> 4) == 2)
2414 450d4ff5 ths
                                 ? 0
2415 450d4ff5 ths
                                 : (((prefix_insn >> 4) & 3) == 1
2416 450d4ff5 ths
                                    ? CRIS_DIS_FLAG_MEM_TARGET2_MEM_WORD
2417 450d4ff5 ths
                                    : CRIS_DIS_FLAG_MEM_TARGET2_MEM_BYTE)));
2418 450d4ff5 ths
                      }
2419 450d4ff5 ths
                    break;
2420 450d4ff5 ths
2421 450d4ff5 ths
                  default:
2422 450d4ff5 ths
                    (*info->fprintf_func) (info->stream, "?prefix-bug");
2423 450d4ff5 ths
                  }
2424 450d4ff5 ths
2425 450d4ff5 ths
                /* To mark that the prefix is used, reset it.  */
2426 450d4ff5 ths
                prefix_opcodep = NULL;
2427 450d4ff5 ths
              }
2428 450d4ff5 ths
            else
2429 450d4ff5 ths
              {
2430 450d4ff5 ths
                tp = format_reg (disdata, insn & 15, tp, with_reg_prefix);
2431 450d4ff5 ths
2432 450d4ff5 ths
                info->flags |= CRIS_DIS_FLAG_MEM_TARGET_IS_REG;
2433 450d4ff5 ths
                info->target = insn & 15;
2434 450d4ff5 ths
2435 450d4ff5 ths
                if (insn & 0x400)
2436 450d4ff5 ths
                  *tp++ = '+';
2437 450d4ff5 ths
              }
2438 450d4ff5 ths
            *tp++ = ']';
2439 450d4ff5 ths
          }
2440 450d4ff5 ths
        break;
2441 450d4ff5 ths
2442 450d4ff5 ths
      case 'x':
2443 450d4ff5 ths
        tp = format_reg (disdata, (insn >> 12) & 15, tp, with_reg_prefix);
2444 450d4ff5 ths
        *tp++ = '.';
2445 450d4ff5 ths
        *tp++ = mode_char[(insn >> 4) & 3];
2446 450d4ff5 ths
        break;
2447 450d4ff5 ths
2448 450d4ff5 ths
      case 'I':
2449 450d4ff5 ths
        tp = format_dec (insn & 63, tp, 0);
2450 450d4ff5 ths
        break;
2451 450d4ff5 ths
2452 450d4ff5 ths
      case 'b':
2453 450d4ff5 ths
        {
2454 450d4ff5 ths
          int where = buffer[2] + buffer[3] * 256;
2455 450d4ff5 ths
2456 450d4ff5 ths
          if (where > 32767)
2457 450d4ff5 ths
            where -= 65536;
2458 450d4ff5 ths
2459 450d4ff5 ths
          where += addr + ((disdata->distype == cris_dis_v32) ? 0 : 4);
2460 450d4ff5 ths
2461 450d4ff5 ths
          if (insn == BA_PC_INCR_OPCODE)
2462 450d4ff5 ths
            info->insn_type = dis_branch;
2463 450d4ff5 ths
          else
2464 450d4ff5 ths
            info->insn_type = dis_condbranch;
2465 450d4ff5 ths
2466 450d4ff5 ths
          info->target = (bfd_vma) where;
2467 450d4ff5 ths
2468 450d4ff5 ths
          *tp = 0;
2469 450d4ff5 ths
          tp = temp;
2470 450d4ff5 ths
          (*info->fprintf_func) (info->stream, "%s%s ",
2471 450d4ff5 ths
                                 temp, cris_cc_strings[insn >> 12]);
2472 450d4ff5 ths
2473 450d4ff5 ths
          (*info->print_address_func) ((bfd_vma) where, info);
2474 450d4ff5 ths
        }
2475 450d4ff5 ths
      break;
2476 450d4ff5 ths
2477 450d4ff5 ths
    case 'c':
2478 450d4ff5 ths
      tp = format_dec (insn & 31, tp, 0);
2479 450d4ff5 ths
      break;
2480 450d4ff5 ths
2481 450d4ff5 ths
    case 'C':
2482 450d4ff5 ths
      tp = format_dec (insn & 15, tp, 0);
2483 450d4ff5 ths
      break;
2484 450d4ff5 ths
2485 450d4ff5 ths
    case 'o':
2486 450d4ff5 ths
      {
2487 450d4ff5 ths
        long offset = insn & 0xfe;
2488 450d4ff5 ths
        bfd_vma target;
2489 450d4ff5 ths
2490 450d4ff5 ths
        if (insn & 1)
2491 450d4ff5 ths
          offset |= ~0xff;
2492 450d4ff5 ths
2493 450d4ff5 ths
        if (opcodep->match == BA_QUICK_OPCODE)
2494 450d4ff5 ths
          info->insn_type = dis_branch;
2495 450d4ff5 ths
        else
2496 450d4ff5 ths
          info->insn_type = dis_condbranch;
2497 450d4ff5 ths
2498 450d4ff5 ths
        target = addr + ((disdata->distype == cris_dis_v32) ? 0 : 2) + offset;
2499 450d4ff5 ths
        info->target = target;
2500 450d4ff5 ths
        *tp = 0;
2501 450d4ff5 ths
        tp = temp;
2502 450d4ff5 ths
        (*info->fprintf_func) (info->stream, "%s", temp);
2503 450d4ff5 ths
        (*info->print_address_func) (target, info);
2504 450d4ff5 ths
      }
2505 450d4ff5 ths
      break;
2506 450d4ff5 ths
2507 450d4ff5 ths
    case 'Q':
2508 450d4ff5 ths
    case 'O':
2509 450d4ff5 ths
      {
2510 450d4ff5 ths
        long number = buffer[0];
2511 450d4ff5 ths
2512 450d4ff5 ths
        if (number > 127)
2513 450d4ff5 ths
          number = number - 256;
2514 450d4ff5 ths
2515 450d4ff5 ths
        tp = format_dec (number, tp, 1);
2516 450d4ff5 ths
        *tp++ = ',';
2517 450d4ff5 ths
        tp = format_reg (disdata, (insn >> 12) & 15, tp, with_reg_prefix);
2518 450d4ff5 ths
      }
2519 450d4ff5 ths
      break;
2520 450d4ff5 ths
2521 450d4ff5 ths
    case 'f':
2522 450d4ff5 ths
      tp = print_flags (disdata, insn, tp);
2523 450d4ff5 ths
      break;
2524 450d4ff5 ths
2525 450d4ff5 ths
    case 'i':
2526 450d4ff5 ths
      tp = format_dec ((insn & 32) ? (insn & 31) | ~31L : insn & 31, tp, 1);
2527 450d4ff5 ths
      break;
2528 450d4ff5 ths
2529 450d4ff5 ths
    case 'P':
2530 450d4ff5 ths
      {
2531 450d4ff5 ths
        const struct cris_spec_reg *sregp
2532 450d4ff5 ths
          = spec_reg_info ((insn >> 12) & 15, disdata->distype);
2533 450d4ff5 ths
2534 450d4ff5 ths
        if (sregp->name == NULL)
2535 450d4ff5 ths
          /* Should have been caught as a non-match eariler.  */
2536 450d4ff5 ths
          *tp++ = '?';
2537 450d4ff5 ths
        else
2538 450d4ff5 ths
          {
2539 450d4ff5 ths
            if (with_reg_prefix)
2540 450d4ff5 ths
              *tp++ = REGISTER_PREFIX_CHAR;
2541 450d4ff5 ths
            strcpy (tp, sregp->name);
2542 450d4ff5 ths
            tp += strlen (tp);
2543 450d4ff5 ths
          }
2544 450d4ff5 ths
      }
2545 450d4ff5 ths
      break;
2546 450d4ff5 ths
2547 450d4ff5 ths
    default:
2548 450d4ff5 ths
      strcpy (tp, "???");
2549 450d4ff5 ths
      tp += 3;
2550 450d4ff5 ths
    }
2551 450d4ff5 ths
  }
2552 450d4ff5 ths
2553 450d4ff5 ths
  *tp = 0;
2554 450d4ff5 ths
2555 450d4ff5 ths
  if (prefix_opcodep)
2556 450d4ff5 ths
    (*info->fprintf_func) (info->stream, " (OOPS unused prefix \"%s: %s\")",
2557 450d4ff5 ths
                           prefix_opcodep->name, prefix_opcodep->args);
2558 450d4ff5 ths
2559 450d4ff5 ths
  (*info->fprintf_func) (info->stream, "%s", temp);
2560 450d4ff5 ths
2561 450d4ff5 ths
  /* Get info for matching case-tables, if we don't have any active.
2562 450d4ff5 ths
     We assume that the last constant seen is used; either in the insn
2563 450d4ff5 ths
     itself or in a "move.d const,rN, sub.d rN,rM"-like sequence.  */
2564 450d4ff5 ths
  if (TRACE_CASE && case_offset_counter == 0)
2565 450d4ff5 ths
    {
2566 450d4ff5 ths
      if (CONST_STRNEQ (opcodep->name, "sub"))
2567 450d4ff5 ths
        case_offset = last_immediate;
2568 450d4ff5 ths
2569 450d4ff5 ths
      /* It could also be an "add", if there are negative case-values.  */
2570 450d4ff5 ths
      else if (CONST_STRNEQ (opcodep->name, "add"))
2571 450d4ff5 ths
        /* The first case is the negated operand to the add.  */
2572 450d4ff5 ths
        case_offset = -last_immediate;
2573 450d4ff5 ths
2574 450d4ff5 ths
      /* A bound insn will tell us the number of cases.  */
2575 450d4ff5 ths
      else if (CONST_STRNEQ (opcodep->name, "bound"))
2576 450d4ff5 ths
        no_of_case_offsets = last_immediate + 1;
2577 450d4ff5 ths
2578 450d4ff5 ths
      /* A jump or jsr or branch breaks the chain of insns for a
2579 450d4ff5 ths
         case-table, so assume default first-case again.  */
2580 450d4ff5 ths
      else if (info->insn_type == dis_jsr
2581 450d4ff5 ths
               || info->insn_type == dis_branch
2582 450d4ff5 ths
               || info->insn_type == dis_condbranch)
2583 450d4ff5 ths
        case_offset = 0;
2584 450d4ff5 ths
    }
2585 450d4ff5 ths
}
2586 450d4ff5 ths
2587 450d4ff5 ths
2588 450d4ff5 ths
/* Print the CRIS instruction at address memaddr on stream.  Returns
2589 450d4ff5 ths
   length of the instruction, in bytes.  Prefix register names with `$' if
2590 450d4ff5 ths
   WITH_REG_PREFIX.  */
2591 450d4ff5 ths
2592 450d4ff5 ths
static int
2593 450d4ff5 ths
print_insn_cris_generic (bfd_vma memaddr,
2594 450d4ff5 ths
                         disassemble_info *info,
2595 450d4ff5 ths
                         bfd_boolean with_reg_prefix)
2596 450d4ff5 ths
{
2597 450d4ff5 ths
  int nbytes;
2598 450d4ff5 ths
  unsigned int insn;
2599 450d4ff5 ths
  const struct cris_opcode *matchedp;
2600 450d4ff5 ths
  int advance = 0;
2601 450d4ff5 ths
  struct cris_disasm_data *disdata
2602 450d4ff5 ths
    = (struct cris_disasm_data *) info->private_data;
2603 450d4ff5 ths
2604 450d4ff5 ths
  /* No instruction will be disassembled as longer than this number of
2605 450d4ff5 ths
     bytes; stacked prefixes will not be expanded.  */
2606 450d4ff5 ths
  unsigned char buffer[MAX_BYTES_PER_CRIS_INSN];
2607 450d4ff5 ths
  unsigned char *bufp;
2608 450d4ff5 ths
  int status = 0;
2609 450d4ff5 ths
  bfd_vma addr;
2610 450d4ff5 ths
2611 450d4ff5 ths
  /* There will be an "out of range" error after the last instruction.
2612 450d4ff5 ths
     Reading pairs of bytes in decreasing number, we hope that we will get
2613 450d4ff5 ths
     at least the amount that we will consume.
2614 450d4ff5 ths

2615 450d4ff5 ths
     If we can't get any data, or we do not get enough data, we print
2616 450d4ff5 ths
     the error message.  */
2617 450d4ff5 ths
2618 bfaf9a43 edgar_igl
  nbytes = info->buffer_length;
2619 bfaf9a43 edgar_igl
  if (nbytes > MAX_BYTES_PER_CRIS_INSN)
2620 bfaf9a43 edgar_igl
          nbytes = MAX_BYTES_PER_CRIS_INSN;
2621 bfaf9a43 edgar_igl
  status = (*info->read_memory_func) (memaddr, buffer, nbytes, info);  
2622 450d4ff5 ths
2623 450d4ff5 ths
  /* If we did not get all we asked for, then clear the rest.
2624 450d4ff5 ths
     Hopefully this makes a reproducible result in case of errors.  */
2625 450d4ff5 ths
  if (nbytes != MAX_BYTES_PER_CRIS_INSN)
2626 450d4ff5 ths
    memset (buffer + nbytes, 0, MAX_BYTES_PER_CRIS_INSN - nbytes);
2627 450d4ff5 ths
2628 450d4ff5 ths
  addr = memaddr;
2629 450d4ff5 ths
  bufp = buffer;
2630 450d4ff5 ths
2631 450d4ff5 ths
  /* Set some defaults for the insn info.  */
2632 450d4ff5 ths
  info->insn_info_valid = 1;
2633 450d4ff5 ths
  info->branch_delay_insns = 0;
2634 450d4ff5 ths
  info->data_size = 0;
2635 450d4ff5 ths
  info->insn_type = dis_nonbranch;
2636 450d4ff5 ths
  info->flags = 0;
2637 450d4ff5 ths
  info->target = 0;
2638 450d4ff5 ths
  info->target2 = 0;
2639 450d4ff5 ths
2640 450d4ff5 ths
  /* If we got any data, disassemble it.  */
2641 450d4ff5 ths
  if (nbytes != 0)
2642 450d4ff5 ths
    {
2643 450d4ff5 ths
      matchedp = NULL;
2644 450d4ff5 ths
2645 450d4ff5 ths
      insn = bufp[0] + bufp[1] * 256;
2646 450d4ff5 ths
2647 450d4ff5 ths
      /* If we're in a case-table, don't disassemble the offsets.  */
2648 450d4ff5 ths
      if (TRACE_CASE && case_offset_counter != 0)
2649 450d4ff5 ths
        {
2650 450d4ff5 ths
          info->insn_type = dis_noninsn;
2651 450d4ff5 ths
          advance += 2;
2652 450d4ff5 ths
2653 450d4ff5 ths
          /* If to print data as offsets, then shortcut here.  */
2654 450d4ff5 ths
          (*info->fprintf_func) (info->stream, "case %ld%s: -> ",
2655 450d4ff5 ths
                                 case_offset + no_of_case_offsets
2656 450d4ff5 ths
                                 - case_offset_counter,
2657 450d4ff5 ths
                                 case_offset_counter == 1 ? "/default" :
2658 450d4ff5 ths
                                 "");
2659 450d4ff5 ths
2660 450d4ff5 ths
          (*info->print_address_func) ((bfd_vma)
2661 450d4ff5 ths
                                       ((short) (insn)
2662 450d4ff5 ths
                                        + (long) (addr
2663 450d4ff5 ths
                                                  - (no_of_case_offsets
2664 450d4ff5 ths
                                                     - case_offset_counter)
2665 450d4ff5 ths
                                                  * 2)), info);
2666 450d4ff5 ths
          case_offset_counter--;
2667 450d4ff5 ths
2668 450d4ff5 ths
          /* The default case start (without a "sub" or "add") must be
2669 450d4ff5 ths
             zero.  */
2670 450d4ff5 ths
          if (case_offset_counter == 0)
2671 450d4ff5 ths
            case_offset = 0;
2672 450d4ff5 ths
        }
2673 450d4ff5 ths
      else if (insn == 0)
2674 450d4ff5 ths
        {
2675 450d4ff5 ths
          /* We're often called to disassemble zeroes.  While this is a
2676 450d4ff5 ths
             valid "bcc .+2" insn, it is also useless enough and enough
2677 450d4ff5 ths
             of a nuiscance that we will just output "bcc .+2" for it
2678 450d4ff5 ths
             and signal it as a noninsn.  */
2679 450d4ff5 ths
          (*info->fprintf_func) (info->stream,
2680 450d4ff5 ths
                                 disdata->distype == cris_dis_v32
2681 450d4ff5 ths
                                 ? "bcc ." : "bcc .+2");
2682 450d4ff5 ths
          info->insn_type = dis_noninsn;
2683 450d4ff5 ths
          advance += 2;
2684 450d4ff5 ths
        }
2685 450d4ff5 ths
      else
2686 450d4ff5 ths
        {
2687 450d4ff5 ths
          const struct cris_opcode *prefix_opcodep = NULL;
2688 450d4ff5 ths
          unsigned char *prefix_buffer = bufp;
2689 450d4ff5 ths
          unsigned int prefix_insn = insn;
2690 450d4ff5 ths
          int prefix_size = 0;
2691 450d4ff5 ths
2692 450d4ff5 ths
          matchedp = get_opcode_entry (insn, NO_CRIS_PREFIX, disdata);
2693 450d4ff5 ths
2694 450d4ff5 ths
          /* Check if we're supposed to write out prefixes as address
2695 450d4ff5 ths
             modes and if this was a prefix.  */
2696 450d4ff5 ths
          if (matchedp != NULL && PARSE_PREFIX && matchedp->args[0] == 'p')
2697 450d4ff5 ths
            {
2698 450d4ff5 ths
              /* If it's a prefix, put it into the prefix vars and get the
2699 450d4ff5 ths
                 main insn.  */
2700 450d4ff5 ths
              prefix_size = bytes_to_skip (prefix_insn, matchedp,
2701 450d4ff5 ths
                                           disdata->distype, NULL);
2702 450d4ff5 ths
              prefix_opcodep = matchedp;
2703 450d4ff5 ths
2704 450d4ff5 ths
              insn = bufp[prefix_size] + bufp[prefix_size + 1] * 256;
2705 450d4ff5 ths
              matchedp = get_opcode_entry (insn, prefix_insn, disdata);
2706 450d4ff5 ths
2707 450d4ff5 ths
              if (matchedp != NULL)
2708 450d4ff5 ths
                {
2709 450d4ff5 ths
                  addr += prefix_size;
2710 450d4ff5 ths
                  bufp += prefix_size;
2711 450d4ff5 ths
                  advance += prefix_size;
2712 450d4ff5 ths
                }
2713 450d4ff5 ths
              else
2714 450d4ff5 ths
                {
2715 450d4ff5 ths
                  /* The "main" insn wasn't valid, at least not when
2716 450d4ff5 ths
                     prefixed.  Put back things enough to output the
2717 450d4ff5 ths
                     prefix insn only, as a normal insn.  */
2718 450d4ff5 ths
                  matchedp = prefix_opcodep;
2719 450d4ff5 ths
                  insn = prefix_insn;
2720 450d4ff5 ths
                  prefix_opcodep = NULL;
2721 450d4ff5 ths
                }
2722 450d4ff5 ths
            }
2723 450d4ff5 ths
2724 450d4ff5 ths
          if (matchedp == NULL)
2725 450d4ff5 ths
            {
2726 450d4ff5 ths
              (*info->fprintf_func) (info->stream, "??0x%x", insn);
2727 450d4ff5 ths
              advance += 2;
2728 450d4ff5 ths
2729 450d4ff5 ths
              info->insn_type = dis_noninsn;
2730 450d4ff5 ths
            }
2731 450d4ff5 ths
          else
2732 450d4ff5 ths
            {
2733 450d4ff5 ths
              advance
2734 450d4ff5 ths
                += bytes_to_skip (insn, matchedp, disdata->distype,
2735 450d4ff5 ths
                                  prefix_opcodep);
2736 450d4ff5 ths
2737 450d4ff5 ths
              /* The info_type and assorted fields will be set according
2738 450d4ff5 ths
                 to the operands.   */
2739 450d4ff5 ths
              print_with_operands (matchedp, insn, bufp, addr, info,
2740 450d4ff5 ths
                                   prefix_opcodep, prefix_insn,
2741 450d4ff5 ths
                                   prefix_buffer, with_reg_prefix);
2742 450d4ff5 ths
            }
2743 450d4ff5 ths
        }
2744 450d4ff5 ths
    }
2745 450d4ff5 ths
  else
2746 450d4ff5 ths
    info->insn_type = dis_noninsn;
2747 450d4ff5 ths
2748 450d4ff5 ths
  /* If we read less than MAX_BYTES_PER_CRIS_INSN, i.e. we got an error
2749 450d4ff5 ths
     status when reading that much, and the insn decoding indicated a
2750 450d4ff5 ths
     length exceeding what we read, there is an error.  */
2751 450d4ff5 ths
  if (status != 0 && (nbytes == 0 || advance > nbytes))
2752 450d4ff5 ths
    {
2753 450d4ff5 ths
      (*info->memory_error_func) (status, memaddr, info);
2754 450d4ff5 ths
      return -1;
2755 450d4ff5 ths
    }
2756 450d4ff5 ths
2757 450d4ff5 ths
  /* Max supported insn size with one folded prefix insn.  */
2758 450d4ff5 ths
  info->bytes_per_line = MAX_BYTES_PER_CRIS_INSN;
2759 450d4ff5 ths
2760 450d4ff5 ths
  /* I would like to set this to a fixed value larger than the actual
2761 450d4ff5 ths
     number of bytes to print in order to avoid spaces between bytes,
2762 450d4ff5 ths
     but objdump.c (2.9.1) does not like that, so we print 16-bit
2763 450d4ff5 ths
     chunks, which is the next choice.  */
2764 450d4ff5 ths
  info->bytes_per_chunk = 2;
2765 450d4ff5 ths
2766 450d4ff5 ths
  /* Printing bytes in order of increasing addresses makes sense,
2767 450d4ff5 ths
     especially on a little-endian target.
2768 450d4ff5 ths
     This is completely the opposite of what you think; setting this to
2769 450d4ff5 ths
     BFD_ENDIAN_LITTLE will print bytes in order N..0 rather than the 0..N
2770 450d4ff5 ths
     we want.  */
2771 450d4ff5 ths
  info->display_endian = BFD_ENDIAN_BIG;
2772 450d4ff5 ths
2773 450d4ff5 ths
  return advance;
2774 450d4ff5 ths
}
2775 450d4ff5 ths
2776 450d4ff5 ths
/* Disassemble, prefixing register names with `$'.  CRIS v0..v10.  */
2777 450d4ff5 ths
#if 0
2778 450d4ff5 ths
static int
2779 450d4ff5 ths
print_insn_cris_with_register_prefix (bfd_vma vma,
2780 450d4ff5 ths
                                      disassemble_info *info)
2781 450d4ff5 ths
{
2782 450d4ff5 ths
  if (info->private_data == NULL
2783 450d4ff5 ths
      && !cris_parse_disassembler_options (info, cris_dis_v0_v10))
2784 450d4ff5 ths
    return -1;
2785 450d4ff5 ths
  return print_insn_cris_generic (vma, info, TRUE);
2786 450d4ff5 ths
}
2787 450d4ff5 ths
#endif
2788 450d4ff5 ths
/* Disassemble, prefixing register names with `$'.  CRIS v32.  */
2789 450d4ff5 ths
2790 450d4ff5 ths
static int
2791 450d4ff5 ths
print_insn_crisv32_with_register_prefix (bfd_vma vma,
2792 450d4ff5 ths
                                         disassemble_info *info)
2793 450d4ff5 ths
{
2794 450d4ff5 ths
  if (info->private_data == NULL
2795 450d4ff5 ths
      && !cris_parse_disassembler_options (info, cris_dis_v32))
2796 450d4ff5 ths
    return -1;
2797 450d4ff5 ths
  return print_insn_cris_generic (vma, info, TRUE);
2798 450d4ff5 ths
}
2799 450d4ff5 ths
2800 450d4ff5 ths
#if 0
2801 450d4ff5 ths
/* Disassemble, prefixing register names with `$'.
2802 450d4ff5 ths
   Common v10 and v32 subset.  */
2803 450d4ff5 ths

2804 450d4ff5 ths
static int
2805 450d4ff5 ths
print_insn_crisv10_v32_with_register_prefix (bfd_vma vma,
2806 450d4ff5 ths
                                             disassemble_info *info)
2807 450d4ff5 ths
{
2808 450d4ff5 ths
  if (info->private_data == NULL
2809 450d4ff5 ths
      && !cris_parse_disassembler_options (info, cris_dis_common_v10_v32))
2810 450d4ff5 ths
    return -1;
2811 450d4ff5 ths
  return print_insn_cris_generic (vma, info, TRUE);
2812 450d4ff5 ths
}
2813 450d4ff5 ths

2814 450d4ff5 ths
/* Disassemble, no prefixes on register names.  CRIS v0..v10.  */
2815 450d4ff5 ths

2816 450d4ff5 ths
static int
2817 450d4ff5 ths
print_insn_cris_without_register_prefix (bfd_vma vma,
2818 450d4ff5 ths
                                         disassemble_info *info)
2819 450d4ff5 ths
{
2820 450d4ff5 ths
  if (info->private_data == NULL
2821 450d4ff5 ths
      && !cris_parse_disassembler_options (info, cris_dis_v0_v10))
2822 450d4ff5 ths
    return -1;
2823 450d4ff5 ths
  return print_insn_cris_generic (vma, info, FALSE);
2824 450d4ff5 ths
}
2825 450d4ff5 ths

2826 450d4ff5 ths
/* Disassemble, no prefixes on register names.  CRIS v32.  */
2827 450d4ff5 ths

2828 450d4ff5 ths
static int
2829 450d4ff5 ths
print_insn_crisv32_without_register_prefix (bfd_vma vma,
2830 450d4ff5 ths
                                            disassemble_info *info)
2831 450d4ff5 ths
{
2832 450d4ff5 ths
  if (info->private_data == NULL
2833 450d4ff5 ths
      && !cris_parse_disassembler_options (info, cris_dis_v32))
2834 450d4ff5 ths
    return -1;
2835 450d4ff5 ths
  return print_insn_cris_generic (vma, info, FALSE);
2836 450d4ff5 ths
}
2837 450d4ff5 ths

2838 450d4ff5 ths
/* Disassemble, no prefixes on register names.
2839 450d4ff5 ths
   Common v10 and v32 subset.  */
2840 450d4ff5 ths

2841 450d4ff5 ths
static int
2842 450d4ff5 ths
print_insn_crisv10_v32_without_register_prefix (bfd_vma vma,
2843 450d4ff5 ths
                                                disassemble_info *info)
2844 450d4ff5 ths
{
2845 450d4ff5 ths
  if (info->private_data == NULL
2846 450d4ff5 ths
      && !cris_parse_disassembler_options (info, cris_dis_common_v10_v32))
2847 450d4ff5 ths
    return -1;
2848 450d4ff5 ths
  return print_insn_cris_generic (vma, info, FALSE);
2849 450d4ff5 ths
}
2850 450d4ff5 ths
#endif
2851 450d4ff5 ths
2852 450d4ff5 ths
int
2853 450d4ff5 ths
print_insn_crisv32 (bfd_vma vma,
2854 450d4ff5 ths
                    disassemble_info *info)
2855 450d4ff5 ths
{
2856 450d4ff5 ths
  return print_insn_crisv32_with_register_prefix(vma, info);
2857 450d4ff5 ths
}
2858 450d4ff5 ths
2859 450d4ff5 ths
/* Return a disassembler-function that prints registers with a `$' prefix,
2860 450d4ff5 ths
   or one that prints registers without a prefix.
2861 450d4ff5 ths
   FIXME: We should improve the solution to avoid the multitude of
2862 450d4ff5 ths
   functions seen above.  */
2863 450d4ff5 ths
#if 0
2864 450d4ff5 ths
disassembler_ftype
2865 450d4ff5 ths
cris_get_disassembler (bfd *abfd)
2866 450d4ff5 ths
{
2867 450d4ff5 ths
  /* If there's no bfd in sight, we return what is valid as input in all
2868 450d4ff5 ths
     contexts if fed back to the assembler: disassembly *with* register
2869 450d4ff5 ths
     prefix.  Unfortunately this will be totally wrong for v32.  */
2870 450d4ff5 ths
  if (abfd == NULL)
2871 450d4ff5 ths
    return print_insn_cris_with_register_prefix;
2872 450d4ff5 ths

2873 450d4ff5 ths
  if (bfd_get_symbol_leading_char (abfd) == 0)
2874 450d4ff5 ths
    {
2875 450d4ff5 ths
      if (bfd_get_mach (abfd) == bfd_mach_cris_v32)
2876 450d4ff5 ths
        return print_insn_crisv32_with_register_prefix;
2877 450d4ff5 ths
      if (bfd_get_mach (abfd) == bfd_mach_cris_v10_v32)
2878 450d4ff5 ths
        return print_insn_crisv10_v32_with_register_prefix;
2879 450d4ff5 ths

2880 450d4ff5 ths
      /* We default to v10.  This may be specifically specified in the
2881 450d4ff5 ths
         bfd mach, but is also the default setting.  */
2882 450d4ff5 ths
      return print_insn_cris_with_register_prefix;
2883 450d4ff5 ths
    }
2884 450d4ff5 ths

2885 450d4ff5 ths
  if (bfd_get_mach (abfd) == bfd_mach_cris_v32)
2886 450d4ff5 ths
    return print_insn_crisv32_without_register_prefix;
2887 450d4ff5 ths
  if (bfd_get_mach (abfd) == bfd_mach_cris_v10_v32)
2888 450d4ff5 ths
    return print_insn_crisv10_v32_without_register_prefix;
2889 450d4ff5 ths
  return print_insn_cris_without_register_prefix;
2890 450d4ff5 ths
}
2891 450d4ff5 ths
#endif
2892 450d4ff5 ths
/* Local variables:
2893 450d4ff5 ths
   eval: (c-set-style "gnu")
2894 450d4ff5 ths
   indent-tabs-mode: t
2895 450d4ff5 ths
   End:  */