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, write to the Free Software
20 Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
21 MA 02110-1301, USA. */
25 #include "target-cris/opcode-cris.h"
26 //#include "libiberty.h"
31 #define CONST_STRNEQ(STR1,STR2) (strncmp ((STR1), (STR2), sizeof (STR2) - 1) == 0)
33 /* cris-opc.c -- Table of opcodes for the CRIS processor.
34 Copyright 2000, 2001, 2004 Free Software Foundation, Inc.
35 Contributed by Axis Communications AB, Lund, Sweden.
36 Originally written for GAS 1.38.1 by Mikael Asker.
37 Reorganized by Hans-Peter Nilsson.
39 This file is part of GAS, GDB and the GNU binutils.
41 GAS, GDB, and GNU binutils is free software; you can redistribute it
42 and/or modify it under the terms of the GNU General Public License as
43 published by the Free Software Foundation; either version 2, or (at your
44 option) any later version.
46 GAS, GDB, and GNU binutils are distributed in the hope that they will be
47 useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
48 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
49 GNU General Public License for more details.
51 You should have received a copy of the GNU General Public License
52 along with this program; if not, write to the Free Software
53 Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */
59 /* This table isn't used for CRISv32 and the size of immediate operands. */
60 const struct cris_spec_reg
63 {"bz", 0, 1, cris_ver_v32p
, NULL
},
64 {"p0", 0, 1, 0, NULL
},
65 {"vr", 1, 1, 0, NULL
},
66 {"p1", 1, 1, 0, NULL
},
67 {"pid", 2, 1, cris_ver_v32p
, NULL
},
68 {"p2", 2, 1, cris_ver_v32p
, NULL
},
69 {"p2", 2, 1, cris_ver_warning
, NULL
},
70 {"srs", 3, 1, cris_ver_v32p
, NULL
},
71 {"p3", 3, 1, cris_ver_v32p
, NULL
},
72 {"p3", 3, 1, cris_ver_warning
, NULL
},
73 {"wz", 4, 2, cris_ver_v32p
, NULL
},
74 {"p4", 4, 2, 0, NULL
},
75 {"ccr", 5, 2, cris_ver_v0_10
, NULL
},
76 {"exs", 5, 4, cris_ver_v32p
, NULL
},
77 {"p5", 5, 2, cris_ver_v0_10
, NULL
},
78 {"p5", 5, 4, cris_ver_v32p
, NULL
},
79 {"dcr0",6, 2, cris_ver_v0_3
, NULL
},
80 {"eda", 6, 4, cris_ver_v32p
, NULL
},
81 {"p6", 6, 2, cris_ver_v0_3
, NULL
},
82 {"p6", 6, 4, cris_ver_v32p
, NULL
},
83 {"dcr1/mof", 7, 4, cris_ver_v10p
,
84 "Register `dcr1/mof' with ambiguous size specified. Guessing 4 bytes"},
85 {"dcr1/mof", 7, 2, cris_ver_v0_3
,
86 "Register `dcr1/mof' with ambiguous size specified. Guessing 2 bytes"},
87 {"mof", 7, 4, cris_ver_v10p
, NULL
},
88 {"dcr1",7, 2, cris_ver_v0_3
, NULL
},
89 {"p7", 7, 4, cris_ver_v10p
, NULL
},
90 {"p7", 7, 2, cris_ver_v0_3
, NULL
},
91 {"dz", 8, 4, cris_ver_v32p
, NULL
},
92 {"p8", 8, 4, 0, NULL
},
93 {"ibr", 9, 4, cris_ver_v0_10
, NULL
},
94 {"ebp", 9, 4, cris_ver_v32p
, NULL
},
95 {"p9", 9, 4, 0, NULL
},
96 {"irp", 10, 4, cris_ver_v0_10
, NULL
},
97 {"erp", 10, 4, cris_ver_v32p
, NULL
},
98 {"p10", 10, 4, 0, NULL
},
99 {"srp", 11, 4, 0, NULL
},
100 {"p11", 11, 4, 0, NULL
},
101 /* For disassembly use only. Accept at assembly with a warning. */
102 {"bar/dtp0", 12, 4, cris_ver_warning
,
103 "Ambiguous register `bar/dtp0' specified"},
104 {"nrp", 12, 4, cris_ver_v32p
, NULL
},
105 {"bar", 12, 4, cris_ver_v8_10
, NULL
},
106 {"dtp0",12, 4, cris_ver_v0_3
, NULL
},
107 {"p12", 12, 4, 0, NULL
},
108 /* For disassembly use only. Accept at assembly with a warning. */
109 {"dccr/dtp1",13, 4, cris_ver_warning
,
110 "Ambiguous register `dccr/dtp1' specified"},
111 {"ccs", 13, 4, cris_ver_v32p
, NULL
},
112 {"dccr",13, 4, cris_ver_v8_10
, NULL
},
113 {"dtp1",13, 4, cris_ver_v0_3
, NULL
},
114 {"p13", 13, 4, 0, NULL
},
115 {"brp", 14, 4, cris_ver_v3_10
, NULL
},
116 {"usp", 14, 4, cris_ver_v32p
, NULL
},
117 {"p14", 14, 4, cris_ver_v3p
, NULL
},
118 {"usp", 15, 4, cris_ver_v10
, NULL
},
119 {"spc", 15, 4, cris_ver_v32p
, NULL
},
120 {"p15", 15, 4, cris_ver_v10p
, NULL
},
121 {NULL
, 0, 0, cris_ver_version_all
, NULL
}
124 /* Add version specifiers to this table when necessary.
125 The (now) regular coding of register names suggests a simpler
127 const struct cris_support_reg cris_support_regs
[] =
148 /* All CRIS opcodes are 16 bits.
150 - The match component is a mask saying which bits must match a
151 particular opcode in order for an instruction to be an instance
154 - The args component is a string containing characters symbolically
155 matching the operands of an instruction. Used for both assembly
158 Operand-matching characters:
161 A The string "ACR" (case-insensitive).
162 B Not really an operand. It causes a "BDAP -size,SP" prefix to be
163 output for the PUSH alias-instructions and recognizes a push-
164 prefix at disassembly. This letter isn't recognized for v32.
165 Must be followed by a R or P letter.
166 ! Non-match pattern, will not match if there's a prefix insn.
167 b Non-matching operand, used for branches with 16-bit
168 displacement. Only recognized by the disassembler.
169 c 5-bit unsigned immediate in bits <4:0>.
170 C 4-bit unsigned immediate in bits <3:0>.
171 d At assembly, optionally (as in put other cases before this one)
172 ".d" or ".D" at the start of the operands, followed by one space
173 character. At disassembly, nothing.
174 D General register in bits <15:12> and <3:0>.
175 f List of flags in bits <15:12> and <3:0>.
176 i 6-bit signed immediate in bits <5:0>.
177 I 6-bit unsigned immediate in bits <5:0>.
178 M Size modifier (B, W or D) for CLEAR instructions.
179 m Size modifier (B, W or D) in bits <5:4>
180 N A 32-bit dword, like in the difference between s and y.
181 This has no effect on bits in the opcode. Can also be expressed
183 n As N, but PC-relative (to the start of the instruction).
184 o [-128..127] word offset in bits <7:1> and <0>. Used by 8-bit
186 O [-128..127] offset in bits <7:0>. Also matches a comma and a
187 general register after the expression, in bits <15:12>. Used
188 only for the BDAP prefix insn (in v32 the ADDOQ insn; same opcode).
189 P Special register in bits <15:12>.
190 p Indicates that the insn is a prefix insn. Must be first
192 Q As O, but don't relax; force an 8-bit offset.
193 R General register in bits <15:12>.
194 r General register in bits <3:0>.
195 S Source operand in bit <10> and a prefix; a 3-operand prefix
197 s Source operand in bits <10> and <3:0>, optionally with a
198 side-effect prefix, except [pc] (the name, not R15 as in ACR)
199 isn't allowed for v32 and higher.
200 T Support register in bits <15:12>.
201 u 4-bit (PC-relative) unsigned immediate word offset in bits <3:0>.
202 U Relaxes to either u or n, instruction is assumed LAPCQ or LAPC.
203 Not recognized at disassembly.
204 x Register-dot-modifier, for example "r5.w" in bits <15:12> and <5:4>.
205 y Like 's' but do not allow an integer at assembly.
206 Y The difference s-y; only an integer is allowed.
207 z Size modifier (B or W) in bit <4>. */
210 /* Please note the order of the opcodes in this table is significant.
211 The assembler requires that all instances of the same mnemonic must
212 be consecutive. If they aren't, the assembler might not recognize
213 them, or may indicate an internal error.
215 The disassembler should not normally care about the order of the
216 opcodes, but will prefer an earlier alternative if the "match-score"
217 (see cris-dis.c) is computed as equal.
219 It should not be significant for proper execution that this table is
220 in alphabetical order, but please follow that convention for an easy
223 const struct cris_opcode
226 {"abs", 0x06B0, 0x0940, "r,R", 0, SIZE_NONE
, 0,
229 {"add", 0x0600, 0x09c0, "m r,R", 0, SIZE_NONE
, 0,
230 cris_reg_mode_add_sub_cmp_and_or_move_op
},
232 {"add", 0x0A00, 0x01c0, "m s,R", 0, SIZE_FIELD
, 0,
233 cris_none_reg_mode_add_sub_cmp_and_or_move_op
},
235 {"add", 0x0A00, 0x01c0, "m S,D", 0, SIZE_NONE
,
237 cris_none_reg_mode_add_sub_cmp_and_or_move_op
},
239 {"add", 0x0a00, 0x05c0, "m S,R,r", 0, SIZE_NONE
,
241 cris_three_operand_add_sub_cmp_and_or_op
},
243 {"add", 0x0A00, 0x01c0, "m s,R", 0, SIZE_FIELD
,
245 cris_none_reg_mode_add_sub_cmp_and_or_move_op
},
247 {"addc", 0x0570, 0x0A80, "r,R", 0, SIZE_FIX_32
,
249 cris_not_implemented_op
},
251 {"addc", 0x09A0, 0x0250, "s,R", 0, SIZE_FIX_32
,
253 cris_not_implemented_op
},
255 {"addi", 0x0540, 0x0A80, "x,r,A", 0, SIZE_NONE
,
259 {"addi", 0x0500, 0x0Ac0, "x,r", 0, SIZE_NONE
, 0,
262 /* This collates after "addo", but we want to disassemble as "addoq",
264 {"addoq", 0x0100, 0x0E00, "Q,A", 0, SIZE_NONE
,
266 cris_not_implemented_op
},
268 {"addo", 0x0940, 0x0280, "m s,R,A", 0, SIZE_FIELD_SIGNED
,
270 cris_not_implemented_op
},
272 /* This must be located after the insn above, lest we misinterpret
273 "addo.b -1,r0,acr" as "addo .b-1,r0,acr". FIXME: Sounds like a
275 {"addo", 0x0100, 0x0E00, "O,A", 0, SIZE_NONE
,
277 cris_not_implemented_op
},
279 {"addq", 0x0200, 0x0Dc0, "I,R", 0, SIZE_NONE
, 0,
280 cris_quick_mode_add_sub_op
},
282 {"adds", 0x0420, 0x0Bc0, "z r,R", 0, SIZE_NONE
, 0,
283 cris_reg_mode_add_sub_cmp_and_or_move_op
},
285 /* FIXME: SIZE_FIELD_SIGNED and all necessary changes. */
286 {"adds", 0x0820, 0x03c0, "z s,R", 0, SIZE_FIELD
, 0,
287 cris_none_reg_mode_add_sub_cmp_and_or_move_op
},
289 {"adds", 0x0820, 0x03c0, "z S,D", 0, SIZE_NONE
,
291 cris_none_reg_mode_add_sub_cmp_and_or_move_op
},
293 {"adds", 0x0820, 0x07c0, "z S,R,r", 0, SIZE_NONE
,
295 cris_three_operand_add_sub_cmp_and_or_op
},
297 {"addu", 0x0400, 0x0be0, "z r,R", 0, SIZE_NONE
, 0,
298 cris_reg_mode_add_sub_cmp_and_or_move_op
},
300 /* FIXME: SIZE_FIELD_UNSIGNED and all necessary changes. */
301 {"addu", 0x0800, 0x03e0, "z s,R", 0, SIZE_FIELD
, 0,
302 cris_none_reg_mode_add_sub_cmp_and_or_move_op
},
304 {"addu", 0x0800, 0x03e0, "z S,D", 0, SIZE_NONE
,
306 cris_none_reg_mode_add_sub_cmp_and_or_move_op
},
308 {"addu", 0x0800, 0x07e0, "z S,R,r", 0, SIZE_NONE
,
310 cris_three_operand_add_sub_cmp_and_or_op
},
312 {"and", 0x0700, 0x08C0, "m r,R", 0, SIZE_NONE
, 0,
313 cris_reg_mode_add_sub_cmp_and_or_move_op
},
315 {"and", 0x0B00, 0x00C0, "m s,R", 0, SIZE_FIELD
, 0,
316 cris_none_reg_mode_add_sub_cmp_and_or_move_op
},
318 {"and", 0x0B00, 0x00C0, "m S,D", 0, SIZE_NONE
,
320 cris_none_reg_mode_add_sub_cmp_and_or_move_op
},
322 {"and", 0x0B00, 0x04C0, "m S,R,r", 0, SIZE_NONE
,
324 cris_three_operand_add_sub_cmp_and_or_op
},
326 {"andq", 0x0300, 0x0CC0, "i,R", 0, SIZE_NONE
, 0,
327 cris_quick_mode_and_cmp_move_or_op
},
329 {"asr", 0x0780, 0x0840, "m r,R", 0, SIZE_NONE
, 0,
332 {"asrq", 0x03a0, 0x0c40, "c,R", 0, SIZE_NONE
, 0,
335 {"ax", 0x15B0, 0xEA4F, "", 0, SIZE_NONE
, 0,
338 /* FIXME: Should use branch #defines. */
339 {"b", 0x0dff, 0x0200, "b", 1, SIZE_NONE
, 0,
340 cris_sixteen_bit_offset_branch_op
},
344 0x0F00+(0xF-CC_A
)*0x1000, "o", 1, SIZE_NONE
, 0,
345 cris_eight_bit_offset_branch_op
},
347 /* Needs to come after the usual "ba o", which might be relaxed to
349 {"ba", BA_DWORD_OPCODE
,
350 0xffff & (~BA_DWORD_OPCODE
), "n", 0, SIZE_FIX_32
,
352 cris_none_reg_mode_jump_op
},
354 {"bas", 0x0EBF, 0x0140, "n,P", 0, SIZE_FIX_32
,
356 cris_none_reg_mode_jump_op
},
358 {"basc", 0x0EFF, 0x0100, "n,P", 0, SIZE_FIX_32
,
360 cris_none_reg_mode_jump_op
},
363 BRANCH_QUICK_OPCODE
+CC_CC
*0x1000,
364 0x0f00+(0xF-CC_CC
)*0x1000, "o", 1, SIZE_NONE
, 0,
365 cris_eight_bit_offset_branch_op
},
368 BRANCH_QUICK_OPCODE
+CC_CS
*0x1000,
369 0x0f00+(0xF-CC_CS
)*0x1000, "o", 1, SIZE_NONE
, 0,
370 cris_eight_bit_offset_branch_op
},
373 BDAP_INDIR_OPCODE
, BDAP_INDIR_Z_BITS
, "pm s,R", 0, SIZE_FIELD_SIGNED
,
378 BDAP_QUICK_OPCODE
, BDAP_QUICK_Z_BITS
, "pO", 0, SIZE_NONE
,
380 cris_quick_mode_bdap_prefix
},
383 BRANCH_QUICK_OPCODE
+CC_EQ
*0x1000,
384 0x0f00+(0xF-CC_EQ
)*0x1000, "o", 1, SIZE_NONE
, 0,
385 cris_eight_bit_offset_branch_op
},
387 /* This is deliberately put before "bext" to trump it, even though not
388 in alphabetical order, since we don't do excluding version checks
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_EXT
*0x1000,
398 0x0f00+(0xF-CC_EXT
)*0x1000, "o", 1, SIZE_NONE
,
400 cris_eight_bit_offset_branch_op
},
403 BRANCH_QUICK_OPCODE
+CC_GE
*0x1000,
404 0x0f00+(0xF-CC_GE
)*0x1000, "o", 1, SIZE_NONE
, 0,
405 cris_eight_bit_offset_branch_op
},
408 BRANCH_QUICK_OPCODE
+CC_GT
*0x1000,
409 0x0f00+(0xF-CC_GT
)*0x1000, "o", 1, SIZE_NONE
, 0,
410 cris_eight_bit_offset_branch_op
},
413 BRANCH_QUICK_OPCODE
+CC_HI
*0x1000,
414 0x0f00+(0xF-CC_HI
)*0x1000, "o", 1, SIZE_NONE
, 0,
415 cris_eight_bit_offset_branch_op
},
418 BRANCH_QUICK_OPCODE
+CC_HS
*0x1000,
419 0x0f00+(0xF-CC_HS
)*0x1000, "o", 1, SIZE_NONE
, 0,
420 cris_eight_bit_offset_branch_op
},
422 {"biap", BIAP_OPCODE
, BIAP_Z_BITS
, "pm r,R", 0, SIZE_NONE
,
427 BRANCH_QUICK_OPCODE
+CC_LE
*0x1000,
428 0x0f00+(0xF-CC_LE
)*0x1000, "o", 1, SIZE_NONE
, 0,
429 cris_eight_bit_offset_branch_op
},
432 BRANCH_QUICK_OPCODE
+CC_LO
*0x1000,
433 0x0f00+(0xF-CC_LO
)*0x1000, "o", 1, SIZE_NONE
, 0,
434 cris_eight_bit_offset_branch_op
},
437 BRANCH_QUICK_OPCODE
+CC_LS
*0x1000,
438 0x0f00+(0xF-CC_LS
)*0x1000, "o", 1, SIZE_NONE
, 0,
439 cris_eight_bit_offset_branch_op
},
442 BRANCH_QUICK_OPCODE
+CC_LT
*0x1000,
443 0x0f00+(0xF-CC_LT
)*0x1000, "o", 1, SIZE_NONE
, 0,
444 cris_eight_bit_offset_branch_op
},
447 BRANCH_QUICK_OPCODE
+CC_MI
*0x1000,
448 0x0f00+(0xF-CC_MI
)*0x1000, "o", 1, SIZE_NONE
, 0,
449 cris_eight_bit_offset_branch_op
},
451 {"bmod", 0x0ab0, 0x0140, "s,R", 0, SIZE_FIX_32
,
453 cris_not_implemented_op
},
455 {"bmod", 0x0ab0, 0x0140, "S,D", 0, SIZE_NONE
,
457 cris_not_implemented_op
},
459 {"bmod", 0x0ab0, 0x0540, "S,R,r", 0, SIZE_NONE
,
461 cris_not_implemented_op
},
464 BRANCH_QUICK_OPCODE
+CC_NE
*0x1000,
465 0x0f00+(0xF-CC_NE
)*0x1000, "o", 1, SIZE_NONE
, 0,
466 cris_eight_bit_offset_branch_op
},
468 {"bound", 0x05c0, 0x0A00, "m r,R", 0, SIZE_NONE
, 0,
469 cris_two_operand_bound_op
},
470 /* FIXME: SIZE_FIELD_UNSIGNED and all necessary changes. */
471 {"bound", 0x09c0, 0x0200, "m s,R", 0, SIZE_FIELD
,
473 cris_two_operand_bound_op
},
474 /* FIXME: SIZE_FIELD_UNSIGNED and all necessary changes. */
475 {"bound", 0x0dcf, 0x0200, "m Y,R", 0, SIZE_FIELD
, 0,
476 cris_two_operand_bound_op
},
477 {"bound", 0x09c0, 0x0200, "m S,D", 0, SIZE_NONE
,
479 cris_two_operand_bound_op
},
480 {"bound", 0x09c0, 0x0600, "m S,R,r", 0, SIZE_NONE
,
482 cris_three_operand_bound_op
},
485 BRANCH_QUICK_OPCODE
+CC_PL
*0x1000,
486 0x0f00+(0xF-CC_PL
)*0x1000, "o", 1, SIZE_NONE
, 0,
487 cris_eight_bit_offset_branch_op
},
489 {"break", 0xe930, 0x16c0, "C", 0, SIZE_NONE
,
494 BRANCH_QUICK_OPCODE
+CC_EXT
*0x1000,
495 0x0f00+(0xF-CC_EXT
)*0x1000, "o", 1, SIZE_NONE
,
497 cris_eight_bit_offset_branch_op
},
499 {"bsr", 0xBEBF, 0x4140, "n", 0, SIZE_FIX_32
,
501 cris_none_reg_mode_jump_op
},
503 {"bsrc", 0xBEFF, 0x4100, "n", 0, SIZE_FIX_32
,
505 cris_none_reg_mode_jump_op
},
507 {"bstore", 0x0af0, 0x0100, "s,R", 0, SIZE_FIX_32
,
509 cris_not_implemented_op
},
511 {"bstore", 0x0af0, 0x0100, "S,D", 0, SIZE_NONE
,
513 cris_not_implemented_op
},
515 {"bstore", 0x0af0, 0x0500, "S,R,r", 0, SIZE_NONE
,
517 cris_not_implemented_op
},
519 {"btst", 0x04F0, 0x0B00, "r,R", 0, SIZE_NONE
, 0,
521 {"btstq", 0x0380, 0x0C60, "c,R", 0, SIZE_NONE
, 0,
525 BRANCH_QUICK_OPCODE
+CC_VC
*0x1000,
526 0x0f00+(0xF-CC_VC
)*0x1000, "o", 1, SIZE_NONE
, 0,
527 cris_eight_bit_offset_branch_op
},
530 BRANCH_QUICK_OPCODE
+CC_VS
*0x1000,
531 0x0f00+(0xF-CC_VS
)*0x1000, "o", 1, SIZE_NONE
, 0,
532 cris_eight_bit_offset_branch_op
},
534 {"clear", 0x0670, 0x3980, "M r", 0, SIZE_NONE
, 0,
535 cris_reg_mode_clear_op
},
537 {"clear", 0x0A70, 0x3180, "M y", 0, SIZE_NONE
, 0,
538 cris_none_reg_mode_clear_test_op
},
540 {"clear", 0x0A70, 0x3180, "M S", 0, SIZE_NONE
,
542 cris_none_reg_mode_clear_test_op
},
544 {"clearf", 0x05F0, 0x0A00, "f", 0, SIZE_NONE
, 0,
547 {"cmp", 0x06C0, 0x0900, "m r,R", 0, SIZE_NONE
, 0,
548 cris_reg_mode_add_sub_cmp_and_or_move_op
},
550 {"cmp", 0x0Ac0, 0x0100, "m s,R", 0, SIZE_FIELD
, 0,
551 cris_none_reg_mode_add_sub_cmp_and_or_move_op
},
553 {"cmp", 0x0Ac0, 0x0100, "m S,D", 0, SIZE_NONE
,
555 cris_none_reg_mode_add_sub_cmp_and_or_move_op
},
557 {"cmpq", 0x02C0, 0x0D00, "i,R", 0, SIZE_NONE
, 0,
558 cris_quick_mode_and_cmp_move_or_op
},
560 /* FIXME: SIZE_FIELD_SIGNED and all necessary changes. */
561 {"cmps", 0x08e0, 0x0300, "z s,R", 0, SIZE_FIELD
, 0,
562 cris_none_reg_mode_add_sub_cmp_and_or_move_op
},
564 {"cmps", 0x08e0, 0x0300, "z S,D", 0, SIZE_NONE
,
566 cris_none_reg_mode_add_sub_cmp_and_or_move_op
},
568 /* FIXME: SIZE_FIELD_UNSIGNED and all necessary changes. */
569 {"cmpu", 0x08c0, 0x0320, "z s,R" , 0, SIZE_FIELD
, 0,
570 cris_none_reg_mode_add_sub_cmp_and_or_move_op
},
572 {"cmpu", 0x08c0, 0x0320, "z S,D", 0, SIZE_NONE
,
574 cris_none_reg_mode_add_sub_cmp_and_or_move_op
},
576 {"di", 0x25F0, 0xDA0F, "", 0, SIZE_NONE
, 0,
579 {"dip", DIP_OPCODE
, DIP_Z_BITS
, "ps", 0, SIZE_FIX_32
,
583 {"div", 0x0980, 0x0640, "m R,r", 0, SIZE_FIELD
, 0,
584 cris_not_implemented_op
},
586 {"dstep", 0x06f0, 0x0900, "r,R", 0, SIZE_NONE
, 0,
587 cris_dstep_logshift_mstep_neg_not_op
},
589 {"ei", 0x25B0, 0xDA4F, "", 0, SIZE_NONE
, 0,
592 {"fidxd", 0x0ab0, 0xf540, "[r]", 0, SIZE_NONE
,
594 cris_not_implemented_op
},
596 {"fidxi", 0x0d30, 0xF2C0, "[r]", 0, SIZE_NONE
,
598 cris_not_implemented_op
},
600 {"ftagd", 0x1AB0, 0xE540, "[r]", 0, SIZE_NONE
,
602 cris_not_implemented_op
},
604 {"ftagi", 0x1D30, 0xE2C0, "[r]", 0, SIZE_NONE
,
606 cris_not_implemented_op
},
608 {"halt", 0xF930, 0x06CF, "", 0, SIZE_NONE
,
610 cris_not_implemented_op
},
612 {"jas", 0x09B0, 0x0640, "r,P", 0, SIZE_NONE
,
614 cris_reg_mode_jump_op
},
616 {"jas", 0x0DBF, 0x0240, "N,P", 0, SIZE_FIX_32
,
618 cris_reg_mode_jump_op
},
620 {"jasc", 0x0B30, 0x04C0, "r,P", 0, SIZE_NONE
,
622 cris_reg_mode_jump_op
},
624 {"jasc", 0x0F3F, 0x00C0, "N,P", 0, SIZE_FIX_32
,
626 cris_reg_mode_jump_op
},
628 {"jbrc", 0x69b0, 0x9640, "r", 0, SIZE_NONE
,
630 cris_reg_mode_jump_op
},
632 {"jbrc", 0x6930, 0x92c0, "s", 0, SIZE_FIX_32
,
634 cris_none_reg_mode_jump_op
},
636 {"jbrc", 0x6930, 0x92c0, "S", 0, SIZE_NONE
,
638 cris_none_reg_mode_jump_op
},
640 {"jir", 0xA9b0, 0x5640, "r", 0, SIZE_NONE
,
642 cris_reg_mode_jump_op
},
644 {"jir", 0xA930, 0x52c0, "s", 0, SIZE_FIX_32
,
646 cris_none_reg_mode_jump_op
},
648 {"jir", 0xA930, 0x52c0, "S", 0, SIZE_NONE
,
650 cris_none_reg_mode_jump_op
},
652 {"jirc", 0x29b0, 0xd640, "r", 0, SIZE_NONE
,
654 cris_reg_mode_jump_op
},
656 {"jirc", 0x2930, 0xd2c0, "s", 0, SIZE_FIX_32
,
658 cris_none_reg_mode_jump_op
},
660 {"jirc", 0x2930, 0xd2c0, "S", 0, SIZE_NONE
,
662 cris_none_reg_mode_jump_op
},
664 {"jsr", 0xB9b0, 0x4640, "r", 0, SIZE_NONE
, 0,
665 cris_reg_mode_jump_op
},
667 {"jsr", 0xB930, 0x42c0, "s", 0, SIZE_FIX_32
,
669 cris_none_reg_mode_jump_op
},
671 {"jsr", 0xBDBF, 0x4240, "N", 0, SIZE_FIX_32
,
673 cris_none_reg_mode_jump_op
},
675 {"jsr", 0xB930, 0x42c0, "S", 0, SIZE_NONE
,
677 cris_none_reg_mode_jump_op
},
679 {"jsrc", 0x39b0, 0xc640, "r", 0, SIZE_NONE
,
681 cris_reg_mode_jump_op
},
683 {"jsrc", 0x3930, 0xc2c0, "s", 0, SIZE_FIX_32
,
685 cris_none_reg_mode_jump_op
},
687 {"jsrc", 0x3930, 0xc2c0, "S", 0, SIZE_NONE
,
689 cris_none_reg_mode_jump_op
},
691 {"jsrc", 0xBB30, 0x44C0, "r", 0, SIZE_NONE
,
693 cris_reg_mode_jump_op
},
695 {"jsrc", 0xBF3F, 0x40C0, "N", 0, SIZE_FIX_32
,
697 cris_reg_mode_jump_op
},
699 {"jump", 0x09b0, 0xF640, "r", 0, SIZE_NONE
, 0,
700 cris_reg_mode_jump_op
},
703 JUMP_INDIR_OPCODE
, JUMP_INDIR_Z_BITS
, "s", 0, SIZE_FIX_32
,
705 cris_none_reg_mode_jump_op
},
708 JUMP_INDIR_OPCODE
, JUMP_INDIR_Z_BITS
, "S", 0, SIZE_NONE
,
710 cris_none_reg_mode_jump_op
},
712 {"jump", 0x09F0, 0x060F, "P", 0, SIZE_NONE
,
714 cris_none_reg_mode_jump_op
},
717 JUMP_PC_INCR_OPCODE_V32
,
718 (0xffff & ~JUMP_PC_INCR_OPCODE_V32
), "N", 0, SIZE_FIX_32
,
720 cris_none_reg_mode_jump_op
},
722 {"jmpu", 0x8930, 0x72c0, "s", 0, SIZE_FIX_32
,
724 cris_none_reg_mode_jump_op
},
726 {"jmpu", 0x8930, 0x72c0, "S", 0, SIZE_NONE
,
728 cris_none_reg_mode_jump_op
},
730 {"lapc", 0x0970, 0x0680, "U,R", 0, SIZE_NONE
,
732 cris_not_implemented_op
},
734 {"lapc", 0x0D7F, 0x0280, "dn,R", 0, SIZE_FIX_32
,
736 cris_not_implemented_op
},
738 {"lapcq", 0x0970, 0x0680, "u,R", 0, SIZE_NONE
,
742 {"lsl", 0x04C0, 0x0B00, "m r,R", 0, SIZE_NONE
, 0,
743 cris_dstep_logshift_mstep_neg_not_op
},
745 {"lslq", 0x03c0, 0x0C20, "c,R", 0, SIZE_NONE
, 0,
746 cris_dstep_logshift_mstep_neg_not_op
},
748 {"lsr", 0x07C0, 0x0800, "m r,R", 0, SIZE_NONE
, 0,
749 cris_dstep_logshift_mstep_neg_not_op
},
751 {"lsrq", 0x03e0, 0x0C00, "c,R", 0, SIZE_NONE
, 0,
752 cris_dstep_logshift_mstep_neg_not_op
},
754 {"lz", 0x0730, 0x08C0, "r,R", 0, SIZE_NONE
,
756 cris_not_implemented_op
},
758 {"mcp", 0x07f0, 0x0800, "P,r", 0, SIZE_NONE
,
760 cris_not_implemented_op
},
762 {"move", 0x0640, 0x0980, "m r,R", 0, SIZE_NONE
, 0,
763 cris_reg_mode_add_sub_cmp_and_or_move_op
},
765 {"move", 0x0A40, 0x0180, "m s,R", 0, SIZE_FIELD
, 0,
766 cris_none_reg_mode_add_sub_cmp_and_or_move_op
},
768 {"move", 0x0A40, 0x0180, "m S,D", 0, SIZE_NONE
,
770 cris_none_reg_mode_add_sub_cmp_and_or_move_op
},
772 {"move", 0x0630, 0x09c0, "r,P", 0, SIZE_NONE
, 0,
773 cris_move_to_preg_op
},
775 {"move", 0x0670, 0x0980, "P,r", 0, SIZE_NONE
, 0,
776 cris_reg_mode_move_from_preg_op
},
778 {"move", 0x0BC0, 0x0000, "m R,y", 0, SIZE_FIELD
, 0,
779 cris_none_reg_mode_add_sub_cmp_and_or_move_op
},
781 {"move", 0x0BC0, 0x0000, "m D,S", 0, SIZE_NONE
,
783 cris_none_reg_mode_add_sub_cmp_and_or_move_op
},
786 MOVE_M_TO_PREG_OPCODE
, MOVE_M_TO_PREG_ZBITS
,
787 "s,P", 0, SIZE_SPEC_REG
, 0,
788 cris_move_to_preg_op
},
790 {"move", 0x0A30, 0x01c0, "S,P", 0, SIZE_NONE
,
792 cris_move_to_preg_op
},
794 {"move", 0x0A70, 0x0180, "P,y", 0, SIZE_SPEC_REG
, 0,
795 cris_none_reg_mode_move_from_preg_op
},
797 {"move", 0x0A70, 0x0180, "P,S", 0, SIZE_NONE
,
799 cris_none_reg_mode_move_from_preg_op
},
801 {"move", 0x0B70, 0x0480, "r,T", 0, SIZE_NONE
,
803 cris_not_implemented_op
},
805 {"move", 0x0F70, 0x0080, "T,r", 0, SIZE_NONE
,
807 cris_not_implemented_op
},
809 {"movem", 0x0BF0, 0x0000, "R,y", 0, SIZE_FIX_32
, 0,
810 cris_move_reg_to_mem_movem_op
},
812 {"movem", 0x0BF0, 0x0000, "D,S", 0, SIZE_NONE
,
814 cris_move_reg_to_mem_movem_op
},
816 {"movem", 0x0BB0, 0x0040, "s,R", 0, SIZE_FIX_32
, 0,
817 cris_move_mem_to_reg_movem_op
},
819 {"movem", 0x0BB0, 0x0040, "S,D", 0, SIZE_NONE
,
821 cris_move_mem_to_reg_movem_op
},
823 {"moveq", 0x0240, 0x0D80, "i,R", 0, SIZE_NONE
, 0,
824 cris_quick_mode_and_cmp_move_or_op
},
826 {"movs", 0x0460, 0x0B80, "z r,R", 0, SIZE_NONE
, 0,
827 cris_reg_mode_add_sub_cmp_and_or_move_op
},
829 /* FIXME: SIZE_FIELD_SIGNED and all necessary changes. */
830 {"movs", 0x0860, 0x0380, "z s,R", 0, SIZE_FIELD
, 0,
831 cris_none_reg_mode_add_sub_cmp_and_or_move_op
},
833 {"movs", 0x0860, 0x0380, "z S,D", 0, SIZE_NONE
,
835 cris_none_reg_mode_add_sub_cmp_and_or_move_op
},
837 {"movu", 0x0440, 0x0Ba0, "z r,R", 0, SIZE_NONE
, 0,
838 cris_reg_mode_add_sub_cmp_and_or_move_op
},
840 /* FIXME: SIZE_FIELD_UNSIGNED and all necessary changes. */
841 {"movu", 0x0840, 0x03a0, "z s,R", 0, SIZE_FIELD
, 0,
842 cris_none_reg_mode_add_sub_cmp_and_or_move_op
},
844 {"movu", 0x0840, 0x03a0, "z S,D", 0, SIZE_NONE
,
846 cris_none_reg_mode_add_sub_cmp_and_or_move_op
},
848 {"mstep", 0x07f0, 0x0800, "r,R", 0, SIZE_NONE
,
850 cris_dstep_logshift_mstep_neg_not_op
},
852 {"muls", 0x0d00, 0x02c0, "m r,R", 0, SIZE_NONE
,
856 {"mulu", 0x0900, 0x06c0, "m r,R", 0, SIZE_NONE
,
860 {"neg", 0x0580, 0x0A40, "m r,R", 0, SIZE_NONE
, 0,
861 cris_dstep_logshift_mstep_neg_not_op
},
863 {"nop", NOP_OPCODE
, NOP_Z_BITS
, "", 0, SIZE_NONE
,
867 {"nop", NOP_OPCODE_V32
, NOP_Z_BITS_V32
, "", 0, SIZE_NONE
,
871 {"not", 0x8770, 0x7880, "r", 0, SIZE_NONE
, 0,
872 cris_dstep_logshift_mstep_neg_not_op
},
874 {"or", 0x0740, 0x0880, "m r,R", 0, SIZE_NONE
, 0,
875 cris_reg_mode_add_sub_cmp_and_or_move_op
},
877 {"or", 0x0B40, 0x0080, "m s,R", 0, SIZE_FIELD
, 0,
878 cris_none_reg_mode_add_sub_cmp_and_or_move_op
},
880 {"or", 0x0B40, 0x0080, "m S,D", 0, SIZE_NONE
,
882 cris_none_reg_mode_add_sub_cmp_and_or_move_op
},
884 {"or", 0x0B40, 0x0480, "m S,R,r", 0, SIZE_NONE
,
886 cris_three_operand_add_sub_cmp_and_or_op
},
888 {"orq", 0x0340, 0x0C80, "i,R", 0, SIZE_NONE
, 0,
889 cris_quick_mode_and_cmp_move_or_op
},
891 {"pop", 0x0E6E, 0x0191, "!R", 0, SIZE_NONE
,
893 cris_none_reg_mode_add_sub_cmp_and_or_move_op
},
895 {"pop", 0x0e3e, 0x01c1, "!P", 0, SIZE_NONE
,
897 cris_none_reg_mode_move_from_preg_op
},
899 {"push", 0x0FEE, 0x0011, "BR", 0, SIZE_NONE
,
901 cris_none_reg_mode_add_sub_cmp_and_or_move_op
},
903 {"push", 0x0E7E, 0x0181, "BP", 0, SIZE_NONE
,
905 cris_move_to_preg_op
},
907 {"rbf", 0x3b30, 0xc0c0, "y", 0, SIZE_NONE
,
909 cris_not_implemented_op
},
911 {"rbf", 0x3b30, 0xc0c0, "S", 0, SIZE_NONE
,
913 cris_not_implemented_op
},
915 {"rfe", 0x2930, 0xD6CF, "", 0, SIZE_NONE
,
917 cris_not_implemented_op
},
919 {"rfg", 0x4930, 0xB6CF, "", 0, SIZE_NONE
,
921 cris_not_implemented_op
},
923 {"rfn", 0x5930, 0xA6CF, "", 0, SIZE_NONE
,
925 cris_not_implemented_op
},
927 {"ret", 0xB67F, 0x4980, "", 1, SIZE_NONE
,
929 cris_reg_mode_move_from_preg_op
},
931 {"ret", 0xB9F0, 0x460F, "", 1, SIZE_NONE
,
933 cris_reg_mode_move_from_preg_op
},
935 {"retb", 0xe67f, 0x1980, "", 1, SIZE_NONE
,
937 cris_reg_mode_move_from_preg_op
},
939 {"rete", 0xA9F0, 0x560F, "", 1, SIZE_NONE
,
941 cris_reg_mode_move_from_preg_op
},
943 {"reti", 0xA67F, 0x5980, "", 1, SIZE_NONE
,
945 cris_reg_mode_move_from_preg_op
},
947 {"retn", 0xC9F0, 0x360F, "", 1, SIZE_NONE
,
949 cris_reg_mode_move_from_preg_op
},
951 {"sbfs", 0x3b70, 0xc080, "y", 0, SIZE_NONE
,
953 cris_not_implemented_op
},
955 {"sbfs", 0x3b70, 0xc080, "S", 0, SIZE_NONE
,
957 cris_not_implemented_op
},
961 0x0AC0+(0xf-CC_A
)*0x1000, "r", 0, SIZE_NONE
, 0,
965 0x0530+CC_EXT
*0x1000,
966 0x0AC0+(0xf-CC_EXT
)*0x1000, "r", 0, SIZE_NONE
,
972 0x0AC0+(0xf-CC_CC
)*0x1000, "r", 0, SIZE_NONE
, 0,
977 0x0AC0+(0xf-CC_CS
)*0x1000, "r", 0, SIZE_NONE
, 0,
982 0x0AC0+(0xf-CC_EQ
)*0x1000, "r", 0, SIZE_NONE
, 0,
985 {"setf", 0x05b0, 0x0A40, "f", 0, SIZE_NONE
, 0,
988 {"sfe", 0x3930, 0xC6CF, "", 0, SIZE_NONE
,
990 cris_not_implemented_op
},
992 /* Need to have "swf" in front of "sext" so it is the one displayed in
995 0x0530+CC_EXT
*0x1000,
996 0x0AC0+(0xf-CC_EXT
)*0x1000, "r", 0, SIZE_NONE
,
1001 0x0530+CC_EXT
*0x1000,
1002 0x0AC0+(0xf-CC_EXT
)*0x1000, "r", 0, SIZE_NONE
,
1007 0x0530+CC_GE
*0x1000,
1008 0x0AC0+(0xf-CC_GE
)*0x1000, "r", 0, SIZE_NONE
, 0,
1012 0x0530+CC_GT
*0x1000,
1013 0x0AC0+(0xf-CC_GT
)*0x1000, "r", 0, SIZE_NONE
, 0,
1017 0x0530+CC_HI
*0x1000,
1018 0x0AC0+(0xf-CC_HI
)*0x1000, "r", 0, SIZE_NONE
, 0,
1022 0x0530+CC_HS
*0x1000,
1023 0x0AC0+(0xf-CC_HS
)*0x1000, "r", 0, SIZE_NONE
, 0,
1027 0x0530+CC_LE
*0x1000,
1028 0x0AC0+(0xf-CC_LE
)*0x1000, "r", 0, SIZE_NONE
, 0,
1032 0x0530+CC_LO
*0x1000,
1033 0x0AC0+(0xf-CC_LO
)*0x1000, "r", 0, SIZE_NONE
, 0,
1037 0x0530+CC_LS
*0x1000,
1038 0x0AC0+(0xf-CC_LS
)*0x1000, "r", 0, SIZE_NONE
, 0,
1042 0x0530+CC_LT
*0x1000,
1043 0x0AC0+(0xf-CC_LT
)*0x1000, "r", 0, SIZE_NONE
, 0,
1047 0x0530+CC_MI
*0x1000,
1048 0x0AC0+(0xf-CC_MI
)*0x1000, "r", 0, SIZE_NONE
, 0,
1052 0x0530+CC_NE
*0x1000,
1053 0x0AC0+(0xf-CC_NE
)*0x1000, "r", 0, SIZE_NONE
, 0,
1057 0x0530+CC_PL
*0x1000,
1058 0x0AC0+(0xf-CC_PL
)*0x1000, "r", 0, SIZE_NONE
, 0,
1061 {"sub", 0x0680, 0x0940, "m r,R", 0, SIZE_NONE
, 0,
1062 cris_reg_mode_add_sub_cmp_and_or_move_op
},
1064 {"sub", 0x0a80, 0x0140, "m s,R", 0, SIZE_FIELD
, 0,
1065 cris_none_reg_mode_add_sub_cmp_and_or_move_op
},
1067 {"sub", 0x0a80, 0x0140, "m S,D", 0, SIZE_NONE
,
1069 cris_none_reg_mode_add_sub_cmp_and_or_move_op
},
1071 {"sub", 0x0a80, 0x0540, "m S,R,r", 0, SIZE_NONE
,
1073 cris_three_operand_add_sub_cmp_and_or_op
},
1075 {"subq", 0x0280, 0x0d40, "I,R", 0, SIZE_NONE
, 0,
1076 cris_quick_mode_add_sub_op
},
1078 {"subs", 0x04a0, 0x0b40, "z r,R", 0, SIZE_NONE
, 0,
1079 cris_reg_mode_add_sub_cmp_and_or_move_op
},
1081 /* FIXME: SIZE_FIELD_SIGNED and all necessary changes. */
1082 {"subs", 0x08a0, 0x0340, "z s,R", 0, SIZE_FIELD
, 0,
1083 cris_none_reg_mode_add_sub_cmp_and_or_move_op
},
1085 {"subs", 0x08a0, 0x0340, "z S,D", 0, SIZE_NONE
,
1087 cris_none_reg_mode_add_sub_cmp_and_or_move_op
},
1089 {"subs", 0x08a0, 0x0740, "z S,R,r", 0, SIZE_NONE
,
1091 cris_three_operand_add_sub_cmp_and_or_op
},
1093 {"subu", 0x0480, 0x0b60, "z r,R", 0, SIZE_NONE
, 0,
1094 cris_reg_mode_add_sub_cmp_and_or_move_op
},
1096 /* FIXME: SIZE_FIELD_UNSIGNED and all necessary changes. */
1097 {"subu", 0x0880, 0x0360, "z s,R", 0, SIZE_FIELD
, 0,
1098 cris_none_reg_mode_add_sub_cmp_and_or_move_op
},
1100 {"subu", 0x0880, 0x0360, "z S,D", 0, SIZE_NONE
,
1102 cris_none_reg_mode_add_sub_cmp_and_or_move_op
},
1104 {"subu", 0x0880, 0x0760, "z S,R,r", 0, SIZE_NONE
,
1106 cris_three_operand_add_sub_cmp_and_or_op
},
1109 0x0530+CC_VC
*0x1000,
1110 0x0AC0+(0xf-CC_VC
)*0x1000, "r", 0, SIZE_NONE
, 0,
1114 0x0530+CC_VS
*0x1000,
1115 0x0AC0+(0xf-CC_VS
)*0x1000, "r", 0, SIZE_NONE
, 0,
1118 /* The insn "swapn" is the same as "not" and will be disassembled as
1119 such, but the swap* family of mnmonics are generally v8-and-higher
1120 only, so count it in. */
1121 {"swapn", 0x8770, 0x7880, "r", 0, SIZE_NONE
,
1123 cris_not_implemented_op
},
1125 {"swapw", 0x4770, 0xb880, "r", 0, SIZE_NONE
,
1127 cris_not_implemented_op
},
1129 {"swapnw", 0xc770, 0x3880, "r", 0, SIZE_NONE
,
1131 cris_not_implemented_op
},
1133 {"swapb", 0x2770, 0xd880, "r", 0, SIZE_NONE
,
1135 cris_not_implemented_op
},
1137 {"swapnb", 0xA770, 0x5880, "r", 0, SIZE_NONE
,
1139 cris_not_implemented_op
},
1141 {"swapwb", 0x6770, 0x9880, "r", 0, SIZE_NONE
,
1143 cris_not_implemented_op
},
1145 {"swapnwb", 0xE770, 0x1880, "r", 0, SIZE_NONE
,
1147 cris_not_implemented_op
},
1149 {"swapr", 0x1770, 0xe880, "r", 0, SIZE_NONE
,
1151 cris_not_implemented_op
},
1153 {"swapnr", 0x9770, 0x6880, "r", 0, SIZE_NONE
,
1155 cris_not_implemented_op
},
1157 {"swapwr", 0x5770, 0xa880, "r", 0, SIZE_NONE
,
1159 cris_not_implemented_op
},
1161 {"swapnwr", 0xd770, 0x2880, "r", 0, SIZE_NONE
,
1163 cris_not_implemented_op
},
1165 {"swapbr", 0x3770, 0xc880, "r", 0, SIZE_NONE
,
1167 cris_not_implemented_op
},
1169 {"swapnbr", 0xb770, 0x4880, "r", 0, SIZE_NONE
,
1171 cris_not_implemented_op
},
1173 {"swapwbr", 0x7770, 0x8880, "r", 0, SIZE_NONE
,
1175 cris_not_implemented_op
},
1177 {"swapnwbr", 0xf770, 0x0880, "r", 0, SIZE_NONE
,
1179 cris_not_implemented_op
},
1181 {"test", 0x0640, 0x0980, "m D", 0, SIZE_NONE
,
1183 cris_reg_mode_test_op
},
1185 {"test", 0x0b80, 0xf040, "m y", 0, SIZE_FIELD
, 0,
1186 cris_none_reg_mode_clear_test_op
},
1188 {"test", 0x0b80, 0xf040, "m S", 0, SIZE_NONE
,
1190 cris_none_reg_mode_clear_test_op
},
1192 {"xor", 0x07B0, 0x0840, "r,R", 0, SIZE_NONE
, 0,
1195 {NULL
, 0, 0, NULL
, 0, 0, 0, cris_not_implemented_op
}
1198 /* Condition-names, indexed by the CC_* numbers as found in cris.h. */
1217 /* This is a placeholder. In v0, this would be "ext". In v32, this
1218 is "sb". See cris_conds15. */
1222 /* Different names and semantics for condition 1111 (0xf). */
1223 const struct cris_cond15 cris_cond15s
[] =
1225 /* FIXME: In what version did condition "ext" disappear? */
1226 {"ext", cris_ver_v0_3
},
1227 {"wf", cris_ver_v10
},
1228 {"sb", cris_ver_v32p
},
1235 * eval: (c-set-style "gnu")
1236 * indent-tabs-mode: t
1241 /* No instruction will be disassembled longer than this. In theory, and
1242 in silicon, address prefixes can be cascaded. In practice, cascading
1243 is not used by GCC, and not supported by the assembler. */
1244 #ifndef MAX_BYTES_PER_CRIS_INSN
1245 #define MAX_BYTES_PER_CRIS_INSN 8
1248 /* Whether or not to decode prefixes, folding it into the following
1249 instruction. FIXME: Make this optional later. */
1250 #ifndef PARSE_PREFIX
1251 #define PARSE_PREFIX 1
1254 /* Sometimes we prefix all registers with this character. */
1255 #define REGISTER_PREFIX_CHAR '$'
1257 /* Whether or not to trace the following sequence:
1260 adds.w [pc+r%d.w],pc
1262 This is the assembly form of a switch-statement in C.
1263 The "sub is optional. If there is none, then X will be zero.
1264 X is the value of the first case,
1265 Y is the number of cases (including default).
1267 This results in case offsets printed on the form:
1268 case N: -> case_address
1269 where N is an estimation on the corresponding 'case' operand in C,
1270 and case_address is where execution of that case continues after the
1271 sequence presented above.
1273 The old style of output was to print the offsets as instructions,
1274 which made it hard to follow "case"-constructs in the disassembly,
1275 and caused a lot of annoying warnings about undefined instructions.
1277 FIXME: Make this optional later. */
1279 #define TRACE_CASE (disdata->trace_case)
1282 enum cris_disass_family
1283 { cris_dis_v0_v10
, cris_dis_common_v10_v32
, cris_dis_v32
};
1285 /* Stored in the disasm_info->private_data member. */
1286 struct cris_disasm_data
1288 /* Whether to print something less confusing if we find something
1289 matching a switch-construct. */
1290 bfd_boolean trace_case
;
1292 /* Whether this code is flagged as crisv32. FIXME: Should be an enum
1293 that includes "compatible". */
1294 enum cris_disass_family distype
;
1297 /* Value of first element in switch. */
1298 static long case_offset
= 0;
1300 /* How many more case-offsets to print. */
1301 static long case_offset_counter
= 0;
1303 /* Number of case offsets. */
1304 static long no_of_case_offsets
= 0;
1306 /* Candidate for next case_offset. */
1307 static long last_immediate
= 0;
1309 static int cris_constraint
1310 (const char *, unsigned, unsigned, struct cris_disasm_data
*);
1312 /* Parse disassembler options and store state in info. FIXME: For the
1313 time being, we abuse static variables. */
1316 cris_parse_disassembler_options (disassemble_info
*info
,
1317 enum cris_disass_family distype
)
1319 struct cris_disasm_data
*disdata
;
1321 info
->private_data
= calloc (1, sizeof (struct cris_disasm_data
));
1322 disdata
= (struct cris_disasm_data
*) info
->private_data
;
1323 if (disdata
== NULL
)
1328 = (info
->disassembler_options
== NULL
1329 || (strcmp (info
->disassembler_options
, "nocase") != 0));
1331 disdata
->distype
= distype
;
1335 static const struct cris_spec_reg
*
1336 spec_reg_info (unsigned int sreg
, enum cris_disass_family distype
)
1340 for (i
= 0; cris_spec_regs
[i
].name
!= NULL
; i
++)
1342 if (cris_spec_regs
[i
].number
== sreg
)
1344 if (distype
== cris_dis_v32
)
1345 switch (cris_spec_regs
[i
].applicable_version
)
1347 case cris_ver_warning
:
1348 case cris_ver_version_all
:
1353 /* No ambiguous sizes or register names with CRISv32. */
1354 if (cris_spec_regs
[i
].warning
== NULL
)
1355 return &cris_spec_regs
[i
];
1359 else if (cris_spec_regs
[i
].applicable_version
!= cris_ver_v32p
)
1360 return &cris_spec_regs
[i
];
1367 /* Return the number of bits in the argument. */
1370 number_of_bits (unsigned int val
)
1374 for (bits
= 0; val
!= 0; val
&= val
- 1)
1380 /* Get an entry in the opcode-table. */
1382 static const struct cris_opcode
*
1383 get_opcode_entry (unsigned int insn
,
1384 unsigned int prefix_insn
,
1385 struct cris_disasm_data
*disdata
)
1387 /* For non-prefixed insns, we keep a table of pointers, indexed by the
1388 insn code. Each entry is initialized when found to be NULL. */
1389 static const struct cris_opcode
**opc_table
= NULL
;
1391 const struct cris_opcode
*max_matchedp
= NULL
;
1392 const struct cris_opcode
**prefix_opc_table
= NULL
;
1394 /* We hold a table for each prefix that need to be handled differently. */
1395 static const struct cris_opcode
**dip_prefixes
= NULL
;
1396 static const struct cris_opcode
**bdapq_m1_prefixes
= NULL
;
1397 static const struct cris_opcode
**bdapq_m2_prefixes
= NULL
;
1398 static const struct cris_opcode
**bdapq_m4_prefixes
= NULL
;
1399 static const struct cris_opcode
**rest_prefixes
= NULL
;
1401 /* Allocate and clear the opcode-table. */
1402 if (opc_table
== NULL
)
1404 opc_table
= malloc (65536 * sizeof (opc_table
[0]));
1405 if (opc_table
== NULL
)
1408 memset (opc_table
, 0, 65536 * sizeof (const struct cris_opcode
*));
1411 = malloc (65536 * sizeof (const struct cris_opcode
**));
1412 if (dip_prefixes
== NULL
)
1415 memset (dip_prefixes
, 0, 65536 * sizeof (dip_prefixes
[0]));
1418 = malloc (65536 * sizeof (const struct cris_opcode
**));
1419 if (bdapq_m1_prefixes
== NULL
)
1422 memset (bdapq_m1_prefixes
, 0, 65536 * sizeof (bdapq_m1_prefixes
[0]));
1425 = malloc (65536 * sizeof (const struct cris_opcode
**));
1426 if (bdapq_m2_prefixes
== NULL
)
1429 memset (bdapq_m2_prefixes
, 0, 65536 * sizeof (bdapq_m2_prefixes
[0]));
1432 = malloc (65536 * sizeof (const struct cris_opcode
**));
1433 if (bdapq_m4_prefixes
== NULL
)
1436 memset (bdapq_m4_prefixes
, 0, 65536 * sizeof (bdapq_m4_prefixes
[0]));
1439 = malloc (65536 * sizeof (const struct cris_opcode
**));
1440 if (rest_prefixes
== NULL
)
1443 memset (rest_prefixes
, 0, 65536 * sizeof (rest_prefixes
[0]));
1446 /* Get the right table if this is a prefix.
1447 This code is connected to cris_constraints in that it knows what
1448 prefixes play a role in recognition of patterns; the necessary
1449 state is reflected by which table is used. If constraints
1450 involving match or non-match of prefix insns are changed, then this
1451 probably needs changing too. */
1452 if (prefix_insn
!= NO_CRIS_PREFIX
)
1454 const struct cris_opcode
*popcodep
1455 = (opc_table
[prefix_insn
] != NULL
1456 ? opc_table
[prefix_insn
]
1457 : get_opcode_entry (prefix_insn
, NO_CRIS_PREFIX
, disdata
));
1459 if (popcodep
== NULL
)
1462 if (popcodep
->match
== BDAP_QUICK_OPCODE
)
1464 /* Since some offsets are recognized with "push" macros, we
1465 have to have different tables for them. */
1466 int offset
= (prefix_insn
& 255);
1474 prefix_opc_table
= bdapq_m4_prefixes
;
1478 prefix_opc_table
= bdapq_m2_prefixes
;
1482 prefix_opc_table
= bdapq_m1_prefixes
;
1486 prefix_opc_table
= rest_prefixes
;
1490 else if (popcodep
->match
== DIP_OPCODE
)
1491 /* We don't allow postincrement when the prefix is DIP, so use a
1492 different table for DIP. */
1493 prefix_opc_table
= dip_prefixes
;
1495 prefix_opc_table
= rest_prefixes
;
1498 if (prefix_insn
!= NO_CRIS_PREFIX
1499 && prefix_opc_table
[insn
] != NULL
)
1500 max_matchedp
= prefix_opc_table
[insn
];
1501 else if (prefix_insn
== NO_CRIS_PREFIX
&& opc_table
[insn
] != NULL
)
1502 max_matchedp
= opc_table
[insn
];
1505 const struct cris_opcode
*opcodep
;
1506 int max_level_of_match
= -1;
1508 for (opcodep
= cris_opcodes
;
1509 opcodep
->name
!= NULL
;
1514 if (disdata
->distype
== cris_dis_v32
)
1516 switch (opcodep
->applicable_version
)
1518 case cris_ver_version_all
:
1522 case cris_ver_v0_10
:
1523 case cris_ver_v3_10
:
1524 case cris_ver_sim_v0_10
:
1525 case cris_ver_v8_10
:
1527 case cris_ver_warning
:
1544 switch (opcodep
->applicable_version
)
1546 case cris_ver_version_all
:
1549 case cris_ver_v0_10
:
1551 case cris_ver_v8_10
:
1553 case cris_ver_sim_v0_10
:
1555 case cris_ver_warning
:
1568 /* We give a double lead for bits matching the template in
1569 cris_opcodes. Not even, because then "move p8,r10" would
1570 be given 2 bits lead over "clear.d r10". When there's a
1571 tie, the first entry in the table wins. This is
1572 deliberate, to avoid a more complicated recognition
1574 if ((opcodep
->match
& insn
) == opcodep
->match
1575 && (opcodep
->lose
& insn
) == 0
1577 = cris_constraint (opcodep
->args
,
1583 += 2 * number_of_bits (opcodep
->match
1585 > max_level_of_match
))
1587 max_matchedp
= opcodep
;
1588 max_level_of_match
= level_of_match
;
1590 /* If there was a full match, never mind looking
1592 if (level_of_match
>= 2 * 16)
1596 /* Fill in the new entry.
1598 If there are changes to the opcode-table involving prefixes, and
1599 disassembly then does not work correctly, try removing the
1600 else-clause below that fills in the prefix-table. If that
1601 helps, you need to change the prefix_opc_table setting above, or
1602 something related. */
1603 if (prefix_insn
== NO_CRIS_PREFIX
)
1604 opc_table
[insn
] = max_matchedp
;
1606 prefix_opc_table
[insn
] = max_matchedp
;
1609 return max_matchedp
;
1612 /* Return -1 if the constraints of a bitwise-matched instruction say
1613 that there is no match. Otherwise return a nonnegative number
1614 indicating the confidence in the match (higher is better). */
1617 cris_constraint (const char *cs
,
1619 unsigned int prefix_insn
,
1620 struct cris_disasm_data
*disdata
)
1627 for (s
= cs
; *s
; s
++)
1631 /* Do not recognize "pop" if there's a prefix and then only for
1633 if (prefix_insn
!= NO_CRIS_PREFIX
1634 || disdata
->distype
!= cris_dis_v0_v10
)
1639 /* Not recognized at disassembly. */
1643 /* Size modifier for "clear", i.e. special register 0, 4 or 8.
1644 Check that it is one of them. Only special register 12 could
1645 be mismatched, but checking for matches is more logical than
1646 checking for mismatches when there are only a few cases. */
1647 tmp
= ((insn
>> 12) & 0xf);
1648 if (tmp
!= 0 && tmp
!= 4 && tmp
!= 8)
1653 if ((insn
& 0x30) == 0x30)
1658 /* A prefix operand without side-effect. */
1659 if (prefix_insn
!= NO_CRIS_PREFIX
&& (insn
& 0x400) == 0)
1670 /* If this is a prefixed insn with postincrement (side-effect),
1671 the prefix must not be DIP. */
1672 if (prefix_insn
!= NO_CRIS_PREFIX
)
1676 const struct cris_opcode
*prefix_opcodep
1677 = get_opcode_entry (prefix_insn
, NO_CRIS_PREFIX
, disdata
);
1679 if (prefix_opcodep
->match
== DIP_OPCODE
)
1688 /* If we don't fall through, then the prefix is ok. */
1691 /* A "push" prefix. Check for valid "push" size.
1692 In case of special register, it may be != 4. */
1693 if (prefix_insn
!= NO_CRIS_PREFIX
)
1695 /* Match the prefix insn to BDAPQ. */
1696 const struct cris_opcode
*prefix_opcodep
1697 = get_opcode_entry (prefix_insn
, NO_CRIS_PREFIX
, disdata
);
1699 if (prefix_opcodep
->match
== BDAP_QUICK_OPCODE
)
1701 int pushsize
= (prefix_insn
& 255);
1708 unsigned int spec_reg
= (insn
>> 12) & 15;
1709 const struct cris_spec_reg
*sregp
1710 = spec_reg_info (spec_reg
, disdata
->distype
);
1712 /* For a special-register, the "prefix size" must
1713 match the size of the register. */
1714 if (sregp
&& sregp
->reg_size
== (unsigned int) -pushsize
)
1717 else if (s
[1] == 'R')
1719 if ((insn
& 0x30) == 0x20 && pushsize
== -4)
1722 /* FIXME: Should abort here; next constraint letter
1723 *must* be 'P' or 'R'. */
1729 retval
= (((insn
>> 12) & 15) == (insn
& 15));
1738 const struct cris_spec_reg
*sregp
1739 = spec_reg_info ((insn
>> 12) & 15, disdata
->distype
);
1741 /* Since we match four bits, we will give a value of 4-1 = 3
1742 in a match. If there is a corresponding exact match of a
1743 special register in another pattern, it will get a value of
1744 4, which will be higher. This should be correct in that an
1745 exact pattern would match better than a general pattern.
1747 Note that there is a reason for not returning zero; the
1748 pattern for "clear" is partly matched in the bit-pattern
1749 (the two lower bits must be zero), while the bit-pattern
1750 for a move from a special register is matched in the
1751 register constraint. */
1763 if (prefix_insn
!= NO_CRIS_PREFIX
&& ! prefix_ok
)
1769 /* Format number as hex with a leading "0x" into outbuffer. */
1772 format_hex (unsigned long number
,
1774 struct cris_disasm_data
*disdata
)
1776 /* Truncate negative numbers on >32-bit hosts. */
1777 number
&= 0xffffffff;
1779 sprintf (outbuffer
, "0x%lx", number
);
1781 /* Save this value for the "case" support. */
1783 last_immediate
= number
;
1785 return outbuffer
+ strlen (outbuffer
);
1788 /* Format number as decimal into outbuffer. Parameter signedp says
1789 whether the number should be formatted as signed (!= 0) or
1793 format_dec (long number
, char *outbuffer
, int signedp
)
1795 last_immediate
= number
;
1796 sprintf (outbuffer
, signedp
? "%ld" : "%lu", number
);
1798 return outbuffer
+ strlen (outbuffer
);
1801 /* Format the name of the general register regno into outbuffer. */
1804 format_reg (struct cris_disasm_data
*disdata
,
1806 char *outbuffer_start
,
1807 bfd_boolean with_reg_prefix
)
1809 char *outbuffer
= outbuffer_start
;
1811 if (with_reg_prefix
)
1812 *outbuffer
++ = REGISTER_PREFIX_CHAR
;
1817 /* For v32, there is no context in which we output PC. */
1818 if (disdata
->distype
== cris_dis_v32
)
1819 strcpy (outbuffer
, "acr");
1821 strcpy (outbuffer
, "pc");
1825 strcpy (outbuffer
, "sp");
1829 sprintf (outbuffer
, "r%d", regno
);
1833 return outbuffer_start
+ strlen (outbuffer_start
);
1836 /* Format the name of a support register into outbuffer. */
1839 format_sup_reg (unsigned int regno
,
1840 char *outbuffer_start
,
1841 bfd_boolean with_reg_prefix
)
1843 char *outbuffer
= outbuffer_start
;
1846 if (with_reg_prefix
)
1847 *outbuffer
++ = REGISTER_PREFIX_CHAR
;
1849 for (i
= 0; cris_support_regs
[i
].name
!= NULL
; i
++)
1850 if (cris_support_regs
[i
].number
== regno
)
1852 sprintf (outbuffer
, "%s", cris_support_regs
[i
].name
);
1853 return outbuffer_start
+ strlen (outbuffer_start
);
1856 /* There's supposed to be register names covering all numbers, though
1857 some may be generic names. */
1858 sprintf (outbuffer
, "format_sup_reg-BUG");
1859 return outbuffer_start
+ strlen (outbuffer_start
);
1862 /* Return the length of an instruction. */
1865 bytes_to_skip (unsigned int insn
,
1866 const struct cris_opcode
*matchedp
,
1867 enum cris_disass_family distype
,
1868 const struct cris_opcode
*prefix_matchedp
)
1870 /* Each insn is a word plus "immediate" operands. */
1871 unsigned to_skip
= 2;
1872 const char *template = matchedp
->args
;
1875 for (s
= template; *s
; s
++)
1876 if ((*s
== 's' || *s
== 'N' || *s
== 'Y')
1877 && (insn
& 0x400) && (insn
& 15) == 15
1878 && prefix_matchedp
== NULL
)
1880 /* Immediate via [pc+], so we have to check the size of the
1882 int mode_size
= 1 << ((insn
>> 4) & (*template == 'z' ? 1 : 3));
1884 if (matchedp
->imm_oprnd_size
== SIZE_FIX_32
)
1886 else if (matchedp
->imm_oprnd_size
== SIZE_SPEC_REG
)
1888 const struct cris_spec_reg
*sregp
1889 = spec_reg_info ((insn
>> 12) & 15, distype
);
1891 /* FIXME: Improve error handling; should have been caught
1896 /* PC is incremented by two, not one, for a byte. Except on
1897 CRISv32, where constants are always DWORD-size for
1898 special registers. */
1900 distype
== cris_dis_v32
? 4 : (sregp
->reg_size
+ 1) & ~1;
1903 to_skip
+= (mode_size
+ 1) & ~1;
1913 /* Print condition code flags. */
1916 print_flags (struct cris_disasm_data
*disdata
, unsigned int insn
, char *cp
)
1918 /* Use the v8 (Etrax 100) flag definitions for disassembly.
1919 The differences with v0 (Etrax 1..4) vs. Svinto are:
1922 FIXME: Emit v0..v3 flag names somehow. */
1923 static const char v8_fnames
[] = "cvznxibm";
1924 static const char v32_fnames
[] = "cvznxiup";
1926 = disdata
->distype
== cris_dis_v32
? v32_fnames
: v8_fnames
;
1928 unsigned char flagbits
= (((insn
>> 8) & 0xf0) | (insn
& 15));
1931 for (i
= 0; i
< 8; i
++)
1932 if (flagbits
& (1 << i
))
1938 /* Print out an insn with its operands, and update the info->insn_type
1939 fields. The prefix_opcodep and the rest hold a prefix insn that is
1940 supposed to be output as an address mode. */
1943 print_with_operands (const struct cris_opcode
*opcodep
,
1945 unsigned char *buffer
,
1947 disassemble_info
*info
,
1948 /* If a prefix insn was before this insn (and is supposed
1949 to be output as an address), here is a description of
1951 const struct cris_opcode
*prefix_opcodep
,
1952 unsigned int prefix_insn
,
1953 unsigned char *prefix_buffer
,
1954 bfd_boolean with_reg_prefix
)
1956 /* Get a buffer of somewhat reasonable size where we store
1957 intermediate parts of the insn. */
1958 char temp
[sizeof (".d [$r13=$r12-2147483648],$r10") * 2];
1960 static const char mode_char
[] = "bwd?";
1963 struct cris_disasm_data
*disdata
1964 = (struct cris_disasm_data
*) info
->private_data
;
1966 /* Print out the name first thing we do. */
1967 (*info
->fprintf_func
) (info
->stream
, "%s", opcodep
->name
);
1972 /* Ignore any prefix indicator. */
1976 if (*s
== 'm' || *s
== 'M' || *s
== 'z')
1980 /* Get the size-letter. */
1982 ? (insn
& 0x8000 ? 'd'
1983 : insn
& 0x4000 ? 'w' : 'b')
1984 : mode_char
[(insn
>> 4) & (*s
== 'z' ? 1 : 3)];
1986 /* Ignore the size and the space character that follows. */
1990 /* Add a space if this isn't a long-branch, because for those will add
1991 the condition part of the name later. */
1992 if (opcodep
->match
!= (BRANCH_PC_LOW
+ BRANCH_INCR_HIGH
* 256))
1995 /* Fill in the insn-type if deducible from the name (and there's no
1997 if (opcodep
->name
[0] == 'j')
1999 if (CONST_STRNEQ (opcodep
->name
, "jsr"))
2000 /* It's "jsr" or "jsrc". */
2001 info
->insn_type
= dis_jsr
;
2003 /* Any other jump-type insn is considered a branch. */
2004 info
->insn_type
= dis_branch
;
2007 /* We might know some more fields right now. */
2008 info
->branch_delay_insns
= opcodep
->delayed
;
2010 /* Handle operands. */
2016 tp
= format_sup_reg ((insn
>> 12) & 15, tp
, with_reg_prefix
);
2020 if (with_reg_prefix
)
2021 *tp
++ = REGISTER_PREFIX_CHAR
;
2034 /* Ignore at this point; used at earlier stages to avoid
2035 recognition if there's a prefix at something that in other
2036 ways looks like a "pop". */
2040 /* Ignore. This is an optional ".d " on the large one of
2045 /* This was the prefix that made this a "push". We've already
2046 handled it by recognizing it, so signal that the prefix is
2047 handled by setting it to NULL. */
2048 prefix_opcodep
= NULL
;
2053 tp
= format_reg (disdata
, insn
& 15, tp
, with_reg_prefix
);
2057 tp
= format_reg (disdata
, (insn
>> 12) & 15, tp
, with_reg_prefix
);
2062 /* Like N but pc-relative to the start of the insn. */
2063 unsigned long number
2064 = (buffer
[2] + buffer
[3] * 256 + buffer
[4] * 65536
2065 + buffer
[5] * 0x1000000 + addr
);
2067 /* Finish off and output previous formatted bytes. */
2070 (*info
->fprintf_func
) (info
->stream
, "%s", temp
);
2073 (*info
->print_address_func
) ((bfd_vma
) number
, info
);
2079 /* Like n but the offset is bits <3:0> in the instruction. */
2080 unsigned long number
= (buffer
[0] & 0xf) * 2 + addr
;
2082 /* Finish off and output previous formatted bytes. */
2085 (*info
->fprintf_func
) (info
->stream
, "%s", temp
);
2088 (*info
->print_address_func
) ((bfd_vma
) number
, info
);
2097 /* Any "normal" memory operand. */
2098 if ((insn
& 0x400) && (insn
& 15) == 15 && prefix_opcodep
== NULL
)
2100 /* We're looking at [pc+], i.e. we need to output an immediate
2101 number, where the size can depend on different things. */
2104 = ((*cs
== 'z' && (insn
& 0x20))
2105 || opcodep
->match
== BDAP_QUICK_OPCODE
);
2108 if (opcodep
->imm_oprnd_size
== SIZE_FIX_32
)
2110 else if (opcodep
->imm_oprnd_size
== SIZE_SPEC_REG
)
2112 const struct cris_spec_reg
*sregp
2113 = spec_reg_info ((insn
>> 12) & 15, disdata
->distype
);
2115 /* A NULL return should have been as a non-match earlier,
2116 so catch it as an internal error in the error-case
2119 /* Whatever non-valid size. */
2122 /* PC is always incremented by a multiple of two.
2123 For CRISv32, immediates are always 4 bytes for
2124 special registers. */
2125 nbytes
= disdata
->distype
== cris_dis_v32
2126 ? 4 : (sregp
->reg_size
+ 1) & ~1;
2130 int mode_size
= 1 << ((insn
>> 4) & (*cs
== 'z' ? 1 : 3));
2142 if (signedp
&& number
> 127)
2147 number
= buffer
[2] + buffer
[3] * 256;
2148 if (signedp
&& number
> 32767)
2154 = buffer
[2] + buffer
[3] * 256 + buffer
[4] * 65536
2155 + buffer
[5] * 0x1000000;
2164 if ((*cs
== 'z' && (insn
& 0x20))
2165 || (opcodep
->match
== BDAP_QUICK_OPCODE
2166 && (nbytes
<= 2 || buffer
[1 + nbytes
] == 0)))
2167 tp
= format_dec (number
, tp
, signedp
);
2170 unsigned int highbyte
= (number
>> 24) & 0xff;
2172 /* Either output this as an address or as a number. If it's
2173 a dword with the same high-byte as the address of the
2174 insn, assume it's an address, and also if it's a non-zero
2175 non-0xff high-byte. If this is a jsr or a jump, then
2176 it's definitely an address. */
2178 && (highbyte
== ((addr
>> 24) & 0xff)
2179 || (highbyte
!= 0 && highbyte
!= 0xff)
2180 || info
->insn_type
== dis_branch
2181 || info
->insn_type
== dis_jsr
))
2183 /* Finish off and output previous formatted bytes. */
2187 (*info
->fprintf_func
) (info
->stream
, "%s", temp
);
2189 (*info
->print_address_func
) ((bfd_vma
) number
, info
);
2191 info
->target
= number
;
2194 tp
= format_hex (number
, tp
, disdata
);
2199 /* Not an immediate number. Then this is a (possibly
2200 prefixed) memory operand. */
2201 if (info
->insn_type
!= dis_nonbranch
)
2205 & (opcodep
->args
[0] == 'z' ? 1 : 3));
2207 info
->insn_type
= dis_dref
;
2208 info
->flags
|= CRIS_DIS_FLAG_MEMREF
;
2210 if (opcodep
->imm_oprnd_size
== SIZE_FIX_32
)
2212 else if (opcodep
->imm_oprnd_size
== SIZE_SPEC_REG
)
2214 const struct cris_spec_reg
*sregp
2215 = spec_reg_info ((insn
>> 12) & 15, disdata
->distype
);
2217 /* FIXME: Improve error handling; should have been caught
2222 size
= sregp
->reg_size
;
2227 info
->data_size
= size
;
2233 /* We don't match dip with a postincremented field
2234 as a side-effect address mode. */
2235 && ((insn
& 0x400) == 0
2236 || prefix_opcodep
->match
!= DIP_OPCODE
))
2240 tp
= format_reg (disdata
, insn
& 15, tp
, with_reg_prefix
);
2245 /* We mainly ignore the prefix format string when the
2246 address-mode syntax is output. */
2247 switch (prefix_opcodep
->match
)
2250 /* It's [r], [r+] or [pc+]. */
2251 if ((prefix_insn
& 0x400) && (prefix_insn
& 15) == 15)
2253 /* It's [pc+]. This cannot possibly be anything
2255 unsigned long number
2256 = prefix_buffer
[2] + prefix_buffer
[3] * 256
2257 + prefix_buffer
[4] * 65536
2258 + prefix_buffer
[5] * 0x1000000;
2260 info
->target
= (bfd_vma
) number
;
2262 /* Finish off and output previous formatted
2267 (*info
->fprintf_func
) (info
->stream
, "%s", temp
);
2269 (*info
->print_address_func
) ((bfd_vma
) number
, info
);
2273 /* For a memref in an address, we use target2.
2274 In this case, target is zero. */
2276 |= (CRIS_DIS_FLAG_MEM_TARGET2_IS_REG
2277 | CRIS_DIS_FLAG_MEM_TARGET2_MEM
);
2279 info
->target2
= prefix_insn
& 15;
2282 tp
= format_reg (disdata
, prefix_insn
& 15, tp
,
2284 if (prefix_insn
& 0x400)
2290 case BDAP_QUICK_OPCODE
:
2294 number
= prefix_buffer
[0];
2298 /* Output "reg+num" or, if num < 0, "reg-num". */
2299 tp
= format_reg (disdata
, (prefix_insn
>> 12) & 15, tp
,
2303 tp
= format_dec (number
, tp
, 1);
2305 info
->flags
|= CRIS_DIS_FLAG_MEM_TARGET_IS_REG
;
2306 info
->target
= (prefix_insn
>> 12) & 15;
2307 info
->target2
= (bfd_vma
) number
;
2312 /* Output "r+R.m". */
2313 tp
= format_reg (disdata
, prefix_insn
& 15, tp
,
2316 tp
= format_reg (disdata
, (prefix_insn
>> 12) & 15, tp
,
2319 *tp
++ = mode_char
[(prefix_insn
>> 4) & 3];
2322 |= (CRIS_DIS_FLAG_MEM_TARGET2_IS_REG
2323 | CRIS_DIS_FLAG_MEM_TARGET_IS_REG
2325 | ((prefix_insn
& 0x8000)
2326 ? CRIS_DIS_FLAG_MEM_TARGET2_MULT4
2327 : ((prefix_insn
& 0x8000)
2328 ? CRIS_DIS_FLAG_MEM_TARGET2_MULT2
: 0)));
2330 /* Is it the casejump? It's a "adds.w [pc+r%d.w],pc". */
2331 if (insn
== 0xf83f && (prefix_insn
& ~0xf000) == 0x55f)
2332 /* Then start interpreting data as offsets. */
2333 case_offset_counter
= no_of_case_offsets
;
2336 case BDAP_INDIR_OPCODE
:
2337 /* Output "r+s.m", or, if "s" is [pc+], "r+s" or
2339 tp
= format_reg (disdata
, (prefix_insn
>> 12) & 15, tp
,
2342 if ((prefix_insn
& 0x400) && (prefix_insn
& 15) == 15)
2345 unsigned int nbytes
;
2347 /* It's a value. Get its size. */
2348 int mode_size
= 1 << ((prefix_insn
>> 4) & 3);
2358 number
= prefix_buffer
[2];
2364 number
= prefix_buffer
[2] + prefix_buffer
[3] * 256;
2371 = prefix_buffer
[2] + prefix_buffer
[3] * 256
2372 + prefix_buffer
[4] * 65536
2373 + prefix_buffer
[5] * 0x1000000;
2382 info
->flags
|= CRIS_DIS_FLAG_MEM_TARGET_IS_REG
;
2383 info
->target2
= (bfd_vma
) number
;
2385 /* If the size is dword, then assume it's an
2389 /* Finish off and output previous formatted
2394 (*info
->fprintf_func
) (info
->stream
, "%s", temp
);
2396 (*info
->print_address_func
) ((bfd_vma
) number
, info
);
2402 tp
= format_dec (number
, tp
, 1);
2407 /* Output "r+[R].m" or "r+[R+].m". */
2410 tp
= format_reg (disdata
, prefix_insn
& 15, tp
,
2412 if (prefix_insn
& 0x400)
2416 *tp
++ = mode_char
[(prefix_insn
>> 4) & 3];
2419 |= (CRIS_DIS_FLAG_MEM_TARGET2_IS_REG
2420 | CRIS_DIS_FLAG_MEM_TARGET2_MEM
2421 | CRIS_DIS_FLAG_MEM_TARGET_IS_REG
2423 | (((prefix_insn
>> 4) == 2)
2425 : (((prefix_insn
>> 4) & 3) == 1
2426 ? CRIS_DIS_FLAG_MEM_TARGET2_MEM_WORD
2427 : CRIS_DIS_FLAG_MEM_TARGET2_MEM_BYTE
)));
2432 (*info
->fprintf_func
) (info
->stream
, "?prefix-bug");
2435 /* To mark that the prefix is used, reset it. */
2436 prefix_opcodep
= NULL
;
2440 tp
= format_reg (disdata
, insn
& 15, tp
, with_reg_prefix
);
2442 info
->flags
|= CRIS_DIS_FLAG_MEM_TARGET_IS_REG
;
2443 info
->target
= insn
& 15;
2453 tp
= format_reg (disdata
, (insn
>> 12) & 15, tp
, with_reg_prefix
);
2455 *tp
++ = mode_char
[(insn
>> 4) & 3];
2459 tp
= format_dec (insn
& 63, tp
, 0);
2464 int where
= buffer
[2] + buffer
[3] * 256;
2469 where
+= addr
+ ((disdata
->distype
== cris_dis_v32
) ? 0 : 4);
2471 if (insn
== BA_PC_INCR_OPCODE
)
2472 info
->insn_type
= dis_branch
;
2474 info
->insn_type
= dis_condbranch
;
2476 info
->target
= (bfd_vma
) where
;
2480 (*info
->fprintf_func
) (info
->stream
, "%s%s ",
2481 temp
, cris_cc_strings
[insn
>> 12]);
2483 (*info
->print_address_func
) ((bfd_vma
) where
, info
);
2488 tp
= format_dec (insn
& 31, tp
, 0);
2492 tp
= format_dec (insn
& 15, tp
, 0);
2497 long offset
= insn
& 0xfe;
2503 if (opcodep
->match
== BA_QUICK_OPCODE
)
2504 info
->insn_type
= dis_branch
;
2506 info
->insn_type
= dis_condbranch
;
2508 target
= addr
+ ((disdata
->distype
== cris_dis_v32
) ? 0 : 2) + offset
;
2509 info
->target
= target
;
2512 (*info
->fprintf_func
) (info
->stream
, "%s", temp
);
2513 (*info
->print_address_func
) (target
, info
);
2520 long number
= buffer
[0];
2523 number
= number
- 256;
2525 tp
= format_dec (number
, tp
, 1);
2527 tp
= format_reg (disdata
, (insn
>> 12) & 15, tp
, with_reg_prefix
);
2532 tp
= print_flags (disdata
, insn
, tp
);
2536 tp
= format_dec ((insn
& 32) ? (insn
& 31) | ~31L : insn
& 31, tp
, 1);
2541 const struct cris_spec_reg
*sregp
2542 = spec_reg_info ((insn
>> 12) & 15, disdata
->distype
);
2544 if (sregp
->name
== NULL
)
2545 /* Should have been caught as a non-match eariler. */
2549 if (with_reg_prefix
)
2550 *tp
++ = REGISTER_PREFIX_CHAR
;
2551 strcpy (tp
, sregp
->name
);
2566 (*info
->fprintf_func
) (info
->stream
, " (OOPS unused prefix \"%s: %s\")",
2567 prefix_opcodep
->name
, prefix_opcodep
->args
);
2569 (*info
->fprintf_func
) (info
->stream
, "%s", temp
);
2571 /* Get info for matching case-tables, if we don't have any active.
2572 We assume that the last constant seen is used; either in the insn
2573 itself or in a "move.d const,rN, sub.d rN,rM"-like sequence. */
2574 if (TRACE_CASE
&& case_offset_counter
== 0)
2576 if (CONST_STRNEQ (opcodep
->name
, "sub"))
2577 case_offset
= last_immediate
;
2579 /* It could also be an "add", if there are negative case-values. */
2580 else if (CONST_STRNEQ (opcodep
->name
, "add"))
2581 /* The first case is the negated operand to the add. */
2582 case_offset
= -last_immediate
;
2584 /* A bound insn will tell us the number of cases. */
2585 else if (CONST_STRNEQ (opcodep
->name
, "bound"))
2586 no_of_case_offsets
= last_immediate
+ 1;
2588 /* A jump or jsr or branch breaks the chain of insns for a
2589 case-table, so assume default first-case again. */
2590 else if (info
->insn_type
== dis_jsr
2591 || info
->insn_type
== dis_branch
2592 || info
->insn_type
== dis_condbranch
)
2598 /* Print the CRIS instruction at address memaddr on stream. Returns
2599 length of the instruction, in bytes. Prefix register names with `$' if
2603 print_insn_cris_generic (bfd_vma memaddr
,
2604 disassemble_info
*info
,
2605 bfd_boolean with_reg_prefix
)
2609 const struct cris_opcode
*matchedp
;
2611 struct cris_disasm_data
*disdata
2612 = (struct cris_disasm_data
*) info
->private_data
;
2614 /* No instruction will be disassembled as longer than this number of
2615 bytes; stacked prefixes will not be expanded. */
2616 unsigned char buffer
[MAX_BYTES_PER_CRIS_INSN
];
2617 unsigned char *bufp
;
2621 /* There will be an "out of range" error after the last instruction.
2622 Reading pairs of bytes in decreasing number, we hope that we will get
2623 at least the amount that we will consume.
2625 If we can't get any data, or we do not get enough data, we print
2626 the error message. */
2628 for (nbytes
= MAX_BYTES_PER_CRIS_INSN
; nbytes
> 0; nbytes
-= 2)
2630 status
= (*info
->read_memory_func
) (memaddr
, buffer
, nbytes
, info
);
2635 /* If we did not get all we asked for, then clear the rest.
2636 Hopefully this makes a reproducible result in case of errors. */
2637 if (nbytes
!= MAX_BYTES_PER_CRIS_INSN
)
2638 memset (buffer
+ nbytes
, 0, MAX_BYTES_PER_CRIS_INSN
- nbytes
);
2643 /* Set some defaults for the insn info. */
2644 info
->insn_info_valid
= 1;
2645 info
->branch_delay_insns
= 0;
2646 info
->data_size
= 0;
2647 info
->insn_type
= dis_nonbranch
;
2652 /* If we got any data, disassemble it. */
2657 insn
= bufp
[0] + bufp
[1] * 256;
2659 /* If we're in a case-table, don't disassemble the offsets. */
2660 if (TRACE_CASE
&& case_offset_counter
!= 0)
2662 info
->insn_type
= dis_noninsn
;
2665 /* If to print data as offsets, then shortcut here. */
2666 (*info
->fprintf_func
) (info
->stream
, "case %ld%s: -> ",
2667 case_offset
+ no_of_case_offsets
2668 - case_offset_counter
,
2669 case_offset_counter
== 1 ? "/default" :
2672 (*info
->print_address_func
) ((bfd_vma
)
2675 - (no_of_case_offsets
2676 - case_offset_counter
)
2678 case_offset_counter
--;
2680 /* The default case start (without a "sub" or "add") must be
2682 if (case_offset_counter
== 0)
2687 /* We're often called to disassemble zeroes. While this is a
2688 valid "bcc .+2" insn, it is also useless enough and enough
2689 of a nuiscance that we will just output "bcc .+2" for it
2690 and signal it as a noninsn. */
2691 (*info
->fprintf_func
) (info
->stream
,
2692 disdata
->distype
== cris_dis_v32
2693 ? "bcc ." : "bcc .+2");
2694 info
->insn_type
= dis_noninsn
;
2699 const struct cris_opcode
*prefix_opcodep
= NULL
;
2700 unsigned char *prefix_buffer
= bufp
;
2701 unsigned int prefix_insn
= insn
;
2702 int prefix_size
= 0;
2704 matchedp
= get_opcode_entry (insn
, NO_CRIS_PREFIX
, disdata
);
2706 /* Check if we're supposed to write out prefixes as address
2707 modes and if this was a prefix. */
2708 if (matchedp
!= NULL
&& PARSE_PREFIX
&& matchedp
->args
[0] == 'p')
2710 /* If it's a prefix, put it into the prefix vars and get the
2712 prefix_size
= bytes_to_skip (prefix_insn
, matchedp
,
2713 disdata
->distype
, NULL
);
2714 prefix_opcodep
= matchedp
;
2716 insn
= bufp
[prefix_size
] + bufp
[prefix_size
+ 1] * 256;
2717 matchedp
= get_opcode_entry (insn
, prefix_insn
, disdata
);
2719 if (matchedp
!= NULL
)
2721 addr
+= prefix_size
;
2722 bufp
+= prefix_size
;
2723 advance
+= prefix_size
;
2727 /* The "main" insn wasn't valid, at least not when
2728 prefixed. Put back things enough to output the
2729 prefix insn only, as a normal insn. */
2730 matchedp
= prefix_opcodep
;
2732 prefix_opcodep
= NULL
;
2736 if (matchedp
== NULL
)
2738 (*info
->fprintf_func
) (info
->stream
, "??0x%x", insn
);
2741 info
->insn_type
= dis_noninsn
;
2746 += bytes_to_skip (insn
, matchedp
, disdata
->distype
,
2749 /* The info_type and assorted fields will be set according
2751 print_with_operands (matchedp
, insn
, bufp
, addr
, info
,
2752 prefix_opcodep
, prefix_insn
,
2753 prefix_buffer
, with_reg_prefix
);
2758 info
->insn_type
= dis_noninsn
;
2760 /* If we read less than MAX_BYTES_PER_CRIS_INSN, i.e. we got an error
2761 status when reading that much, and the insn decoding indicated a
2762 length exceeding what we read, there is an error. */
2763 if (status
!= 0 && (nbytes
== 0 || advance
> nbytes
))
2765 (*info
->memory_error_func
) (status
, memaddr
, info
);
2769 /* Max supported insn size with one folded prefix insn. */
2770 info
->bytes_per_line
= MAX_BYTES_PER_CRIS_INSN
;
2772 /* I would like to set this to a fixed value larger than the actual
2773 number of bytes to print in order to avoid spaces between bytes,
2774 but objdump.c (2.9.1) does not like that, so we print 16-bit
2775 chunks, which is the next choice. */
2776 info
->bytes_per_chunk
= 2;
2778 /* Printing bytes in order of increasing addresses makes sense,
2779 especially on a little-endian target.
2780 This is completely the opposite of what you think; setting this to
2781 BFD_ENDIAN_LITTLE will print bytes in order N..0 rather than the 0..N
2783 info
->display_endian
= BFD_ENDIAN_BIG
;
2788 /* Disassemble, prefixing register names with `$'. CRIS v0..v10. */
2791 print_insn_cris_with_register_prefix (bfd_vma vma
,
2792 disassemble_info
*info
)
2794 if (info
->private_data
== NULL
2795 && !cris_parse_disassembler_options (info
, cris_dis_v0_v10
))
2797 return print_insn_cris_generic (vma
, info
, TRUE
);
2800 /* Disassemble, prefixing register names with `$'. CRIS v32. */
2803 print_insn_crisv32_with_register_prefix (bfd_vma vma
,
2804 disassemble_info
*info
)
2806 if (info
->private_data
== NULL
2807 && !cris_parse_disassembler_options (info
, cris_dis_v32
))
2809 return print_insn_cris_generic (vma
, info
, TRUE
);
2813 /* Disassemble, prefixing register names with `$'.
2814 Common v10 and v32 subset. */
2817 print_insn_crisv10_v32_with_register_prefix (bfd_vma vma
,
2818 disassemble_info
*info
)
2820 if (info
->private_data
== NULL
2821 && !cris_parse_disassembler_options (info
, cris_dis_common_v10_v32
))
2823 return print_insn_cris_generic (vma
, info
, TRUE
);
2826 /* Disassemble, no prefixes on register names. CRIS v0..v10. */
2829 print_insn_cris_without_register_prefix (bfd_vma vma
,
2830 disassemble_info
*info
)
2832 if (info
->private_data
== NULL
2833 && !cris_parse_disassembler_options (info
, cris_dis_v0_v10
))
2835 return print_insn_cris_generic (vma
, info
, FALSE
);
2838 /* Disassemble, no prefixes on register names. CRIS v32. */
2841 print_insn_crisv32_without_register_prefix (bfd_vma vma
,
2842 disassemble_info
*info
)
2844 if (info
->private_data
== NULL
2845 && !cris_parse_disassembler_options (info
, cris_dis_v32
))
2847 return print_insn_cris_generic (vma
, info
, FALSE
);
2850 /* Disassemble, no prefixes on register names.
2851 Common v10 and v32 subset. */
2854 print_insn_crisv10_v32_without_register_prefix (bfd_vma vma
,
2855 disassemble_info
*info
)
2857 if (info
->private_data
== NULL
2858 && !cris_parse_disassembler_options (info
, cris_dis_common_v10_v32
))
2860 return print_insn_cris_generic (vma
, info
, FALSE
);
2865 print_insn_crisv32 (bfd_vma vma
,
2866 disassemble_info
*info
)
2868 return print_insn_crisv32_with_register_prefix(vma
, info
);
2871 /* Return a disassembler-function that prints registers with a `$' prefix,
2872 or one that prints registers without a prefix.
2873 FIXME: We should improve the solution to avoid the multitude of
2874 functions seen above. */
2877 cris_get_disassembler (bfd
*abfd
)
2879 /* If there's no bfd in sight, we return what is valid as input in all
2880 contexts if fed back to the assembler: disassembly *with* register
2881 prefix. Unfortunately this will be totally wrong for v32. */
2883 return print_insn_cris_with_register_prefix
;
2885 if (bfd_get_symbol_leading_char (abfd
) == 0)
2887 if (bfd_get_mach (abfd
) == bfd_mach_cris_v32
)
2888 return print_insn_crisv32_with_register_prefix
;
2889 if (bfd_get_mach (abfd
) == bfd_mach_cris_v10_v32
)
2890 return print_insn_crisv10_v32_with_register_prefix
;
2892 /* We default to v10. This may be specifically specified in the
2893 bfd mach, but is also the default setting. */
2894 return print_insn_cris_with_register_prefix
;
2897 if (bfd_get_mach (abfd
) == bfd_mach_cris_v32
)
2898 return print_insn_crisv32_without_register_prefix
;
2899 if (bfd_get_mach (abfd
) == bfd_mach_cris_v10_v32
)
2900 return print_insn_crisv10_v32_without_register_prefix
;
2901 return print_insn_cris_without_register_prefix
;
2905 eval: (c-set-style "gnu")