1 /* Disassembler code for CRIS.
2 Copyright 2000, 2001, 2002, 2004, 2005, 2006 Free Software Foundation, Inc.
3 Contributed by Axis Communications AB, Lund, Sweden.
4 Written by Hans-Peter Nilsson.
6 This file is part of the GNU binutils and GDB, the GNU debugger.
8 This program is free software; you can redistribute it and/or modify it
9 under the terms of the GNU General Public License as published by the
10 Free Software Foundation; either version 2, or (at your option) any later
13 This program is distributed in the hope that it will be useful, but WITHOUT
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, see <http://www.gnu.org/licenses/>. */
21 #include "qemu/osdep.h"
22 #include "qemu-common.h"
23 #include "disas/bfd.h"
24 #include "target/cris/opcode-cris.h"
26 #define CONST_STRNEQ(STR1,STR2) (strncmp ((STR1), (STR2), sizeof (STR2) - 1) == 0)
28 /* cris-opc.c -- Table of opcodes for the CRIS processor.
29 Copyright 2000, 2001, 2004 Free Software Foundation, Inc.
30 Contributed by Axis Communications AB, Lund, Sweden.
31 Originally written for GAS 1.38.1 by Mikael Asker.
32 Reorganized by Hans-Peter Nilsson.
34 This file is part of GAS, GDB and the GNU binutils.
36 GAS, GDB, and GNU binutils is free software; you can redistribute it
37 and/or modify it under the terms of the GNU General Public License as
38 published by the Free Software Foundation; either version 2, or (at your
39 option) any later version.
41 GAS, GDB, and GNU binutils are distributed in the hope that they will be
42 useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
43 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
44 GNU General Public License for more details.
46 You should have received a copy of the GNU General Public License
47 along with this program; if not, see <http://www.gnu.org/licenses/>. */
53 /* This table isn't used for CRISv32 and the size of immediate operands. */
54 const struct cris_spec_reg
57 {"bz", 0, 1, cris_ver_v32p
, NULL
},
58 {"p0", 0, 1, 0, NULL
},
59 {"vr", 1, 1, 0, NULL
},
60 {"p1", 1, 1, 0, NULL
},
61 {"pid", 2, 1, cris_ver_v32p
, NULL
},
62 {"p2", 2, 1, cris_ver_v32p
, NULL
},
63 {"p2", 2, 1, cris_ver_warning
, NULL
},
64 {"srs", 3, 1, cris_ver_v32p
, NULL
},
65 {"p3", 3, 1, cris_ver_v32p
, NULL
},
66 {"p3", 3, 1, cris_ver_warning
, NULL
},
67 {"wz", 4, 2, cris_ver_v32p
, NULL
},
68 {"p4", 4, 2, 0, NULL
},
69 {"ccr", 5, 2, cris_ver_v0_10
, NULL
},
70 {"exs", 5, 4, cris_ver_v32p
, NULL
},
71 {"p5", 5, 2, cris_ver_v0_10
, NULL
},
72 {"p5", 5, 4, cris_ver_v32p
, NULL
},
73 {"dcr0",6, 2, cris_ver_v0_3
, NULL
},
74 {"eda", 6, 4, cris_ver_v32p
, NULL
},
75 {"p6", 6, 2, cris_ver_v0_3
, NULL
},
76 {"p6", 6, 4, cris_ver_v32p
, NULL
},
77 {"dcr1/mof", 7, 4, cris_ver_v10p
,
78 "Register `dcr1/mof' with ambiguous size specified. Guessing 4 bytes"},
79 {"dcr1/mof", 7, 2, cris_ver_v0_3
,
80 "Register `dcr1/mof' with ambiguous size specified. Guessing 2 bytes"},
81 {"mof", 7, 4, cris_ver_v10p
, NULL
},
82 {"dcr1",7, 2, cris_ver_v0_3
, NULL
},
83 {"p7", 7, 4, cris_ver_v10p
, NULL
},
84 {"p7", 7, 2, cris_ver_v0_3
, NULL
},
85 {"dz", 8, 4, cris_ver_v32p
, NULL
},
86 {"p8", 8, 4, 0, NULL
},
87 {"ibr", 9, 4, cris_ver_v0_10
, NULL
},
88 {"ebp", 9, 4, cris_ver_v32p
, NULL
},
89 {"p9", 9, 4, 0, NULL
},
90 {"irp", 10, 4, cris_ver_v0_10
, NULL
},
91 {"erp", 10, 4, cris_ver_v32p
, NULL
},
92 {"p10", 10, 4, 0, NULL
},
93 {"srp", 11, 4, 0, NULL
},
94 {"p11", 11, 4, 0, NULL
},
95 /* For disassembly use only. Accept at assembly with a warning. */
96 {"bar/dtp0", 12, 4, cris_ver_warning
,
97 "Ambiguous register `bar/dtp0' specified"},
98 {"nrp", 12, 4, cris_ver_v32p
, NULL
},
99 {"bar", 12, 4, cris_ver_v8_10
, NULL
},
100 {"dtp0",12, 4, cris_ver_v0_3
, NULL
},
101 {"p12", 12, 4, 0, NULL
},
102 /* For disassembly use only. Accept at assembly with a warning. */
103 {"dccr/dtp1",13, 4, cris_ver_warning
,
104 "Ambiguous register `dccr/dtp1' specified"},
105 {"ccs", 13, 4, cris_ver_v32p
, NULL
},
106 {"dccr",13, 4, cris_ver_v8_10
, NULL
},
107 {"dtp1",13, 4, cris_ver_v0_3
, NULL
},
108 {"p13", 13, 4, 0, NULL
},
109 {"brp", 14, 4, cris_ver_v3_10
, NULL
},
110 {"usp", 14, 4, cris_ver_v32p
, NULL
},
111 {"p14", 14, 4, cris_ver_v3p
, NULL
},
112 {"usp", 15, 4, cris_ver_v10
, NULL
},
113 {"spc", 15, 4, cris_ver_v32p
, NULL
},
114 {"p15", 15, 4, cris_ver_v10p
, NULL
},
115 {NULL
, 0, 0, cris_ver_version_all
, NULL
}
118 /* Add version specifiers to this table when necessary.
119 The (now) regular coding of register names suggests a simpler
121 const struct cris_support_reg cris_support_regs
[] =
142 /* All CRIS opcodes are 16 bits.
144 - The match component is a mask saying which bits must match a
145 particular opcode in order for an instruction to be an instance
148 - The args component is a string containing characters symbolically
149 matching the operands of an instruction. Used for both assembly
152 Operand-matching characters:
155 A The string "ACR" (case-insensitive).
156 B Not really an operand. It causes a "BDAP -size,SP" prefix to be
157 output for the PUSH alias-instructions and recognizes a push-
158 prefix at disassembly. This letter isn't recognized for v32.
159 Must be followed by a R or P letter.
160 ! Non-match pattern, will not match if there's a prefix insn.
161 b Non-matching operand, used for branches with 16-bit
162 displacement. Only recognized by the disassembler.
163 c 5-bit unsigned immediate in bits <4:0>.
164 C 4-bit unsigned immediate in bits <3:0>.
165 d At assembly, optionally (as in put other cases before this one)
166 ".d" or ".D" at the start of the operands, followed by one space
167 character. At disassembly, nothing.
168 D General register in bits <15:12> and <3:0>.
169 f List of flags in bits <15:12> and <3:0>.
170 i 6-bit signed immediate in bits <5:0>.
171 I 6-bit unsigned immediate in bits <5:0>.
172 M Size modifier (B, W or D) for CLEAR instructions.
173 m Size modifier (B, W or D) in bits <5:4>
174 N A 32-bit dword, like in the difference between s and y.
175 This has no effect on bits in the opcode. Can also be expressed
177 n As N, but PC-relative (to the start of the instruction).
178 o [-128..127] word offset in bits <7:1> and <0>. Used by 8-bit
180 O [-128..127] offset in bits <7:0>. Also matches a comma and a
181 general register after the expression, in bits <15:12>. Used
182 only for the BDAP prefix insn (in v32 the ADDOQ insn; same opcode).
183 P Special register in bits <15:12>.
184 p Indicates that the insn is a prefix insn. Must be first
186 Q As O, but don't relax; force an 8-bit offset.
187 R General register in bits <15:12>.
188 r General register in bits <3:0>.
189 S Source operand in bit <10> and a prefix; a 3-operand prefix
191 s Source operand in bits <10> and <3:0>, optionally with a
192 side-effect prefix, except [pc] (the name, not R15 as in ACR)
193 isn't allowed for v32 and higher.
194 T Support register in bits <15:12>.
195 u 4-bit (PC-relative) unsigned immediate word offset in bits <3:0>.
196 U Relaxes to either u or n, instruction is assumed LAPCQ or LAPC.
197 Not recognized at disassembly.
198 x Register-dot-modifier, for example "r5.w" in bits <15:12> and <5:4>.
199 y Like 's' but do not allow an integer at assembly.
200 Y The difference s-y; only an integer is allowed.
201 z Size modifier (B or W) in bit <4>. */
204 /* Please note the order of the opcodes in this table is significant.
205 The assembler requires that all instances of the same mnemonic must
206 be consecutive. If they aren't, the assembler might not recognize
207 them, or may indicate an internal error.
209 The disassembler should not normally care about the order of the
210 opcodes, but will prefer an earlier alternative if the "match-score"
211 (see cris-dis.c) is computed as equal.
213 It should not be significant for proper execution that this table is
214 in alphabetical order, but please follow that convention for an easy
217 const struct cris_opcode
220 {"abs", 0x06B0, 0x0940, "r,R", 0, SIZE_NONE
, 0,
223 {"add", 0x0600, 0x09c0, "m r,R", 0, SIZE_NONE
, 0,
224 cris_reg_mode_add_sub_cmp_and_or_move_op
},
226 {"add", 0x0A00, 0x01c0, "m s,R", 0, SIZE_FIELD
, 0,
227 cris_none_reg_mode_add_sub_cmp_and_or_move_op
},
229 {"add", 0x0A00, 0x01c0, "m S,D", 0, SIZE_NONE
,
231 cris_none_reg_mode_add_sub_cmp_and_or_move_op
},
233 {"add", 0x0a00, 0x05c0, "m S,R,r", 0, SIZE_NONE
,
235 cris_three_operand_add_sub_cmp_and_or_op
},
237 {"add", 0x0A00, 0x01c0, "m s,R", 0, SIZE_FIELD
,
239 cris_none_reg_mode_add_sub_cmp_and_or_move_op
},
241 {"addc", 0x0570, 0x0A80, "r,R", 0, SIZE_FIX_32
,
243 cris_not_implemented_op
},
245 {"addc", 0x09A0, 0x0250, "s,R", 0, SIZE_FIX_32
,
247 cris_not_implemented_op
},
249 {"addi", 0x0540, 0x0A80, "x,r,A", 0, SIZE_NONE
,
253 {"addi", 0x0500, 0x0Ac0, "x,r", 0, SIZE_NONE
, 0,
256 /* This collates after "addo", but we want to disassemble as "addoq",
258 {"addoq", 0x0100, 0x0E00, "Q,A", 0, SIZE_NONE
,
260 cris_not_implemented_op
},
262 {"addo", 0x0940, 0x0280, "m s,R,A", 0, SIZE_FIELD_SIGNED
,
264 cris_not_implemented_op
},
266 /* This must be located after the insn above, lest we misinterpret
267 "addo.b -1,r0,acr" as "addo .b-1,r0,acr". FIXME: Sounds like a
269 {"addo", 0x0100, 0x0E00, "O,A", 0, SIZE_NONE
,
271 cris_not_implemented_op
},
273 {"addq", 0x0200, 0x0Dc0, "I,R", 0, SIZE_NONE
, 0,
274 cris_quick_mode_add_sub_op
},
276 {"adds", 0x0420, 0x0Bc0, "z r,R", 0, SIZE_NONE
, 0,
277 cris_reg_mode_add_sub_cmp_and_or_move_op
},
279 /* FIXME: SIZE_FIELD_SIGNED and all necessary changes. */
280 {"adds", 0x0820, 0x03c0, "z s,R", 0, SIZE_FIELD
, 0,
281 cris_none_reg_mode_add_sub_cmp_and_or_move_op
},
283 {"adds", 0x0820, 0x03c0, "z S,D", 0, SIZE_NONE
,
285 cris_none_reg_mode_add_sub_cmp_and_or_move_op
},
287 {"adds", 0x0820, 0x07c0, "z S,R,r", 0, SIZE_NONE
,
289 cris_three_operand_add_sub_cmp_and_or_op
},
291 {"addu", 0x0400, 0x0be0, "z r,R", 0, SIZE_NONE
, 0,
292 cris_reg_mode_add_sub_cmp_and_or_move_op
},
294 /* FIXME: SIZE_FIELD_UNSIGNED and all necessary changes. */
295 {"addu", 0x0800, 0x03e0, "z s,R", 0, SIZE_FIELD
, 0,
296 cris_none_reg_mode_add_sub_cmp_and_or_move_op
},
298 {"addu", 0x0800, 0x03e0, "z S,D", 0, SIZE_NONE
,
300 cris_none_reg_mode_add_sub_cmp_and_or_move_op
},
302 {"addu", 0x0800, 0x07e0, "z S,R,r", 0, SIZE_NONE
,
304 cris_three_operand_add_sub_cmp_and_or_op
},
306 {"and", 0x0700, 0x08C0, "m r,R", 0, SIZE_NONE
, 0,
307 cris_reg_mode_add_sub_cmp_and_or_move_op
},
309 {"and", 0x0B00, 0x00C0, "m s,R", 0, SIZE_FIELD
, 0,
310 cris_none_reg_mode_add_sub_cmp_and_or_move_op
},
312 {"and", 0x0B00, 0x00C0, "m S,D", 0, SIZE_NONE
,
314 cris_none_reg_mode_add_sub_cmp_and_or_move_op
},
316 {"and", 0x0B00, 0x04C0, "m S,R,r", 0, SIZE_NONE
,
318 cris_three_operand_add_sub_cmp_and_or_op
},
320 {"andq", 0x0300, 0x0CC0, "i,R", 0, SIZE_NONE
, 0,
321 cris_quick_mode_and_cmp_move_or_op
},
323 {"asr", 0x0780, 0x0840, "m r,R", 0, SIZE_NONE
, 0,
326 {"asrq", 0x03a0, 0x0c40, "c,R", 0, SIZE_NONE
, 0,
329 {"ax", 0x15B0, 0xEA4F, "", 0, SIZE_NONE
, 0,
332 /* FIXME: Should use branch #defines. */
333 {"b", 0x0dff, 0x0200, "b", 1, SIZE_NONE
, 0,
334 cris_sixteen_bit_offset_branch_op
},
338 0x0F00+(0xF-CC_A
)*0x1000, "o", 1, SIZE_NONE
, 0,
339 cris_eight_bit_offset_branch_op
},
341 /* Needs to come after the usual "ba o", which might be relaxed to
343 {"ba", BA_DWORD_OPCODE
,
344 0xffff & (~BA_DWORD_OPCODE
), "n", 0, SIZE_FIX_32
,
346 cris_none_reg_mode_jump_op
},
348 {"bas", 0x0EBF, 0x0140, "n,P", 0, SIZE_FIX_32
,
350 cris_none_reg_mode_jump_op
},
352 {"basc", 0x0EFF, 0x0100, "n,P", 0, SIZE_FIX_32
,
354 cris_none_reg_mode_jump_op
},
357 BRANCH_QUICK_OPCODE
+CC_CC
*0x1000,
358 0x0f00+(0xF-CC_CC
)*0x1000, "o", 1, SIZE_NONE
, 0,
359 cris_eight_bit_offset_branch_op
},
362 BRANCH_QUICK_OPCODE
+CC_CS
*0x1000,
363 0x0f00+(0xF-CC_CS
)*0x1000, "o", 1, SIZE_NONE
, 0,
364 cris_eight_bit_offset_branch_op
},
367 BDAP_INDIR_OPCODE
, BDAP_INDIR_Z_BITS
, "pm s,R", 0, SIZE_FIELD_SIGNED
,
372 BDAP_QUICK_OPCODE
, BDAP_QUICK_Z_BITS
, "pO", 0, SIZE_NONE
,
374 cris_quick_mode_bdap_prefix
},
377 BRANCH_QUICK_OPCODE
+CC_EQ
*0x1000,
378 0x0f00+(0xF-CC_EQ
)*0x1000, "o", 1, SIZE_NONE
, 0,
379 cris_eight_bit_offset_branch_op
},
381 /* This is deliberately put before "bext" to trump it, even though not
382 in alphabetical order, since we don't do excluding version checks
385 BRANCH_QUICK_OPCODE
+CC_EXT
*0x1000,
386 0x0f00+(0xF-CC_EXT
)*0x1000, "o", 1, SIZE_NONE
,
388 cris_eight_bit_offset_branch_op
},
391 BRANCH_QUICK_OPCODE
+CC_EXT
*0x1000,
392 0x0f00+(0xF-CC_EXT
)*0x1000, "o", 1, SIZE_NONE
,
394 cris_eight_bit_offset_branch_op
},
397 BRANCH_QUICK_OPCODE
+CC_GE
*0x1000,
398 0x0f00+(0xF-CC_GE
)*0x1000, "o", 1, SIZE_NONE
, 0,
399 cris_eight_bit_offset_branch_op
},
402 BRANCH_QUICK_OPCODE
+CC_GT
*0x1000,
403 0x0f00+(0xF-CC_GT
)*0x1000, "o", 1, SIZE_NONE
, 0,
404 cris_eight_bit_offset_branch_op
},
407 BRANCH_QUICK_OPCODE
+CC_HI
*0x1000,
408 0x0f00+(0xF-CC_HI
)*0x1000, "o", 1, SIZE_NONE
, 0,
409 cris_eight_bit_offset_branch_op
},
412 BRANCH_QUICK_OPCODE
+CC_HS
*0x1000,
413 0x0f00+(0xF-CC_HS
)*0x1000, "o", 1, SIZE_NONE
, 0,
414 cris_eight_bit_offset_branch_op
},
416 {"biap", BIAP_OPCODE
, BIAP_Z_BITS
, "pm r,R", 0, SIZE_NONE
,
421 BRANCH_QUICK_OPCODE
+CC_LE
*0x1000,
422 0x0f00+(0xF-CC_LE
)*0x1000, "o", 1, SIZE_NONE
, 0,
423 cris_eight_bit_offset_branch_op
},
426 BRANCH_QUICK_OPCODE
+CC_LO
*0x1000,
427 0x0f00+(0xF-CC_LO
)*0x1000, "o", 1, SIZE_NONE
, 0,
428 cris_eight_bit_offset_branch_op
},
431 BRANCH_QUICK_OPCODE
+CC_LS
*0x1000,
432 0x0f00+(0xF-CC_LS
)*0x1000, "o", 1, SIZE_NONE
, 0,
433 cris_eight_bit_offset_branch_op
},
436 BRANCH_QUICK_OPCODE
+CC_LT
*0x1000,
437 0x0f00+(0xF-CC_LT
)*0x1000, "o", 1, SIZE_NONE
, 0,
438 cris_eight_bit_offset_branch_op
},
441 BRANCH_QUICK_OPCODE
+CC_MI
*0x1000,
442 0x0f00+(0xF-CC_MI
)*0x1000, "o", 1, SIZE_NONE
, 0,
443 cris_eight_bit_offset_branch_op
},
445 {"bmod", 0x0ab0, 0x0140, "s,R", 0, SIZE_FIX_32
,
447 cris_not_implemented_op
},
449 {"bmod", 0x0ab0, 0x0140, "S,D", 0, SIZE_NONE
,
451 cris_not_implemented_op
},
453 {"bmod", 0x0ab0, 0x0540, "S,R,r", 0, SIZE_NONE
,
455 cris_not_implemented_op
},
458 BRANCH_QUICK_OPCODE
+CC_NE
*0x1000,
459 0x0f00+(0xF-CC_NE
)*0x1000, "o", 1, SIZE_NONE
, 0,
460 cris_eight_bit_offset_branch_op
},
462 {"bound", 0x05c0, 0x0A00, "m r,R", 0, SIZE_NONE
, 0,
463 cris_two_operand_bound_op
},
464 /* FIXME: SIZE_FIELD_UNSIGNED and all necessary changes. */
465 {"bound", 0x09c0, 0x0200, "m s,R", 0, SIZE_FIELD
,
467 cris_two_operand_bound_op
},
468 /* FIXME: SIZE_FIELD_UNSIGNED and all necessary changes. */
469 {"bound", 0x0dcf, 0x0200, "m Y,R", 0, SIZE_FIELD
, 0,
470 cris_two_operand_bound_op
},
471 {"bound", 0x09c0, 0x0200, "m S,D", 0, SIZE_NONE
,
473 cris_two_operand_bound_op
},
474 {"bound", 0x09c0, 0x0600, "m S,R,r", 0, SIZE_NONE
,
476 cris_three_operand_bound_op
},
479 BRANCH_QUICK_OPCODE
+CC_PL
*0x1000,
480 0x0f00+(0xF-CC_PL
)*0x1000, "o", 1, SIZE_NONE
, 0,
481 cris_eight_bit_offset_branch_op
},
483 {"break", 0xe930, 0x16c0, "C", 0, SIZE_NONE
,
488 BRANCH_QUICK_OPCODE
+CC_EXT
*0x1000,
489 0x0f00+(0xF-CC_EXT
)*0x1000, "o", 1, SIZE_NONE
,
491 cris_eight_bit_offset_branch_op
},
493 {"bsr", 0xBEBF, 0x4140, "n", 0, SIZE_FIX_32
,
495 cris_none_reg_mode_jump_op
},
497 {"bsrc", 0xBEFF, 0x4100, "n", 0, SIZE_FIX_32
,
499 cris_none_reg_mode_jump_op
},
501 {"bstore", 0x0af0, 0x0100, "s,R", 0, SIZE_FIX_32
,
503 cris_not_implemented_op
},
505 {"bstore", 0x0af0, 0x0100, "S,D", 0, SIZE_NONE
,
507 cris_not_implemented_op
},
509 {"bstore", 0x0af0, 0x0500, "S,R,r", 0, SIZE_NONE
,
511 cris_not_implemented_op
},
513 {"btst", 0x04F0, 0x0B00, "r,R", 0, SIZE_NONE
, 0,
515 {"btstq", 0x0380, 0x0C60, "c,R", 0, SIZE_NONE
, 0,
519 BRANCH_QUICK_OPCODE
+CC_VC
*0x1000,
520 0x0f00+(0xF-CC_VC
)*0x1000, "o", 1, SIZE_NONE
, 0,
521 cris_eight_bit_offset_branch_op
},
524 BRANCH_QUICK_OPCODE
+CC_VS
*0x1000,
525 0x0f00+(0xF-CC_VS
)*0x1000, "o", 1, SIZE_NONE
, 0,
526 cris_eight_bit_offset_branch_op
},
528 {"clear", 0x0670, 0x3980, "M r", 0, SIZE_NONE
, 0,
529 cris_reg_mode_clear_op
},
531 {"clear", 0x0A70, 0x3180, "M y", 0, SIZE_NONE
, 0,
532 cris_none_reg_mode_clear_test_op
},
534 {"clear", 0x0A70, 0x3180, "M S", 0, SIZE_NONE
,
536 cris_none_reg_mode_clear_test_op
},
538 {"clearf", 0x05F0, 0x0A00, "f", 0, SIZE_NONE
, 0,
541 {"cmp", 0x06C0, 0x0900, "m r,R", 0, SIZE_NONE
, 0,
542 cris_reg_mode_add_sub_cmp_and_or_move_op
},
544 {"cmp", 0x0Ac0, 0x0100, "m s,R", 0, SIZE_FIELD
, 0,
545 cris_none_reg_mode_add_sub_cmp_and_or_move_op
},
547 {"cmp", 0x0Ac0, 0x0100, "m S,D", 0, SIZE_NONE
,
549 cris_none_reg_mode_add_sub_cmp_and_or_move_op
},
551 {"cmpq", 0x02C0, 0x0D00, "i,R", 0, SIZE_NONE
, 0,
552 cris_quick_mode_and_cmp_move_or_op
},
554 /* FIXME: SIZE_FIELD_SIGNED and all necessary changes. */
555 {"cmps", 0x08e0, 0x0300, "z s,R", 0, SIZE_FIELD
, 0,
556 cris_none_reg_mode_add_sub_cmp_and_or_move_op
},
558 {"cmps", 0x08e0, 0x0300, "z S,D", 0, SIZE_NONE
,
560 cris_none_reg_mode_add_sub_cmp_and_or_move_op
},
562 /* FIXME: SIZE_FIELD_UNSIGNED and all necessary changes. */
563 {"cmpu", 0x08c0, 0x0320, "z s,R" , 0, SIZE_FIELD
, 0,
564 cris_none_reg_mode_add_sub_cmp_and_or_move_op
},
566 {"cmpu", 0x08c0, 0x0320, "z S,D", 0, SIZE_NONE
,
568 cris_none_reg_mode_add_sub_cmp_and_or_move_op
},
570 {"di", 0x25F0, 0xDA0F, "", 0, SIZE_NONE
, 0,
573 {"dip", DIP_OPCODE
, DIP_Z_BITS
, "ps", 0, SIZE_FIX_32
,
577 {"div", 0x0980, 0x0640, "m R,r", 0, SIZE_FIELD
, 0,
578 cris_not_implemented_op
},
580 {"dstep", 0x06f0, 0x0900, "r,R", 0, SIZE_NONE
, 0,
581 cris_dstep_logshift_mstep_neg_not_op
},
583 {"ei", 0x25B0, 0xDA4F, "", 0, SIZE_NONE
, 0,
586 {"fidxd", 0x0ab0, 0xf540, "[r]", 0, SIZE_NONE
,
588 cris_not_implemented_op
},
590 {"fidxi", 0x0d30, 0xF2C0, "[r]", 0, SIZE_NONE
,
592 cris_not_implemented_op
},
594 {"ftagd", 0x1AB0, 0xE540, "[r]", 0, SIZE_NONE
,
596 cris_not_implemented_op
},
598 {"ftagi", 0x1D30, 0xE2C0, "[r]", 0, SIZE_NONE
,
600 cris_not_implemented_op
},
602 {"halt", 0xF930, 0x06CF, "", 0, SIZE_NONE
,
604 cris_not_implemented_op
},
606 {"jas", 0x09B0, 0x0640, "r,P", 0, SIZE_NONE
,
608 cris_reg_mode_jump_op
},
610 {"jas", 0x0DBF, 0x0240, "N,P", 0, SIZE_FIX_32
,
612 cris_reg_mode_jump_op
},
614 {"jasc", 0x0B30, 0x04C0, "r,P", 0, SIZE_NONE
,
616 cris_reg_mode_jump_op
},
618 {"jasc", 0x0F3F, 0x00C0, "N,P", 0, SIZE_FIX_32
,
620 cris_reg_mode_jump_op
},
622 {"jbrc", 0x69b0, 0x9640, "r", 0, SIZE_NONE
,
624 cris_reg_mode_jump_op
},
626 {"jbrc", 0x6930, 0x92c0, "s", 0, SIZE_FIX_32
,
628 cris_none_reg_mode_jump_op
},
630 {"jbrc", 0x6930, 0x92c0, "S", 0, SIZE_NONE
,
632 cris_none_reg_mode_jump_op
},
634 {"jir", 0xA9b0, 0x5640, "r", 0, SIZE_NONE
,
636 cris_reg_mode_jump_op
},
638 {"jir", 0xA930, 0x52c0, "s", 0, SIZE_FIX_32
,
640 cris_none_reg_mode_jump_op
},
642 {"jir", 0xA930, 0x52c0, "S", 0, SIZE_NONE
,
644 cris_none_reg_mode_jump_op
},
646 {"jirc", 0x29b0, 0xd640, "r", 0, SIZE_NONE
,
648 cris_reg_mode_jump_op
},
650 {"jirc", 0x2930, 0xd2c0, "s", 0, SIZE_FIX_32
,
652 cris_none_reg_mode_jump_op
},
654 {"jirc", 0x2930, 0xd2c0, "S", 0, SIZE_NONE
,
656 cris_none_reg_mode_jump_op
},
658 {"jsr", 0xB9b0, 0x4640, "r", 0, SIZE_NONE
, 0,
659 cris_reg_mode_jump_op
},
661 {"jsr", 0xB930, 0x42c0, "s", 0, SIZE_FIX_32
,
663 cris_none_reg_mode_jump_op
},
665 {"jsr", 0xBDBF, 0x4240, "N", 0, SIZE_FIX_32
,
667 cris_none_reg_mode_jump_op
},
669 {"jsr", 0xB930, 0x42c0, "S", 0, SIZE_NONE
,
671 cris_none_reg_mode_jump_op
},
673 {"jsrc", 0x39b0, 0xc640, "r", 0, SIZE_NONE
,
675 cris_reg_mode_jump_op
},
677 {"jsrc", 0x3930, 0xc2c0, "s", 0, SIZE_FIX_32
,
679 cris_none_reg_mode_jump_op
},
681 {"jsrc", 0x3930, 0xc2c0, "S", 0, SIZE_NONE
,
683 cris_none_reg_mode_jump_op
},
685 {"jsrc", 0xBB30, 0x44C0, "r", 0, SIZE_NONE
,
687 cris_reg_mode_jump_op
},
689 {"jsrc", 0xBF3F, 0x40C0, "N", 0, SIZE_FIX_32
,
691 cris_reg_mode_jump_op
},
693 {"jump", 0x09b0, 0xF640, "r", 0, SIZE_NONE
, 0,
694 cris_reg_mode_jump_op
},
697 JUMP_INDIR_OPCODE
, JUMP_INDIR_Z_BITS
, "s", 0, SIZE_FIX_32
,
699 cris_none_reg_mode_jump_op
},
702 JUMP_INDIR_OPCODE
, JUMP_INDIR_Z_BITS
, "S", 0, SIZE_NONE
,
704 cris_none_reg_mode_jump_op
},
706 {"jump", 0x09F0, 0x060F, "P", 0, SIZE_NONE
,
708 cris_none_reg_mode_jump_op
},
711 JUMP_PC_INCR_OPCODE_V32
,
712 (0xffff & ~JUMP_PC_INCR_OPCODE_V32
), "N", 0, SIZE_FIX_32
,
714 cris_none_reg_mode_jump_op
},
716 {"jmpu", 0x8930, 0x72c0, "s", 0, SIZE_FIX_32
,
718 cris_none_reg_mode_jump_op
},
720 {"jmpu", 0x8930, 0x72c0, "S", 0, SIZE_NONE
,
722 cris_none_reg_mode_jump_op
},
724 {"lapc", 0x0970, 0x0680, "U,R", 0, SIZE_NONE
,
726 cris_not_implemented_op
},
728 {"lapc", 0x0D7F, 0x0280, "dn,R", 0, SIZE_FIX_32
,
730 cris_not_implemented_op
},
732 {"lapcq", 0x0970, 0x0680, "u,R", 0, SIZE_NONE
,
736 {"lsl", 0x04C0, 0x0B00, "m r,R", 0, SIZE_NONE
, 0,
737 cris_dstep_logshift_mstep_neg_not_op
},
739 {"lslq", 0x03c0, 0x0C20, "c,R", 0, SIZE_NONE
, 0,
740 cris_dstep_logshift_mstep_neg_not_op
},
742 {"lsr", 0x07C0, 0x0800, "m r,R", 0, SIZE_NONE
, 0,
743 cris_dstep_logshift_mstep_neg_not_op
},
745 {"lsrq", 0x03e0, 0x0C00, "c,R", 0, SIZE_NONE
, 0,
746 cris_dstep_logshift_mstep_neg_not_op
},
748 {"lz", 0x0730, 0x08C0, "r,R", 0, SIZE_NONE
,
750 cris_not_implemented_op
},
752 {"mcp", 0x07f0, 0x0800, "P,r", 0, SIZE_NONE
,
754 cris_not_implemented_op
},
756 {"move", 0x0640, 0x0980, "m r,R", 0, SIZE_NONE
, 0,
757 cris_reg_mode_add_sub_cmp_and_or_move_op
},
759 {"move", 0x0A40, 0x0180, "m s,R", 0, SIZE_FIELD
, 0,
760 cris_none_reg_mode_add_sub_cmp_and_or_move_op
},
762 {"move", 0x0A40, 0x0180, "m S,D", 0, SIZE_NONE
,
764 cris_none_reg_mode_add_sub_cmp_and_or_move_op
},
766 {"move", 0x0630, 0x09c0, "r,P", 0, SIZE_NONE
, 0,
767 cris_move_to_preg_op
},
769 {"move", 0x0670, 0x0980, "P,r", 0, SIZE_NONE
, 0,
770 cris_reg_mode_move_from_preg_op
},
772 {"move", 0x0BC0, 0x0000, "m R,y", 0, SIZE_FIELD
, 0,
773 cris_none_reg_mode_add_sub_cmp_and_or_move_op
},
775 {"move", 0x0BC0, 0x0000, "m D,S", 0, SIZE_NONE
,
777 cris_none_reg_mode_add_sub_cmp_and_or_move_op
},
780 MOVE_M_TO_PREG_OPCODE
, MOVE_M_TO_PREG_ZBITS
,
781 "s,P", 0, SIZE_SPEC_REG
, 0,
782 cris_move_to_preg_op
},
784 {"move", 0x0A30, 0x01c0, "S,P", 0, SIZE_NONE
,
786 cris_move_to_preg_op
},
788 {"move", 0x0A70, 0x0180, "P,y", 0, SIZE_SPEC_REG
, 0,
789 cris_none_reg_mode_move_from_preg_op
},
791 {"move", 0x0A70, 0x0180, "P,S", 0, SIZE_NONE
,
793 cris_none_reg_mode_move_from_preg_op
},
795 {"move", 0x0B70, 0x0480, "r,T", 0, SIZE_NONE
,
797 cris_not_implemented_op
},
799 {"move", 0x0F70, 0x0080, "T,r", 0, SIZE_NONE
,
801 cris_not_implemented_op
},
803 {"movem", 0x0BF0, 0x0000, "R,y", 0, SIZE_FIX_32
, 0,
804 cris_move_reg_to_mem_movem_op
},
806 {"movem", 0x0BF0, 0x0000, "D,S", 0, SIZE_NONE
,
808 cris_move_reg_to_mem_movem_op
},
810 {"movem", 0x0BB0, 0x0040, "s,R", 0, SIZE_FIX_32
, 0,
811 cris_move_mem_to_reg_movem_op
},
813 {"movem", 0x0BB0, 0x0040, "S,D", 0, SIZE_NONE
,
815 cris_move_mem_to_reg_movem_op
},
817 {"moveq", 0x0240, 0x0D80, "i,R", 0, SIZE_NONE
, 0,
818 cris_quick_mode_and_cmp_move_or_op
},
820 {"movs", 0x0460, 0x0B80, "z r,R", 0, SIZE_NONE
, 0,
821 cris_reg_mode_add_sub_cmp_and_or_move_op
},
823 /* FIXME: SIZE_FIELD_SIGNED and all necessary changes. */
824 {"movs", 0x0860, 0x0380, "z s,R", 0, SIZE_FIELD
, 0,
825 cris_none_reg_mode_add_sub_cmp_and_or_move_op
},
827 {"movs", 0x0860, 0x0380, "z S,D", 0, SIZE_NONE
,
829 cris_none_reg_mode_add_sub_cmp_and_or_move_op
},
831 {"movu", 0x0440, 0x0Ba0, "z r,R", 0, SIZE_NONE
, 0,
832 cris_reg_mode_add_sub_cmp_and_or_move_op
},
834 /* FIXME: SIZE_FIELD_UNSIGNED and all necessary changes. */
835 {"movu", 0x0840, 0x03a0, "z s,R", 0, SIZE_FIELD
, 0,
836 cris_none_reg_mode_add_sub_cmp_and_or_move_op
},
838 {"movu", 0x0840, 0x03a0, "z S,D", 0, SIZE_NONE
,
840 cris_none_reg_mode_add_sub_cmp_and_or_move_op
},
842 {"mstep", 0x07f0, 0x0800, "r,R", 0, SIZE_NONE
,
844 cris_dstep_logshift_mstep_neg_not_op
},
846 {"muls", 0x0d00, 0x02c0, "m r,R", 0, SIZE_NONE
,
850 {"mulu", 0x0900, 0x06c0, "m r,R", 0, SIZE_NONE
,
854 {"neg", 0x0580, 0x0A40, "m r,R", 0, SIZE_NONE
, 0,
855 cris_dstep_logshift_mstep_neg_not_op
},
857 {"nop", NOP_OPCODE
, NOP_Z_BITS
, "", 0, SIZE_NONE
,
861 {"nop", NOP_OPCODE_V32
, NOP_Z_BITS_V32
, "", 0, SIZE_NONE
,
865 {"not", 0x8770, 0x7880, "r", 0, SIZE_NONE
, 0,
866 cris_dstep_logshift_mstep_neg_not_op
},
868 {"or", 0x0740, 0x0880, "m r,R", 0, SIZE_NONE
, 0,
869 cris_reg_mode_add_sub_cmp_and_or_move_op
},
871 {"or", 0x0B40, 0x0080, "m s,R", 0, SIZE_FIELD
, 0,
872 cris_none_reg_mode_add_sub_cmp_and_or_move_op
},
874 {"or", 0x0B40, 0x0080, "m S,D", 0, SIZE_NONE
,
876 cris_none_reg_mode_add_sub_cmp_and_or_move_op
},
878 {"or", 0x0B40, 0x0480, "m S,R,r", 0, SIZE_NONE
,
880 cris_three_operand_add_sub_cmp_and_or_op
},
882 {"orq", 0x0340, 0x0C80, "i,R", 0, SIZE_NONE
, 0,
883 cris_quick_mode_and_cmp_move_or_op
},
885 {"pop", 0x0E6E, 0x0191, "!R", 0, SIZE_NONE
,
887 cris_none_reg_mode_add_sub_cmp_and_or_move_op
},
889 {"pop", 0x0e3e, 0x01c1, "!P", 0, SIZE_NONE
,
891 cris_none_reg_mode_move_from_preg_op
},
893 {"push", 0x0FEE, 0x0011, "BR", 0, SIZE_NONE
,
895 cris_none_reg_mode_add_sub_cmp_and_or_move_op
},
897 {"push", 0x0E7E, 0x0181, "BP", 0, SIZE_NONE
,
899 cris_move_to_preg_op
},
901 {"rbf", 0x3b30, 0xc0c0, "y", 0, SIZE_NONE
,
903 cris_not_implemented_op
},
905 {"rbf", 0x3b30, 0xc0c0, "S", 0, SIZE_NONE
,
907 cris_not_implemented_op
},
909 {"rfe", 0x2930, 0xD6CF, "", 0, SIZE_NONE
,
911 cris_not_implemented_op
},
913 {"rfg", 0x4930, 0xB6CF, "", 0, SIZE_NONE
,
915 cris_not_implemented_op
},
917 {"rfn", 0x5930, 0xA6CF, "", 0, SIZE_NONE
,
919 cris_not_implemented_op
},
921 {"ret", 0xB67F, 0x4980, "", 1, SIZE_NONE
,
923 cris_reg_mode_move_from_preg_op
},
925 {"ret", 0xB9F0, 0x460F, "", 1, SIZE_NONE
,
927 cris_reg_mode_move_from_preg_op
},
929 {"retb", 0xe67f, 0x1980, "", 1, SIZE_NONE
,
931 cris_reg_mode_move_from_preg_op
},
933 {"rete", 0xA9F0, 0x560F, "", 1, SIZE_NONE
,
935 cris_reg_mode_move_from_preg_op
},
937 {"reti", 0xA67F, 0x5980, "", 1, SIZE_NONE
,
939 cris_reg_mode_move_from_preg_op
},
941 {"retn", 0xC9F0, 0x360F, "", 1, SIZE_NONE
,
943 cris_reg_mode_move_from_preg_op
},
945 {"sbfs", 0x3b70, 0xc080, "y", 0, SIZE_NONE
,
947 cris_not_implemented_op
},
949 {"sbfs", 0x3b70, 0xc080, "S", 0, SIZE_NONE
,
951 cris_not_implemented_op
},
955 0x0AC0+(0xf-CC_A
)*0x1000, "r", 0, SIZE_NONE
, 0,
959 0x0530+CC_EXT
*0x1000,
960 0x0AC0+(0xf-CC_EXT
)*0x1000, "r", 0, SIZE_NONE
,
966 0x0AC0+(0xf-CC_CC
)*0x1000, "r", 0, SIZE_NONE
, 0,
971 0x0AC0+(0xf-CC_CS
)*0x1000, "r", 0, SIZE_NONE
, 0,
976 0x0AC0+(0xf-CC_EQ
)*0x1000, "r", 0, SIZE_NONE
, 0,
979 {"setf", 0x05b0, 0x0A40, "f", 0, SIZE_NONE
, 0,
982 {"sfe", 0x3930, 0xC6CF, "", 0, SIZE_NONE
,
984 cris_not_implemented_op
},
986 /* Need to have "swf" in front of "sext" so it is the one displayed in
989 0x0530+CC_EXT
*0x1000,
990 0x0AC0+(0xf-CC_EXT
)*0x1000, "r", 0, SIZE_NONE
,
995 0x0530+CC_EXT
*0x1000,
996 0x0AC0+(0xf-CC_EXT
)*0x1000, "r", 0, SIZE_NONE
,
1001 0x0530+CC_GE
*0x1000,
1002 0x0AC0+(0xf-CC_GE
)*0x1000, "r", 0, SIZE_NONE
, 0,
1006 0x0530+CC_GT
*0x1000,
1007 0x0AC0+(0xf-CC_GT
)*0x1000, "r", 0, SIZE_NONE
, 0,
1011 0x0530+CC_HI
*0x1000,
1012 0x0AC0+(0xf-CC_HI
)*0x1000, "r", 0, SIZE_NONE
, 0,
1016 0x0530+CC_HS
*0x1000,
1017 0x0AC0+(0xf-CC_HS
)*0x1000, "r", 0, SIZE_NONE
, 0,
1021 0x0530+CC_LE
*0x1000,
1022 0x0AC0+(0xf-CC_LE
)*0x1000, "r", 0, SIZE_NONE
, 0,
1026 0x0530+CC_LO
*0x1000,
1027 0x0AC0+(0xf-CC_LO
)*0x1000, "r", 0, SIZE_NONE
, 0,
1031 0x0530+CC_LS
*0x1000,
1032 0x0AC0+(0xf-CC_LS
)*0x1000, "r", 0, SIZE_NONE
, 0,
1036 0x0530+CC_LT
*0x1000,
1037 0x0AC0+(0xf-CC_LT
)*0x1000, "r", 0, SIZE_NONE
, 0,
1041 0x0530+CC_MI
*0x1000,
1042 0x0AC0+(0xf-CC_MI
)*0x1000, "r", 0, SIZE_NONE
, 0,
1046 0x0530+CC_NE
*0x1000,
1047 0x0AC0+(0xf-CC_NE
)*0x1000, "r", 0, SIZE_NONE
, 0,
1051 0x0530+CC_PL
*0x1000,
1052 0x0AC0+(0xf-CC_PL
)*0x1000, "r", 0, SIZE_NONE
, 0,
1055 {"sub", 0x0680, 0x0940, "m r,R", 0, SIZE_NONE
, 0,
1056 cris_reg_mode_add_sub_cmp_and_or_move_op
},
1058 {"sub", 0x0a80, 0x0140, "m s,R", 0, SIZE_FIELD
, 0,
1059 cris_none_reg_mode_add_sub_cmp_and_or_move_op
},
1061 {"sub", 0x0a80, 0x0140, "m S,D", 0, SIZE_NONE
,
1063 cris_none_reg_mode_add_sub_cmp_and_or_move_op
},
1065 {"sub", 0x0a80, 0x0540, "m S,R,r", 0, SIZE_NONE
,
1067 cris_three_operand_add_sub_cmp_and_or_op
},
1069 {"subq", 0x0280, 0x0d40, "I,R", 0, SIZE_NONE
, 0,
1070 cris_quick_mode_add_sub_op
},
1072 {"subs", 0x04a0, 0x0b40, "z r,R", 0, SIZE_NONE
, 0,
1073 cris_reg_mode_add_sub_cmp_and_or_move_op
},
1075 /* FIXME: SIZE_FIELD_SIGNED and all necessary changes. */
1076 {"subs", 0x08a0, 0x0340, "z s,R", 0, SIZE_FIELD
, 0,
1077 cris_none_reg_mode_add_sub_cmp_and_or_move_op
},
1079 {"subs", 0x08a0, 0x0340, "z S,D", 0, SIZE_NONE
,
1081 cris_none_reg_mode_add_sub_cmp_and_or_move_op
},
1083 {"subs", 0x08a0, 0x0740, "z S,R,r", 0, SIZE_NONE
,
1085 cris_three_operand_add_sub_cmp_and_or_op
},
1087 {"subu", 0x0480, 0x0b60, "z r,R", 0, SIZE_NONE
, 0,
1088 cris_reg_mode_add_sub_cmp_and_or_move_op
},
1090 /* FIXME: SIZE_FIELD_UNSIGNED and all necessary changes. */
1091 {"subu", 0x0880, 0x0360, "z s,R", 0, SIZE_FIELD
, 0,
1092 cris_none_reg_mode_add_sub_cmp_and_or_move_op
},
1094 {"subu", 0x0880, 0x0360, "z S,D", 0, SIZE_NONE
,
1096 cris_none_reg_mode_add_sub_cmp_and_or_move_op
},
1098 {"subu", 0x0880, 0x0760, "z S,R,r", 0, SIZE_NONE
,
1100 cris_three_operand_add_sub_cmp_and_or_op
},
1103 0x0530+CC_VC
*0x1000,
1104 0x0AC0+(0xf-CC_VC
)*0x1000, "r", 0, SIZE_NONE
, 0,
1108 0x0530+CC_VS
*0x1000,
1109 0x0AC0+(0xf-CC_VS
)*0x1000, "r", 0, SIZE_NONE
, 0,
1112 /* The insn "swapn" is the same as "not" and will be disassembled as
1113 such, but the swap* family of mnmonics are generally v8-and-higher
1114 only, so count it in. */
1115 {"swapn", 0x8770, 0x7880, "r", 0, SIZE_NONE
,
1117 cris_not_implemented_op
},
1119 {"swapw", 0x4770, 0xb880, "r", 0, SIZE_NONE
,
1121 cris_not_implemented_op
},
1123 {"swapnw", 0xc770, 0x3880, "r", 0, SIZE_NONE
,
1125 cris_not_implemented_op
},
1127 {"swapb", 0x2770, 0xd880, "r", 0, SIZE_NONE
,
1129 cris_not_implemented_op
},
1131 {"swapnb", 0xA770, 0x5880, "r", 0, SIZE_NONE
,
1133 cris_not_implemented_op
},
1135 {"swapwb", 0x6770, 0x9880, "r", 0, SIZE_NONE
,
1137 cris_not_implemented_op
},
1139 {"swapnwb", 0xE770, 0x1880, "r", 0, SIZE_NONE
,
1141 cris_not_implemented_op
},
1143 {"swapr", 0x1770, 0xe880, "r", 0, SIZE_NONE
,
1145 cris_not_implemented_op
},
1147 {"swapnr", 0x9770, 0x6880, "r", 0, SIZE_NONE
,
1149 cris_not_implemented_op
},
1151 {"swapwr", 0x5770, 0xa880, "r", 0, SIZE_NONE
,
1153 cris_not_implemented_op
},
1155 {"swapnwr", 0xd770, 0x2880, "r", 0, SIZE_NONE
,
1157 cris_not_implemented_op
},
1159 {"swapbr", 0x3770, 0xc880, "r", 0, SIZE_NONE
,
1161 cris_not_implemented_op
},
1163 {"swapnbr", 0xb770, 0x4880, "r", 0, SIZE_NONE
,
1165 cris_not_implemented_op
},
1167 {"swapwbr", 0x7770, 0x8880, "r", 0, SIZE_NONE
,
1169 cris_not_implemented_op
},
1171 {"swapnwbr", 0xf770, 0x0880, "r", 0, SIZE_NONE
,
1173 cris_not_implemented_op
},
1175 {"test", 0x0640, 0x0980, "m D", 0, SIZE_NONE
,
1177 cris_reg_mode_test_op
},
1179 {"test", 0x0b80, 0xf040, "m y", 0, SIZE_FIELD
, 0,
1180 cris_none_reg_mode_clear_test_op
},
1182 {"test", 0x0b80, 0xf040, "m S", 0, SIZE_NONE
,
1184 cris_none_reg_mode_clear_test_op
},
1186 {"xor", 0x07B0, 0x0840, "r,R", 0, SIZE_NONE
, 0,
1189 {NULL
, 0, 0, NULL
, 0, 0, 0, cris_not_implemented_op
}
1192 /* Condition-names, indexed by the CC_* numbers as found in cris.h. */
1211 /* This is a placeholder. In v0, this would be "ext". In v32, this
1218 * eval: (c-set-style "gnu")
1219 * indent-tabs-mode: t
1224 /* No instruction will be disassembled longer than this. In theory, and
1225 in silicon, address prefixes can be cascaded. In practice, cascading
1226 is not used by GCC, and not supported by the assembler. */
1227 #ifndef MAX_BYTES_PER_CRIS_INSN
1228 #define MAX_BYTES_PER_CRIS_INSN 8
1231 /* Whether or not to decode prefixes, folding it into the following
1232 instruction. FIXME: Make this optional later. */
1233 #ifndef PARSE_PREFIX
1234 #define PARSE_PREFIX 1
1237 /* Sometimes we prefix all registers with this character. */
1238 #define REGISTER_PREFIX_CHAR '$'
1240 /* Whether or not to trace the following sequence:
1243 adds.w [pc+r%d.w],pc
1245 This is the assembly form of a switch-statement in C.
1246 The "sub is optional. If there is none, then X will be zero.
1247 X is the value of the first case,
1248 Y is the number of cases (including default).
1250 This results in case offsets printed on the form:
1251 case N: -> case_address
1252 where N is an estimation on the corresponding 'case' operand in C,
1253 and case_address is where execution of that case continues after the
1254 sequence presented above.
1256 The old style of output was to print the offsets as instructions,
1257 which made it hard to follow "case"-constructs in the disassembly,
1258 and caused a lot of annoying warnings about undefined instructions.
1260 FIXME: Make this optional later. */
1262 #define TRACE_CASE (disdata->trace_case)
1265 enum cris_disass_family
1266 { cris_dis_v0_v10
, cris_dis_common_v10_v32
, cris_dis_v32
};
1268 /* Stored in the disasm_info->private_data member. */
1269 struct cris_disasm_data
1271 /* Whether to print something less confusing if we find something
1272 matching a switch-construct. */
1273 bfd_boolean trace_case
;
1275 /* Whether this code is flagged as crisv32. FIXME: Should be an enum
1276 that includes "compatible". */
1277 enum cris_disass_family distype
;
1280 /* Value of first element in switch. */
1281 static long case_offset
= 0;
1283 /* How many more case-offsets to print. */
1284 static long case_offset_counter
= 0;
1286 /* Number of case offsets. */
1287 static long no_of_case_offsets
= 0;
1289 /* Candidate for next case_offset. */
1290 static long last_immediate
= 0;
1292 static int cris_constraint
1293 (const char *, unsigned, unsigned, struct cris_disasm_data
*);
1295 /* Parse disassembler options and store state in info. FIXME: For the
1296 time being, we abuse static variables. */
1299 cris_parse_disassembler_options (disassemble_info
*info
,
1300 enum cris_disass_family distype
)
1302 struct cris_disasm_data
*disdata
;
1304 info
->private_data
= calloc (1, sizeof (struct cris_disasm_data
));
1305 disdata
= (struct cris_disasm_data
*) info
->private_data
;
1306 if (disdata
== NULL
)
1311 = (info
->disassembler_options
== NULL
1312 || (strcmp (info
->disassembler_options
, "nocase") != 0));
1314 disdata
->distype
= distype
;
1318 static const struct cris_spec_reg
*
1319 spec_reg_info (unsigned int sreg
, enum cris_disass_family distype
)
1323 for (i
= 0; cris_spec_regs
[i
].name
!= NULL
; i
++)
1325 if (cris_spec_regs
[i
].number
== sreg
)
1327 if (distype
== cris_dis_v32
)
1328 switch (cris_spec_regs
[i
].applicable_version
)
1330 case cris_ver_warning
:
1331 case cris_ver_version_all
:
1336 /* No ambiguous sizes or register names with CRISv32. */
1337 if (cris_spec_regs
[i
].warning
== NULL
)
1338 return &cris_spec_regs
[i
];
1342 else if (cris_spec_regs
[i
].applicable_version
!= cris_ver_v32p
)
1343 return &cris_spec_regs
[i
];
1350 /* Return the number of bits in the argument. */
1353 number_of_bits (unsigned int val
)
1357 for (bits
= 0; val
!= 0; val
&= val
- 1)
1363 /* Get an entry in the opcode-table. */
1365 static const struct cris_opcode
*
1366 get_opcode_entry (unsigned int insn
,
1367 unsigned int prefix_insn
,
1368 struct cris_disasm_data
*disdata
)
1370 /* For non-prefixed insns, we keep a table of pointers, indexed by the
1371 insn code. Each entry is initialized when found to be NULL. */
1372 static const struct cris_opcode
**opc_table
= NULL
;
1374 const struct cris_opcode
*max_matchedp
= NULL
;
1375 const struct cris_opcode
**prefix_opc_table
= NULL
;
1377 /* We hold a table for each prefix that need to be handled differently. */
1378 static const struct cris_opcode
**dip_prefixes
= NULL
;
1379 static const struct cris_opcode
**bdapq_m1_prefixes
= NULL
;
1380 static const struct cris_opcode
**bdapq_m2_prefixes
= NULL
;
1381 static const struct cris_opcode
**bdapq_m4_prefixes
= NULL
;
1382 static const struct cris_opcode
**rest_prefixes
= NULL
;
1384 /* Allocate and clear the opcode-table. */
1385 if (opc_table
== NULL
)
1387 opc_table
= g_new0(const struct cris_opcode
*, 65536);
1388 dip_prefixes
= g_new0(const struct cris_opcode
*, 65536);
1389 bdapq_m1_prefixes
= g_new0(const struct cris_opcode
*, 65536);
1390 bdapq_m2_prefixes
= g_new0(const struct cris_opcode
*, 65536);
1391 bdapq_m4_prefixes
= g_new0(const struct cris_opcode
*, 65536);
1392 rest_prefixes
= g_new0(const struct cris_opcode
*, 65536);
1395 /* Get the right table if this is a prefix.
1396 This code is connected to cris_constraints in that it knows what
1397 prefixes play a role in recognition of patterns; the necessary
1398 state is reflected by which table is used. If constraints
1399 involving match or non-match of prefix insns are changed, then this
1400 probably needs changing too. */
1401 if (prefix_insn
!= NO_CRIS_PREFIX
)
1403 const struct cris_opcode
*popcodep
1404 = (opc_table
[prefix_insn
] != NULL
1405 ? opc_table
[prefix_insn
]
1406 : get_opcode_entry (prefix_insn
, NO_CRIS_PREFIX
, disdata
));
1408 if (popcodep
== NULL
)
1411 if (popcodep
->match
== BDAP_QUICK_OPCODE
)
1413 /* Since some offsets are recognized with "push" macros, we
1414 have to have different tables for them. */
1415 int offset
= (prefix_insn
& 255);
1423 prefix_opc_table
= bdapq_m4_prefixes
;
1427 prefix_opc_table
= bdapq_m2_prefixes
;
1431 prefix_opc_table
= bdapq_m1_prefixes
;
1435 prefix_opc_table
= rest_prefixes
;
1439 else if (popcodep
->match
== DIP_OPCODE
)
1440 /* We don't allow postincrement when the prefix is DIP, so use a
1441 different table for DIP. */
1442 prefix_opc_table
= dip_prefixes
;
1444 prefix_opc_table
= rest_prefixes
;
1447 if (prefix_insn
!= NO_CRIS_PREFIX
1448 && prefix_opc_table
[insn
] != NULL
)
1449 max_matchedp
= prefix_opc_table
[insn
];
1450 else if (prefix_insn
== NO_CRIS_PREFIX
&& opc_table
[insn
] != NULL
)
1451 max_matchedp
= opc_table
[insn
];
1454 const struct cris_opcode
*opcodep
;
1455 int max_level_of_match
= -1;
1457 for (opcodep
= cris_opcodes
;
1458 opcodep
->name
!= NULL
;
1463 if (disdata
->distype
== cris_dis_v32
)
1465 switch (opcodep
->applicable_version
)
1467 case cris_ver_version_all
:
1471 case cris_ver_v0_10
:
1472 case cris_ver_v3_10
:
1473 case cris_ver_sim_v0_10
:
1474 case cris_ver_v8_10
:
1476 case cris_ver_warning
:
1493 switch (opcodep
->applicable_version
)
1495 case cris_ver_version_all
:
1498 case cris_ver_v0_10
:
1500 case cris_ver_v8_10
:
1502 case cris_ver_sim_v0_10
:
1504 case cris_ver_warning
:
1517 /* We give a double lead for bits matching the template in
1518 cris_opcodes. Not even, because then "move p8,r10" would
1519 be given 2 bits lead over "clear.d r10". When there's a
1520 tie, the first entry in the table wins. This is
1521 deliberate, to avoid a more complicated recognition
1523 if ((opcodep
->match
& insn
) == opcodep
->match
1524 && (opcodep
->lose
& insn
) == 0
1526 = cris_constraint (opcodep
->args
,
1532 += 2 * number_of_bits (opcodep
->match
1534 > max_level_of_match
))
1536 max_matchedp
= opcodep
;
1537 max_level_of_match
= level_of_match
;
1539 /* If there was a full match, never mind looking
1541 if (level_of_match
>= 2 * 16)
1545 /* Fill in the new entry.
1547 If there are changes to the opcode-table involving prefixes, and
1548 disassembly then does not work correctly, try removing the
1549 else-clause below that fills in the prefix-table. If that
1550 helps, you need to change the prefix_opc_table setting above, or
1551 something related. */
1552 if (prefix_insn
== NO_CRIS_PREFIX
)
1553 opc_table
[insn
] = max_matchedp
;
1555 prefix_opc_table
[insn
] = max_matchedp
;
1558 return max_matchedp
;
1561 /* Return -1 if the constraints of a bitwise-matched instruction say
1562 that there is no match. Otherwise return a nonnegative number
1563 indicating the confidence in the match (higher is better). */
1566 cris_constraint (const char *cs
,
1568 unsigned int prefix_insn
,
1569 struct cris_disasm_data
*disdata
)
1576 for (s
= cs
; *s
; s
++)
1580 /* Do not recognize "pop" if there's a prefix and then only for
1582 if (prefix_insn
!= NO_CRIS_PREFIX
1583 || disdata
->distype
!= cris_dis_v0_v10
)
1588 /* Not recognized at disassembly. */
1592 /* Size modifier for "clear", i.e. special register 0, 4 or 8.
1593 Check that it is one of them. Only special register 12 could
1594 be mismatched, but checking for matches is more logical than
1595 checking for mismatches when there are only a few cases. */
1596 tmp
= ((insn
>> 12) & 0xf);
1597 if (tmp
!= 0 && tmp
!= 4 && tmp
!= 8)
1602 if ((insn
& 0x30) == 0x30)
1607 /* A prefix operand without side-effect. */
1608 if (prefix_insn
!= NO_CRIS_PREFIX
&& (insn
& 0x400) == 0)
1619 /* If this is a prefixed insn with postincrement (side-effect),
1620 the prefix must not be DIP. */
1621 if (prefix_insn
!= NO_CRIS_PREFIX
)
1625 const struct cris_opcode
*prefix_opcodep
1626 = get_opcode_entry (prefix_insn
, NO_CRIS_PREFIX
, disdata
);
1628 if (prefix_opcodep
->match
== DIP_OPCODE
)
1637 /* If we don't fall through, then the prefix is ok. */
1640 /* A "push" prefix. Check for valid "push" size.
1641 In case of special register, it may be != 4. */
1642 if (prefix_insn
!= NO_CRIS_PREFIX
)
1644 /* Match the prefix insn to BDAPQ. */
1645 const struct cris_opcode
*prefix_opcodep
1646 = get_opcode_entry (prefix_insn
, NO_CRIS_PREFIX
, disdata
);
1648 if (prefix_opcodep
->match
== BDAP_QUICK_OPCODE
)
1650 int pushsize
= (prefix_insn
& 255);
1657 unsigned int spec_reg
= (insn
>> 12) & 15;
1658 const struct cris_spec_reg
*sregp
1659 = spec_reg_info (spec_reg
, disdata
->distype
);
1661 /* For a special-register, the "prefix size" must
1662 match the size of the register. */
1663 if (sregp
&& sregp
->reg_size
== (unsigned int) -pushsize
)
1666 else if (s
[1] == 'R')
1668 if ((insn
& 0x30) == 0x20 && pushsize
== -4)
1671 /* FIXME: Should abort here; next constraint letter
1672 *must* be 'P' or 'R'. */
1678 retval
= (((insn
>> 12) & 15) == (insn
& 15));
1687 const struct cris_spec_reg
*sregp
1688 = spec_reg_info ((insn
>> 12) & 15, disdata
->distype
);
1690 /* Since we match four bits, we will give a value of 4-1 = 3
1691 in a match. If there is a corresponding exact match of a
1692 special register in another pattern, it will get a value of
1693 4, which will be higher. This should be correct in that an
1694 exact pattern would match better than a general pattern.
1696 Note that there is a reason for not returning zero; the
1697 pattern for "clear" is partly matched in the bit-pattern
1698 (the two lower bits must be zero), while the bit-pattern
1699 for a move from a special register is matched in the
1700 register constraint. */
1712 if (prefix_insn
!= NO_CRIS_PREFIX
&& ! prefix_ok
)
1718 /* Format number as hex with a leading "0x" into outbuffer. */
1721 format_hex (unsigned long number
,
1723 struct cris_disasm_data
*disdata
)
1725 /* Truncate negative numbers on >32-bit hosts. */
1726 number
&= 0xffffffff;
1728 sprintf (outbuffer
, "0x%lx", number
);
1730 /* Save this value for the "case" support. */
1732 last_immediate
= number
;
1734 return outbuffer
+ strlen (outbuffer
);
1737 /* Format number as decimal into outbuffer. Parameter signedp says
1738 whether the number should be formatted as signed (!= 0) or
1742 format_dec (long number
, char *outbuffer
, int signedp
)
1744 last_immediate
= number
;
1745 sprintf (outbuffer
, signedp
? "%ld" : "%lu", number
);
1747 return outbuffer
+ strlen (outbuffer
);
1750 /* Format the name of the general register regno into outbuffer. */
1753 format_reg (struct cris_disasm_data
*disdata
,
1755 char *outbuffer_start
,
1756 bfd_boolean with_reg_prefix
)
1758 char *outbuffer
= outbuffer_start
;
1760 if (with_reg_prefix
)
1761 *outbuffer
++ = REGISTER_PREFIX_CHAR
;
1766 /* For v32, there is no context in which we output PC. */
1767 if (disdata
->distype
== cris_dis_v32
)
1768 strcpy (outbuffer
, "acr");
1770 strcpy (outbuffer
, "pc");
1774 strcpy (outbuffer
, "sp");
1778 sprintf (outbuffer
, "r%d", regno
);
1782 return outbuffer_start
+ strlen (outbuffer_start
);
1785 /* Format the name of a support register into outbuffer. */
1788 format_sup_reg (unsigned int regno
,
1789 char *outbuffer_start
,
1790 bfd_boolean with_reg_prefix
)
1792 char *outbuffer
= outbuffer_start
;
1795 if (with_reg_prefix
)
1796 *outbuffer
++ = REGISTER_PREFIX_CHAR
;
1798 for (i
= 0; cris_support_regs
[i
].name
!= NULL
; i
++)
1799 if (cris_support_regs
[i
].number
== regno
)
1801 sprintf (outbuffer
, "%s", cris_support_regs
[i
].name
);
1802 return outbuffer_start
+ strlen (outbuffer_start
);
1805 /* There's supposed to be register names covering all numbers, though
1806 some may be generic names. */
1807 sprintf (outbuffer
, "format_sup_reg-BUG");
1808 return outbuffer_start
+ strlen (outbuffer_start
);
1811 /* Return the length of an instruction. */
1814 bytes_to_skip (unsigned int insn
,
1815 const struct cris_opcode
*matchedp
,
1816 enum cris_disass_family distype
,
1817 const struct cris_opcode
*prefix_matchedp
)
1819 /* Each insn is a word plus "immediate" operands. */
1820 unsigned to_skip
= 2;
1821 const char *template = matchedp
->args
;
1824 for (s
= template; *s
; s
++)
1825 if ((*s
== 's' || *s
== 'N' || *s
== 'Y')
1826 && (insn
& 0x400) && (insn
& 15) == 15
1827 && prefix_matchedp
== NULL
)
1829 /* Immediate via [pc+], so we have to check the size of the
1831 int mode_size
= 1 << ((insn
>> 4) & (*template == 'z' ? 1 : 3));
1833 if (matchedp
->imm_oprnd_size
== SIZE_FIX_32
)
1835 else if (matchedp
->imm_oprnd_size
== SIZE_SPEC_REG
)
1837 const struct cris_spec_reg
*sregp
1838 = spec_reg_info ((insn
>> 12) & 15, distype
);
1840 /* FIXME: Improve error handling; should have been caught
1845 /* PC is incremented by two, not one, for a byte. Except on
1846 CRISv32, where constants are always DWORD-size for
1847 special registers. */
1849 distype
== cris_dis_v32
? 4 : (sregp
->reg_size
+ 1) & ~1;
1852 to_skip
+= (mode_size
+ 1) & ~1;
1862 /* Print condition code flags. */
1865 print_flags (struct cris_disasm_data
*disdata
, unsigned int insn
, char *cp
)
1867 /* Use the v8 (Etrax 100) flag definitions for disassembly.
1868 The differences with v0 (Etrax 1..4) vs. Svinto are:
1871 FIXME: Emit v0..v3 flag names somehow. */
1872 static const char v8_fnames
[] = "cvznxibm";
1873 static const char v32_fnames
[] = "cvznxiup";
1875 = disdata
->distype
== cris_dis_v32
? v32_fnames
: v8_fnames
;
1877 unsigned char flagbits
= (((insn
>> 8) & 0xf0) | (insn
& 15));
1880 for (i
= 0; i
< 8; i
++)
1881 if (flagbits
& (1 << i
))
1887 /* Print out an insn with its operands, and update the info->insn_type
1888 fields. The prefix_opcodep and the rest hold a prefix insn that is
1889 supposed to be output as an address mode. */
1892 print_with_operands (const struct cris_opcode
*opcodep
,
1894 unsigned char *buffer
,
1896 disassemble_info
*info
,
1897 /* If a prefix insn was before this insn (and is supposed
1898 to be output as an address), here is a description of
1900 const struct cris_opcode
*prefix_opcodep
,
1901 unsigned int prefix_insn
,
1902 unsigned char *prefix_buffer
,
1903 bfd_boolean with_reg_prefix
)
1905 /* Get a buffer of somewhat reasonable size where we store
1906 intermediate parts of the insn. */
1907 char temp
[sizeof (".d [$r13=$r12-2147483648],$r10") * 2];
1909 static const char mode_char
[] = "bwd?";
1912 struct cris_disasm_data
*disdata
1913 = (struct cris_disasm_data
*) info
->private_data
;
1915 /* Print out the name first thing we do. */
1916 (*info
->fprintf_func
) (info
->stream
, "%s", opcodep
->name
);
1921 /* Ignore any prefix indicator. */
1925 if (*s
== 'm' || *s
== 'M' || *s
== 'z')
1929 /* Get the size-letter. */
1931 ? (insn
& 0x8000 ? 'd'
1932 : insn
& 0x4000 ? 'w' : 'b')
1933 : mode_char
[(insn
>> 4) & (*s
== 'z' ? 1 : 3)];
1935 /* Ignore the size and the space character that follows. */
1939 /* Add a space if this isn't a long-branch, because for those will add
1940 the condition part of the name later. */
1941 if (opcodep
->match
!= (BRANCH_PC_LOW
+ BRANCH_INCR_HIGH
* 256))
1944 /* Fill in the insn-type if deducible from the name (and there's no
1946 if (opcodep
->name
[0] == 'j')
1948 if (CONST_STRNEQ (opcodep
->name
, "jsr"))
1949 /* It's "jsr" or "jsrc". */
1950 info
->insn_type
= dis_jsr
;
1952 /* Any other jump-type insn is considered a branch. */
1953 info
->insn_type
= dis_branch
;
1956 /* We might know some more fields right now. */
1957 info
->branch_delay_insns
= opcodep
->delayed
;
1959 /* Handle operands. */
1965 tp
= format_sup_reg ((insn
>> 12) & 15, tp
, with_reg_prefix
);
1969 if (with_reg_prefix
)
1970 *tp
++ = REGISTER_PREFIX_CHAR
;
1983 /* Ignore at this point; used at earlier stages to avoid
1984 recognition if there's a prefix at something that in other
1985 ways looks like a "pop". */
1989 /* Ignore. This is an optional ".d " on the large one of
1994 /* This was the prefix that made this a "push". We've already
1995 handled it by recognizing it, so signal that the prefix is
1996 handled by setting it to NULL. */
1997 prefix_opcodep
= NULL
;
2002 tp
= format_reg (disdata
, insn
& 15, tp
, with_reg_prefix
);
2006 tp
= format_reg (disdata
, (insn
>> 12) & 15, tp
, with_reg_prefix
);
2011 /* Like N but pc-relative to the start of the insn. */
2012 unsigned long number
2013 = (buffer
[2] + buffer
[3] * 256 + buffer
[4] * 65536
2014 + buffer
[5] * 0x1000000 + addr
);
2016 /* Finish off and output previous formatted bytes. */
2019 (*info
->fprintf_func
) (info
->stream
, "%s", temp
);
2022 (*info
->print_address_func
) ((bfd_vma
) number
, info
);
2028 /* Like n but the offset is bits <3:0> in the instruction. */
2029 unsigned long number
= (buffer
[0] & 0xf) * 2 + addr
;
2031 /* Finish off and output previous formatted bytes. */
2034 (*info
->fprintf_func
) (info
->stream
, "%s", temp
);
2037 (*info
->print_address_func
) ((bfd_vma
) number
, info
);
2046 /* Any "normal" memory operand. */
2047 if ((insn
& 0x400) && (insn
& 15) == 15 && prefix_opcodep
== NULL
)
2049 /* We're looking at [pc+], i.e. we need to output an immediate
2050 number, where the size can depend on different things. */
2053 = ((*cs
== 'z' && (insn
& 0x20))
2054 || opcodep
->match
== BDAP_QUICK_OPCODE
);
2057 if (opcodep
->imm_oprnd_size
== SIZE_FIX_32
)
2059 else if (opcodep
->imm_oprnd_size
== SIZE_SPEC_REG
)
2061 const struct cris_spec_reg
*sregp
2062 = spec_reg_info ((insn
>> 12) & 15, disdata
->distype
);
2064 /* A NULL return should have been as a non-match earlier,
2065 so catch it as an internal error in the error-case
2068 /* Whatever non-valid size. */
2071 /* PC is always incremented by a multiple of two.
2072 For CRISv32, immediates are always 4 bytes for
2073 special registers. */
2074 nbytes
= disdata
->distype
== cris_dis_v32
2075 ? 4 : (sregp
->reg_size
+ 1) & ~1;
2079 int mode_size
= 1 << ((insn
>> 4) & (*cs
== 'z' ? 1 : 3));
2091 if (signedp
&& number
> 127)
2096 number
= buffer
[2] + buffer
[3] * 256;
2097 if (signedp
&& number
> 32767)
2103 = buffer
[2] + buffer
[3] * 256 + buffer
[4] * 65536
2104 + buffer
[5] * 0x1000000;
2113 if ((*cs
== 'z' && (insn
& 0x20))
2114 || (opcodep
->match
== BDAP_QUICK_OPCODE
2115 && (nbytes
<= 2 || buffer
[1 + nbytes
] == 0)))
2116 tp
= format_dec (number
, tp
, signedp
);
2119 unsigned int highbyte
= (number
>> 24) & 0xff;
2121 /* Either output this as an address or as a number. If it's
2122 a dword with the same high-byte as the address of the
2123 insn, assume it's an address, and also if it's a non-zero
2124 non-0xff high-byte. If this is a jsr or a jump, then
2125 it's definitely an address. */
2127 && (highbyte
== ((addr
>> 24) & 0xff)
2128 || (highbyte
!= 0 && highbyte
!= 0xff)
2129 || info
->insn_type
== dis_branch
2130 || info
->insn_type
== dis_jsr
))
2132 /* Finish off and output previous formatted bytes. */
2136 (*info
->fprintf_func
) (info
->stream
, "%s", temp
);
2138 (*info
->print_address_func
) ((bfd_vma
) number
, info
);
2140 info
->target
= number
;
2143 tp
= format_hex (number
, tp
, disdata
);
2148 /* Not an immediate number. Then this is a (possibly
2149 prefixed) memory operand. */
2150 if (info
->insn_type
!= dis_nonbranch
)
2154 & (opcodep
->args
[0] == 'z' ? 1 : 3));
2156 info
->insn_type
= dis_dref
;
2157 info
->flags
|= CRIS_DIS_FLAG_MEMREF
;
2159 if (opcodep
->imm_oprnd_size
== SIZE_FIX_32
)
2161 else if (opcodep
->imm_oprnd_size
== SIZE_SPEC_REG
)
2163 const struct cris_spec_reg
*sregp
2164 = spec_reg_info ((insn
>> 12) & 15, disdata
->distype
);
2166 /* FIXME: Improve error handling; should have been caught
2171 size
= sregp
->reg_size
;
2176 info
->data_size
= size
;
2182 /* We don't match dip with a postincremented field
2183 as a side-effect address mode. */
2184 && ((insn
& 0x400) == 0
2185 || prefix_opcodep
->match
!= DIP_OPCODE
))
2189 tp
= format_reg (disdata
, insn
& 15, tp
, with_reg_prefix
);
2194 /* We mainly ignore the prefix format string when the
2195 address-mode syntax is output. */
2196 switch (prefix_opcodep
->match
)
2199 /* It's [r], [r+] or [pc+]. */
2200 if ((prefix_insn
& 0x400) && (prefix_insn
& 15) == 15)
2202 /* It's [pc+]. This cannot possibly be anything
2204 unsigned long number
2205 = prefix_buffer
[2] + prefix_buffer
[3] * 256
2206 + prefix_buffer
[4] * 65536
2207 + prefix_buffer
[5] * 0x1000000;
2209 info
->target
= (bfd_vma
) number
;
2211 /* Finish off and output previous formatted
2216 (*info
->fprintf_func
) (info
->stream
, "%s", temp
);
2218 (*info
->print_address_func
) ((bfd_vma
) number
, info
);
2222 /* For a memref in an address, we use target2.
2223 In this case, target is zero. */
2225 |= (CRIS_DIS_FLAG_MEM_TARGET2_IS_REG
2226 | CRIS_DIS_FLAG_MEM_TARGET2_MEM
);
2228 info
->target2
= prefix_insn
& 15;
2231 tp
= format_reg (disdata
, prefix_insn
& 15, tp
,
2233 if (prefix_insn
& 0x400)
2239 case BDAP_QUICK_OPCODE
:
2243 number
= prefix_buffer
[0];
2247 /* Output "reg+num" or, if num < 0, "reg-num". */
2248 tp
= format_reg (disdata
, (prefix_insn
>> 12) & 15, tp
,
2252 tp
= format_dec (number
, tp
, 1);
2254 info
->flags
|= CRIS_DIS_FLAG_MEM_TARGET_IS_REG
;
2255 info
->target
= (prefix_insn
>> 12) & 15;
2256 info
->target2
= (bfd_vma
) number
;
2261 /* Output "r+R.m". */
2262 tp
= format_reg (disdata
, prefix_insn
& 15, tp
,
2265 tp
= format_reg (disdata
, (prefix_insn
>> 12) & 15, tp
,
2268 *tp
++ = mode_char
[(prefix_insn
>> 4) & 3];
2271 |= (CRIS_DIS_FLAG_MEM_TARGET2_IS_REG
2272 | CRIS_DIS_FLAG_MEM_TARGET_IS_REG
2274 | ((prefix_insn
& 0x8000)
2275 ? CRIS_DIS_FLAG_MEM_TARGET2_MULT4
2276 : ((prefix_insn
& 0x8000)
2277 ? CRIS_DIS_FLAG_MEM_TARGET2_MULT2
: 0)));
2279 /* Is it the casejump? It's a "adds.w [pc+r%d.w],pc". */
2280 if (insn
== 0xf83f && (prefix_insn
& ~0xf000) == 0x55f)
2281 /* Then start interpreting data as offsets. */
2282 case_offset_counter
= no_of_case_offsets
;
2285 case BDAP_INDIR_OPCODE
:
2286 /* Output "r+s.m", or, if "s" is [pc+], "r+s" or
2288 tp
= format_reg (disdata
, (prefix_insn
>> 12) & 15, tp
,
2291 if ((prefix_insn
& 0x400) && (prefix_insn
& 15) == 15)
2294 unsigned int nbytes
;
2296 /* It's a value. Get its size. */
2297 int mode_size
= 1 << ((prefix_insn
>> 4) & 3);
2307 number
= prefix_buffer
[2];
2313 number
= prefix_buffer
[2] + prefix_buffer
[3] * 256;
2320 = prefix_buffer
[2] + prefix_buffer
[3] * 256
2321 + prefix_buffer
[4] * 65536
2322 + prefix_buffer
[5] * 0x1000000;
2331 info
->flags
|= CRIS_DIS_FLAG_MEM_TARGET_IS_REG
;
2332 info
->target2
= (bfd_vma
) number
;
2334 /* If the size is dword, then assume it's an
2338 /* Finish off and output previous formatted
2343 (*info
->fprintf_func
) (info
->stream
, "%s", temp
);
2345 (*info
->print_address_func
) ((bfd_vma
) number
, info
);
2351 tp
= format_dec (number
, tp
, 1);
2356 /* Output "r+[R].m" or "r+[R+].m". */
2359 tp
= format_reg (disdata
, prefix_insn
& 15, tp
,
2361 if (prefix_insn
& 0x400)
2365 *tp
++ = mode_char
[(prefix_insn
>> 4) & 3];
2368 |= (CRIS_DIS_FLAG_MEM_TARGET2_IS_REG
2369 | CRIS_DIS_FLAG_MEM_TARGET2_MEM
2370 | CRIS_DIS_FLAG_MEM_TARGET_IS_REG
2372 | (((prefix_insn
>> 4) == 2)
2374 : (((prefix_insn
>> 4) & 3) == 1
2375 ? CRIS_DIS_FLAG_MEM_TARGET2_MEM_WORD
2376 : CRIS_DIS_FLAG_MEM_TARGET2_MEM_BYTE
)));
2381 (*info
->fprintf_func
) (info
->stream
, "?prefix-bug");
2384 /* To mark that the prefix is used, reset it. */
2385 prefix_opcodep
= NULL
;
2389 tp
= format_reg (disdata
, insn
& 15, tp
, with_reg_prefix
);
2391 info
->flags
|= CRIS_DIS_FLAG_MEM_TARGET_IS_REG
;
2392 info
->target
= insn
& 15;
2402 tp
= format_reg (disdata
, (insn
>> 12) & 15, tp
, with_reg_prefix
);
2404 *tp
++ = mode_char
[(insn
>> 4) & 3];
2408 tp
= format_dec (insn
& 63, tp
, 0);
2413 int where
= buffer
[2] + buffer
[3] * 256;
2418 where
+= addr
+ ((disdata
->distype
== cris_dis_v32
) ? 0 : 4);
2420 if (insn
== BA_PC_INCR_OPCODE
)
2421 info
->insn_type
= dis_branch
;
2423 info
->insn_type
= dis_condbranch
;
2425 info
->target
= (bfd_vma
) where
;
2429 (*info
->fprintf_func
) (info
->stream
, "%s%s ",
2430 temp
, cris_cc_strings
[insn
>> 12]);
2432 (*info
->print_address_func
) ((bfd_vma
) where
, info
);
2437 tp
= format_dec (insn
& 31, tp
, 0);
2441 tp
= format_dec (insn
& 15, tp
, 0);
2446 long offset
= insn
& 0xfe;
2452 if (opcodep
->match
== BA_QUICK_OPCODE
)
2453 info
->insn_type
= dis_branch
;
2455 info
->insn_type
= dis_condbranch
;
2457 target
= addr
+ ((disdata
->distype
== cris_dis_v32
) ? 0 : 2) + offset
;
2458 info
->target
= target
;
2461 (*info
->fprintf_func
) (info
->stream
, "%s", temp
);
2462 (*info
->print_address_func
) (target
, info
);
2469 long number
= buffer
[0];
2472 number
= number
- 256;
2474 tp
= format_dec (number
, tp
, 1);
2476 tp
= format_reg (disdata
, (insn
>> 12) & 15, tp
, with_reg_prefix
);
2481 tp
= print_flags (disdata
, insn
, tp
);
2485 tp
= format_dec ((insn
& 32) ? (insn
& 31) | ~31L : insn
& 31, tp
, 1);
2490 const struct cris_spec_reg
*sregp
2491 = spec_reg_info ((insn
>> 12) & 15, disdata
->distype
);
2493 if (sregp
== NULL
|| sregp
->name
== NULL
)
2494 /* Should have been caught as a non-match earlier. */
2498 if (with_reg_prefix
)
2499 *tp
++ = REGISTER_PREFIX_CHAR
;
2500 strcpy (tp
, sregp
->name
);
2515 (*info
->fprintf_func
) (info
->stream
, " (OOPS unused prefix \"%s: %s\")",
2516 prefix_opcodep
->name
, prefix_opcodep
->args
);
2518 (*info
->fprintf_func
) (info
->stream
, "%s", temp
);
2520 /* Get info for matching case-tables, if we don't have any active.
2521 We assume that the last constant seen is used; either in the insn
2522 itself or in a "move.d const,rN, sub.d rN,rM"-like sequence. */
2523 if (TRACE_CASE
&& case_offset_counter
== 0)
2525 if (CONST_STRNEQ (opcodep
->name
, "sub"))
2526 case_offset
= last_immediate
;
2528 /* It could also be an "add", if there are negative case-values. */
2529 else if (CONST_STRNEQ (opcodep
->name
, "add"))
2530 /* The first case is the negated operand to the add. */
2531 case_offset
= -last_immediate
;
2533 /* A bound insn will tell us the number of cases. */
2534 else if (CONST_STRNEQ (opcodep
->name
, "bound"))
2535 no_of_case_offsets
= last_immediate
+ 1;
2537 /* A jump or jsr or branch breaks the chain of insns for a
2538 case-table, so assume default first-case again. */
2539 else if (info
->insn_type
== dis_jsr
2540 || info
->insn_type
== dis_branch
2541 || info
->insn_type
== dis_condbranch
)
2547 /* Print the CRIS instruction at address memaddr on stream. Returns
2548 length of the instruction, in bytes. Prefix register names with `$' if
2552 print_insn_cris_generic (bfd_vma memaddr
,
2553 disassemble_info
*info
,
2554 bfd_boolean with_reg_prefix
)
2558 const struct cris_opcode
*matchedp
;
2560 struct cris_disasm_data
*disdata
2561 = (struct cris_disasm_data
*) info
->private_data
;
2563 /* No instruction will be disassembled as longer than this number of
2564 bytes; stacked prefixes will not be expanded. */
2565 unsigned char buffer
[MAX_BYTES_PER_CRIS_INSN
];
2566 unsigned char *bufp
;
2570 /* There will be an "out of range" error after the last instruction.
2571 Reading pairs of bytes in decreasing number, we hope that we will get
2572 at least the amount that we will consume.
2574 If we can't get any data, or we do not get enough data, we print
2575 the error message. */
2577 nbytes
= info
->buffer_length
? info
->buffer_length
2578 : MAX_BYTES_PER_CRIS_INSN
;
2579 nbytes
= MIN(nbytes
, MAX_BYTES_PER_CRIS_INSN
);
2580 status
= (*info
->read_memory_func
) (memaddr
, buffer
, nbytes
, info
);
2582 /* If we did not get all we asked for, then clear the rest.
2583 Hopefully this makes a reproducible result in case of errors. */
2584 if (nbytes
!= MAX_BYTES_PER_CRIS_INSN
)
2585 memset (buffer
+ nbytes
, 0, MAX_BYTES_PER_CRIS_INSN
- nbytes
);
2590 /* Set some defaults for the insn info. */
2591 info
->insn_info_valid
= 1;
2592 info
->branch_delay_insns
= 0;
2593 info
->data_size
= 0;
2594 info
->insn_type
= dis_nonbranch
;
2599 /* If we got any data, disassemble it. */
2604 insn
= bufp
[0] + bufp
[1] * 256;
2606 /* If we're in a case-table, don't disassemble the offsets. */
2607 if (TRACE_CASE
&& case_offset_counter
!= 0)
2609 info
->insn_type
= dis_noninsn
;
2612 /* If to print data as offsets, then shortcut here. */
2613 (*info
->fprintf_func
) (info
->stream
, "case %ld%s: -> ",
2614 case_offset
+ no_of_case_offsets
2615 - case_offset_counter
,
2616 case_offset_counter
== 1 ? "/default" :
2619 (*info
->print_address_func
) ((bfd_vma
)
2622 - (no_of_case_offsets
2623 - case_offset_counter
)
2625 case_offset_counter
--;
2627 /* The default case start (without a "sub" or "add") must be
2629 if (case_offset_counter
== 0)
2634 /* We're often called to disassemble zeroes. While this is a
2635 valid "bcc .+2" insn, it is also useless enough and enough
2636 of a nuiscance that we will just output "bcc .+2" for it
2637 and signal it as a noninsn. */
2638 (*info
->fprintf_func
) (info
->stream
,
2639 disdata
->distype
== cris_dis_v32
2640 ? "bcc ." : "bcc .+2");
2641 info
->insn_type
= dis_noninsn
;
2646 const struct cris_opcode
*prefix_opcodep
= NULL
;
2647 unsigned char *prefix_buffer
= bufp
;
2648 unsigned int prefix_insn
= insn
;
2649 int prefix_size
= 0;
2651 matchedp
= get_opcode_entry (insn
, NO_CRIS_PREFIX
, disdata
);
2653 /* Check if we're supposed to write out prefixes as address
2654 modes and if this was a prefix. */
2655 if (matchedp
!= NULL
&& PARSE_PREFIX
&& matchedp
->args
[0] == 'p')
2657 /* If it's a prefix, put it into the prefix vars and get the
2659 prefix_size
= bytes_to_skip (prefix_insn
, matchedp
,
2660 disdata
->distype
, NULL
);
2661 prefix_opcodep
= matchedp
;
2663 insn
= bufp
[prefix_size
] + bufp
[prefix_size
+ 1] * 256;
2664 matchedp
= get_opcode_entry (insn
, prefix_insn
, disdata
);
2666 if (matchedp
!= NULL
)
2668 addr
+= prefix_size
;
2669 bufp
+= prefix_size
;
2670 advance
+= prefix_size
;
2674 /* The "main" insn wasn't valid, at least not when
2675 prefixed. Put back things enough to output the
2676 prefix insn only, as a normal insn. */
2677 matchedp
= prefix_opcodep
;
2679 prefix_opcodep
= NULL
;
2683 if (matchedp
== NULL
)
2685 (*info
->fprintf_func
) (info
->stream
, "??0x%x", insn
);
2688 info
->insn_type
= dis_noninsn
;
2693 += bytes_to_skip (insn
, matchedp
, disdata
->distype
,
2696 /* The info_type and assorted fields will be set according
2698 print_with_operands (matchedp
, insn
, bufp
, addr
, info
,
2699 prefix_opcodep
, prefix_insn
,
2700 prefix_buffer
, with_reg_prefix
);
2705 info
->insn_type
= dis_noninsn
;
2707 /* If we read less than MAX_BYTES_PER_CRIS_INSN, i.e. we got an error
2708 status when reading that much, and the insn decoding indicated a
2709 length exceeding what we read, there is an error. */
2710 if (status
!= 0 && (nbytes
== 0 || advance
> nbytes
))
2712 (*info
->memory_error_func
) (status
, memaddr
, info
);
2716 /* Max supported insn size with one folded prefix insn. */
2717 info
->bytes_per_line
= MAX_BYTES_PER_CRIS_INSN
;
2719 /* I would like to set this to a fixed value larger than the actual
2720 number of bytes to print in order to avoid spaces between bytes,
2721 but objdump.c (2.9.1) does not like that, so we print 16-bit
2722 chunks, which is the next choice. */
2723 info
->bytes_per_chunk
= 2;
2725 /* Printing bytes in order of increasing addresses makes sense,
2726 especially on a little-endian target.
2727 This is completely the opposite of what you think; setting this to
2728 BFD_ENDIAN_LITTLE will print bytes in order N..0 rather than the 0..N
2730 info
->display_endian
= BFD_ENDIAN_BIG
;
2735 /* Disassemble, prefixing register names with `$'. CRIS v0..v10. */
2737 print_insn_cris_with_register_prefix (bfd_vma vma
,
2738 disassemble_info
*info
)
2740 if (info
->private_data
== NULL
2741 && !cris_parse_disassembler_options (info
, cris_dis_v0_v10
))
2743 return print_insn_cris_generic (vma
, info
, true);
2745 /* Disassemble, prefixing register names with `$'. CRIS v32. */
2748 print_insn_crisv32_with_register_prefix (bfd_vma vma
,
2749 disassemble_info
*info
)
2751 if (info
->private_data
== NULL
2752 && !cris_parse_disassembler_options (info
, cris_dis_v32
))
2754 return print_insn_cris_generic (vma
, info
, true);
2758 /* Disassemble, prefixing register names with `$'.
2759 Common v10 and v32 subset. */
2762 print_insn_crisv10_v32_with_register_prefix (bfd_vma vma
,
2763 disassemble_info
*info
)
2765 if (info
->private_data
== NULL
2766 && !cris_parse_disassembler_options (info
, cris_dis_common_v10_v32
))
2768 return print_insn_cris_generic (vma
, info
, true);
2771 /* Disassemble, no prefixes on register names. CRIS v0..v10. */
2774 print_insn_cris_without_register_prefix (bfd_vma vma
,
2775 disassemble_info
*info
)
2777 if (info
->private_data
== NULL
2778 && !cris_parse_disassembler_options (info
, cris_dis_v0_v10
))
2780 return print_insn_cris_generic (vma
, info
, false);
2783 /* Disassemble, no prefixes on register names. CRIS v32. */
2786 print_insn_crisv32_without_register_prefix (bfd_vma vma
,
2787 disassemble_info
*info
)
2789 if (info
->private_data
== NULL
2790 && !cris_parse_disassembler_options (info
, cris_dis_v32
))
2792 return print_insn_cris_generic (vma
, info
, false);
2795 /* Disassemble, no prefixes on register names.
2796 Common v10 and v32 subset. */
2799 print_insn_crisv10_v32_without_register_prefix (bfd_vma vma
,
2800 disassemble_info
*info
)
2802 if (info
->private_data
== NULL
2803 && !cris_parse_disassembler_options (info
, cris_dis_common_v10_v32
))
2805 return print_insn_cris_generic (vma
, info
, false);
2810 print_insn_crisv10 (bfd_vma vma
,
2811 disassemble_info
*info
)
2813 return print_insn_cris_with_register_prefix(vma
, info
);
2817 print_insn_crisv32 (bfd_vma vma
,
2818 disassemble_info
*info
)
2820 return print_insn_crisv32_with_register_prefix(vma
, info
);
2823 /* Return a disassembler-function that prints registers with a `$' prefix,
2824 or one that prints registers without a prefix.
2825 FIXME: We should improve the solution to avoid the multitude of
2826 functions seen above. */
2829 cris_get_disassembler (bfd
*abfd
)
2831 /* If there's no bfd in sight, we return what is valid as input in all
2832 contexts if fed back to the assembler: disassembly *with* register
2833 prefix. Unfortunately this will be totally wrong for v32. */
2835 return print_insn_cris_with_register_prefix
;
2837 if (bfd_get_symbol_leading_char (abfd
) == 0)
2839 if (bfd_get_mach (abfd
) == bfd_mach_cris_v32
)
2840 return print_insn_crisv32_with_register_prefix
;
2841 if (bfd_get_mach (abfd
) == bfd_mach_cris_v10_v32
)
2842 return print_insn_crisv10_v32_with_register_prefix
;
2844 /* We default to v10. This may be specifically specified in the
2845 bfd mach, but is also the default setting. */
2846 return print_insn_cris_with_register_prefix
;
2849 if (bfd_get_mach (abfd
) == bfd_mach_cris_v32
)
2850 return print_insn_crisv32_without_register_prefix
;
2851 if (bfd_get_mach (abfd
) == bfd_mach_cris_v10_v32
)
2852 return print_insn_crisv10_v32_without_register_prefix
;
2853 return print_insn_cris_without_register_prefix
;
2857 eval: (c-set-style "gnu")