Statistics
| Branch: | Revision:

root / cris-dis.c @ 54cdaa1b

History | View | Annotate | Download (80.2 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 8167ee88 Blue Swirl
   along with this program; if not, see <http://www.gnu.org/licenses/>. */
20 450d4ff5 ths
21 47b01cf3 Stefan Weil
#include "qemu-common.h"
22 450d4ff5 ths
#include "dis-asm.h"
23 450d4ff5 ths
//#include "sysdep.h"
24 450d4ff5 ths
#include "target-cris/opcode-cris.h"
25 450d4ff5 ths
//#include "libiberty.h"
26 1eec614b aliguori
27 450d4ff5 ths
#define CONST_STRNEQ(STR1,STR2) (strncmp ((STR1), (STR2), sizeof (STR2) - 1) == 0)
28 450d4ff5 ths
29 450d4ff5 ths
/* cris-opc.c -- Table of opcodes for the CRIS processor.
30 450d4ff5 ths
   Copyright 2000, 2001, 2004 Free Software Foundation, Inc.
31 450d4ff5 ths
   Contributed by Axis Communications AB, Lund, Sweden.
32 450d4ff5 ths
   Originally written for GAS 1.38.1 by Mikael Asker.
33 450d4ff5 ths
   Reorganized by Hans-Peter Nilsson.
34 450d4ff5 ths

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

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

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

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

145 450d4ff5 ths
   - The match component is a mask saying which bits must match a
146 450d4ff5 ths
     particular opcode in order for an instruction to be an instance
147 450d4ff5 ths
     of that opcode.
148 450d4ff5 ths

149 450d4ff5 ths
   - The args component is a string containing characters symbolically
150 450d4ff5 ths
     matching the operands of an instruction.  Used for both assembly
151 450d4ff5 ths
     and disassembly.
152 450d4ff5 ths

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

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

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

1257 450d4ff5 ths
   This is the assembly form of a switch-statement in C.
1258 450d4ff5 ths
   The "sub is optional.  If there is none, then X will be zero.
1259 450d4ff5 ths
   X is the value of the first case,
1260 450d4ff5 ths
   Y is the number of cases (including default).
1261 450d4ff5 ths

1262 450d4ff5 ths
   This results in case offsets printed on the form:
1263 450d4ff5 ths
    case N: -> case_address
1264 450d4ff5 ths
   where N is an estimation on the corresponding 'case' operand in C,
1265 450d4ff5 ths
   and case_address is where execution of that case continues after the
1266 450d4ff5 ths
   sequence presented above.
1267 450d4ff5 ths

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

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

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

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

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

2797 450d4ff5 ths
static int
2798 450d4ff5 ths
print_insn_crisv10_v32_with_register_prefix (bfd_vma vma,
2799 450d4ff5 ths
                                             disassemble_info *info)
2800 450d4ff5 ths
{
2801 450d4ff5 ths
  if (info->private_data == NULL
2802 450d4ff5 ths
      && !cris_parse_disassembler_options (info, cris_dis_common_v10_v32))
2803 450d4ff5 ths
    return -1;
2804 47cbc7aa Juan Quintela
  return print_insn_cris_generic (vma, info, true);
2805 450d4ff5 ths
}
2806 450d4ff5 ths

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

2809 450d4ff5 ths
static int
2810 450d4ff5 ths
print_insn_cris_without_register_prefix (bfd_vma vma,
2811 450d4ff5 ths
                                         disassemble_info *info)
2812 450d4ff5 ths
{
2813 450d4ff5 ths
  if (info->private_data == NULL
2814 450d4ff5 ths
      && !cris_parse_disassembler_options (info, cris_dis_v0_v10))
2815 450d4ff5 ths
    return -1;
2816 47cbc7aa Juan Quintela
  return print_insn_cris_generic (vma, info, false);
2817 450d4ff5 ths
}
2818 450d4ff5 ths

2819 450d4ff5 ths
/* Disassemble, no prefixes on register names.  CRIS v32.  */
2820 450d4ff5 ths

2821 450d4ff5 ths
static int
2822 450d4ff5 ths
print_insn_crisv32_without_register_prefix (bfd_vma vma,
2823 450d4ff5 ths
                                            disassemble_info *info)
2824 450d4ff5 ths
{
2825 450d4ff5 ths
  if (info->private_data == NULL
2826 450d4ff5 ths
      && !cris_parse_disassembler_options (info, cris_dis_v32))
2827 450d4ff5 ths
    return -1;
2828 47cbc7aa Juan Quintela
  return print_insn_cris_generic (vma, info, false);
2829 450d4ff5 ths
}
2830 450d4ff5 ths

2831 450d4ff5 ths
/* Disassemble, no prefixes on register names.
2832 450d4ff5 ths
   Common v10 and v32 subset.  */
2833 450d4ff5 ths

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

2866 450d4ff5 ths
  if (bfd_get_symbol_leading_char (abfd) == 0)
2867 450d4ff5 ths
    {
2868 450d4ff5 ths
      if (bfd_get_mach (abfd) == bfd_mach_cris_v32)
2869 450d4ff5 ths
        return print_insn_crisv32_with_register_prefix;
2870 450d4ff5 ths
      if (bfd_get_mach (abfd) == bfd_mach_cris_v10_v32)
2871 450d4ff5 ths
        return print_insn_crisv10_v32_with_register_prefix;
2872 450d4ff5 ths

2873 450d4ff5 ths
      /* We default to v10.  This may be specifically specified in the
2874 450d4ff5 ths
         bfd mach, but is also the default setting.  */
2875 450d4ff5 ths
      return print_insn_cris_with_register_prefix;
2876 450d4ff5 ths
    }
2877 450d4ff5 ths

2878 450d4ff5 ths
  if (bfd_get_mach (abfd) == bfd_mach_cris_v32)
2879 450d4ff5 ths
    return print_insn_crisv32_without_register_prefix;
2880 450d4ff5 ths
  if (bfd_get_mach (abfd) == bfd_mach_cris_v10_v32)
2881 450d4ff5 ths
    return print_insn_crisv10_v32_without_register_prefix;
2882 450d4ff5 ths
  return print_insn_cris_without_register_prefix;
2883 450d4ff5 ths
}
2884 450d4ff5 ths
#endif
2885 450d4ff5 ths
/* Local variables:
2886 450d4ff5 ths
   eval: (c-set-style "gnu")
2887 450d4ff5 ths
   indent-tabs-mode: t
2888 450d4ff5 ths
   End:  */