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-common.h"
24 #include "target-cris/opcode-cris.h"
25 //#include "libiberty.h"
27 #define CONST_STRNEQ(STR1,STR2) (strncmp ((STR1), (STR2), sizeof (STR2) - 1) == 0)
29 /* cris-opc.c -- Table of opcodes for the CRIS processor.
30 Copyright 2000, 2001, 2004 Free Software Foundation, Inc.
31 Contributed by Axis Communications AB, Lund, Sweden.
32 Originally written for GAS 1.38.1 by Mikael Asker.
33 Reorganized by Hans-Peter Nilsson.
35 This file is part of GAS, GDB and the GNU binutils.
37 GAS, GDB, and GNU binutils is free software; you can redistribute it
38 and/or modify it under the terms of the GNU General Public License as
39 published by the Free Software Foundation; either version 2, or (at your
40 option) any later version.
42 GAS, GDB, and GNU binutils are distributed in the hope that they will be
43 useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
44 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
45 GNU General Public License for more details.
47 You should have received a copy of the GNU General Public License
48 along with this program; if not, see <http://www.gnu.org/licenses/>. */
54 /* This table isn't used for CRISv32 and the size of immediate operands. */
55 const struct cris_spec_reg
58 {"bz", 0, 1, cris_ver_v32p
, NULL
},
59 {"p0", 0, 1, 0, NULL
},
60 {"vr", 1, 1, 0, NULL
},
61 {"p1", 1, 1, 0, NULL
},
62 {"pid", 2, 1, cris_ver_v32p
, NULL
},
63 {"p2", 2, 1, cris_ver_v32p
, NULL
},
64 {"p2", 2, 1, cris_ver_warning
, NULL
},
65 {"srs", 3, 1, cris_ver_v32p
, NULL
},
66 {"p3", 3, 1, cris_ver_v32p
, NULL
},
67 {"p3", 3, 1, cris_ver_warning
, NULL
},
68 {"wz", 4, 2, cris_ver_v32p
, NULL
},
69 {"p4", 4, 2, 0, NULL
},
70 {"ccr", 5, 2, cris_ver_v0_10
, NULL
},
71 {"exs", 5, 4, cris_ver_v32p
, NULL
},
72 {"p5", 5, 2, cris_ver_v0_10
, NULL
},
73 {"p5", 5, 4, cris_ver_v32p
, NULL
},
74 {"dcr0",6, 2, cris_ver_v0_3
, NULL
},
75 {"eda", 6, 4, cris_ver_v32p
, NULL
},
76 {"p6", 6, 2, cris_ver_v0_3
, NULL
},
77 {"p6", 6, 4, cris_ver_v32p
, NULL
},
78 {"dcr1/mof", 7, 4, cris_ver_v10p
,
79 "Register `dcr1/mof' with ambiguous size specified. Guessing 4 bytes"},
80 {"dcr1/mof", 7, 2, cris_ver_v0_3
,
81 "Register `dcr1/mof' with ambiguous size specified. Guessing 2 bytes"},
82 {"mof", 7, 4, cris_ver_v10p
, NULL
},
83 {"dcr1",7, 2, cris_ver_v0_3
, NULL
},
84 {"p7", 7, 4, cris_ver_v10p
, NULL
},
85 {"p7", 7, 2, cris_ver_v0_3
, NULL
},
86 {"dz", 8, 4, cris_ver_v32p
, NULL
},
87 {"p8", 8, 4, 0, NULL
},
88 {"ibr", 9, 4, cris_ver_v0_10
, NULL
},
89 {"ebp", 9, 4, cris_ver_v32p
, NULL
},
90 {"p9", 9, 4, 0, NULL
},
91 {"irp", 10, 4, cris_ver_v0_10
, NULL
},
92 {"erp", 10, 4, cris_ver_v32p
, NULL
},
93 {"p10", 10, 4, 0, NULL
},
94 {"srp", 11, 4, 0, NULL
},
95 {"p11", 11, 4, 0, NULL
},
96 /* For disassembly use only. Accept at assembly with a warning. */
97 {"bar/dtp0", 12, 4, cris_ver_warning
,
98 "Ambiguous register `bar/dtp0' specified"},
99 {"nrp", 12, 4, cris_ver_v32p
, NULL
},
100 {"bar", 12, 4, cris_ver_v8_10
, NULL
},
101 {"dtp0",12, 4, cris_ver_v0_3
, NULL
},
102 {"p12", 12, 4, 0, NULL
},
103 /* For disassembly use only. Accept at assembly with a warning. */
104 {"dccr/dtp1",13, 4, cris_ver_warning
,
105 "Ambiguous register `dccr/dtp1' specified"},
106 {"ccs", 13, 4, cris_ver_v32p
, NULL
},
107 {"dccr",13, 4, cris_ver_v8_10
, NULL
},
108 {"dtp1",13, 4, cris_ver_v0_3
, NULL
},
109 {"p13", 13, 4, 0, NULL
},
110 {"brp", 14, 4, cris_ver_v3_10
, NULL
},
111 {"usp", 14, 4, cris_ver_v32p
, NULL
},
112 {"p14", 14, 4, cris_ver_v3p
, NULL
},
113 {"usp", 15, 4, cris_ver_v10
, NULL
},
114 {"spc", 15, 4, cris_ver_v32p
, NULL
},
115 {"p15", 15, 4, cris_ver_v10p
, NULL
},
116 {NULL
, 0, 0, cris_ver_version_all
, NULL
}
119 /* Add version specifiers to this table when necessary.
120 The (now) regular coding of register names suggests a simpler
122 const struct cris_support_reg cris_support_regs
[] =
143 /* All CRIS opcodes are 16 bits.
145 - The match component is a mask saying which bits must match a
146 particular opcode in order for an instruction to be an instance
149 - The args component is a string containing characters symbolically
150 matching the operands of an instruction. Used for both assembly
153 Operand-matching characters:
156 A The string "ACR" (case-insensitive).
157 B Not really an operand. It causes a "BDAP -size,SP" prefix to be
158 output for the PUSH alias-instructions and recognizes a push-
159 prefix at disassembly. This letter isn't recognized for v32.
160 Must be followed by a R or P letter.
161 ! Non-match pattern, will not match if there's a prefix insn.
162 b Non-matching operand, used for branches with 16-bit
163 displacement. Only recognized by the disassembler.
164 c 5-bit unsigned immediate in bits <4:0>.
165 C 4-bit unsigned immediate in bits <3:0>.
166 d At assembly, optionally (as in put other cases before this one)
167 ".d" or ".D" at the start of the operands, followed by one space
168 character. At disassembly, nothing.
169 D General register in bits <15:12> and <3:0>.
170 f List of flags in bits <15:12> and <3:0>.
171 i 6-bit signed immediate in bits <5:0>.
172 I 6-bit unsigned immediate in bits <5:0>.
173 M Size modifier (B, W or D) for CLEAR instructions.
174 m Size modifier (B, W or D) in bits <5:4>
175 N A 32-bit dword, like in the difference between s and y.
176 This has no effect on bits in the opcode. Can also be expressed
178 n As N, but PC-relative (to the start of the instruction).
179 o [-128..127] word offset in bits <7:1> and <0>. Used by 8-bit
181 O [-128..127] offset in bits <7:0>. Also matches a comma and a
182 general register after the expression, in bits <15:12>. Used
183 only for the BDAP prefix insn (in v32 the ADDOQ insn; same opcode).
184 P Special register in bits <15:12>.
185 p Indicates that the insn is a prefix insn. Must be first
187 Q As O, but don't relax; force an 8-bit offset.
188 R General register in bits <15:12>.
189 r General register in bits <3:0>.
190 S Source operand in bit <10> and a prefix; a 3-operand prefix
192 s Source operand in bits <10> and <3:0>, optionally with a
193 side-effect prefix, except [pc] (the name, not R15 as in ACR)
194 isn't allowed for v32 and higher.
195 T Support register in bits <15:12>.
196 u 4-bit (PC-relative) unsigned immediate word offset in bits <3:0>.
197 U Relaxes to either u or n, instruction is assumed LAPCQ or LAPC.
198 Not recognized at disassembly.
199 x Register-dot-modifier, for example "r5.w" in bits <15:12> and <5:4>.
200 y Like 's' but do not allow an integer at assembly.
201 Y The difference s-y; only an integer is allowed.
202 z Size modifier (B or W) in bit <4>. */
205 /* Please note the order of the opcodes in this table is significant.
206 The assembler requires that all instances of the same mnemonic must
207 be consecutive. If they aren't, the assembler might not recognize
208 them, or may indicate an internal error.
210 The disassembler should not normally care about the order of the
211 opcodes, but will prefer an earlier alternative if the "match-score"
212 (see cris-dis.c) is computed as equal.
214 It should not be significant for proper execution that this table is
215 in alphabetical order, but please follow that convention for an easy
218 const struct cris_opcode
221 {"abs", 0x06B0, 0x0940, "r,R", 0, SIZE_NONE
, 0,
224 {"add", 0x0600, 0x09c0, "m r,R", 0, SIZE_NONE
, 0,
225 cris_reg_mode_add_sub_cmp_and_or_move_op
},
227 {"add", 0x0A00, 0x01c0, "m s,R", 0, SIZE_FIELD
, 0,
228 cris_none_reg_mode_add_sub_cmp_and_or_move_op
},
230 {"add", 0x0A00, 0x01c0, "m S,D", 0, SIZE_NONE
,
232 cris_none_reg_mode_add_sub_cmp_and_or_move_op
},
234 {"add", 0x0a00, 0x05c0, "m S,R,r", 0, SIZE_NONE
,
236 cris_three_operand_add_sub_cmp_and_or_op
},
238 {"add", 0x0A00, 0x01c0, "m s,R", 0, SIZE_FIELD
,
240 cris_none_reg_mode_add_sub_cmp_and_or_move_op
},
242 {"addc", 0x0570, 0x0A80, "r,R", 0, SIZE_FIX_32
,
244 cris_not_implemented_op
},
246 {"addc", 0x09A0, 0x0250, "s,R", 0, SIZE_FIX_32
,
248 cris_not_implemented_op
},
250 {"addi", 0x0540, 0x0A80, "x,r,A", 0, SIZE_NONE
,
254 {"addi", 0x0500, 0x0Ac0, "x,r", 0, SIZE_NONE
, 0,
257 /* This collates after "addo", but we want to disassemble as "addoq",
259 {"addoq", 0x0100, 0x0E00, "Q,A", 0, SIZE_NONE
,
261 cris_not_implemented_op
},
263 {"addo", 0x0940, 0x0280, "m s,R,A", 0, SIZE_FIELD_SIGNED
,
265 cris_not_implemented_op
},
267 /* This must be located after the insn above, lest we misinterpret
268 "addo.b -1,r0,acr" as "addo .b-1,r0,acr". FIXME: Sounds like a
270 {"addo", 0x0100, 0x0E00, "O,A", 0, SIZE_NONE
,
272 cris_not_implemented_op
},
274 {"addq", 0x0200, 0x0Dc0, "I,R", 0, SIZE_NONE
, 0,
275 cris_quick_mode_add_sub_op
},
277 {"adds", 0x0420, 0x0Bc0, "z r,R", 0, SIZE_NONE
, 0,
278 cris_reg_mode_add_sub_cmp_and_or_move_op
},
280 /* FIXME: SIZE_FIELD_SIGNED and all necessary changes. */
281 {"adds", 0x0820, 0x03c0, "z s,R", 0, SIZE_FIELD
, 0,
282 cris_none_reg_mode_add_sub_cmp_and_or_move_op
},
284 {"adds", 0x0820, 0x03c0, "z S,D", 0, SIZE_NONE
,
286 cris_none_reg_mode_add_sub_cmp_and_or_move_op
},
288 {"adds", 0x0820, 0x07c0, "z S,R,r", 0, SIZE_NONE
,
290 cris_three_operand_add_sub_cmp_and_or_op
},
292 {"addu", 0x0400, 0x0be0, "z r,R", 0, SIZE_NONE
, 0,
293 cris_reg_mode_add_sub_cmp_and_or_move_op
},
295 /* FIXME: SIZE_FIELD_UNSIGNED and all necessary changes. */
296 {"addu", 0x0800, 0x03e0, "z s,R", 0, SIZE_FIELD
, 0,
297 cris_none_reg_mode_add_sub_cmp_and_or_move_op
},
299 {"addu", 0x0800, 0x03e0, "z S,D", 0, SIZE_NONE
,
301 cris_none_reg_mode_add_sub_cmp_and_or_move_op
},
303 {"addu", 0x0800, 0x07e0, "z S,R,r", 0, SIZE_NONE
,
305 cris_three_operand_add_sub_cmp_and_or_op
},
307 {"and", 0x0700, 0x08C0, "m r,R", 0, SIZE_NONE
, 0,
308 cris_reg_mode_add_sub_cmp_and_or_move_op
},
310 {"and", 0x0B00, 0x00C0, "m s,R", 0, SIZE_FIELD
, 0,
311 cris_none_reg_mode_add_sub_cmp_and_or_move_op
},
313 {"and", 0x0B00, 0x00C0, "m S,D", 0, SIZE_NONE
,
315 cris_none_reg_mode_add_sub_cmp_and_or_move_op
},
317 {"and", 0x0B00, 0x04C0, "m S,R,r", 0, SIZE_NONE
,
319 cris_three_operand_add_sub_cmp_and_or_op
},
321 {"andq", 0x0300, 0x0CC0, "i,R", 0, SIZE_NONE
, 0,
322 cris_quick_mode_and_cmp_move_or_op
},
324 {"asr", 0x0780, 0x0840, "m r,R", 0, SIZE_NONE
, 0,
327 {"asrq", 0x03a0, 0x0c40, "c,R", 0, SIZE_NONE
, 0,
330 {"ax", 0x15B0, 0xEA4F, "", 0, SIZE_NONE
, 0,
333 /* FIXME: Should use branch #defines. */
334 {"b", 0x0dff, 0x0200, "b", 1, SIZE_NONE
, 0,
335 cris_sixteen_bit_offset_branch_op
},
339 0x0F00+(0xF-CC_A
)*0x1000, "o", 1, SIZE_NONE
, 0,
340 cris_eight_bit_offset_branch_op
},
342 /* Needs to come after the usual "ba o", which might be relaxed to
344 {"ba", BA_DWORD_OPCODE
,
345 0xffff & (~BA_DWORD_OPCODE
), "n", 0, SIZE_FIX_32
,
347 cris_none_reg_mode_jump_op
},
349 {"bas", 0x0EBF, 0x0140, "n,P", 0, SIZE_FIX_32
,
351 cris_none_reg_mode_jump_op
},
353 {"basc", 0x0EFF, 0x0100, "n,P", 0, SIZE_FIX_32
,
355 cris_none_reg_mode_jump_op
},
358 BRANCH_QUICK_OPCODE
+CC_CC
*0x1000,
359 0x0f00+(0xF-CC_CC
)*0x1000, "o", 1, SIZE_NONE
, 0,
360 cris_eight_bit_offset_branch_op
},
363 BRANCH_QUICK_OPCODE
+CC_CS
*0x1000,
364 0x0f00+(0xF-CC_CS
)*0x1000, "o", 1, SIZE_NONE
, 0,
365 cris_eight_bit_offset_branch_op
},
368 BDAP_INDIR_OPCODE
, BDAP_INDIR_Z_BITS
, "pm s,R", 0, SIZE_FIELD_SIGNED
,
373 BDAP_QUICK_OPCODE
, BDAP_QUICK_Z_BITS
, "pO", 0, SIZE_NONE
,
375 cris_quick_mode_bdap_prefix
},
378 BRANCH_QUICK_OPCODE
+CC_EQ
*0x1000,
379 0x0f00+(0xF-CC_EQ
)*0x1000, "o", 1, SIZE_NONE
, 0,
380 cris_eight_bit_offset_branch_op
},
382 /* This is deliberately put before "bext" to trump it, even though not
383 in alphabetical order, since we don't do excluding version checks
386 BRANCH_QUICK_OPCODE
+CC_EXT
*0x1000,
387 0x0f00+(0xF-CC_EXT
)*0x1000, "o", 1, SIZE_NONE
,
389 cris_eight_bit_offset_branch_op
},
392 BRANCH_QUICK_OPCODE
+CC_EXT
*0x1000,
393 0x0f00+(0xF-CC_EXT
)*0x1000, "o", 1, SIZE_NONE
,
395 cris_eight_bit_offset_branch_op
},
398 BRANCH_QUICK_OPCODE
+CC_GE
*0x1000,
399 0x0f00+(0xF-CC_GE
)*0x1000, "o", 1, SIZE_NONE
, 0,
400 cris_eight_bit_offset_branch_op
},
403 BRANCH_QUICK_OPCODE
+CC_GT
*0x1000,
404 0x0f00+(0xF-CC_GT
)*0x1000, "o", 1, SIZE_NONE
, 0,
405 cris_eight_bit_offset_branch_op
},
408 BRANCH_QUICK_OPCODE
+CC_HI
*0x1000,
409 0x0f00+(0xF-CC_HI
)*0x1000, "o", 1, SIZE_NONE
, 0,
410 cris_eight_bit_offset_branch_op
},
413 BRANCH_QUICK_OPCODE
+CC_HS
*0x1000,
414 0x0f00+(0xF-CC_HS
)*0x1000, "o", 1, SIZE_NONE
, 0,
415 cris_eight_bit_offset_branch_op
},
417 {"biap", BIAP_OPCODE
, BIAP_Z_BITS
, "pm r,R", 0, SIZE_NONE
,
422 BRANCH_QUICK_OPCODE
+CC_LE
*0x1000,
423 0x0f00+(0xF-CC_LE
)*0x1000, "o", 1, SIZE_NONE
, 0,
424 cris_eight_bit_offset_branch_op
},
427 BRANCH_QUICK_OPCODE
+CC_LO
*0x1000,
428 0x0f00+(0xF-CC_LO
)*0x1000, "o", 1, SIZE_NONE
, 0,
429 cris_eight_bit_offset_branch_op
},
432 BRANCH_QUICK_OPCODE
+CC_LS
*0x1000,
433 0x0f00+(0xF-CC_LS
)*0x1000, "o", 1, SIZE_NONE
, 0,
434 cris_eight_bit_offset_branch_op
},
437 BRANCH_QUICK_OPCODE
+CC_LT
*0x1000,
438 0x0f00+(0xF-CC_LT
)*0x1000, "o", 1, SIZE_NONE
, 0,
439 cris_eight_bit_offset_branch_op
},
442 BRANCH_QUICK_OPCODE
+CC_MI
*0x1000,
443 0x0f00+(0xF-CC_MI
)*0x1000, "o", 1, SIZE_NONE
, 0,
444 cris_eight_bit_offset_branch_op
},
446 {"bmod", 0x0ab0, 0x0140, "s,R", 0, SIZE_FIX_32
,
448 cris_not_implemented_op
},
450 {"bmod", 0x0ab0, 0x0140, "S,D", 0, SIZE_NONE
,
452 cris_not_implemented_op
},
454 {"bmod", 0x0ab0, 0x0540, "S,R,r", 0, SIZE_NONE
,
456 cris_not_implemented_op
},
459 BRANCH_QUICK_OPCODE
+CC_NE
*0x1000,
460 0x0f00+(0xF-CC_NE
)*0x1000, "o", 1, SIZE_NONE
, 0,
461 cris_eight_bit_offset_branch_op
},
463 {"bound", 0x05c0, 0x0A00, "m r,R", 0, SIZE_NONE
, 0,
464 cris_two_operand_bound_op
},
465 /* FIXME: SIZE_FIELD_UNSIGNED and all necessary changes. */
466 {"bound", 0x09c0, 0x0200, "m s,R", 0, SIZE_FIELD
,
468 cris_two_operand_bound_op
},
469 /* FIXME: SIZE_FIELD_UNSIGNED and all necessary changes. */
470 {"bound", 0x0dcf, 0x0200, "m Y,R", 0, SIZE_FIELD
, 0,
471 cris_two_operand_bound_op
},
472 {"bound", 0x09c0, 0x0200, "m S,D", 0, SIZE_NONE
,
474 cris_two_operand_bound_op
},
475 {"bound", 0x09c0, 0x0600, "m S,R,r", 0, SIZE_NONE
,
477 cris_three_operand_bound_op
},
480 BRANCH_QUICK_OPCODE
+CC_PL
*0x1000,
481 0x0f00+(0xF-CC_PL
)*0x1000, "o", 1, SIZE_NONE
, 0,
482 cris_eight_bit_offset_branch_op
},
484 {"break", 0xe930, 0x16c0, "C", 0, SIZE_NONE
,
489 BRANCH_QUICK_OPCODE
+CC_EXT
*0x1000,
490 0x0f00+(0xF-CC_EXT
)*0x1000, "o", 1, SIZE_NONE
,
492 cris_eight_bit_offset_branch_op
},
494 {"bsr", 0xBEBF, 0x4140, "n", 0, SIZE_FIX_32
,
496 cris_none_reg_mode_jump_op
},
498 {"bsrc", 0xBEFF, 0x4100, "n", 0, SIZE_FIX_32
,
500 cris_none_reg_mode_jump_op
},
502 {"bstore", 0x0af0, 0x0100, "s,R", 0, SIZE_FIX_32
,
504 cris_not_implemented_op
},
506 {"bstore", 0x0af0, 0x0100, "S,D", 0, SIZE_NONE
,
508 cris_not_implemented_op
},
510 {"bstore", 0x0af0, 0x0500, "S,R,r", 0, SIZE_NONE
,
512 cris_not_implemented_op
},
514 {"btst", 0x04F0, 0x0B00, "r,R", 0, SIZE_NONE
, 0,
516 {"btstq", 0x0380, 0x0C60, "c,R", 0, SIZE_NONE
, 0,
520 BRANCH_QUICK_OPCODE
+CC_VC
*0x1000,
521 0x0f00+(0xF-CC_VC
)*0x1000, "o", 1, SIZE_NONE
, 0,
522 cris_eight_bit_offset_branch_op
},
525 BRANCH_QUICK_OPCODE
+CC_VS
*0x1000,
526 0x0f00+(0xF-CC_VS
)*0x1000, "o", 1, SIZE_NONE
, 0,
527 cris_eight_bit_offset_branch_op
},
529 {"clear", 0x0670, 0x3980, "M r", 0, SIZE_NONE
, 0,
530 cris_reg_mode_clear_op
},
532 {"clear", 0x0A70, 0x3180, "M y", 0, SIZE_NONE
, 0,
533 cris_none_reg_mode_clear_test_op
},
535 {"clear", 0x0A70, 0x3180, "M S", 0, SIZE_NONE
,
537 cris_none_reg_mode_clear_test_op
},
539 {"clearf", 0x05F0, 0x0A00, "f", 0, SIZE_NONE
, 0,
542 {"cmp", 0x06C0, 0x0900, "m r,R", 0, SIZE_NONE
, 0,
543 cris_reg_mode_add_sub_cmp_and_or_move_op
},
545 {"cmp", 0x0Ac0, 0x0100, "m s,R", 0, SIZE_FIELD
, 0,
546 cris_none_reg_mode_add_sub_cmp_and_or_move_op
},
548 {"cmp", 0x0Ac0, 0x0100, "m S,D", 0, SIZE_NONE
,
550 cris_none_reg_mode_add_sub_cmp_and_or_move_op
},
552 {"cmpq", 0x02C0, 0x0D00, "i,R", 0, SIZE_NONE
, 0,
553 cris_quick_mode_and_cmp_move_or_op
},
555 /* FIXME: SIZE_FIELD_SIGNED and all necessary changes. */
556 {"cmps", 0x08e0, 0x0300, "z s,R", 0, SIZE_FIELD
, 0,
557 cris_none_reg_mode_add_sub_cmp_and_or_move_op
},
559 {"cmps", 0x08e0, 0x0300, "z S,D", 0, SIZE_NONE
,
561 cris_none_reg_mode_add_sub_cmp_and_or_move_op
},
563 /* FIXME: SIZE_FIELD_UNSIGNED and all necessary changes. */
564 {"cmpu", 0x08c0, 0x0320, "z s,R" , 0, SIZE_FIELD
, 0,
565 cris_none_reg_mode_add_sub_cmp_and_or_move_op
},
567 {"cmpu", 0x08c0, 0x0320, "z S,D", 0, SIZE_NONE
,
569 cris_none_reg_mode_add_sub_cmp_and_or_move_op
},
571 {"di", 0x25F0, 0xDA0F, "", 0, SIZE_NONE
, 0,
574 {"dip", DIP_OPCODE
, DIP_Z_BITS
, "ps", 0, SIZE_FIX_32
,
578 {"div", 0x0980, 0x0640, "m R,r", 0, SIZE_FIELD
, 0,
579 cris_not_implemented_op
},
581 {"dstep", 0x06f0, 0x0900, "r,R", 0, SIZE_NONE
, 0,
582 cris_dstep_logshift_mstep_neg_not_op
},
584 {"ei", 0x25B0, 0xDA4F, "", 0, SIZE_NONE
, 0,
587 {"fidxd", 0x0ab0, 0xf540, "[r]", 0, SIZE_NONE
,
589 cris_not_implemented_op
},
591 {"fidxi", 0x0d30, 0xF2C0, "[r]", 0, SIZE_NONE
,
593 cris_not_implemented_op
},
595 {"ftagd", 0x1AB0, 0xE540, "[r]", 0, SIZE_NONE
,
597 cris_not_implemented_op
},
599 {"ftagi", 0x1D30, 0xE2C0, "[r]", 0, SIZE_NONE
,
601 cris_not_implemented_op
},
603 {"halt", 0xF930, 0x06CF, "", 0, SIZE_NONE
,
605 cris_not_implemented_op
},
607 {"jas", 0x09B0, 0x0640, "r,P", 0, SIZE_NONE
,
609 cris_reg_mode_jump_op
},
611 {"jas", 0x0DBF, 0x0240, "N,P", 0, SIZE_FIX_32
,
613 cris_reg_mode_jump_op
},
615 {"jasc", 0x0B30, 0x04C0, "r,P", 0, SIZE_NONE
,
617 cris_reg_mode_jump_op
},
619 {"jasc", 0x0F3F, 0x00C0, "N,P", 0, SIZE_FIX_32
,
621 cris_reg_mode_jump_op
},
623 {"jbrc", 0x69b0, 0x9640, "r", 0, SIZE_NONE
,
625 cris_reg_mode_jump_op
},
627 {"jbrc", 0x6930, 0x92c0, "s", 0, SIZE_FIX_32
,
629 cris_none_reg_mode_jump_op
},
631 {"jbrc", 0x6930, 0x92c0, "S", 0, SIZE_NONE
,
633 cris_none_reg_mode_jump_op
},
635 {"jir", 0xA9b0, 0x5640, "r", 0, SIZE_NONE
,
637 cris_reg_mode_jump_op
},
639 {"jir", 0xA930, 0x52c0, "s", 0, SIZE_FIX_32
,
641 cris_none_reg_mode_jump_op
},
643 {"jir", 0xA930, 0x52c0, "S", 0, SIZE_NONE
,
645 cris_none_reg_mode_jump_op
},
647 {"jirc", 0x29b0, 0xd640, "r", 0, SIZE_NONE
,
649 cris_reg_mode_jump_op
},
651 {"jirc", 0x2930, 0xd2c0, "s", 0, SIZE_FIX_32
,
653 cris_none_reg_mode_jump_op
},
655 {"jirc", 0x2930, 0xd2c0, "S", 0, SIZE_NONE
,
657 cris_none_reg_mode_jump_op
},
659 {"jsr", 0xB9b0, 0x4640, "r", 0, SIZE_NONE
, 0,
660 cris_reg_mode_jump_op
},
662 {"jsr", 0xB930, 0x42c0, "s", 0, SIZE_FIX_32
,
664 cris_none_reg_mode_jump_op
},
666 {"jsr", 0xBDBF, 0x4240, "N", 0, SIZE_FIX_32
,
668 cris_none_reg_mode_jump_op
},
670 {"jsr", 0xB930, 0x42c0, "S", 0, SIZE_NONE
,
672 cris_none_reg_mode_jump_op
},
674 {"jsrc", 0x39b0, 0xc640, "r", 0, SIZE_NONE
,
676 cris_reg_mode_jump_op
},
678 {"jsrc", 0x3930, 0xc2c0, "s", 0, SIZE_FIX_32
,
680 cris_none_reg_mode_jump_op
},
682 {"jsrc", 0x3930, 0xc2c0, "S", 0, SIZE_NONE
,
684 cris_none_reg_mode_jump_op
},
686 {"jsrc", 0xBB30, 0x44C0, "r", 0, SIZE_NONE
,
688 cris_reg_mode_jump_op
},
690 {"jsrc", 0xBF3F, 0x40C0, "N", 0, SIZE_FIX_32
,
692 cris_reg_mode_jump_op
},
694 {"jump", 0x09b0, 0xF640, "r", 0, SIZE_NONE
, 0,
695 cris_reg_mode_jump_op
},
698 JUMP_INDIR_OPCODE
, JUMP_INDIR_Z_BITS
, "s", 0, SIZE_FIX_32
,
700 cris_none_reg_mode_jump_op
},
703 JUMP_INDIR_OPCODE
, JUMP_INDIR_Z_BITS
, "S", 0, SIZE_NONE
,
705 cris_none_reg_mode_jump_op
},
707 {"jump", 0x09F0, 0x060F, "P", 0, SIZE_NONE
,
709 cris_none_reg_mode_jump_op
},
712 JUMP_PC_INCR_OPCODE_V32
,
713 (0xffff & ~JUMP_PC_INCR_OPCODE_V32
), "N", 0, SIZE_FIX_32
,
715 cris_none_reg_mode_jump_op
},
717 {"jmpu", 0x8930, 0x72c0, "s", 0, SIZE_FIX_32
,
719 cris_none_reg_mode_jump_op
},
721 {"jmpu", 0x8930, 0x72c0, "S", 0, SIZE_NONE
,
723 cris_none_reg_mode_jump_op
},
725 {"lapc", 0x0970, 0x0680, "U,R", 0, SIZE_NONE
,
727 cris_not_implemented_op
},
729 {"lapc", 0x0D7F, 0x0280, "dn,R", 0, SIZE_FIX_32
,
731 cris_not_implemented_op
},
733 {"lapcq", 0x0970, 0x0680, "u,R", 0, SIZE_NONE
,
737 {"lsl", 0x04C0, 0x0B00, "m r,R", 0, SIZE_NONE
, 0,
738 cris_dstep_logshift_mstep_neg_not_op
},
740 {"lslq", 0x03c0, 0x0C20, "c,R", 0, SIZE_NONE
, 0,
741 cris_dstep_logshift_mstep_neg_not_op
},
743 {"lsr", 0x07C0, 0x0800, "m r,R", 0, SIZE_NONE
, 0,
744 cris_dstep_logshift_mstep_neg_not_op
},
746 {"lsrq", 0x03e0, 0x0C00, "c,R", 0, SIZE_NONE
, 0,
747 cris_dstep_logshift_mstep_neg_not_op
},
749 {"lz", 0x0730, 0x08C0, "r,R", 0, SIZE_NONE
,
751 cris_not_implemented_op
},
753 {"mcp", 0x07f0, 0x0800, "P,r", 0, SIZE_NONE
,
755 cris_not_implemented_op
},
757 {"move", 0x0640, 0x0980, "m r,R", 0, SIZE_NONE
, 0,
758 cris_reg_mode_add_sub_cmp_and_or_move_op
},
760 {"move", 0x0A40, 0x0180, "m s,R", 0, SIZE_FIELD
, 0,
761 cris_none_reg_mode_add_sub_cmp_and_or_move_op
},
763 {"move", 0x0A40, 0x0180, "m S,D", 0, SIZE_NONE
,
765 cris_none_reg_mode_add_sub_cmp_and_or_move_op
},
767 {"move", 0x0630, 0x09c0, "r,P", 0, SIZE_NONE
, 0,
768 cris_move_to_preg_op
},
770 {"move", 0x0670, 0x0980, "P,r", 0, SIZE_NONE
, 0,
771 cris_reg_mode_move_from_preg_op
},
773 {"move", 0x0BC0, 0x0000, "m R,y", 0, SIZE_FIELD
, 0,
774 cris_none_reg_mode_add_sub_cmp_and_or_move_op
},
776 {"move", 0x0BC0, 0x0000, "m D,S", 0, SIZE_NONE
,
778 cris_none_reg_mode_add_sub_cmp_and_or_move_op
},
781 MOVE_M_TO_PREG_OPCODE
, MOVE_M_TO_PREG_ZBITS
,
782 "s,P", 0, SIZE_SPEC_REG
, 0,
783 cris_move_to_preg_op
},
785 {"move", 0x0A30, 0x01c0, "S,P", 0, SIZE_NONE
,
787 cris_move_to_preg_op
},
789 {"move", 0x0A70, 0x0180, "P,y", 0, SIZE_SPEC_REG
, 0,
790 cris_none_reg_mode_move_from_preg_op
},
792 {"move", 0x0A70, 0x0180, "P,S", 0, SIZE_NONE
,
794 cris_none_reg_mode_move_from_preg_op
},
796 {"move", 0x0B70, 0x0480, "r,T", 0, SIZE_NONE
,
798 cris_not_implemented_op
},
800 {"move", 0x0F70, 0x0080, "T,r", 0, SIZE_NONE
,
802 cris_not_implemented_op
},
804 {"movem", 0x0BF0, 0x0000, "R,y", 0, SIZE_FIX_32
, 0,
805 cris_move_reg_to_mem_movem_op
},
807 {"movem", 0x0BF0, 0x0000, "D,S", 0, SIZE_NONE
,
809 cris_move_reg_to_mem_movem_op
},
811 {"movem", 0x0BB0, 0x0040, "s,R", 0, SIZE_FIX_32
, 0,
812 cris_move_mem_to_reg_movem_op
},
814 {"movem", 0x0BB0, 0x0040, "S,D", 0, SIZE_NONE
,
816 cris_move_mem_to_reg_movem_op
},
818 {"moveq", 0x0240, 0x0D80, "i,R", 0, SIZE_NONE
, 0,
819 cris_quick_mode_and_cmp_move_or_op
},
821 {"movs", 0x0460, 0x0B80, "z r,R", 0, SIZE_NONE
, 0,
822 cris_reg_mode_add_sub_cmp_and_or_move_op
},
824 /* FIXME: SIZE_FIELD_SIGNED and all necessary changes. */
825 {"movs", 0x0860, 0x0380, "z s,R", 0, SIZE_FIELD
, 0,
826 cris_none_reg_mode_add_sub_cmp_and_or_move_op
},
828 {"movs", 0x0860, 0x0380, "z S,D", 0, SIZE_NONE
,
830 cris_none_reg_mode_add_sub_cmp_and_or_move_op
},
832 {"movu", 0x0440, 0x0Ba0, "z r,R", 0, SIZE_NONE
, 0,
833 cris_reg_mode_add_sub_cmp_and_or_move_op
},
835 /* FIXME: SIZE_FIELD_UNSIGNED and all necessary changes. */
836 {"movu", 0x0840, 0x03a0, "z s,R", 0, SIZE_FIELD
, 0,
837 cris_none_reg_mode_add_sub_cmp_and_or_move_op
},
839 {"movu", 0x0840, 0x03a0, "z S,D", 0, SIZE_NONE
,
841 cris_none_reg_mode_add_sub_cmp_and_or_move_op
},
843 {"mstep", 0x07f0, 0x0800, "r,R", 0, SIZE_NONE
,
845 cris_dstep_logshift_mstep_neg_not_op
},
847 {"muls", 0x0d00, 0x02c0, "m r,R", 0, SIZE_NONE
,
851 {"mulu", 0x0900, 0x06c0, "m r,R", 0, SIZE_NONE
,
855 {"neg", 0x0580, 0x0A40, "m r,R", 0, SIZE_NONE
, 0,
856 cris_dstep_logshift_mstep_neg_not_op
},
858 {"nop", NOP_OPCODE
, NOP_Z_BITS
, "", 0, SIZE_NONE
,
862 {"nop", NOP_OPCODE_V32
, NOP_Z_BITS_V32
, "", 0, SIZE_NONE
,
866 {"not", 0x8770, 0x7880, "r", 0, SIZE_NONE
, 0,
867 cris_dstep_logshift_mstep_neg_not_op
},
869 {"or", 0x0740, 0x0880, "m r,R", 0, SIZE_NONE
, 0,
870 cris_reg_mode_add_sub_cmp_and_or_move_op
},
872 {"or", 0x0B40, 0x0080, "m s,R", 0, SIZE_FIELD
, 0,
873 cris_none_reg_mode_add_sub_cmp_and_or_move_op
},
875 {"or", 0x0B40, 0x0080, "m S,D", 0, SIZE_NONE
,
877 cris_none_reg_mode_add_sub_cmp_and_or_move_op
},
879 {"or", 0x0B40, 0x0480, "m S,R,r", 0, SIZE_NONE
,
881 cris_three_operand_add_sub_cmp_and_or_op
},
883 {"orq", 0x0340, 0x0C80, "i,R", 0, SIZE_NONE
, 0,
884 cris_quick_mode_and_cmp_move_or_op
},
886 {"pop", 0x0E6E, 0x0191, "!R", 0, SIZE_NONE
,
888 cris_none_reg_mode_add_sub_cmp_and_or_move_op
},
890 {"pop", 0x0e3e, 0x01c1, "!P", 0, SIZE_NONE
,
892 cris_none_reg_mode_move_from_preg_op
},
894 {"push", 0x0FEE, 0x0011, "BR", 0, SIZE_NONE
,
896 cris_none_reg_mode_add_sub_cmp_and_or_move_op
},
898 {"push", 0x0E7E, 0x0181, "BP", 0, SIZE_NONE
,
900 cris_move_to_preg_op
},
902 {"rbf", 0x3b30, 0xc0c0, "y", 0, SIZE_NONE
,
904 cris_not_implemented_op
},
906 {"rbf", 0x3b30, 0xc0c0, "S", 0, SIZE_NONE
,
908 cris_not_implemented_op
},
910 {"rfe", 0x2930, 0xD6CF, "", 0, SIZE_NONE
,
912 cris_not_implemented_op
},
914 {"rfg", 0x4930, 0xB6CF, "", 0, SIZE_NONE
,
916 cris_not_implemented_op
},
918 {"rfn", 0x5930, 0xA6CF, "", 0, SIZE_NONE
,
920 cris_not_implemented_op
},
922 {"ret", 0xB67F, 0x4980, "", 1, SIZE_NONE
,
924 cris_reg_mode_move_from_preg_op
},
926 {"ret", 0xB9F0, 0x460F, "", 1, SIZE_NONE
,
928 cris_reg_mode_move_from_preg_op
},
930 {"retb", 0xe67f, 0x1980, "", 1, SIZE_NONE
,
932 cris_reg_mode_move_from_preg_op
},
934 {"rete", 0xA9F0, 0x560F, "", 1, SIZE_NONE
,
936 cris_reg_mode_move_from_preg_op
},
938 {"reti", 0xA67F, 0x5980, "", 1, SIZE_NONE
,
940 cris_reg_mode_move_from_preg_op
},
942 {"retn", 0xC9F0, 0x360F, "", 1, SIZE_NONE
,
944 cris_reg_mode_move_from_preg_op
},
946 {"sbfs", 0x3b70, 0xc080, "y", 0, SIZE_NONE
,
948 cris_not_implemented_op
},
950 {"sbfs", 0x3b70, 0xc080, "S", 0, SIZE_NONE
,
952 cris_not_implemented_op
},
956 0x0AC0+(0xf-CC_A
)*0x1000, "r", 0, SIZE_NONE
, 0,
960 0x0530+CC_EXT
*0x1000,
961 0x0AC0+(0xf-CC_EXT
)*0x1000, "r", 0, SIZE_NONE
,
967 0x0AC0+(0xf-CC_CC
)*0x1000, "r", 0, SIZE_NONE
, 0,
972 0x0AC0+(0xf-CC_CS
)*0x1000, "r", 0, SIZE_NONE
, 0,
977 0x0AC0+(0xf-CC_EQ
)*0x1000, "r", 0, SIZE_NONE
, 0,
980 {"setf", 0x05b0, 0x0A40, "f", 0, SIZE_NONE
, 0,
983 {"sfe", 0x3930, 0xC6CF, "", 0, SIZE_NONE
,
985 cris_not_implemented_op
},
987 /* Need to have "swf" in front of "sext" so it is the one displayed in
990 0x0530+CC_EXT
*0x1000,
991 0x0AC0+(0xf-CC_EXT
)*0x1000, "r", 0, SIZE_NONE
,
996 0x0530+CC_EXT
*0x1000,
997 0x0AC0+(0xf-CC_EXT
)*0x1000, "r", 0, SIZE_NONE
,
1002 0x0530+CC_GE
*0x1000,
1003 0x0AC0+(0xf-CC_GE
)*0x1000, "r", 0, SIZE_NONE
, 0,
1007 0x0530+CC_GT
*0x1000,
1008 0x0AC0+(0xf-CC_GT
)*0x1000, "r", 0, SIZE_NONE
, 0,
1012 0x0530+CC_HI
*0x1000,
1013 0x0AC0+(0xf-CC_HI
)*0x1000, "r", 0, SIZE_NONE
, 0,
1017 0x0530+CC_HS
*0x1000,
1018 0x0AC0+(0xf-CC_HS
)*0x1000, "r", 0, SIZE_NONE
, 0,
1022 0x0530+CC_LE
*0x1000,
1023 0x0AC0+(0xf-CC_LE
)*0x1000, "r", 0, SIZE_NONE
, 0,
1027 0x0530+CC_LO
*0x1000,
1028 0x0AC0+(0xf-CC_LO
)*0x1000, "r", 0, SIZE_NONE
, 0,
1032 0x0530+CC_LS
*0x1000,
1033 0x0AC0+(0xf-CC_LS
)*0x1000, "r", 0, SIZE_NONE
, 0,
1037 0x0530+CC_LT
*0x1000,
1038 0x0AC0+(0xf-CC_LT
)*0x1000, "r", 0, SIZE_NONE
, 0,
1042 0x0530+CC_MI
*0x1000,
1043 0x0AC0+(0xf-CC_MI
)*0x1000, "r", 0, SIZE_NONE
, 0,
1047 0x0530+CC_NE
*0x1000,
1048 0x0AC0+(0xf-CC_NE
)*0x1000, "r", 0, SIZE_NONE
, 0,
1052 0x0530+CC_PL
*0x1000,
1053 0x0AC0+(0xf-CC_PL
)*0x1000, "r", 0, SIZE_NONE
, 0,
1056 {"sub", 0x0680, 0x0940, "m r,R", 0, SIZE_NONE
, 0,
1057 cris_reg_mode_add_sub_cmp_and_or_move_op
},
1059 {"sub", 0x0a80, 0x0140, "m s,R", 0, SIZE_FIELD
, 0,
1060 cris_none_reg_mode_add_sub_cmp_and_or_move_op
},
1062 {"sub", 0x0a80, 0x0140, "m S,D", 0, SIZE_NONE
,
1064 cris_none_reg_mode_add_sub_cmp_and_or_move_op
},
1066 {"sub", 0x0a80, 0x0540, "m S,R,r", 0, SIZE_NONE
,
1068 cris_three_operand_add_sub_cmp_and_or_op
},
1070 {"subq", 0x0280, 0x0d40, "I,R", 0, SIZE_NONE
, 0,
1071 cris_quick_mode_add_sub_op
},
1073 {"subs", 0x04a0, 0x0b40, "z r,R", 0, SIZE_NONE
, 0,
1074 cris_reg_mode_add_sub_cmp_and_or_move_op
},
1076 /* FIXME: SIZE_FIELD_SIGNED and all necessary changes. */
1077 {"subs", 0x08a0, 0x0340, "z s,R", 0, SIZE_FIELD
, 0,
1078 cris_none_reg_mode_add_sub_cmp_and_or_move_op
},
1080 {"subs", 0x08a0, 0x0340, "z S,D", 0, SIZE_NONE
,
1082 cris_none_reg_mode_add_sub_cmp_and_or_move_op
},
1084 {"subs", 0x08a0, 0x0740, "z S,R,r", 0, SIZE_NONE
,
1086 cris_three_operand_add_sub_cmp_and_or_op
},
1088 {"subu", 0x0480, 0x0b60, "z r,R", 0, SIZE_NONE
, 0,
1089 cris_reg_mode_add_sub_cmp_and_or_move_op
},
1091 /* FIXME: SIZE_FIELD_UNSIGNED and all necessary changes. */
1092 {"subu", 0x0880, 0x0360, "z s,R", 0, SIZE_FIELD
, 0,
1093 cris_none_reg_mode_add_sub_cmp_and_or_move_op
},
1095 {"subu", 0x0880, 0x0360, "z S,D", 0, SIZE_NONE
,
1097 cris_none_reg_mode_add_sub_cmp_and_or_move_op
},
1099 {"subu", 0x0880, 0x0760, "z S,R,r", 0, SIZE_NONE
,
1101 cris_three_operand_add_sub_cmp_and_or_op
},
1104 0x0530+CC_VC
*0x1000,
1105 0x0AC0+(0xf-CC_VC
)*0x1000, "r", 0, SIZE_NONE
, 0,
1109 0x0530+CC_VS
*0x1000,
1110 0x0AC0+(0xf-CC_VS
)*0x1000, "r", 0, SIZE_NONE
, 0,
1113 /* The insn "swapn" is the same as "not" and will be disassembled as
1114 such, but the swap* family of mnmonics are generally v8-and-higher
1115 only, so count it in. */
1116 {"swapn", 0x8770, 0x7880, "r", 0, SIZE_NONE
,
1118 cris_not_implemented_op
},
1120 {"swapw", 0x4770, 0xb880, "r", 0, SIZE_NONE
,
1122 cris_not_implemented_op
},
1124 {"swapnw", 0xc770, 0x3880, "r", 0, SIZE_NONE
,
1126 cris_not_implemented_op
},
1128 {"swapb", 0x2770, 0xd880, "r", 0, SIZE_NONE
,
1130 cris_not_implemented_op
},
1132 {"swapnb", 0xA770, 0x5880, "r", 0, SIZE_NONE
,
1134 cris_not_implemented_op
},
1136 {"swapwb", 0x6770, 0x9880, "r", 0, SIZE_NONE
,
1138 cris_not_implemented_op
},
1140 {"swapnwb", 0xE770, 0x1880, "r", 0, SIZE_NONE
,
1142 cris_not_implemented_op
},
1144 {"swapr", 0x1770, 0xe880, "r", 0, SIZE_NONE
,
1146 cris_not_implemented_op
},
1148 {"swapnr", 0x9770, 0x6880, "r", 0, SIZE_NONE
,
1150 cris_not_implemented_op
},
1152 {"swapwr", 0x5770, 0xa880, "r", 0, SIZE_NONE
,
1154 cris_not_implemented_op
},
1156 {"swapnwr", 0xd770, 0x2880, "r", 0, SIZE_NONE
,
1158 cris_not_implemented_op
},
1160 {"swapbr", 0x3770, 0xc880, "r", 0, SIZE_NONE
,
1162 cris_not_implemented_op
},
1164 {"swapnbr", 0xb770, 0x4880, "r", 0, SIZE_NONE
,
1166 cris_not_implemented_op
},
1168 {"swapwbr", 0x7770, 0x8880, "r", 0, SIZE_NONE
,
1170 cris_not_implemented_op
},
1172 {"swapnwbr", 0xf770, 0x0880, "r", 0, SIZE_NONE
,
1174 cris_not_implemented_op
},
1176 {"test", 0x0640, 0x0980, "m D", 0, SIZE_NONE
,
1178 cris_reg_mode_test_op
},
1180 {"test", 0x0b80, 0xf040, "m y", 0, SIZE_FIELD
, 0,
1181 cris_none_reg_mode_clear_test_op
},
1183 {"test", 0x0b80, 0xf040, "m S", 0, SIZE_NONE
,
1185 cris_none_reg_mode_clear_test_op
},
1187 {"xor", 0x07B0, 0x0840, "r,R", 0, SIZE_NONE
, 0,
1190 {NULL
, 0, 0, NULL
, 0, 0, 0, cris_not_implemented_op
}
1193 /* Condition-names, indexed by the CC_* numbers as found in cris.h. */
1212 /* This is a placeholder. In v0, this would be "ext". In v32, this
1213 is "sb". See cris_conds15. */
1217 /* Different names and semantics for condition 1111 (0xf). */
1218 const struct cris_cond15 cris_cond15s
[] =
1220 /* FIXME: In what version did condition "ext" disappear? */
1221 {"ext", cris_ver_v0_3
},
1222 {"wf", cris_ver_v10
},
1223 {"sb", cris_ver_v32p
},
1230 * eval: (c-set-style "gnu")
1231 * indent-tabs-mode: t
1236 /* No instruction will be disassembled longer than this. In theory, and
1237 in silicon, address prefixes can be cascaded. In practice, cascading
1238 is not used by GCC, and not supported by the assembler. */
1239 #ifndef MAX_BYTES_PER_CRIS_INSN
1240 #define MAX_BYTES_PER_CRIS_INSN 8
1243 /* Whether or not to decode prefixes, folding it into the following
1244 instruction. FIXME: Make this optional later. */
1245 #ifndef PARSE_PREFIX
1246 #define PARSE_PREFIX 1
1249 /* Sometimes we prefix all registers with this character. */
1250 #define REGISTER_PREFIX_CHAR '$'
1252 /* Whether or not to trace the following sequence:
1255 adds.w [pc+r%d.w],pc
1257 This is the assembly form of a switch-statement in C.
1258 The "sub is optional. If there is none, then X will be zero.
1259 X is the value of the first case,
1260 Y is the number of cases (including default).
1262 This results in case offsets printed on the form:
1263 case N: -> case_address
1264 where N is an estimation on the corresponding 'case' operand in C,
1265 and case_address is where execution of that case continues after the
1266 sequence presented above.
1268 The old style of output was to print the offsets as instructions,
1269 which made it hard to follow "case"-constructs in the disassembly,
1270 and caused a lot of annoying warnings about undefined instructions.
1272 FIXME: Make this optional later. */
1274 #define TRACE_CASE (disdata->trace_case)
1277 enum cris_disass_family
1278 { cris_dis_v0_v10
, cris_dis_common_v10_v32
, cris_dis_v32
};
1280 /* Stored in the disasm_info->private_data member. */
1281 struct cris_disasm_data
1283 /* Whether to print something less confusing if we find something
1284 matching a switch-construct. */
1285 bfd_boolean trace_case
;
1287 /* Whether this code is flagged as crisv32. FIXME: Should be an enum
1288 that includes "compatible". */
1289 enum cris_disass_family distype
;
1292 /* Value of first element in switch. */
1293 static long case_offset
= 0;
1295 /* How many more case-offsets to print. */
1296 static long case_offset_counter
= 0;
1298 /* Number of case offsets. */
1299 static long no_of_case_offsets
= 0;
1301 /* Candidate for next case_offset. */
1302 static long last_immediate
= 0;
1304 static int cris_constraint
1305 (const char *, unsigned, unsigned, struct cris_disasm_data
*);
1307 /* Parse disassembler options and store state in info. FIXME: For the
1308 time being, we abuse static variables. */
1311 cris_parse_disassembler_options (disassemble_info
*info
,
1312 enum cris_disass_family distype
)
1314 struct cris_disasm_data
*disdata
;
1316 info
->private_data
= calloc (1, sizeof (struct cris_disasm_data
));
1317 disdata
= (struct cris_disasm_data
*) info
->private_data
;
1318 if (disdata
== NULL
)
1323 = (info
->disassembler_options
== NULL
1324 || (strcmp (info
->disassembler_options
, "nocase") != 0));
1326 disdata
->distype
= distype
;
1330 static const struct cris_spec_reg
*
1331 spec_reg_info (unsigned int sreg
, enum cris_disass_family distype
)
1335 for (i
= 0; cris_spec_regs
[i
].name
!= NULL
; i
++)
1337 if (cris_spec_regs
[i
].number
== sreg
)
1339 if (distype
== cris_dis_v32
)
1340 switch (cris_spec_regs
[i
].applicable_version
)
1342 case cris_ver_warning
:
1343 case cris_ver_version_all
:
1348 /* No ambiguous sizes or register names with CRISv32. */
1349 if (cris_spec_regs
[i
].warning
== NULL
)
1350 return &cris_spec_regs
[i
];
1354 else if (cris_spec_regs
[i
].applicable_version
!= cris_ver_v32p
)
1355 return &cris_spec_regs
[i
];
1362 /* Return the number of bits in the argument. */
1365 number_of_bits (unsigned int val
)
1369 for (bits
= 0; val
!= 0; val
&= val
- 1)
1375 /* Get an entry in the opcode-table. */
1377 static const struct cris_opcode
*
1378 get_opcode_entry (unsigned int insn
,
1379 unsigned int prefix_insn
,
1380 struct cris_disasm_data
*disdata
)
1382 /* For non-prefixed insns, we keep a table of pointers, indexed by the
1383 insn code. Each entry is initialized when found to be NULL. */
1384 static const struct cris_opcode
**opc_table
= NULL
;
1386 const struct cris_opcode
*max_matchedp
= NULL
;
1387 const struct cris_opcode
**prefix_opc_table
= NULL
;
1389 /* We hold a table for each prefix that need to be handled differently. */
1390 static const struct cris_opcode
**dip_prefixes
= NULL
;
1391 static const struct cris_opcode
**bdapq_m1_prefixes
= NULL
;
1392 static const struct cris_opcode
**bdapq_m2_prefixes
= NULL
;
1393 static const struct cris_opcode
**bdapq_m4_prefixes
= NULL
;
1394 static const struct cris_opcode
**rest_prefixes
= NULL
;
1396 /* Allocate and clear the opcode-table. */
1397 if (opc_table
== NULL
)
1399 opc_table
= g_malloc (65536 * sizeof (opc_table
[0]));
1401 memset (opc_table
, 0, 65536 * sizeof (const struct cris_opcode
*));
1404 = g_malloc (65536 * sizeof (const struct cris_opcode
**));
1406 memset (dip_prefixes
, 0, 65536 * sizeof (dip_prefixes
[0]));
1409 = g_malloc (65536 * sizeof (const struct cris_opcode
**));
1411 memset (bdapq_m1_prefixes
, 0, 65536 * sizeof (bdapq_m1_prefixes
[0]));
1414 = g_malloc (65536 * sizeof (const struct cris_opcode
**));
1416 memset (bdapq_m2_prefixes
, 0, 65536 * sizeof (bdapq_m2_prefixes
[0]));
1419 = g_malloc (65536 * sizeof (const struct cris_opcode
**));
1421 memset (bdapq_m4_prefixes
, 0, 65536 * sizeof (bdapq_m4_prefixes
[0]));
1424 = g_malloc (65536 * sizeof (const struct cris_opcode
**));
1426 memset (rest_prefixes
, 0, 65536 * sizeof (rest_prefixes
[0]));
1429 /* Get the right table if this is a prefix.
1430 This code is connected to cris_constraints in that it knows what
1431 prefixes play a role in recognition of patterns; the necessary
1432 state is reflected by which table is used. If constraints
1433 involving match or non-match of prefix insns are changed, then this
1434 probably needs changing too. */
1435 if (prefix_insn
!= NO_CRIS_PREFIX
)
1437 const struct cris_opcode
*popcodep
1438 = (opc_table
[prefix_insn
] != NULL
1439 ? opc_table
[prefix_insn
]
1440 : get_opcode_entry (prefix_insn
, NO_CRIS_PREFIX
, disdata
));
1442 if (popcodep
== NULL
)
1445 if (popcodep
->match
== BDAP_QUICK_OPCODE
)
1447 /* Since some offsets are recognized with "push" macros, we
1448 have to have different tables for them. */
1449 int offset
= (prefix_insn
& 255);
1457 prefix_opc_table
= bdapq_m4_prefixes
;
1461 prefix_opc_table
= bdapq_m2_prefixes
;
1465 prefix_opc_table
= bdapq_m1_prefixes
;
1469 prefix_opc_table
= rest_prefixes
;
1473 else if (popcodep
->match
== DIP_OPCODE
)
1474 /* We don't allow postincrement when the prefix is DIP, so use a
1475 different table for DIP. */
1476 prefix_opc_table
= dip_prefixes
;
1478 prefix_opc_table
= rest_prefixes
;
1481 if (prefix_insn
!= NO_CRIS_PREFIX
1482 && prefix_opc_table
[insn
] != NULL
)
1483 max_matchedp
= prefix_opc_table
[insn
];
1484 else if (prefix_insn
== NO_CRIS_PREFIX
&& opc_table
[insn
] != NULL
)
1485 max_matchedp
= opc_table
[insn
];
1488 const struct cris_opcode
*opcodep
;
1489 int max_level_of_match
= -1;
1491 for (opcodep
= cris_opcodes
;
1492 opcodep
->name
!= NULL
;
1497 if (disdata
->distype
== cris_dis_v32
)
1499 switch (opcodep
->applicable_version
)
1501 case cris_ver_version_all
:
1505 case cris_ver_v0_10
:
1506 case cris_ver_v3_10
:
1507 case cris_ver_sim_v0_10
:
1508 case cris_ver_v8_10
:
1510 case cris_ver_warning
:
1527 switch (opcodep
->applicable_version
)
1529 case cris_ver_version_all
:
1532 case cris_ver_v0_10
:
1534 case cris_ver_v8_10
:
1536 case cris_ver_sim_v0_10
:
1538 case cris_ver_warning
:
1551 /* We give a double lead for bits matching the template in
1552 cris_opcodes. Not even, because then "move p8,r10" would
1553 be given 2 bits lead over "clear.d r10". When there's a
1554 tie, the first entry in the table wins. This is
1555 deliberate, to avoid a more complicated recognition
1557 if ((opcodep
->match
& insn
) == opcodep
->match
1558 && (opcodep
->lose
& insn
) == 0
1560 = cris_constraint (opcodep
->args
,
1566 += 2 * number_of_bits (opcodep
->match
1568 > max_level_of_match
))
1570 max_matchedp
= opcodep
;
1571 max_level_of_match
= level_of_match
;
1573 /* If there was a full match, never mind looking
1575 if (level_of_match
>= 2 * 16)
1579 /* Fill in the new entry.
1581 If there are changes to the opcode-table involving prefixes, and
1582 disassembly then does not work correctly, try removing the
1583 else-clause below that fills in the prefix-table. If that
1584 helps, you need to change the prefix_opc_table setting above, or
1585 something related. */
1586 if (prefix_insn
== NO_CRIS_PREFIX
)
1587 opc_table
[insn
] = max_matchedp
;
1589 prefix_opc_table
[insn
] = max_matchedp
;
1592 return max_matchedp
;
1595 /* Return -1 if the constraints of a bitwise-matched instruction say
1596 that there is no match. Otherwise return a nonnegative number
1597 indicating the confidence in the match (higher is better). */
1600 cris_constraint (const char *cs
,
1602 unsigned int prefix_insn
,
1603 struct cris_disasm_data
*disdata
)
1610 for (s
= cs
; *s
; s
++)
1614 /* Do not recognize "pop" if there's a prefix and then only for
1616 if (prefix_insn
!= NO_CRIS_PREFIX
1617 || disdata
->distype
!= cris_dis_v0_v10
)
1622 /* Not recognized at disassembly. */
1626 /* Size modifier for "clear", i.e. special register 0, 4 or 8.
1627 Check that it is one of them. Only special register 12 could
1628 be mismatched, but checking for matches is more logical than
1629 checking for mismatches when there are only a few cases. */
1630 tmp
= ((insn
>> 12) & 0xf);
1631 if (tmp
!= 0 && tmp
!= 4 && tmp
!= 8)
1636 if ((insn
& 0x30) == 0x30)
1641 /* A prefix operand without side-effect. */
1642 if (prefix_insn
!= NO_CRIS_PREFIX
&& (insn
& 0x400) == 0)
1653 /* If this is a prefixed insn with postincrement (side-effect),
1654 the prefix must not be DIP. */
1655 if (prefix_insn
!= NO_CRIS_PREFIX
)
1659 const struct cris_opcode
*prefix_opcodep
1660 = get_opcode_entry (prefix_insn
, NO_CRIS_PREFIX
, disdata
);
1662 if (prefix_opcodep
->match
== DIP_OPCODE
)
1671 /* If we don't fall through, then the prefix is ok. */
1674 /* A "push" prefix. Check for valid "push" size.
1675 In case of special register, it may be != 4. */
1676 if (prefix_insn
!= NO_CRIS_PREFIX
)
1678 /* Match the prefix insn to BDAPQ. */
1679 const struct cris_opcode
*prefix_opcodep
1680 = get_opcode_entry (prefix_insn
, NO_CRIS_PREFIX
, disdata
);
1682 if (prefix_opcodep
->match
== BDAP_QUICK_OPCODE
)
1684 int pushsize
= (prefix_insn
& 255);
1691 unsigned int spec_reg
= (insn
>> 12) & 15;
1692 const struct cris_spec_reg
*sregp
1693 = spec_reg_info (spec_reg
, disdata
->distype
);
1695 /* For a special-register, the "prefix size" must
1696 match the size of the register. */
1697 if (sregp
&& sregp
->reg_size
== (unsigned int) -pushsize
)
1700 else if (s
[1] == 'R')
1702 if ((insn
& 0x30) == 0x20 && pushsize
== -4)
1705 /* FIXME: Should abort here; next constraint letter
1706 *must* be 'P' or 'R'. */
1712 retval
= (((insn
>> 12) & 15) == (insn
& 15));
1721 const struct cris_spec_reg
*sregp
1722 = spec_reg_info ((insn
>> 12) & 15, disdata
->distype
);
1724 /* Since we match four bits, we will give a value of 4-1 = 3
1725 in a match. If there is a corresponding exact match of a
1726 special register in another pattern, it will get a value of
1727 4, which will be higher. This should be correct in that an
1728 exact pattern would match better than a general pattern.
1730 Note that there is a reason for not returning zero; the
1731 pattern for "clear" is partly matched in the bit-pattern
1732 (the two lower bits must be zero), while the bit-pattern
1733 for a move from a special register is matched in the
1734 register constraint. */
1746 if (prefix_insn
!= NO_CRIS_PREFIX
&& ! prefix_ok
)
1752 /* Format number as hex with a leading "0x" into outbuffer. */
1755 format_hex (unsigned long number
,
1757 struct cris_disasm_data
*disdata
)
1759 /* Truncate negative numbers on >32-bit hosts. */
1760 number
&= 0xffffffff;
1762 sprintf (outbuffer
, "0x%lx", number
);
1764 /* Save this value for the "case" support. */
1766 last_immediate
= number
;
1768 return outbuffer
+ strlen (outbuffer
);
1771 /* Format number as decimal into outbuffer. Parameter signedp says
1772 whether the number should be formatted as signed (!= 0) or
1776 format_dec (long number
, char *outbuffer
, int signedp
)
1778 last_immediate
= number
;
1779 sprintf (outbuffer
, signedp
? "%ld" : "%lu", number
);
1781 return outbuffer
+ strlen (outbuffer
);
1784 /* Format the name of the general register regno into outbuffer. */
1787 format_reg (struct cris_disasm_data
*disdata
,
1789 char *outbuffer_start
,
1790 bfd_boolean with_reg_prefix
)
1792 char *outbuffer
= outbuffer_start
;
1794 if (with_reg_prefix
)
1795 *outbuffer
++ = REGISTER_PREFIX_CHAR
;
1800 /* For v32, there is no context in which we output PC. */
1801 if (disdata
->distype
== cris_dis_v32
)
1802 strcpy (outbuffer
, "acr");
1804 strcpy (outbuffer
, "pc");
1808 strcpy (outbuffer
, "sp");
1812 sprintf (outbuffer
, "r%d", regno
);
1816 return outbuffer_start
+ strlen (outbuffer_start
);
1819 /* Format the name of a support register into outbuffer. */
1822 format_sup_reg (unsigned int regno
,
1823 char *outbuffer_start
,
1824 bfd_boolean with_reg_prefix
)
1826 char *outbuffer
= outbuffer_start
;
1829 if (with_reg_prefix
)
1830 *outbuffer
++ = REGISTER_PREFIX_CHAR
;
1832 for (i
= 0; cris_support_regs
[i
].name
!= NULL
; i
++)
1833 if (cris_support_regs
[i
].number
== regno
)
1835 sprintf (outbuffer
, "%s", cris_support_regs
[i
].name
);
1836 return outbuffer_start
+ strlen (outbuffer_start
);
1839 /* There's supposed to be register names covering all numbers, though
1840 some may be generic names. */
1841 sprintf (outbuffer
, "format_sup_reg-BUG");
1842 return outbuffer_start
+ strlen (outbuffer_start
);
1845 /* Return the length of an instruction. */
1848 bytes_to_skip (unsigned int insn
,
1849 const struct cris_opcode
*matchedp
,
1850 enum cris_disass_family distype
,
1851 const struct cris_opcode
*prefix_matchedp
)
1853 /* Each insn is a word plus "immediate" operands. */
1854 unsigned to_skip
= 2;
1855 const char *template = matchedp
->args
;
1858 for (s
= template; *s
; s
++)
1859 if ((*s
== 's' || *s
== 'N' || *s
== 'Y')
1860 && (insn
& 0x400) && (insn
& 15) == 15
1861 && prefix_matchedp
== NULL
)
1863 /* Immediate via [pc+], so we have to check the size of the
1865 int mode_size
= 1 << ((insn
>> 4) & (*template == 'z' ? 1 : 3));
1867 if (matchedp
->imm_oprnd_size
== SIZE_FIX_32
)
1869 else if (matchedp
->imm_oprnd_size
== SIZE_SPEC_REG
)
1871 const struct cris_spec_reg
*sregp
1872 = spec_reg_info ((insn
>> 12) & 15, distype
);
1874 /* FIXME: Improve error handling; should have been caught
1879 /* PC is incremented by two, not one, for a byte. Except on
1880 CRISv32, where constants are always DWORD-size for
1881 special registers. */
1883 distype
== cris_dis_v32
? 4 : (sregp
->reg_size
+ 1) & ~1;
1886 to_skip
+= (mode_size
+ 1) & ~1;
1896 /* Print condition code flags. */
1899 print_flags (struct cris_disasm_data
*disdata
, unsigned int insn
, char *cp
)
1901 /* Use the v8 (Etrax 100) flag definitions for disassembly.
1902 The differences with v0 (Etrax 1..4) vs. Svinto are:
1905 FIXME: Emit v0..v3 flag names somehow. */
1906 static const char v8_fnames
[] = "cvznxibm";
1907 static const char v32_fnames
[] = "cvznxiup";
1909 = disdata
->distype
== cris_dis_v32
? v32_fnames
: v8_fnames
;
1911 unsigned char flagbits
= (((insn
>> 8) & 0xf0) | (insn
& 15));
1914 for (i
= 0; i
< 8; i
++)
1915 if (flagbits
& (1 << i
))
1921 /* Print out an insn with its operands, and update the info->insn_type
1922 fields. The prefix_opcodep and the rest hold a prefix insn that is
1923 supposed to be output as an address mode. */
1926 print_with_operands (const struct cris_opcode
*opcodep
,
1928 unsigned char *buffer
,
1930 disassemble_info
*info
,
1931 /* If a prefix insn was before this insn (and is supposed
1932 to be output as an address), here is a description of
1934 const struct cris_opcode
*prefix_opcodep
,
1935 unsigned int prefix_insn
,
1936 unsigned char *prefix_buffer
,
1937 bfd_boolean with_reg_prefix
)
1939 /* Get a buffer of somewhat reasonable size where we store
1940 intermediate parts of the insn. */
1941 char temp
[sizeof (".d [$r13=$r12-2147483648],$r10") * 2];
1943 static const char mode_char
[] = "bwd?";
1946 struct cris_disasm_data
*disdata
1947 = (struct cris_disasm_data
*) info
->private_data
;
1949 /* Print out the name first thing we do. */
1950 (*info
->fprintf_func
) (info
->stream
, "%s", opcodep
->name
);
1955 /* Ignore any prefix indicator. */
1959 if (*s
== 'm' || *s
== 'M' || *s
== 'z')
1963 /* Get the size-letter. */
1965 ? (insn
& 0x8000 ? 'd'
1966 : insn
& 0x4000 ? 'w' : 'b')
1967 : mode_char
[(insn
>> 4) & (*s
== 'z' ? 1 : 3)];
1969 /* Ignore the size and the space character that follows. */
1973 /* Add a space if this isn't a long-branch, because for those will add
1974 the condition part of the name later. */
1975 if (opcodep
->match
!= (BRANCH_PC_LOW
+ BRANCH_INCR_HIGH
* 256))
1978 /* Fill in the insn-type if deducible from the name (and there's no
1980 if (opcodep
->name
[0] == 'j')
1982 if (CONST_STRNEQ (opcodep
->name
, "jsr"))
1983 /* It's "jsr" or "jsrc". */
1984 info
->insn_type
= dis_jsr
;
1986 /* Any other jump-type insn is considered a branch. */
1987 info
->insn_type
= dis_branch
;
1990 /* We might know some more fields right now. */
1991 info
->branch_delay_insns
= opcodep
->delayed
;
1993 /* Handle operands. */
1999 tp
= format_sup_reg ((insn
>> 12) & 15, tp
, with_reg_prefix
);
2003 if (with_reg_prefix
)
2004 *tp
++ = REGISTER_PREFIX_CHAR
;
2017 /* Ignore at this point; used at earlier stages to avoid
2018 recognition if there's a prefix at something that in other
2019 ways looks like a "pop". */
2023 /* Ignore. This is an optional ".d " on the large one of
2028 /* This was the prefix that made this a "push". We've already
2029 handled it by recognizing it, so signal that the prefix is
2030 handled by setting it to NULL. */
2031 prefix_opcodep
= NULL
;
2036 tp
= format_reg (disdata
, insn
& 15, tp
, with_reg_prefix
);
2040 tp
= format_reg (disdata
, (insn
>> 12) & 15, tp
, with_reg_prefix
);
2045 /* Like N but pc-relative to the start of the insn. */
2046 unsigned long number
2047 = (buffer
[2] + buffer
[3] * 256 + buffer
[4] * 65536
2048 + buffer
[5] * 0x1000000 + addr
);
2050 /* Finish off and output previous formatted bytes. */
2053 (*info
->fprintf_func
) (info
->stream
, "%s", temp
);
2056 (*info
->print_address_func
) ((bfd_vma
) number
, info
);
2062 /* Like n but the offset is bits <3:0> in the instruction. */
2063 unsigned long number
= (buffer
[0] & 0xf) * 2 + addr
;
2065 /* Finish off and output previous formatted bytes. */
2068 (*info
->fprintf_func
) (info
->stream
, "%s", temp
);
2071 (*info
->print_address_func
) ((bfd_vma
) number
, info
);
2080 /* Any "normal" memory operand. */
2081 if ((insn
& 0x400) && (insn
& 15) == 15 && prefix_opcodep
== NULL
)
2083 /* We're looking at [pc+], i.e. we need to output an immediate
2084 number, where the size can depend on different things. */
2087 = ((*cs
== 'z' && (insn
& 0x20))
2088 || opcodep
->match
== BDAP_QUICK_OPCODE
);
2091 if (opcodep
->imm_oprnd_size
== SIZE_FIX_32
)
2093 else if (opcodep
->imm_oprnd_size
== SIZE_SPEC_REG
)
2095 const struct cris_spec_reg
*sregp
2096 = spec_reg_info ((insn
>> 12) & 15, disdata
->distype
);
2098 /* A NULL return should have been as a non-match earlier,
2099 so catch it as an internal error in the error-case
2102 /* Whatever non-valid size. */
2105 /* PC is always incremented by a multiple of two.
2106 For CRISv32, immediates are always 4 bytes for
2107 special registers. */
2108 nbytes
= disdata
->distype
== cris_dis_v32
2109 ? 4 : (sregp
->reg_size
+ 1) & ~1;
2113 int mode_size
= 1 << ((insn
>> 4) & (*cs
== 'z' ? 1 : 3));
2125 if (signedp
&& number
> 127)
2130 number
= buffer
[2] + buffer
[3] * 256;
2131 if (signedp
&& number
> 32767)
2137 = buffer
[2] + buffer
[3] * 256 + buffer
[4] * 65536
2138 + buffer
[5] * 0x1000000;
2147 if ((*cs
== 'z' && (insn
& 0x20))
2148 || (opcodep
->match
== BDAP_QUICK_OPCODE
2149 && (nbytes
<= 2 || buffer
[1 + nbytes
] == 0)))
2150 tp
= format_dec (number
, tp
, signedp
);
2153 unsigned int highbyte
= (number
>> 24) & 0xff;
2155 /* Either output this as an address or as a number. If it's
2156 a dword with the same high-byte as the address of the
2157 insn, assume it's an address, and also if it's a non-zero
2158 non-0xff high-byte. If this is a jsr or a jump, then
2159 it's definitely an address. */
2161 && (highbyte
== ((addr
>> 24) & 0xff)
2162 || (highbyte
!= 0 && highbyte
!= 0xff)
2163 || info
->insn_type
== dis_branch
2164 || info
->insn_type
== dis_jsr
))
2166 /* Finish off and output previous formatted bytes. */
2170 (*info
->fprintf_func
) (info
->stream
, "%s", temp
);
2172 (*info
->print_address_func
) ((bfd_vma
) number
, info
);
2174 info
->target
= number
;
2177 tp
= format_hex (number
, tp
, disdata
);
2182 /* Not an immediate number. Then this is a (possibly
2183 prefixed) memory operand. */
2184 if (info
->insn_type
!= dis_nonbranch
)
2188 & (opcodep
->args
[0] == 'z' ? 1 : 3));
2190 info
->insn_type
= dis_dref
;
2191 info
->flags
|= CRIS_DIS_FLAG_MEMREF
;
2193 if (opcodep
->imm_oprnd_size
== SIZE_FIX_32
)
2195 else if (opcodep
->imm_oprnd_size
== SIZE_SPEC_REG
)
2197 const struct cris_spec_reg
*sregp
2198 = spec_reg_info ((insn
>> 12) & 15, disdata
->distype
);
2200 /* FIXME: Improve error handling; should have been caught
2205 size
= sregp
->reg_size
;
2210 info
->data_size
= size
;
2216 /* We don't match dip with a postincremented field
2217 as a side-effect address mode. */
2218 && ((insn
& 0x400) == 0
2219 || prefix_opcodep
->match
!= DIP_OPCODE
))
2223 tp
= format_reg (disdata
, insn
& 15, tp
, with_reg_prefix
);
2228 /* We mainly ignore the prefix format string when the
2229 address-mode syntax is output. */
2230 switch (prefix_opcodep
->match
)
2233 /* It's [r], [r+] or [pc+]. */
2234 if ((prefix_insn
& 0x400) && (prefix_insn
& 15) == 15)
2236 /* It's [pc+]. This cannot possibly be anything
2238 unsigned long number
2239 = prefix_buffer
[2] + prefix_buffer
[3] * 256
2240 + prefix_buffer
[4] * 65536
2241 + prefix_buffer
[5] * 0x1000000;
2243 info
->target
= (bfd_vma
) number
;
2245 /* Finish off and output previous formatted
2250 (*info
->fprintf_func
) (info
->stream
, "%s", temp
);
2252 (*info
->print_address_func
) ((bfd_vma
) number
, info
);
2256 /* For a memref in an address, we use target2.
2257 In this case, target is zero. */
2259 |= (CRIS_DIS_FLAG_MEM_TARGET2_IS_REG
2260 | CRIS_DIS_FLAG_MEM_TARGET2_MEM
);
2262 info
->target2
= prefix_insn
& 15;
2265 tp
= format_reg (disdata
, prefix_insn
& 15, tp
,
2267 if (prefix_insn
& 0x400)
2273 case BDAP_QUICK_OPCODE
:
2277 number
= prefix_buffer
[0];
2281 /* Output "reg+num" or, if num < 0, "reg-num". */
2282 tp
= format_reg (disdata
, (prefix_insn
>> 12) & 15, tp
,
2286 tp
= format_dec (number
, tp
, 1);
2288 info
->flags
|= CRIS_DIS_FLAG_MEM_TARGET_IS_REG
;
2289 info
->target
= (prefix_insn
>> 12) & 15;
2290 info
->target2
= (bfd_vma
) number
;
2295 /* Output "r+R.m". */
2296 tp
= format_reg (disdata
, prefix_insn
& 15, tp
,
2299 tp
= format_reg (disdata
, (prefix_insn
>> 12) & 15, tp
,
2302 *tp
++ = mode_char
[(prefix_insn
>> 4) & 3];
2305 |= (CRIS_DIS_FLAG_MEM_TARGET2_IS_REG
2306 | CRIS_DIS_FLAG_MEM_TARGET_IS_REG
2308 | ((prefix_insn
& 0x8000)
2309 ? CRIS_DIS_FLAG_MEM_TARGET2_MULT4
2310 : ((prefix_insn
& 0x8000)
2311 ? CRIS_DIS_FLAG_MEM_TARGET2_MULT2
: 0)));
2313 /* Is it the casejump? It's a "adds.w [pc+r%d.w],pc". */
2314 if (insn
== 0xf83f && (prefix_insn
& ~0xf000) == 0x55f)
2315 /* Then start interpreting data as offsets. */
2316 case_offset_counter
= no_of_case_offsets
;
2319 case BDAP_INDIR_OPCODE
:
2320 /* Output "r+s.m", or, if "s" is [pc+], "r+s" or
2322 tp
= format_reg (disdata
, (prefix_insn
>> 12) & 15, tp
,
2325 if ((prefix_insn
& 0x400) && (prefix_insn
& 15) == 15)
2328 unsigned int nbytes
;
2330 /* It's a value. Get its size. */
2331 int mode_size
= 1 << ((prefix_insn
>> 4) & 3);
2341 number
= prefix_buffer
[2];
2347 number
= prefix_buffer
[2] + prefix_buffer
[3] * 256;
2354 = prefix_buffer
[2] + prefix_buffer
[3] * 256
2355 + prefix_buffer
[4] * 65536
2356 + prefix_buffer
[5] * 0x1000000;
2365 info
->flags
|= CRIS_DIS_FLAG_MEM_TARGET_IS_REG
;
2366 info
->target2
= (bfd_vma
) number
;
2368 /* If the size is dword, then assume it's an
2372 /* Finish off and output previous formatted
2377 (*info
->fprintf_func
) (info
->stream
, "%s", temp
);
2379 (*info
->print_address_func
) ((bfd_vma
) number
, info
);
2385 tp
= format_dec (number
, tp
, 1);
2390 /* Output "r+[R].m" or "r+[R+].m". */
2393 tp
= format_reg (disdata
, prefix_insn
& 15, tp
,
2395 if (prefix_insn
& 0x400)
2399 *tp
++ = mode_char
[(prefix_insn
>> 4) & 3];
2402 |= (CRIS_DIS_FLAG_MEM_TARGET2_IS_REG
2403 | CRIS_DIS_FLAG_MEM_TARGET2_MEM
2404 | CRIS_DIS_FLAG_MEM_TARGET_IS_REG
2406 | (((prefix_insn
>> 4) == 2)
2408 : (((prefix_insn
>> 4) & 3) == 1
2409 ? CRIS_DIS_FLAG_MEM_TARGET2_MEM_WORD
2410 : CRIS_DIS_FLAG_MEM_TARGET2_MEM_BYTE
)));
2415 (*info
->fprintf_func
) (info
->stream
, "?prefix-bug");
2418 /* To mark that the prefix is used, reset it. */
2419 prefix_opcodep
= NULL
;
2423 tp
= format_reg (disdata
, insn
& 15, tp
, with_reg_prefix
);
2425 info
->flags
|= CRIS_DIS_FLAG_MEM_TARGET_IS_REG
;
2426 info
->target
= insn
& 15;
2436 tp
= format_reg (disdata
, (insn
>> 12) & 15, tp
, with_reg_prefix
);
2438 *tp
++ = mode_char
[(insn
>> 4) & 3];
2442 tp
= format_dec (insn
& 63, tp
, 0);
2447 int where
= buffer
[2] + buffer
[3] * 256;
2452 where
+= addr
+ ((disdata
->distype
== cris_dis_v32
) ? 0 : 4);
2454 if (insn
== BA_PC_INCR_OPCODE
)
2455 info
->insn_type
= dis_branch
;
2457 info
->insn_type
= dis_condbranch
;
2459 info
->target
= (bfd_vma
) where
;
2463 (*info
->fprintf_func
) (info
->stream
, "%s%s ",
2464 temp
, cris_cc_strings
[insn
>> 12]);
2466 (*info
->print_address_func
) ((bfd_vma
) where
, info
);
2471 tp
= format_dec (insn
& 31, tp
, 0);
2475 tp
= format_dec (insn
& 15, tp
, 0);
2480 long offset
= insn
& 0xfe;
2486 if (opcodep
->match
== BA_QUICK_OPCODE
)
2487 info
->insn_type
= dis_branch
;
2489 info
->insn_type
= dis_condbranch
;
2491 target
= addr
+ ((disdata
->distype
== cris_dis_v32
) ? 0 : 2) + offset
;
2492 info
->target
= target
;
2495 (*info
->fprintf_func
) (info
->stream
, "%s", temp
);
2496 (*info
->print_address_func
) (target
, info
);
2503 long number
= buffer
[0];
2506 number
= number
- 256;
2508 tp
= format_dec (number
, tp
, 1);
2510 tp
= format_reg (disdata
, (insn
>> 12) & 15, tp
, with_reg_prefix
);
2515 tp
= print_flags (disdata
, insn
, tp
);
2519 tp
= format_dec ((insn
& 32) ? (insn
& 31) | ~31L : insn
& 31, tp
, 1);
2524 const struct cris_spec_reg
*sregp
2525 = spec_reg_info ((insn
>> 12) & 15, disdata
->distype
);
2527 if (sregp
->name
== NULL
)
2528 /* Should have been caught as a non-match eariler. */
2532 if (with_reg_prefix
)
2533 *tp
++ = REGISTER_PREFIX_CHAR
;
2534 strcpy (tp
, sregp
->name
);
2549 (*info
->fprintf_func
) (info
->stream
, " (OOPS unused prefix \"%s: %s\")",
2550 prefix_opcodep
->name
, prefix_opcodep
->args
);
2552 (*info
->fprintf_func
) (info
->stream
, "%s", temp
);
2554 /* Get info for matching case-tables, if we don't have any active.
2555 We assume that the last constant seen is used; either in the insn
2556 itself or in a "move.d const,rN, sub.d rN,rM"-like sequence. */
2557 if (TRACE_CASE
&& case_offset_counter
== 0)
2559 if (CONST_STRNEQ (opcodep
->name
, "sub"))
2560 case_offset
= last_immediate
;
2562 /* It could also be an "add", if there are negative case-values. */
2563 else if (CONST_STRNEQ (opcodep
->name
, "add"))
2564 /* The first case is the negated operand to the add. */
2565 case_offset
= -last_immediate
;
2567 /* A bound insn will tell us the number of cases. */
2568 else if (CONST_STRNEQ (opcodep
->name
, "bound"))
2569 no_of_case_offsets
= last_immediate
+ 1;
2571 /* A jump or jsr or branch breaks the chain of insns for a
2572 case-table, so assume default first-case again. */
2573 else if (info
->insn_type
== dis_jsr
2574 || info
->insn_type
== dis_branch
2575 || info
->insn_type
== dis_condbranch
)
2581 /* Print the CRIS instruction at address memaddr on stream. Returns
2582 length of the instruction, in bytes. Prefix register names with `$' if
2586 print_insn_cris_generic (bfd_vma memaddr
,
2587 disassemble_info
*info
,
2588 bfd_boolean with_reg_prefix
)
2592 const struct cris_opcode
*matchedp
;
2594 struct cris_disasm_data
*disdata
2595 = (struct cris_disasm_data
*) info
->private_data
;
2597 /* No instruction will be disassembled as longer than this number of
2598 bytes; stacked prefixes will not be expanded. */
2599 unsigned char buffer
[MAX_BYTES_PER_CRIS_INSN
];
2600 unsigned char *bufp
;
2604 /* There will be an "out of range" error after the last instruction.
2605 Reading pairs of bytes in decreasing number, we hope that we will get
2606 at least the amount that we will consume.
2608 If we can't get any data, or we do not get enough data, we print
2609 the error message. */
2611 nbytes
= info
->buffer_length
;
2612 if (nbytes
> MAX_BYTES_PER_CRIS_INSN
)
2613 nbytes
= MAX_BYTES_PER_CRIS_INSN
;
2614 status
= (*info
->read_memory_func
) (memaddr
, buffer
, nbytes
, info
);
2616 /* If we did not get all we asked for, then clear the rest.
2617 Hopefully this makes a reproducible result in case of errors. */
2618 if (nbytes
!= MAX_BYTES_PER_CRIS_INSN
)
2619 memset (buffer
+ nbytes
, 0, MAX_BYTES_PER_CRIS_INSN
- nbytes
);
2624 /* Set some defaults for the insn info. */
2625 info
->insn_info_valid
= 1;
2626 info
->branch_delay_insns
= 0;
2627 info
->data_size
= 0;
2628 info
->insn_type
= dis_nonbranch
;
2633 /* If we got any data, disassemble it. */
2638 insn
= bufp
[0] + bufp
[1] * 256;
2640 /* If we're in a case-table, don't disassemble the offsets. */
2641 if (TRACE_CASE
&& case_offset_counter
!= 0)
2643 info
->insn_type
= dis_noninsn
;
2646 /* If to print data as offsets, then shortcut here. */
2647 (*info
->fprintf_func
) (info
->stream
, "case %ld%s: -> ",
2648 case_offset
+ no_of_case_offsets
2649 - case_offset_counter
,
2650 case_offset_counter
== 1 ? "/default" :
2653 (*info
->print_address_func
) ((bfd_vma
)
2656 - (no_of_case_offsets
2657 - case_offset_counter
)
2659 case_offset_counter
--;
2661 /* The default case start (without a "sub" or "add") must be
2663 if (case_offset_counter
== 0)
2668 /* We're often called to disassemble zeroes. While this is a
2669 valid "bcc .+2" insn, it is also useless enough and enough
2670 of a nuiscance that we will just output "bcc .+2" for it
2671 and signal it as a noninsn. */
2672 (*info
->fprintf_func
) (info
->stream
,
2673 disdata
->distype
== cris_dis_v32
2674 ? "bcc ." : "bcc .+2");
2675 info
->insn_type
= dis_noninsn
;
2680 const struct cris_opcode
*prefix_opcodep
= NULL
;
2681 unsigned char *prefix_buffer
= bufp
;
2682 unsigned int prefix_insn
= insn
;
2683 int prefix_size
= 0;
2685 matchedp
= get_opcode_entry (insn
, NO_CRIS_PREFIX
, disdata
);
2687 /* Check if we're supposed to write out prefixes as address
2688 modes and if this was a prefix. */
2689 if (matchedp
!= NULL
&& PARSE_PREFIX
&& matchedp
->args
[0] == 'p')
2691 /* If it's a prefix, put it into the prefix vars and get the
2693 prefix_size
= bytes_to_skip (prefix_insn
, matchedp
,
2694 disdata
->distype
, NULL
);
2695 prefix_opcodep
= matchedp
;
2697 insn
= bufp
[prefix_size
] + bufp
[prefix_size
+ 1] * 256;
2698 matchedp
= get_opcode_entry (insn
, prefix_insn
, disdata
);
2700 if (matchedp
!= NULL
)
2702 addr
+= prefix_size
;
2703 bufp
+= prefix_size
;
2704 advance
+= prefix_size
;
2708 /* The "main" insn wasn't valid, at least not when
2709 prefixed. Put back things enough to output the
2710 prefix insn only, as a normal insn. */
2711 matchedp
= prefix_opcodep
;
2713 prefix_opcodep
= NULL
;
2717 if (matchedp
== NULL
)
2719 (*info
->fprintf_func
) (info
->stream
, "??0x%x", insn
);
2722 info
->insn_type
= dis_noninsn
;
2727 += bytes_to_skip (insn
, matchedp
, disdata
->distype
,
2730 /* The info_type and assorted fields will be set according
2732 print_with_operands (matchedp
, insn
, bufp
, addr
, info
,
2733 prefix_opcodep
, prefix_insn
,
2734 prefix_buffer
, with_reg_prefix
);
2739 info
->insn_type
= dis_noninsn
;
2741 /* If we read less than MAX_BYTES_PER_CRIS_INSN, i.e. we got an error
2742 status when reading that much, and the insn decoding indicated a
2743 length exceeding what we read, there is an error. */
2744 if (status
!= 0 && (nbytes
== 0 || advance
> nbytes
))
2746 (*info
->memory_error_func
) (status
, memaddr
, info
);
2750 /* Max supported insn size with one folded prefix insn. */
2751 info
->bytes_per_line
= MAX_BYTES_PER_CRIS_INSN
;
2753 /* I would like to set this to a fixed value larger than the actual
2754 number of bytes to print in order to avoid spaces between bytes,
2755 but objdump.c (2.9.1) does not like that, so we print 16-bit
2756 chunks, which is the next choice. */
2757 info
->bytes_per_chunk
= 2;
2759 /* Printing bytes in order of increasing addresses makes sense,
2760 especially on a little-endian target.
2761 This is completely the opposite of what you think; setting this to
2762 BFD_ENDIAN_LITTLE will print bytes in order N..0 rather than the 0..N
2764 info
->display_endian
= BFD_ENDIAN_BIG
;
2769 /* Disassemble, prefixing register names with `$'. CRIS v0..v10. */
2771 print_insn_cris_with_register_prefix (bfd_vma vma
,
2772 disassemble_info
*info
)
2774 if (info
->private_data
== NULL
2775 && !cris_parse_disassembler_options (info
, cris_dis_v0_v10
))
2777 return print_insn_cris_generic (vma
, info
, true);
2779 /* Disassemble, prefixing register names with `$'. CRIS v32. */
2782 print_insn_crisv32_with_register_prefix (bfd_vma vma
,
2783 disassemble_info
*info
)
2785 if (info
->private_data
== NULL
2786 && !cris_parse_disassembler_options (info
, cris_dis_v32
))
2788 return print_insn_cris_generic (vma
, info
, true);
2792 /* Disassemble, prefixing register names with `$'.
2793 Common v10 and v32 subset. */
2796 print_insn_crisv10_v32_with_register_prefix (bfd_vma vma
,
2797 disassemble_info
*info
)
2799 if (info
->private_data
== NULL
2800 && !cris_parse_disassembler_options (info
, cris_dis_common_v10_v32
))
2802 return print_insn_cris_generic (vma
, info
, true);
2805 /* Disassemble, no prefixes on register names. CRIS v0..v10. */
2808 print_insn_cris_without_register_prefix (bfd_vma vma
,
2809 disassemble_info
*info
)
2811 if (info
->private_data
== NULL
2812 && !cris_parse_disassembler_options (info
, cris_dis_v0_v10
))
2814 return print_insn_cris_generic (vma
, info
, false);
2817 /* Disassemble, no prefixes on register names. CRIS v32. */
2820 print_insn_crisv32_without_register_prefix (bfd_vma vma
,
2821 disassemble_info
*info
)
2823 if (info
->private_data
== NULL
2824 && !cris_parse_disassembler_options (info
, cris_dis_v32
))
2826 return print_insn_cris_generic (vma
, info
, false);
2829 /* Disassemble, no prefixes on register names.
2830 Common v10 and v32 subset. */
2833 print_insn_crisv10_v32_without_register_prefix (bfd_vma vma
,
2834 disassemble_info
*info
)
2836 if (info
->private_data
== NULL
2837 && !cris_parse_disassembler_options (info
, cris_dis_common_v10_v32
))
2839 return print_insn_cris_generic (vma
, info
, false);
2844 print_insn_crisv10 (bfd_vma vma
,
2845 disassemble_info
*info
)
2847 return print_insn_cris_with_register_prefix(vma
, info
);
2851 print_insn_crisv32 (bfd_vma vma
,
2852 disassemble_info
*info
)
2854 return print_insn_crisv32_with_register_prefix(vma
, info
);
2857 /* Return a disassembler-function that prints registers with a `$' prefix,
2858 or one that prints registers without a prefix.
2859 FIXME: We should improve the solution to avoid the multitude of
2860 functions seen above. */
2863 cris_get_disassembler (bfd
*abfd
)
2865 /* If there's no bfd in sight, we return what is valid as input in all
2866 contexts if fed back to the assembler: disassembly *with* register
2867 prefix. Unfortunately this will be totally wrong for v32. */
2869 return print_insn_cris_with_register_prefix
;
2871 if (bfd_get_symbol_leading_char (abfd
) == 0)
2873 if (bfd_get_mach (abfd
) == bfd_mach_cris_v32
)
2874 return print_insn_crisv32_with_register_prefix
;
2875 if (bfd_get_mach (abfd
) == bfd_mach_cris_v10_v32
)
2876 return print_insn_crisv10_v32_with_register_prefix
;
2878 /* We default to v10. This may be specifically specified in the
2879 bfd mach, but is also the default setting. */
2880 return print_insn_cris_with_register_prefix
;
2883 if (bfd_get_mach (abfd
) == bfd_mach_cris_v32
)
2884 return print_insn_crisv32_without_register_prefix
;
2885 if (bfd_get_mach (abfd
) == bfd_mach_cris_v10_v32
)
2886 return print_insn_crisv10_v32_without_register_prefix
;
2887 return print_insn_cris_without_register_prefix
;
2891 eval: (c-set-style "gnu")