1 /* Disassemble ADI Blackfin Instructions.
2 Copyright (C) 2005-2014 Free Software Foundation, Inc.
4 This file is part of libopcodes.
6 This library is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3, or (at your option)
11 It is distributed in the hope that it will be useful, but WITHOUT
12 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
14 License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
19 MA 02110-1301, USA. */
24 #include "opcode/bfin.h"
36 #define HOST_LONG_WORD_SIZE (sizeof (long) * 8)
37 #define XFIELD(w,p,s) (((w) & ((1 << (s)) - 1) << (p)) >> (p))
38 #define SIGNEXTEND(v, n) ((v << (HOST_LONG_WORD_SIZE - (n))) >> (HOST_LONG_WORD_SIZE - (n)))
39 #define MASKBITS(val, bits) (val & ((1 << bits) - 1))
43 typedef unsigned int bu32;
45 static char comment = 0;
46 static char parallel = 0;
50 c_0, c_1, c_4, c_2, c_uimm2, c_uimm3, c_imm3, c_pcrel4,
51 c_imm4, c_uimm4s4, c_uimm4s4d, c_uimm4, c_uimm4s2, c_negimm5s4, c_imm5, c_imm5d, c_uimm5, c_imm6,
52 c_imm7, c_imm7d, c_imm8, c_uimm8, c_pcrel8, c_uimm8s4, c_pcrel8s4, c_lppcrel10, c_pcrel10,
53 c_pcrel12, c_imm16s4, c_luimm16, c_imm16, c_imm16d, c_huimm16, c_rimm16, c_imm16s2, c_uimm16s4,
54 c_uimm16s4d, c_uimm16, c_pcrel24, c_uimm32, c_imm32, c_huimm32, c_huimm32e,
71 } constant_formats[] =
73 { "0", 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0},
74 { "1", 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0},
75 { "4", 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0},
76 { "2", 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0},
77 { "uimm2", 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
78 { "uimm3", 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
79 { "imm3", 3, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0},
80 { "pcrel4", 4, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0},
81 { "imm4", 4, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0},
82 { "uimm4s4", 4, 0, 0, 0, 2, 0, 0, 1, 0, 0, 0},
83 { "uimm4s4d", 4, 0, 0, 0, 2, 0, 0, 1, 1, 0, 0},
84 { "uimm4", 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
85 { "uimm4s2", 4, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0},
86 { "negimm5s4", 5, 0, 1, 0, 2, 0, 1, 0, 0, 0, 0},
87 { "imm5", 5, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0},
88 { "imm5d", 5, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0},
89 { "uimm5", 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
90 { "imm6", 6, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0},
91 { "imm7", 7, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0},
92 { "imm7d", 7, 0, 1, 0, 0, 0, 0, 0, 1, 3, 0},
93 { "imm8", 8, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0},
94 { "uimm8", 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
95 { "pcrel8", 8, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0},
96 { "uimm8s4", 8, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0},
97 { "pcrel8s4", 8, 1, 1, 1, 2, 0, 0, 0, 0, 0, 0},
98 { "lppcrel10", 10, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0},
99 { "pcrel10", 10, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0},
100 { "pcrel12", 12, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0},
101 { "imm16s4", 16, 0, 1, 0, 2, 0, 0, 0, 0, 0, 0},
102 { "luimm16", 16, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0},
103 { "imm16", 16, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0},
104 { "imm16d", 16, 0, 1, 0, 0, 0, 0, 0, 1, 3, 0},
105 { "huimm16", 16, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0},
106 { "rimm16", 16, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0},
107 { "imm16s2", 16, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0},
108 { "uimm16s4", 16, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0},
109 { "uimm16s4d", 16, 0, 0, 0, 2, 0, 0, 0, 1, 0, 0},
110 { "uimm16", 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
111 { "pcrel24", 24, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0},
112 { "uimm32", 32, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
113 { "imm32", 32, 0, 1, 0, 0, 0, 0, 0, 1, 3, 0},
114 { "huimm32", 32, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0},
115 { "huimm32e", 32, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1},
119 fmtconst (const_forms_t cf, TIword x, bfd_vma pc, disassemble_info *outf)
123 if (constant_formats[cf].reloc)
125 bfd_vma ea = (((constant_formats[cf].pcrel ? SIGNEXTEND (x, constant_formats[cf].nbits)
126 : x) + constant_formats[cf].offset) << constant_formats[cf].scale);
127 if (constant_formats[cf].pcrel)
130 /* truncate to 32-bits for proper symbol lookup/matching */
133 if (outf->symbol_at_address_func (ea, outf) || !constant_formats[cf].exact)
135 outf->print_address_func (ea, outf);
140 sprintf (buf, "%lx", (unsigned long) x);
145 /* Negative constants have an implied sign bit. */
146 if (constant_formats[cf].negative)
148 int nb = constant_formats[cf].nbits + 1;
150 x = x | (1 << constant_formats[cf].nbits);
151 x = SIGNEXTEND (x, nb);
154 x = constant_formats[cf].issigned ? SIGNEXTEND (x, constant_formats[cf].nbits) : x;
156 if (constant_formats[cf].offset)
157 x += constant_formats[cf].offset;
159 if (constant_formats[cf].scale)
160 x <<= constant_formats[cf].scale;
162 if (constant_formats[cf].decimal)
163 sprintf (buf, "%*li", constant_formats[cf].leading, x);
166 if (constant_formats[cf].issigned && x < 0)
167 sprintf (buf, "-0x%x", abs (x));
169 sprintf (buf, "0x%lx", (unsigned long) x);
176 fmtconst_val (const_forms_t cf, unsigned int x, unsigned int pc)
178 if (0 && constant_formats[cf].reloc)
180 bu32 ea = (((constant_formats[cf].pcrel
181 ? SIGNEXTEND (x, constant_formats[cf].nbits)
182 : x) + constant_formats[cf].offset)
183 << constant_formats[cf].scale);
184 if (constant_formats[cf].pcrel)
190 /* Negative constants have an implied sign bit. */
191 if (constant_formats[cf].negative)
193 int nb = constant_formats[cf].nbits + 1;
194 x = x | (1 << constant_formats[cf].nbits);
195 x = SIGNEXTEND (x, nb);
197 else if (constant_formats[cf].issigned)
198 x = SIGNEXTEND (x, constant_formats[cf].nbits);
200 x += constant_formats[cf].offset;
201 x <<= constant_formats[cf].scale;
206 enum machine_registers
208 REG_RL0, REG_RL1, REG_RL2, REG_RL3, REG_RL4, REG_RL5, REG_RL6, REG_RL7,
209 REG_RH0, REG_RH1, REG_RH2, REG_RH3, REG_RH4, REG_RH5, REG_RH6, REG_RH7,
210 REG_R0, REG_R1, REG_R2, REG_R3, REG_R4, REG_R5, REG_R6, REG_R7,
211 REG_R1_0, REG_R3_2, REG_R5_4, REG_R7_6, REG_P0, REG_P1, REG_P2, REG_P3,
212 REG_P4, REG_P5, REG_SP, REG_FP, REG_A0x, REG_A1x, REG_A0w, REG_A1w,
213 REG_A0, REG_A1, REG_I0, REG_I1, REG_I2, REG_I3, REG_M0, REG_M1,
214 REG_M2, REG_M3, REG_B0, REG_B1, REG_B2, REG_B3, REG_L0, REG_L1,
216 REG_AZ, REG_AN, REG_AC0, REG_AC1, REG_AV0, REG_AV1, REG_AV0S, REG_AV1S,
217 REG_AQ, REG_V, REG_VS,
218 REG_sftreset, REG_omode, REG_excause, REG_emucause, REG_idle_req, REG_hwerrcause, REG_CC, REG_LC0,
219 REG_LC1, REG_ASTAT, REG_RETS, REG_LT0, REG_LB0, REG_LT1, REG_LB1,
220 REG_CYCLES, REG_CYCLES2, REG_USP, REG_SEQSTAT, REG_SYSCFG, REG_RETI, REG_RETX, REG_RETN,
221 REG_RETE, REG_EMUDAT, REG_BR0, REG_BR1, REG_BR2, REG_BR3, REG_BR4, REG_BR5, REG_BR6,
222 REG_BR7, REG_PL0, REG_PL1, REG_PL2, REG_PL3, REG_PL4, REG_PL5, REG_SLP, REG_FLP,
223 REG_PH0, REG_PH1, REG_PH2, REG_PH3, REG_PH4, REG_PH5, REG_SHP, REG_FHP,
224 REG_IL0, REG_IL1, REG_IL2, REG_IL3, REG_ML0, REG_ML1, REG_ML2, REG_ML3,
225 REG_BL0, REG_BL1, REG_BL2, REG_BL3, REG_LL0, REG_LL1, REG_LL2, REG_LL3,
226 REG_IH0, REG_IH1, REG_IH2, REG_IH3, REG_MH0, REG_MH1, REG_MH2, REG_MH3,
227 REG_BH0, REG_BH1, REG_BH2, REG_BH3, REG_LH0, REG_LH1, REG_LH2, REG_LH3,
228 REG_AC0_COPY, REG_V_COPY, REG_RND_MOD,
234 rc_dregs_lo, rc_dregs_hi, rc_dregs, rc_dregs_pair, rc_pregs, rc_spfp, rc_dregs_hilo, rc_accum_ext,
235 rc_accum_word, rc_accum, rc_iregs, rc_mregs, rc_bregs, rc_lregs, rc_dpregs, rc_gregs,
236 rc_regs, rc_statbits, rc_ignore_bits, rc_ccstat, rc_counters, rc_dregs2_sysregs1, rc_open, rc_sysregs2,
237 rc_sysregs3, rc_allregs,
241 static const char * const reg_names[] =
243 "R0.L", "R1.L", "R2.L", "R3.L", "R4.L", "R5.L", "R6.L", "R7.L",
244 "R0.H", "R1.H", "R2.H", "R3.H", "R4.H", "R5.H", "R6.H", "R7.H",
245 "R0", "R1", "R2", "R3", "R4", "R5", "R6", "R7",
246 "R1:0", "R3:2", "R5:4", "R7:6", "P0", "P1", "P2", "P3",
247 "P4", "P5", "SP", "FP", "A0.X", "A1.X", "A0.W", "A1.W",
248 "A0", "A1", "I0", "I1", "I2", "I3", "M0", "M1",
249 "M2", "M3", "B0", "B1", "B2", "B3", "L0", "L1",
251 "AZ", "AN", "AC0", "AC1", "AV0", "AV1", "AV0S", "AV1S",
253 "sftreset", "omode", "excause", "emucause", "idle_req", "hwerrcause", "CC", "LC0",
254 "LC1", "ASTAT", "RETS", "LT0", "LB0", "LT1", "LB1",
255 "CYCLES", "CYCLES2", "USP", "SEQSTAT", "SYSCFG", "RETI", "RETX", "RETN",
257 "R0.B", "R1.B", "R2.B", "R3.B", "R4.B", "R5.B", "R6.B", "R7.B",
258 "P0.L", "P1.L", "P2.L", "P3.L", "P4.L", "P5.L", "SP.L", "FP.L",
259 "P0.H", "P1.H", "P2.H", "P3.H", "P4.H", "P5.H", "SP.H", "FP.H",
260 "I0.L", "I1.L", "I2.L", "I3.L", "M0.L", "M1.L", "M2.L", "M3.L",
261 "B0.L", "B1.L", "B2.L", "B3.L", "L0.L", "L1.L", "L2.L", "L3.L",
262 "I0.H", "I1.H", "I2.H", "I3.H", "M0.H", "M1.H", "M2.H", "M3.H",
263 "B0.H", "B1.H", "B2.H", "B3.H", "L0.H", "L1.H", "L2.H", "L3.H",
264 "AC0_COPY", "V_COPY", "RND_MOD",
269 #define REGNAME(x) ((x) < REG_LASTREG ? (reg_names[x]) : "...... Illegal register .......")
272 static const enum machine_registers decode_dregs_lo[] =
274 REG_RL0, REG_RL1, REG_RL2, REG_RL3, REG_RL4, REG_RL5, REG_RL6, REG_RL7,
277 #define dregs_lo(x) REGNAME (decode_dregs_lo[(x) & 7])
280 static const enum machine_registers decode_dregs_hi[] =
282 REG_RH0, REG_RH1, REG_RH2, REG_RH3, REG_RH4, REG_RH5, REG_RH6, REG_RH7,
285 #define dregs_hi(x) REGNAME (decode_dregs_hi[(x) & 7])
288 static const enum machine_registers decode_dregs[] =
290 REG_R0, REG_R1, REG_R2, REG_R3, REG_R4, REG_R5, REG_R6, REG_R7,
293 #define dregs(x) REGNAME (decode_dregs[(x) & 7])
296 static const enum machine_registers decode_dregs_byte[] =
298 REG_BR0, REG_BR1, REG_BR2, REG_BR3, REG_BR4, REG_BR5, REG_BR6, REG_BR7,
301 #define dregs_byte(x) REGNAME (decode_dregs_byte[(x) & 7])
304 static const enum machine_registers decode_pregs[] =
306 REG_P0, REG_P1, REG_P2, REG_P3, REG_P4, REG_P5, REG_SP, REG_FP,
309 #define pregs(x) REGNAME (decode_pregs[(x) & 7])
310 #define spfp(x) REGNAME (decode_spfp[(x) & 1])
311 #define dregs_hilo(x, i) REGNAME (decode_dregs_hilo[((i) << 3) | (x)])
312 #define accum_ext(x) REGNAME (decode_accum_ext[(x) & 1])
313 #define accum_word(x) REGNAME (decode_accum_word[(x) & 1])
314 #define accum(x) REGNAME (decode_accum[(x) & 1])
317 static const enum machine_registers decode_iregs[] =
319 REG_I0, REG_I1, REG_I2, REG_I3,
322 #define iregs(x) REGNAME (decode_iregs[(x) & 3])
325 static const enum machine_registers decode_mregs[] =
327 REG_M0, REG_M1, REG_M2, REG_M3,
330 #define mregs(x) REGNAME (decode_mregs[(x) & 3])
331 #define bregs(x) REGNAME (decode_bregs[(x) & 3])
332 #define lregs(x) REGNAME (decode_lregs[(x) & 3])
335 static const enum machine_registers decode_dpregs[] =
337 REG_R0, REG_R1, REG_R2, REG_R3, REG_R4, REG_R5, REG_R6, REG_R7,
338 REG_P0, REG_P1, REG_P2, REG_P3, REG_P4, REG_P5, REG_SP, REG_FP,
341 #define dpregs(x) REGNAME (decode_dpregs[(x) & 15])
344 static const enum machine_registers decode_gregs[] =
346 REG_R0, REG_R1, REG_R2, REG_R3, REG_R4, REG_R5, REG_R6, REG_R7,
347 REG_P0, REG_P1, REG_P2, REG_P3, REG_P4, REG_P5, REG_SP, REG_FP,
350 #define gregs(x, i) REGNAME (decode_gregs[((i) << 3) | (x)])
352 /* [dregs pregs (iregs mregs) (bregs lregs)]. */
353 static const enum machine_registers decode_regs[] =
355 REG_R0, REG_R1, REG_R2, REG_R3, REG_R4, REG_R5, REG_R6, REG_R7,
356 REG_P0, REG_P1, REG_P2, REG_P3, REG_P4, REG_P5, REG_SP, REG_FP,
357 REG_I0, REG_I1, REG_I2, REG_I3, REG_M0, REG_M1, REG_M2, REG_M3,
358 REG_B0, REG_B1, REG_B2, REG_B3, REG_L0, REG_L1, REG_L2, REG_L3,
361 #define regs(x, i) REGNAME (decode_regs[((i) << 3) | (x)])
363 /* [dregs pregs (iregs mregs) (bregs lregs) Low Half]. */
364 static const enum machine_registers decode_regs_lo[] =
366 REG_RL0, REG_RL1, REG_RL2, REG_RL3, REG_RL4, REG_RL5, REG_RL6, REG_RL7,
367 REG_PL0, REG_PL1, REG_PL2, REG_PL3, REG_PL4, REG_PL5, REG_SLP, REG_FLP,
368 REG_IL0, REG_IL1, REG_IL2, REG_IL3, REG_ML0, REG_ML1, REG_ML2, REG_ML3,
369 REG_BL0, REG_BL1, REG_BL2, REG_BL3, REG_LL0, REG_LL1, REG_LL2, REG_LL3,
372 #define regs_lo(x, i) REGNAME (decode_regs_lo[((i) << 3) | (x)])
374 /* [dregs pregs (iregs mregs) (bregs lregs) High Half]. */
375 static const enum machine_registers decode_regs_hi[] =
377 REG_RH0, REG_RH1, REG_RH2, REG_RH3, REG_RH4, REG_RH5, REG_RH6, REG_RH7,
378 REG_PH0, REG_PH1, REG_PH2, REG_PH3, REG_PH4, REG_PH5, REG_SHP, REG_FHP,
379 REG_IH0, REG_IH1, REG_IH2, REG_IH3, REG_MH0, REG_MH1, REG_MH2, REG_MH3,
380 REG_BH0, REG_BH1, REG_BH2, REG_BH3, REG_LH0, REG_LH1, REG_LH2, REG_LH3,
383 #define regs_hi(x, i) REGNAME (decode_regs_hi[((i) << 3) | (x)])
385 static const enum machine_registers decode_statbits[] =
387 REG_AZ, REG_AN, REG_AC0_COPY, REG_V_COPY,
388 REG_LASTREG, REG_LASTREG, REG_AQ, REG_LASTREG,
389 REG_RND_MOD, REG_LASTREG, REG_LASTREG, REG_LASTREG,
390 REG_AC0, REG_AC1, REG_LASTREG, REG_LASTREG,
391 REG_AV0, REG_AV0S, REG_AV1, REG_AV1S,
392 REG_LASTREG, REG_LASTREG, REG_LASTREG, REG_LASTREG,
393 REG_V, REG_VS, REG_LASTREG, REG_LASTREG,
394 REG_LASTREG, REG_LASTREG, REG_LASTREG, REG_LASTREG,
397 #define statbits(x) REGNAME (decode_statbits[(x) & 31])
400 static const enum machine_registers decode_counters[] =
405 #define counters(x) REGNAME (decode_counters[(x) & 1])
406 #define dregs2_sysregs1(x) REGNAME (decode_dregs2_sysregs1[(x) & 7])
408 /* [dregs pregs (iregs mregs) (bregs lregs)
409 dregs2_sysregs1 open sysregs2 sysregs3]. */
410 static const enum machine_registers decode_allregs[] =
412 REG_R0, REG_R1, REG_R2, REG_R3, REG_R4, REG_R5, REG_R6, REG_R7,
413 REG_P0, REG_P1, REG_P2, REG_P3, REG_P4, REG_P5, REG_SP, REG_FP,
414 REG_I0, REG_I1, REG_I2, REG_I3, REG_M0, REG_M1, REG_M2, REG_M3,
415 REG_B0, REG_B1, REG_B2, REG_B3, REG_L0, REG_L1, REG_L2, REG_L3,
416 REG_A0x, REG_A0w, REG_A1x, REG_A1w, REG_LASTREG, REG_LASTREG, REG_ASTAT, REG_RETS,
417 REG_LASTREG, REG_LASTREG, REG_LASTREG, REG_LASTREG, REG_LASTREG, REG_LASTREG, REG_LASTREG, REG_LASTREG,
418 REG_LC0, REG_LT0, REG_LB0, REG_LC1, REG_LT1, REG_LB1, REG_CYCLES, REG_CYCLES2,
419 REG_USP, REG_SEQSTAT, REG_SYSCFG, REG_RETI, REG_RETX, REG_RETN, REG_RETE, REG_EMUDAT,
423 #define IS_DREG(g,r) ((g) == 0 && (r) < 8)
424 #define IS_PREG(g,r) ((g) == 1 && (r) < 8)
425 #define IS_AREG(g,r) ((g) == 4 && (r) >= 0 && (r) < 4)
426 #define IS_GENREG(g,r) ((((g) == 0 || (g) == 1) && (r) < 8) || IS_AREG (g, r))
427 #define IS_DAGREG(g,r) (((g) == 2 || (g) == 3) && (r) < 8)
428 #define IS_SYSREG(g,r) \
429 (((g) == 4 && ((r) == 6 || (r) == 7)) || (g) == 6 || (g) == 7)
430 #define IS_RESERVEDREG(g,r) \
431 (((r) > 7) || ((g) == 4 && ((r) == 4 || (r) == 5)) || (g) == 5)
433 #define allreg(r,g) (!IS_RESERVEDREG (g, r))
434 #define mostreg(r,g) (!(IS_DREG (g, r) || IS_PREG (g, r) || IS_RESERVEDREG (g, r)))
436 #define allregs(x, i) REGNAME (decode_allregs[((i) << 3) | (x)])
437 #define uimm16s4(x) fmtconst (c_uimm16s4, x, 0, outf)
438 #define uimm16s4d(x) fmtconst (c_uimm16s4d, x, 0, outf)
439 #define pcrel4(x) fmtconst (c_pcrel4, x, pc, outf)
440 #define pcrel8(x) fmtconst (c_pcrel8, x, pc, outf)
441 #define pcrel8s4(x) fmtconst (c_pcrel8s4, x, pc, outf)
442 #define pcrel10(x) fmtconst (c_pcrel10, x, pc, outf)
443 #define pcrel12(x) fmtconst (c_pcrel12, x, pc, outf)
444 #define negimm5s4(x) fmtconst (c_negimm5s4, x, 0, outf)
445 #define rimm16(x) fmtconst (c_rimm16, x, 0, outf)
446 #define huimm16(x) fmtconst (c_huimm16, x, 0, outf)
447 #define imm16(x) fmtconst (c_imm16, x, 0, outf)
448 #define imm16d(x) fmtconst (c_imm16d, x, 0, outf)
449 #define uimm2(x) fmtconst (c_uimm2, x, 0, outf)
450 #define uimm3(x) fmtconst (c_uimm3, x, 0, outf)
451 #define luimm16(x) fmtconst (c_luimm16, x, 0, outf)
452 #define uimm4(x) fmtconst (c_uimm4, x, 0, outf)
453 #define uimm5(x) fmtconst (c_uimm5, x, 0, outf)
454 #define imm16s2(x) fmtconst (c_imm16s2, x, 0, outf)
455 #define uimm8(x) fmtconst (c_uimm8, x, 0, outf)
456 #define imm16s4(x) fmtconst (c_imm16s4, x, 0, outf)
457 #define uimm4s2(x) fmtconst (c_uimm4s2, x, 0, outf)
458 #define uimm4s4(x) fmtconst (c_uimm4s4, x, 0, outf)
459 #define uimm4s4d(x) fmtconst (c_uimm4s4d, x, 0, outf)
460 #define lppcrel10(x) fmtconst (c_lppcrel10, x, pc, outf)
461 #define imm3(x) fmtconst (c_imm3, x, 0, outf)
462 #define imm4(x) fmtconst (c_imm4, x, 0, outf)
463 #define uimm8s4(x) fmtconst (c_uimm8s4, x, 0, outf)
464 #define imm5(x) fmtconst (c_imm5, x, 0, outf)
465 #define imm5d(x) fmtconst (c_imm5d, x, 0, outf)
466 #define imm6(x) fmtconst (c_imm6, x, 0, outf)
467 #define imm7(x) fmtconst (c_imm7, x, 0, outf)
468 #define imm7d(x) fmtconst (c_imm7d, x, 0, outf)
469 #define imm8(x) fmtconst (c_imm8, x, 0, outf)
470 #define pcrel24(x) fmtconst (c_pcrel24, x, pc, outf)
471 #define uimm16(x) fmtconst (c_uimm16, x, 0, outf)
472 #define uimm32(x) fmtconst (c_uimm32, x, 0, outf)
473 #define imm32(x) fmtconst (c_imm32, x, 0, outf)
474 #define huimm32(x) fmtconst (c_huimm32, x, 0, outf)
475 #define huimm32e(x) fmtconst (c_huimm32e, x, 0, outf)
476 #define imm7_val(x) fmtconst_val (c_imm7, x, 0)
477 #define imm16_val(x) fmtconst_val (c_uimm16, x, 0)
478 #define luimm16_val(x) fmtconst_val (c_luimm16, x, 0)
480 /* (arch.pm)arch_disassembler_functions. */
482 #define OUTS(p, txt) (p)->fprintf_func ((p)->stream, "%s", txt)
486 amod0 (int s0, int x0, disassemble_info *outf)
488 if (s0 == 1 && x0 == 0)
490 else if (s0 == 0 && x0 == 1)
491 OUTS (outf, " (CO)");
492 else if (s0 == 1 && x0 == 1)
493 OUTS (outf, " (SCO)");
497 amod1 (int s0, int x0, disassemble_info *outf)
499 if (s0 == 0 && x0 == 0)
500 OUTS (outf, " (NS)");
501 else if (s0 == 1 && x0 == 0)
506 amod0amod2 (int s0, int x0, int aop0, disassemble_info *outf)
508 if (s0 == 1 && x0 == 0 && aop0 == 0)
510 else if (s0 == 0 && x0 == 1 && aop0 == 0)
511 OUTS (outf, " (CO)");
512 else if (s0 == 1 && x0 == 1 && aop0 == 0)
513 OUTS (outf, " (SCO)");
514 else if (s0 == 0 && x0 == 0 && aop0 == 2)
515 OUTS (outf, " (ASR)");
516 else if (s0 == 1 && x0 == 0 && aop0 == 2)
517 OUTS (outf, " (S, ASR)");
518 else if (s0 == 0 && x0 == 1 && aop0 == 2)
519 OUTS (outf, " (CO, ASR)");
520 else if (s0 == 1 && x0 == 1 && aop0 == 2)
521 OUTS (outf, " (SCO, ASR)");
522 else if (s0 == 0 && x0 == 0 && aop0 == 3)
523 OUTS (outf, " (ASL)");
524 else if (s0 == 1 && x0 == 0 && aop0 == 3)
525 OUTS (outf, " (S, ASL)");
526 else if (s0 == 0 && x0 == 1 && aop0 == 3)
527 OUTS (outf, " (CO, ASL)");
528 else if (s0 == 1 && x0 == 1 && aop0 == 3)
529 OUTS (outf, " (SCO, ASL)");
533 searchmod (int r0, disassemble_info *outf)
546 aligndir (int r0, disassemble_info *outf)
553 decode_multfunc (int h0, int h1, int src0, int src1, disassemble_info *outf)
558 s0 = dregs_hi (src0);
560 s0 = dregs_lo (src0);
563 s1 = dregs_hi (src1);
565 s1 = dregs_lo (src1);
574 decode_macfunc (int which, int op, int h0, int h1, int src0, int src1, disassemble_info *outf)
577 const char *sop = "<unknown op>";
592 case 0: sop = " = "; break;
593 case 1: sop = " += "; break;
594 case 2: sop = " -= "; break;
600 decode_multfunc (h0, h1, src0, src1, outf);
606 decode_optmode (int mod, int MM, disassemble_info *outf)
608 if (mod == 0 && MM == 0)
623 OUTS (outf, "S2RND");
626 else if (mod == M_W32)
628 else if (mod == M_FU)
630 else if (mod == M_TFU)
632 else if (mod == M_IS)
634 else if (mod == M_ISS2)
636 else if (mod == M_IH)
638 else if (mod == M_IU)
646 static struct saved_state
648 bu32 dpregs[16], iregs[4], mregs[4], bregs[4], lregs[4];
650 bu32 lt[2], lc[2], lb[2];
654 #define DREG(x) (saved_state.dpregs[x])
655 #define GREG(x, i) DPREG ((x) | ((i) << 3))
656 #define DPREG(x) (saved_state.dpregs[x])
657 #define DREG(x) (saved_state.dpregs[x])
658 #define PREG(x) (saved_state.dpregs[(x) + 8])
659 #define SPREG PREG (6)
660 #define FPREG PREG (7)
661 #define IREG(x) (saved_state.iregs[x])
662 #define MREG(x) (saved_state.mregs[x])
663 #define BREG(x) (saved_state.bregs[x])
664 #define LREG(x) (saved_state.lregs[x])
665 #define AXREG(x) (saved_state.ax[x])
666 #define AWREG(x) (saved_state.aw[x])
667 #define LCREG(x) (saved_state.lc[x])
668 #define LTREG(x) (saved_state.lt[x])
669 #define LBREG(x) (saved_state.lb[x])
670 #define RETSREG (saved_state.rets)
673 get_allreg (int grp, int reg)
675 int fullreg = (grp << 3) | reg;
676 /* REG_R0, REG_R1, REG_R2, REG_R3, REG_R4, REG_R5, REG_R6, REG_R7,
677 REG_P0, REG_P1, REG_P2, REG_P3, REG_P4, REG_P5, REG_SP, REG_FP,
678 REG_I0, REG_I1, REG_I2, REG_I3, REG_M0, REG_M1, REG_M2, REG_M3,
679 REG_B0, REG_B1, REG_B2, REG_B3, REG_L0, REG_L1, REG_L2, REG_L3,
680 REG_A0x, REG_A0w, REG_A1x, REG_A1w, , , REG_ASTAT, REG_RETS,
682 REG_LC0, REG_LT0, REG_LB0, REG_LC1, REG_LT1, REG_LB1, REG_CYCLES,
684 REG_USP, REG_SEQSTAT, REG_SYSCFG, REG_RETI, REG_RETX, REG_RETN, REG_RETE,
686 switch (fullreg >> 2)
688 case 0: case 1: return &DREG (reg);
689 case 2: case 3: return &PREG (reg);
690 case 4: return &IREG (reg & 3);
691 case 5: return &MREG (reg & 3);
692 case 6: return &BREG (reg & 3);
693 case 7: return &LREG (reg & 3);
697 case 32: return &AXREG (0);
698 case 33: return &AWREG (0);
699 case 34: return &AXREG (1);
700 case 35: return &AWREG (1);
701 case 39: return &RETSREG;
702 case 48: return &LCREG (0);
703 case 49: return <REG (0);
704 case 50: return &LBREG (0);
705 case 51: return &LCREG (1);
706 case 52: return <REG (1);
707 case 53: return &LBREG (1);
714 decode_ProgCtrl_0 (TIword iw0, disassemble_info *outf)
717 +---+---+---+---|---+---+---+---|---+---+---+---|---+---+---+---+
718 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |.prgfunc.......|.poprnd........|
719 +---+---+---+---|---+---+---+---|---+---+---+---|---+---+---+---+ */
720 int poprnd = ((iw0 >> ProgCtrl_poprnd_bits) & ProgCtrl_poprnd_mask);
721 int prgfunc = ((iw0 >> ProgCtrl_prgfunc_bits) & ProgCtrl_prgfunc_mask);
723 if (prgfunc == 0 && poprnd == 0)
727 else if (prgfunc == 1 && poprnd == 0)
729 else if (prgfunc == 1 && poprnd == 1)
731 else if (prgfunc == 1 && poprnd == 2)
733 else if (prgfunc == 1 && poprnd == 3)
735 else if (prgfunc == 1 && poprnd == 4)
737 else if (prgfunc == 2 && poprnd == 0)
739 else if (prgfunc == 2 && poprnd == 3)
740 OUTS (outf, "CSYNC");
741 else if (prgfunc == 2 && poprnd == 4)
742 OUTS (outf, "SSYNC");
743 else if (prgfunc == 2 && poprnd == 5)
744 OUTS (outf, "EMUEXCPT");
745 else if (prgfunc == 3 && IS_DREG (0, poprnd))
748 OUTS (outf, dregs (poprnd));
750 else if (prgfunc == 4 && IS_DREG (0, poprnd))
753 OUTS (outf, dregs (poprnd));
755 else if (prgfunc == 5 && IS_PREG (1, poprnd))
757 OUTS (outf, "JUMP (");
758 OUTS (outf, pregs (poprnd));
761 else if (prgfunc == 6 && IS_PREG (1, poprnd))
763 OUTS (outf, "CALL (");
764 OUTS (outf, pregs (poprnd));
767 else if (prgfunc == 7 && IS_PREG (1, poprnd))
769 OUTS (outf, "CALL (PC + ");
770 OUTS (outf, pregs (poprnd));
773 else if (prgfunc == 8 && IS_PREG (1, poprnd))
775 OUTS (outf, "JUMP (PC + ");
776 OUTS (outf, pregs (poprnd));
779 else if (prgfunc == 9)
781 OUTS (outf, "RAISE ");
782 OUTS (outf, uimm4 (poprnd));
784 else if (prgfunc == 10)
786 OUTS (outf, "EXCPT ");
787 OUTS (outf, uimm4 (poprnd));
789 else if (prgfunc == 11 && IS_PREG (1, poprnd) && poprnd <= 5)
791 OUTS (outf, "TESTSET (");
792 OUTS (outf, pregs (poprnd));
801 decode_CaCTRL_0 (TIword iw0, disassemble_info *outf)
804 +---+---+---+---|---+---+---+---|---+---+---+---|---+---+---+---+
805 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 1 |.a.|.op....|.reg.......|
806 +---+---+---+---|---+---+---+---|---+---+---+---|---+---+---+---+ */
807 int a = ((iw0 >> CaCTRL_a_bits) & CaCTRL_a_mask);
808 int op = ((iw0 >> CaCTRL_op_bits) & CaCTRL_op_mask);
809 int reg = ((iw0 >> CaCTRL_reg_bits) & CaCTRL_reg_mask);
814 if (a == 0 && op == 0)
816 OUTS (outf, "PREFETCH[");
817 OUTS (outf, pregs (reg));
820 else if (a == 0 && op == 1)
822 OUTS (outf, "FLUSHINV[");
823 OUTS (outf, pregs (reg));
826 else if (a == 0 && op == 2)
828 OUTS (outf, "FLUSH[");
829 OUTS (outf, pregs (reg));
832 else if (a == 0 && op == 3)
834 OUTS (outf, "IFLUSH[");
835 OUTS (outf, pregs (reg));
838 else if (a == 1 && op == 0)
840 OUTS (outf, "PREFETCH[");
841 OUTS (outf, pregs (reg));
844 else if (a == 1 && op == 1)
846 OUTS (outf, "FLUSHINV[");
847 OUTS (outf, pregs (reg));
850 else if (a == 1 && op == 2)
852 OUTS (outf, "FLUSH[");
853 OUTS (outf, pregs (reg));
856 else if (a == 1 && op == 3)
858 OUTS (outf, "IFLUSH[");
859 OUTS (outf, pregs (reg));
868 decode_PushPopReg_0 (TIword iw0, disassemble_info *outf)
871 +---+---+---+---|---+---+---+---|---+---+---+---|---+---+---+---+
872 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 |.W.|.grp.......|.reg.......|
873 +---+---+---+---|---+---+---+---|---+---+---+---|---+---+---+---+ */
874 int W = ((iw0 >> PushPopReg_W_bits) & PushPopReg_W_mask);
875 int grp = ((iw0 >> PushPopReg_grp_bits) & PushPopReg_grp_mask);
876 int reg = ((iw0 >> PushPopReg_reg_bits) & PushPopReg_reg_mask);
881 if (W == 0 && mostreg (reg, grp))
883 OUTS (outf, allregs (reg, grp));
884 OUTS (outf, " = [SP++]");
886 else if (W == 1 && allreg (reg, grp) && !(grp == 1 && reg == 6))
888 OUTS (outf, "[--SP] = ");
889 OUTS (outf, allregs (reg, grp));
897 decode_PushPopMultiple_0 (TIword iw0, disassemble_info *outf)
900 +---+---+---+---|---+---+---+---|---+---+---+---|---+---+---+---+
901 | 0 | 0 | 0 | 0 | 0 | 1 | 0 |.d.|.p.|.W.|.dr........|.pr........|
902 +---+---+---+---|---+---+---+---|---+---+---+---|---+---+---+---+ */
903 int p = ((iw0 >> PushPopMultiple_p_bits) & PushPopMultiple_p_mask);
904 int d = ((iw0 >> PushPopMultiple_d_bits) & PushPopMultiple_d_mask);
905 int W = ((iw0 >> PushPopMultiple_W_bits) & PushPopMultiple_W_mask);
906 int dr = ((iw0 >> PushPopMultiple_dr_bits) & PushPopMultiple_dr_mask);
907 int pr = ((iw0 >> PushPopMultiple_pr_bits) & PushPopMultiple_pr_mask);
915 if (W == 1 && d == 1 && p == 1)
917 OUTS (outf, "[--SP] = (R7:");
918 OUTS (outf, imm5d (dr));
919 OUTS (outf, ", P5:");
920 OUTS (outf, imm5d (pr));
923 else if (W == 1 && d == 1 && p == 0 && pr == 0)
925 OUTS (outf, "[--SP] = (R7:");
926 OUTS (outf, imm5d (dr));
929 else if (W == 1 && d == 0 && p == 1 && dr == 0)
931 OUTS (outf, "[--SP] = (P5:");
932 OUTS (outf, imm5d (pr));
935 else if (W == 0 && d == 1 && p == 1)
938 OUTS (outf, imm5d (dr));
939 OUTS (outf, ", P5:");
940 OUTS (outf, imm5d (pr));
941 OUTS (outf, ") = [SP++]");
943 else if (W == 0 && d == 1 && p == 0 && pr == 0)
946 OUTS (outf, imm5d (dr));
947 OUTS (outf, ") = [SP++]");
949 else if (W == 0 && d == 0 && p == 1 && dr == 0)
952 OUTS (outf, imm5d (pr));
953 OUTS (outf, ") = [SP++]");
961 decode_ccMV_0 (TIword iw0, disassemble_info *outf)
964 +---+---+---+---|---+---+---+---|---+---+---+---|---+---+---+---+
965 | 0 | 0 | 0 | 0 | 0 | 1 | 1 |.T.|.d.|.s.|.dst.......|.src.......|
966 +---+---+---+---|---+---+---+---|---+---+---+---|---+---+---+---+ */
967 int s = ((iw0 >> CCmv_s_bits) & CCmv_s_mask);
968 int d = ((iw0 >> CCmv_d_bits) & CCmv_d_mask);
969 int T = ((iw0 >> CCmv_T_bits) & CCmv_T_mask);
970 int src = ((iw0 >> CCmv_src_bits) & CCmv_src_mask);
971 int dst = ((iw0 >> CCmv_dst_bits) & CCmv_dst_mask);
978 OUTS (outf, "IF CC ");
979 OUTS (outf, gregs (dst, d));
981 OUTS (outf, gregs (src, s));
985 OUTS (outf, "IF !CC ");
986 OUTS (outf, gregs (dst, d));
988 OUTS (outf, gregs (src, s));
996 decode_CCflag_0 (TIword iw0, disassemble_info *outf)
999 +---+---+---+---|---+---+---+---|---+---+---+---|---+---+---+---+
1000 | 0 | 0 | 0 | 0 | 1 |.I.|.opc.......|.G.|.y.........|.x.........|
1001 +---+---+---+---|---+---+---+---|---+---+---+---|---+---+---+---+ */
1002 int x = ((iw0 >> CCflag_x_bits) & CCflag_x_mask);
1003 int y = ((iw0 >> CCflag_y_bits) & CCflag_y_mask);
1004 int I = ((iw0 >> CCflag_I_bits) & CCflag_I_mask);
1005 int G = ((iw0 >> CCflag_G_bits) & CCflag_G_mask);
1006 int opc = ((iw0 >> CCflag_opc_bits) & CCflag_opc_mask);
1011 if (opc == 0 && I == 0 && G == 0)
1013 OUTS (outf, "CC = ");
1014 OUTS (outf, dregs (x));
1015 OUTS (outf, " == ");
1016 OUTS (outf, dregs (y));
1018 else if (opc == 1 && I == 0 && G == 0)
1020 OUTS (outf, "CC = ");
1021 OUTS (outf, dregs (x));
1023 OUTS (outf, dregs (y));
1025 else if (opc == 2 && I == 0 && G == 0)
1027 OUTS (outf, "CC = ");
1028 OUTS (outf, dregs (x));
1029 OUTS (outf, " <= ");
1030 OUTS (outf, dregs (y));
1032 else if (opc == 3 && I == 0 && G == 0)
1034 OUTS (outf, "CC = ");
1035 OUTS (outf, dregs (x));
1037 OUTS (outf, dregs (y));
1038 OUTS (outf, " (IU)");
1040 else if (opc == 4 && I == 0 && G == 0)
1042 OUTS (outf, "CC = ");
1043 OUTS (outf, dregs (x));
1044 OUTS (outf, " <= ");
1045 OUTS (outf, dregs (y));
1046 OUTS (outf, " (IU)");
1048 else if (opc == 0 && I == 1 && G == 0)
1050 OUTS (outf, "CC = ");
1051 OUTS (outf, dregs (x));
1052 OUTS (outf, " == ");
1053 OUTS (outf, imm3 (y));
1055 else if (opc == 1 && I == 1 && G == 0)
1057 OUTS (outf, "CC = ");
1058 OUTS (outf, dregs (x));
1060 OUTS (outf, imm3 (y));
1062 else if (opc == 2 && I == 1 && G == 0)
1064 OUTS (outf, "CC = ");
1065 OUTS (outf, dregs (x));
1066 OUTS (outf, " <= ");
1067 OUTS (outf, imm3 (y));
1069 else if (opc == 3 && I == 1 && G == 0)
1071 OUTS (outf, "CC = ");
1072 OUTS (outf, dregs (x));
1074 OUTS (outf, uimm3 (y));
1075 OUTS (outf, " (IU)");
1077 else if (opc == 4 && I == 1 && G == 0)
1079 OUTS (outf, "CC = ");
1080 OUTS (outf, dregs (x));
1081 OUTS (outf, " <= ");
1082 OUTS (outf, uimm3 (y));
1083 OUTS (outf, " (IU)");
1085 else if (opc == 0 && I == 0 && G == 1)
1087 OUTS (outf, "CC = ");
1088 OUTS (outf, pregs (x));
1089 OUTS (outf, " == ");
1090 OUTS (outf, pregs (y));
1092 else if (opc == 1 && I == 0 && G == 1)
1094 OUTS (outf, "CC = ");
1095 OUTS (outf, pregs (x));
1097 OUTS (outf, pregs (y));
1099 else if (opc == 2 && I == 0 && G == 1)
1101 OUTS (outf, "CC = ");
1102 OUTS (outf, pregs (x));
1103 OUTS (outf, " <= ");
1104 OUTS (outf, pregs (y));
1106 else if (opc == 3 && I == 0 && G == 1)
1108 OUTS (outf, "CC = ");
1109 OUTS (outf, pregs (x));
1111 OUTS (outf, pregs (y));
1112 OUTS (outf, " (IU)");
1114 else if (opc == 4 && I == 0 && G == 1)
1116 OUTS (outf, "CC = ");
1117 OUTS (outf, pregs (x));
1118 OUTS (outf, " <= ");
1119 OUTS (outf, pregs (y));
1120 OUTS (outf, " (IU)");
1122 else if (opc == 0 && I == 1 && G == 1)
1124 OUTS (outf, "CC = ");
1125 OUTS (outf, pregs (x));
1126 OUTS (outf, " == ");
1127 OUTS (outf, imm3 (y));
1129 else if (opc == 1 && I == 1 && G == 1)
1131 OUTS (outf, "CC = ");
1132 OUTS (outf, pregs (x));
1134 OUTS (outf, imm3 (y));
1136 else if (opc == 2 && I == 1 && G == 1)
1138 OUTS (outf, "CC = ");
1139 OUTS (outf, pregs (x));
1140 OUTS (outf, " <= ");
1141 OUTS (outf, imm3 (y));
1143 else if (opc == 3 && I == 1 && G == 1)
1145 OUTS (outf, "CC = ");
1146 OUTS (outf, pregs (x));
1148 OUTS (outf, uimm3 (y));
1149 OUTS (outf, " (IU)");
1151 else if (opc == 4 && I == 1 && G == 1)
1153 OUTS (outf, "CC = ");
1154 OUTS (outf, pregs (x));
1155 OUTS (outf, " <= ");
1156 OUTS (outf, uimm3 (y));
1157 OUTS (outf, " (IU)");
1159 else if (opc == 5 && I == 0 && G == 0 && x == 0 && y == 0)
1160 OUTS (outf, "CC = A0 == A1");
1162 else if (opc == 6 && I == 0 && G == 0 && x == 0 && y == 0)
1163 OUTS (outf, "CC = A0 < A1");
1165 else if (opc == 7 && I == 0 && G == 0 && x == 0 && y == 0)
1166 OUTS (outf, "CC = A0 <= A1");
1174 decode_CC2dreg_0 (TIword iw0, disassemble_info *outf)
1177 +---+---+---+---|---+---+---+---|---+---+---+---|---+---+---+---+
1178 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 |.op....|.reg.......|
1179 +---+---+---+---|---+---+---+---|---+---+---+---|---+---+---+---+ */
1180 int op = ((iw0 >> CC2dreg_op_bits) & CC2dreg_op_mask);
1181 int reg = ((iw0 >> CC2dreg_reg_bits) & CC2dreg_reg_mask);
1188 OUTS (outf, dregs (reg));
1189 OUTS (outf, " = CC");
1193 OUTS (outf, "CC = ");
1194 OUTS (outf, dregs (reg));
1196 else if (op == 3 && reg == 0)
1197 OUTS (outf, "CC = !CC");
1205 decode_CC2stat_0 (TIword iw0, disassemble_info *outf)
1208 +---+---+---+---|---+---+---+---|---+---+---+---|---+---+---+---+
1209 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 1 |.D.|.op....|.cbit..............|
1210 +---+---+---+---|---+---+---+---|---+---+---+---|---+---+---+---+ */
1211 int D = ((iw0 >> CC2stat_D_bits) & CC2stat_D_mask);
1212 int op = ((iw0 >> CC2stat_op_bits) & CC2stat_op_mask);
1213 int cbit = ((iw0 >> CC2stat_cbit_bits) & CC2stat_cbit_mask);
1215 const char *bitname = statbits (cbit);
1220 if (decode_statbits[cbit] == REG_LASTREG)
1222 /* All ASTAT bits except CC may be operated on in hardware, but may
1223 not have a dedicated insn, so still decode "valid" insns. */
1224 static char bitnames[64];
1226 sprintf (bitnames, "ASTAT[%i /* unused bit */]", cbit);
1233 if (op == 0 && D == 0)
1235 OUTS (outf, "CC = ");
1236 OUTS (outf, bitname);
1238 else if (op == 1 && D == 0)
1240 OUTS (outf, "CC |= ");
1241 OUTS (outf, bitname);
1243 else if (op == 2 && D == 0)
1245 OUTS (outf, "CC &= ");
1246 OUTS (outf, bitname);
1248 else if (op == 3 && D == 0)
1250 OUTS (outf, "CC ^= ");
1251 OUTS (outf, bitname);
1253 else if (op == 0 && D == 1)
1255 OUTS (outf, bitname);
1256 OUTS (outf, " = CC");
1258 else if (op == 1 && D == 1)
1260 OUTS (outf, bitname);
1261 OUTS (outf, " |= CC");
1263 else if (op == 2 && D == 1)
1265 OUTS (outf, bitname);
1266 OUTS (outf, " &= CC");
1268 else if (op == 3 && D == 1)
1270 OUTS (outf, bitname);
1271 OUTS (outf, " ^= CC");
1280 decode_BRCC_0 (TIword iw0, bfd_vma pc, disassemble_info *outf)
1283 +---+---+---+---|---+---+---+---|---+---+---+---|---+---+---+---+
1284 | 0 | 0 | 0 | 1 |.T.|.B.|.offset................................|
1285 +---+---+---+---|---+---+---+---|---+---+---+---|---+---+---+---+ */
1286 int B = ((iw0 >> BRCC_B_bits) & BRCC_B_mask);
1287 int T = ((iw0 >> BRCC_T_bits) & BRCC_T_mask);
1288 int offset = ((iw0 >> BRCC_offset_bits) & BRCC_offset_mask);
1293 if (T == 1 && B == 1)
1295 OUTS (outf, "IF CC JUMP 0x");
1296 OUTS (outf, pcrel10 (offset));
1297 OUTS (outf, " (BP)");
1299 else if (T == 0 && B == 1)
1301 OUTS (outf, "IF !CC JUMP 0x");
1302 OUTS (outf, pcrel10 (offset));
1303 OUTS (outf, " (BP)");
1307 OUTS (outf, "IF CC JUMP 0x");
1308 OUTS (outf, pcrel10 (offset));
1312 OUTS (outf, "IF !CC JUMP 0x");
1313 OUTS (outf, pcrel10 (offset));
1322 decode_UJUMP_0 (TIword iw0, bfd_vma pc, disassemble_info *outf)
1325 +---+---+---+---|---+---+---+---|---+---+---+---|---+---+---+---+
1326 | 0 | 0 | 1 | 0 |.offset........................................|
1327 +---+---+---+---|---+---+---+---|---+---+---+---|---+---+---+---+ */
1328 int offset = ((iw0 >> UJump_offset_bits) & UJump_offset_mask);
1333 OUTS (outf, "JUMP.S 0x");
1334 OUTS (outf, pcrel12 (offset));
1339 decode_REGMV_0 (TIword iw0, disassemble_info *outf)
1342 +---+---+---+---|---+---+---+---|---+---+---+---|---+---+---+---+
1343 | 0 | 0 | 1 | 1 |.gd........|.gs........|.dst.......|.src.......|
1344 +---+---+---+---|---+---+---+---|---+---+---+---|---+---+---+---+ */
1345 int gs = ((iw0 >> RegMv_gs_bits) & RegMv_gs_mask);
1346 int gd = ((iw0 >> RegMv_gd_bits) & RegMv_gd_mask);
1347 int src = ((iw0 >> RegMv_src_bits) & RegMv_src_mask);
1348 int dst = ((iw0 >> RegMv_dst_bits) & RegMv_dst_mask);
1350 /* Reserved slots cannot be a src/dst. */
1351 if (IS_RESERVEDREG (gs, src) || IS_RESERVEDREG (gd, dst))
1354 /* Standard register moves */
1355 if ((gs < 2) || /* Dregs/Pregs as source */
1356 (gd < 2) || /* Dregs/Pregs as dest */
1357 (gs == 4 && src < 4) || /* Accumulators as source */
1358 (gd == 4 && dst < 4 && (gs < 4)) || /* Accumulators as dest */
1359 (gs == 7 && src == 7 && !(gd == 4 && dst < 4)) || /* EMUDAT as src */
1360 (gd == 7 && dst == 7)) /* EMUDAT as dest */
1363 /* dareg = dareg (IMBL) */
1364 if (gs < 4 && gd < 4)
1367 /* USP can be src to sysregs, but not dagregs. */
1368 if ((gs == 7 && src == 0) && (gd >= 4))
1371 /* USP can move between genregs (only check Accumulators). */
1372 if (((gs == 7 && src == 0) && (gd == 4 && dst < 4)) ||
1373 ((gd == 7 && dst == 0) && (gs == 4 && src < 4)))
1376 /* Still here ? Invalid reg pair. */
1381 OUTS (outf, allregs (dst, gd));
1383 OUTS (outf, allregs (src, gs));
1388 decode_ALU2op_0 (TIword iw0, disassemble_info *outf)
1391 +---+---+---+---|---+---+---+---|---+---+---+---|---+---+---+---+
1392 | 0 | 1 | 0 | 0 | 0 | 0 |.opc...........|.src.......|.dst.......|
1393 +---+---+---+---|---+---+---+---|---+---+---+---|---+---+---+---+ */
1394 int src = ((iw0 >> ALU2op_src_bits) & ALU2op_src_mask);
1395 int opc = ((iw0 >> ALU2op_opc_bits) & ALU2op_opc_mask);
1396 int dst = ((iw0 >> ALU2op_dst_bits) & ALU2op_dst_mask);
1400 OUTS (outf, dregs (dst));
1401 OUTS (outf, " >>>= ");
1402 OUTS (outf, dregs (src));
1406 OUTS (outf, dregs (dst));
1407 OUTS (outf, " >>= ");
1408 OUTS (outf, dregs (src));
1412 OUTS (outf, dregs (dst));
1413 OUTS (outf, " <<= ");
1414 OUTS (outf, dregs (src));
1418 OUTS (outf, dregs (dst));
1419 OUTS (outf, " *= ");
1420 OUTS (outf, dregs (src));
1424 OUTS (outf, dregs (dst));
1425 OUTS (outf, " = (");
1426 OUTS (outf, dregs (dst));
1428 OUTS (outf, dregs (src));
1429 OUTS (outf, ") << 0x1");
1433 OUTS (outf, dregs (dst));
1434 OUTS (outf, " = (");
1435 OUTS (outf, dregs (dst));
1437 OUTS (outf, dregs (src));
1438 OUTS (outf, ") << 0x2");
1442 OUTS (outf, "DIVQ (");
1443 OUTS (outf, dregs (dst));
1445 OUTS (outf, dregs (src));
1450 OUTS (outf, "DIVS (");
1451 OUTS (outf, dregs (dst));
1453 OUTS (outf, dregs (src));
1458 OUTS (outf, dregs (dst));
1460 OUTS (outf, dregs_lo (src));
1461 OUTS (outf, " (X)");
1465 OUTS (outf, dregs (dst));
1467 OUTS (outf, dregs_lo (src));
1468 OUTS (outf, " (Z)");
1472 OUTS (outf, dregs (dst));
1474 OUTS (outf, dregs_byte (src));
1475 OUTS (outf, " (X)");
1479 OUTS (outf, dregs (dst));
1481 OUTS (outf, dregs_byte (src));
1482 OUTS (outf, " (Z)");
1486 OUTS (outf, dregs (dst));
1487 OUTS (outf, " = -");
1488 OUTS (outf, dregs (src));
1492 OUTS (outf, dregs (dst));
1493 OUTS (outf, " =~ ");
1494 OUTS (outf, dregs (src));
1503 decode_PTR2op_0 (TIword iw0, disassemble_info *outf)
1506 +---+---+---+---|---+---+---+---|---+---+---+---|---+---+---+---+
1507 | 0 | 1 | 0 | 0 | 0 | 1 | 0 |.opc.......|.src.......|.dst.......|
1508 +---+---+---+---|---+---+---+---|---+---+---+---|---+---+---+---+ */
1509 int src = ((iw0 >> PTR2op_src_bits) & PTR2op_dst_mask);
1510 int opc = ((iw0 >> PTR2op_opc_bits) & PTR2op_opc_mask);
1511 int dst = ((iw0 >> PTR2op_dst_bits) & PTR2op_dst_mask);
1515 OUTS (outf, pregs (dst));
1516 OUTS (outf, " -= ");
1517 OUTS (outf, pregs (src));
1521 OUTS (outf, pregs (dst));
1523 OUTS (outf, pregs (src));
1524 OUTS (outf, " << 0x2");
1528 OUTS (outf, pregs (dst));
1530 OUTS (outf, pregs (src));
1531 OUTS (outf, " >> 0x2");
1535 OUTS (outf, pregs (dst));
1537 OUTS (outf, pregs (src));
1538 OUTS (outf, " >> 0x1");
1542 OUTS (outf, pregs (dst));
1543 OUTS (outf, " += ");
1544 OUTS (outf, pregs (src));
1545 OUTS (outf, " (BREV)");
1549 OUTS (outf, pregs (dst));
1550 OUTS (outf, " = (");
1551 OUTS (outf, pregs (dst));
1553 OUTS (outf, pregs (src));
1554 OUTS (outf, ") << 0x1");
1558 OUTS (outf, pregs (dst));
1559 OUTS (outf, " = (");
1560 OUTS (outf, pregs (dst));
1562 OUTS (outf, pregs (src));
1563 OUTS (outf, ") << 0x2");
1572 decode_LOGI2op_0 (TIword iw0, disassemble_info *outf)
1575 +---+---+---+---|---+---+---+---|---+---+---+---|---+---+---+---+
1576 | 0 | 1 | 0 | 0 | 1 |.opc.......|.src...............|.dst.......|
1577 +---+---+---+---|---+---+---+---|---+---+---+---|---+---+---+---+ */
1578 int src = ((iw0 >> LOGI2op_src_bits) & LOGI2op_src_mask);
1579 int opc = ((iw0 >> LOGI2op_opc_bits) & LOGI2op_opc_mask);
1580 int dst = ((iw0 >> LOGI2op_dst_bits) & LOGI2op_dst_mask);
1587 OUTS (outf, "CC = !BITTST (");
1588 OUTS (outf, dregs (dst));
1590 OUTS (outf, uimm5 (src));
1591 OUTS (outf, ");\t\t/* bit");
1592 OUTS (outf, imm7d (src));
1598 OUTS (outf, "CC = BITTST (");
1599 OUTS (outf, dregs (dst));
1601 OUTS (outf, uimm5 (src));
1602 OUTS (outf, ");\t\t/* bit");
1603 OUTS (outf, imm7d (src));
1609 OUTS (outf, "BITSET (");
1610 OUTS (outf, dregs (dst));
1612 OUTS (outf, uimm5 (src));
1613 OUTS (outf, ");\t\t/* bit");
1614 OUTS (outf, imm7d (src));
1620 OUTS (outf, "BITTGL (");
1621 OUTS (outf, dregs (dst));
1623 OUTS (outf, uimm5 (src));
1624 OUTS (outf, ");\t\t/* bit");
1625 OUTS (outf, imm7d (src));
1631 OUTS (outf, "BITCLR (");
1632 OUTS (outf, dregs (dst));
1634 OUTS (outf, uimm5 (src));
1635 OUTS (outf, ");\t\t/* bit");
1636 OUTS (outf, imm7d (src));
1642 OUTS (outf, dregs (dst));
1643 OUTS (outf, " >>>= ");
1644 OUTS (outf, uimm5 (src));
1648 OUTS (outf, dregs (dst));
1649 OUTS (outf, " >>= ");
1650 OUTS (outf, uimm5 (src));
1654 OUTS (outf, dregs (dst));
1655 OUTS (outf, " <<= ");
1656 OUTS (outf, uimm5 (src));
1665 decode_COMP3op_0 (TIword iw0, disassemble_info *outf)
1668 +---+---+---+---|---+---+---+---|---+---+---+---|---+---+---+---+
1669 | 0 | 1 | 0 | 1 |.opc.......|.dst.......|.src1......|.src0......|
1670 +---+---+---+---|---+---+---+---|---+---+---+---|---+---+---+---+ */
1671 int opc = ((iw0 >> COMP3op_opc_bits) & COMP3op_opc_mask);
1672 int dst = ((iw0 >> COMP3op_dst_bits) & COMP3op_dst_mask);
1673 int src0 = ((iw0 >> COMP3op_src0_bits) & COMP3op_src0_mask);
1674 int src1 = ((iw0 >> COMP3op_src1_bits) & COMP3op_src1_mask);
1676 if (opc == 5 && src1 == src0)
1678 OUTS (outf, pregs (dst));
1680 OUTS (outf, pregs (src0));
1681 OUTS (outf, " << 0x1");
1685 OUTS (outf, dregs (dst));
1687 OUTS (outf, dregs (src0));
1689 OUTS (outf, dregs (src1));
1693 OUTS (outf, dregs (dst));
1695 OUTS (outf, dregs (src0));
1697 OUTS (outf, dregs (src1));
1701 OUTS (outf, dregs (dst));
1703 OUTS (outf, dregs (src0));
1705 OUTS (outf, dregs (src1));
1709 OUTS (outf, dregs (dst));
1711 OUTS (outf, dregs (src0));
1713 OUTS (outf, dregs (src1));
1717 OUTS (outf, pregs (dst));
1719 OUTS (outf, pregs (src0));
1721 OUTS (outf, pregs (src1));
1725 OUTS (outf, pregs (dst));
1727 OUTS (outf, pregs (src0));
1728 OUTS (outf, " + (");
1729 OUTS (outf, pregs (src1));
1730 OUTS (outf, " << 0x1)");
1734 OUTS (outf, pregs (dst));
1736 OUTS (outf, pregs (src0));
1737 OUTS (outf, " + (");
1738 OUTS (outf, pregs (src1));
1739 OUTS (outf, " << 0x2)");
1743 OUTS (outf, dregs (dst));
1745 OUTS (outf, dregs (src0));
1747 OUTS (outf, dregs (src1));
1756 decode_COMPI2opD_0 (TIword iw0, disassemble_info *outf)
1759 +---+---+---+---|---+---+---+---|---+---+---+---|---+---+---+---+
1760 | 0 | 1 | 1 | 0 | 0 |.op|..src......................|.dst.......|
1761 +---+---+---+---|---+---+---+---|---+---+---+---|---+---+---+---+ */
1762 int op = ((iw0 >> COMPI2opD_op_bits) & COMPI2opD_op_mask);
1763 int dst = ((iw0 >> COMPI2opD_dst_bits) & COMPI2opD_dst_mask);
1764 int src = ((iw0 >> COMPI2opD_src_bits) & COMPI2opD_src_mask);
1766 bu32 *pval = get_allreg (0, dst);
1771 /* Since we don't have 32-bit immediate loads, we allow the disassembler
1772 to combine them, so it prints out the right values.
1773 Here we keep track of the registers. */
1776 *pval = imm7_val (src);
1778 *pval |= 0xFFFFFF80;
1785 OUTS (outf, dregs (dst));
1787 OUTS (outf, imm7 (src));
1788 OUTS (outf, " (X);\t\t/*\t\t");
1789 OUTS (outf, dregs (dst));
1791 OUTS (outf, uimm32 (*pval));
1793 OUTS (outf, imm32 (*pval));
1794 OUTS (outf, ") */");
1799 OUTS (outf, dregs (dst));
1800 OUTS (outf, " += ");
1801 OUTS (outf, imm7 (src));
1802 OUTS (outf, ";\t\t/* (");
1803 OUTS (outf, imm7d (src));
1804 OUTS (outf, ") */");
1814 decode_COMPI2opP_0 (TIword iw0, disassemble_info *outf)
1817 +---+---+---+---|---+---+---+---|---+---+---+---|---+---+---+---+
1818 | 0 | 1 | 1 | 0 | 1 |.op|.src.......................|.dst.......|
1819 +---+---+---+---|---+---+---+---|---+---+---+---|---+---+---+---+ */
1820 int op = ((iw0 >> COMPI2opP_op_bits) & COMPI2opP_op_mask);
1821 int src = ((iw0 >> COMPI2opP_src_bits) & COMPI2opP_src_mask);
1822 int dst = ((iw0 >> COMPI2opP_dst_bits) & COMPI2opP_dst_mask);
1824 bu32 *pval = get_allreg (1, dst);
1831 *pval = imm7_val (src);
1833 *pval |= 0xFFFFFF80;
1840 OUTS (outf, pregs (dst));
1842 OUTS (outf, imm7 (src));
1843 OUTS (outf, " (X);\t\t/*\t\t");
1844 OUTS (outf, pregs (dst));
1846 OUTS (outf, uimm32 (*pval));
1848 OUTS (outf, imm32 (*pval));
1849 OUTS (outf, ") */");
1854 OUTS (outf, pregs (dst));
1855 OUTS (outf, " += ");
1856 OUTS (outf, imm7 (src));
1857 OUTS (outf, ";\t\t/* (");
1858 OUTS (outf, imm7d (src));
1859 OUTS (outf, ") */");
1869 decode_LDSTpmod_0 (TIword iw0, disassemble_info *outf)
1872 +---+---+---+---|---+---+---+---|---+---+---+---|---+---+---+---+
1873 | 1 | 0 | 0 | 0 |.W.|.aop...|.reg.......|.idx.......|.ptr.......|
1874 +---+---+---+---|---+---+---+---|---+---+---+---|---+---+---+---+ */
1875 int W = ((iw0 >> LDSTpmod_W_bits) & LDSTpmod_W_mask);
1876 int aop = ((iw0 >> LDSTpmod_aop_bits) & LDSTpmod_aop_mask);
1877 int idx = ((iw0 >> LDSTpmod_idx_bits) & LDSTpmod_idx_mask);
1878 int ptr = ((iw0 >> LDSTpmod_ptr_bits) & LDSTpmod_ptr_mask);
1879 int reg = ((iw0 >> LDSTpmod_reg_bits) & LDSTpmod_reg_mask);
1881 if (aop == 1 && W == 0 && idx == ptr)
1883 OUTS (outf, dregs_lo (reg));
1884 OUTS (outf, " = W[");
1885 OUTS (outf, pregs (ptr));
1888 else if (aop == 2 && W == 0 && idx == ptr)
1890 OUTS (outf, dregs_hi (reg));
1891 OUTS (outf, " = W[");
1892 OUTS (outf, pregs (ptr));
1895 else if (aop == 1 && W == 1 && idx == ptr)
1898 OUTS (outf, pregs (ptr));
1899 OUTS (outf, "] = ");
1900 OUTS (outf, dregs_lo (reg));
1902 else if (aop == 2 && W == 1 && idx == ptr)
1905 OUTS (outf, pregs (ptr));
1906 OUTS (outf, "] = ");
1907 OUTS (outf, dregs_hi (reg));
1909 else if (aop == 0 && W == 0)
1911 OUTS (outf, dregs (reg));
1912 OUTS (outf, " = [");
1913 OUTS (outf, pregs (ptr));
1914 OUTS (outf, " ++ ");
1915 OUTS (outf, pregs (idx));
1918 else if (aop == 1 && W == 0)
1920 OUTS (outf, dregs_lo (reg));
1921 OUTS (outf, " = W[");
1922 OUTS (outf, pregs (ptr));
1923 OUTS (outf, " ++ ");
1924 OUTS (outf, pregs (idx));
1927 else if (aop == 2 && W == 0)
1929 OUTS (outf, dregs_hi (reg));
1930 OUTS (outf, " = W[");
1931 OUTS (outf, pregs (ptr));
1932 OUTS (outf, " ++ ");
1933 OUTS (outf, pregs (idx));
1936 else if (aop == 3 && W == 0)
1938 OUTS (outf, dregs (reg));
1939 OUTS (outf, " = W[");
1940 OUTS (outf, pregs (ptr));
1941 OUTS (outf, " ++ ");
1942 OUTS (outf, pregs (idx));
1943 OUTS (outf, "] (Z)");
1945 else if (aop == 3 && W == 1)
1947 OUTS (outf, dregs (reg));
1948 OUTS (outf, " = W[");
1949 OUTS (outf, pregs (ptr));
1950 OUTS (outf, " ++ ");
1951 OUTS (outf, pregs (idx));
1952 OUTS (outf, "] (X)");
1954 else if (aop == 0 && W == 1)
1957 OUTS (outf, pregs (ptr));
1958 OUTS (outf, " ++ ");
1959 OUTS (outf, pregs (idx));
1960 OUTS (outf, "] = ");
1961 OUTS (outf, dregs (reg));
1963 else if (aop == 1 && W == 1)
1966 OUTS (outf, pregs (ptr));
1967 OUTS (outf, " ++ ");
1968 OUTS (outf, pregs (idx));
1969 OUTS (outf, "] = ");
1970 OUTS (outf, dregs_lo (reg));
1972 else if (aop == 2 && W == 1)
1975 OUTS (outf, pregs (ptr));
1976 OUTS (outf, " ++ ");
1977 OUTS (outf, pregs (idx));
1978 OUTS (outf, "] = ");
1979 OUTS (outf, dregs_hi (reg));
1988 decode_dagMODim_0 (TIword iw0, disassemble_info *outf)
1991 +---+---+---+---|---+---+---+---|---+---+---+---|---+---+---+---+
1992 | 1 | 0 | 0 | 1 | 1 | 1 | 1 | 0 |.br| 1 | 1 |.op|.m.....|.i.....|
1993 +---+---+---+---|---+---+---+---|---+---+---+---|---+---+---+---+ */
1994 int i = ((iw0 >> DagMODim_i_bits) & DagMODim_i_mask);
1995 int m = ((iw0 >> DagMODim_m_bits) & DagMODim_m_mask);
1996 int br = ((iw0 >> DagMODim_br_bits) & DagMODim_br_mask);
1997 int op = ((iw0 >> DagMODim_op_bits) & DagMODim_op_mask);
1999 if (op == 0 && br == 1)
2001 OUTS (outf, iregs (i));
2002 OUTS (outf, " += ");
2003 OUTS (outf, mregs (m));
2004 OUTS (outf, " (BREV)");
2008 OUTS (outf, iregs (i));
2009 OUTS (outf, " += ");
2010 OUTS (outf, mregs (m));
2012 else if (op == 1 && br == 0)
2014 OUTS (outf, iregs (i));
2015 OUTS (outf, " -= ");
2016 OUTS (outf, mregs (m));
2025 decode_dagMODik_0 (TIword iw0, disassemble_info *outf)
2028 +---+---+---+---|---+---+---+---|---+---+---+---|---+---+---+---+
2029 | 1 | 0 | 0 | 1 | 1 | 1 | 1 | 1 | 0 | 1 | 1 | 0 |.op....|.i.....|
2030 +---+---+---+---|---+---+---+---|---+---+---+---|---+---+---+---+ */
2031 int i = ((iw0 >> DagMODik_i_bits) & DagMODik_i_mask);
2032 int op = ((iw0 >> DagMODik_op_bits) & DagMODik_op_mask);
2036 OUTS (outf, iregs (i));
2037 OUTS (outf, " += 0x2");
2041 OUTS (outf, iregs (i));
2042 OUTS (outf, " -= 0x2");
2046 OUTS (outf, iregs (i));
2047 OUTS (outf, " += 0x4");
2051 OUTS (outf, iregs (i));
2052 OUTS (outf, " -= 0x4");
2059 OUTS (outf, ";\t\t/* ( ");
2060 if (op == 0 || op == 1)
2062 else if (op == 2 || op == 3)
2064 OUTS (outf, ") */");
2072 decode_dspLDST_0 (TIword iw0, disassemble_info *outf)
2075 +---+---+---+---|---+---+---+---|---+---+---+---|---+---+---+---+
2076 | 1 | 0 | 0 | 1 | 1 | 1 |.W.|.aop...|.m.....|.i.....|.reg.......|
2077 +---+---+---+---|---+---+---+---|---+---+---+---|---+---+---+---+ */
2078 int i = ((iw0 >> DspLDST_i_bits) & DspLDST_i_mask);
2079 int m = ((iw0 >> DspLDST_m_bits) & DspLDST_m_mask);
2080 int W = ((iw0 >> DspLDST_W_bits) & DspLDST_W_mask);
2081 int aop = ((iw0 >> DspLDST_aop_bits) & DspLDST_aop_mask);
2082 int reg = ((iw0 >> DspLDST_reg_bits) & DspLDST_reg_mask);
2084 if (aop == 0 && W == 0 && m == 0)
2086 OUTS (outf, dregs (reg));
2087 OUTS (outf, " = [");
2088 OUTS (outf, iregs (i));
2091 else if (aop == 0 && W == 0 && m == 1)
2093 OUTS (outf, dregs_lo (reg));
2094 OUTS (outf, " = W[");
2095 OUTS (outf, iregs (i));
2098 else if (aop == 0 && W == 0 && m == 2)
2100 OUTS (outf, dregs_hi (reg));
2101 OUTS (outf, " = W[");
2102 OUTS (outf, iregs (i));
2105 else if (aop == 1 && W == 0 && m == 0)
2107 OUTS (outf, dregs (reg));
2108 OUTS (outf, " = [");
2109 OUTS (outf, iregs (i));
2112 else if (aop == 1 && W == 0 && m == 1)
2114 OUTS (outf, dregs_lo (reg));
2115 OUTS (outf, " = W[");
2116 OUTS (outf, iregs (i));
2119 else if (aop == 1 && W == 0 && m == 2)
2121 OUTS (outf, dregs_hi (reg));
2122 OUTS (outf, " = W[");
2123 OUTS (outf, iregs (i));
2126 else if (aop == 2 && W == 0 && m == 0)
2128 OUTS (outf, dregs (reg));
2129 OUTS (outf, " = [");
2130 OUTS (outf, iregs (i));
2133 else if (aop == 2 && W == 0 && m == 1)
2135 OUTS (outf, dregs_lo (reg));
2136 OUTS (outf, " = W[");
2137 OUTS (outf, iregs (i));
2140 else if (aop == 2 && W == 0 && m == 2)
2142 OUTS (outf, dregs_hi (reg));
2143 OUTS (outf, " = W[");
2144 OUTS (outf, iregs (i));
2147 else if (aop == 0 && W == 1 && m == 0)
2150 OUTS (outf, iregs (i));
2151 OUTS (outf, "++] = ");
2152 OUTS (outf, dregs (reg));
2154 else if (aop == 0 && W == 1 && m == 1)
2157 OUTS (outf, iregs (i));
2158 OUTS (outf, "++] = ");
2159 OUTS (outf, dregs_lo (reg));
2161 else if (aop == 0 && W == 1 && m == 2)
2164 OUTS (outf, iregs (i));
2165 OUTS (outf, "++] = ");
2166 OUTS (outf, dregs_hi (reg));
2168 else if (aop == 1 && W == 1 && m == 0)
2171 OUTS (outf, iregs (i));
2172 OUTS (outf, "--] = ");
2173 OUTS (outf, dregs (reg));
2175 else if (aop == 1 && W == 1 && m == 1)
2178 OUTS (outf, iregs (i));
2179 OUTS (outf, "--] = ");
2180 OUTS (outf, dregs_lo (reg));
2182 else if (aop == 1 && W == 1 && m == 2)
2185 OUTS (outf, iregs (i));
2186 OUTS (outf, "--] = ");
2187 OUTS (outf, dregs_hi (reg));
2189 else if (aop == 2 && W == 1 && m == 0)
2192 OUTS (outf, iregs (i));
2193 OUTS (outf, "] = ");
2194 OUTS (outf, dregs (reg));
2196 else if (aop == 2 && W == 1 && m == 1)
2199 OUTS (outf, iregs (i));
2200 OUTS (outf, "] = ");
2201 OUTS (outf, dregs_lo (reg));
2203 else if (aop == 2 && W == 1 && m == 2)
2206 OUTS (outf, iregs (i));
2207 OUTS (outf, "] = ");
2208 OUTS (outf, dregs_hi (reg));
2210 else if (aop == 3 && W == 0)
2212 OUTS (outf, dregs (reg));
2213 OUTS (outf, " = [");
2214 OUTS (outf, iregs (i));
2215 OUTS (outf, " ++ ");
2216 OUTS (outf, mregs (m));
2219 else if (aop == 3 && W == 1)
2222 OUTS (outf, iregs (i));
2223 OUTS (outf, " ++ ");
2224 OUTS (outf, mregs (m));
2225 OUTS (outf, "] = ");
2226 OUTS (outf, dregs (reg));
2235 decode_LDST_0 (TIword iw0, disassemble_info *outf)
2238 +---+---+---+---|---+---+---+---|---+---+---+---|---+---+---+---+
2239 | 1 | 0 | 0 | 1 |.sz....|.W.|.aop...|.Z.|.ptr.......|.reg.......|
2240 +---+---+---+---|---+---+---+---|---+---+---+---|---+---+---+---+ */
2241 int Z = ((iw0 >> LDST_Z_bits) & LDST_Z_mask);
2242 int W = ((iw0 >> LDST_W_bits) & LDST_W_mask);
2243 int sz = ((iw0 >> LDST_sz_bits) & LDST_sz_mask);
2244 int aop = ((iw0 >> LDST_aop_bits) & LDST_aop_mask);
2245 int reg = ((iw0 >> LDST_reg_bits) & LDST_reg_mask);
2246 int ptr = ((iw0 >> LDST_ptr_bits) & LDST_ptr_mask);
2248 if (aop == 0 && sz == 0 && Z == 0 && W == 0)
2250 OUTS (outf, dregs (reg));
2251 OUTS (outf, " = [");
2252 OUTS (outf, pregs (ptr));
2255 else if (aop == 0 && sz == 0 && Z == 1 && W == 0 && reg != ptr)
2257 OUTS (outf, pregs (reg));
2258 OUTS (outf, " = [");
2259 OUTS (outf, pregs (ptr));
2262 else if (aop == 0 && sz == 1 && Z == 0 && W == 0)
2264 OUTS (outf, dregs (reg));
2265 OUTS (outf, " = W[");
2266 OUTS (outf, pregs (ptr));
2267 OUTS (outf, "++] (Z)");
2269 else if (aop == 0 && sz == 1 && Z == 1 && W == 0)
2271 OUTS (outf, dregs (reg));
2272 OUTS (outf, " = W[");
2273 OUTS (outf, pregs (ptr));
2274 OUTS (outf, "++] (X)");
2276 else if (aop == 0 && sz == 2 && Z == 0 && W == 0)
2278 OUTS (outf, dregs (reg));
2279 OUTS (outf, " = B[");
2280 OUTS (outf, pregs (ptr));
2281 OUTS (outf, "++] (Z)");
2283 else if (aop == 0 && sz == 2 && Z == 1 && W == 0)
2285 OUTS (outf, dregs (reg));
2286 OUTS (outf, " = B[");
2287 OUTS (outf, pregs (ptr));
2288 OUTS (outf, "++] (X)");
2290 else if (aop == 1 && sz == 0 && Z == 0 && W == 0)
2292 OUTS (outf, dregs (reg));
2293 OUTS (outf, " = [");
2294 OUTS (outf, pregs (ptr));
2297 else if (aop == 1 && sz == 0 && Z == 1 && W == 0 && reg != ptr)
2299 OUTS (outf, pregs (reg));
2300 OUTS (outf, " = [");
2301 OUTS (outf, pregs (ptr));
2304 else if (aop == 1 && sz == 1 && Z == 0 && W == 0)
2306 OUTS (outf, dregs (reg));
2307 OUTS (outf, " = W[");
2308 OUTS (outf, pregs (ptr));
2309 OUTS (outf, "--] (Z)");
2311 else if (aop == 1 && sz == 1 && Z == 1 && W == 0)
2313 OUTS (outf, dregs (reg));
2314 OUTS (outf, " = W[");
2315 OUTS (outf, pregs (ptr));
2316 OUTS (outf, "--] (X)");
2318 else if (aop == 1 && sz == 2 && Z == 0 && W == 0)
2320 OUTS (outf, dregs (reg));
2321 OUTS (outf, " = B[");
2322 OUTS (outf, pregs (ptr));
2323 OUTS (outf, "--] (Z)");
2325 else if (aop == 1 && sz == 2 && Z == 1 && W == 0)
2327 OUTS (outf, dregs (reg));
2328 OUTS (outf, " = B[");
2329 OUTS (outf, pregs (ptr));
2330 OUTS (outf, "--] (X)");
2332 else if (aop == 2 && sz == 0 && Z == 0 && W == 0)
2334 OUTS (outf, dregs (reg));
2335 OUTS (outf, " = [");
2336 OUTS (outf, pregs (ptr));
2339 else if (aop == 2 && sz == 0 && Z == 1 && W == 0)
2341 OUTS (outf, pregs (reg));
2342 OUTS (outf, " = [");
2343 OUTS (outf, pregs (ptr));
2346 else if (aop == 2 && sz == 1 && Z == 0 && W == 0)
2348 OUTS (outf, dregs (reg));
2349 OUTS (outf, " = W[");
2350 OUTS (outf, pregs (ptr));
2351 OUTS (outf, "] (Z)");
2353 else if (aop == 2 && sz == 1 && Z == 1 && W == 0)
2355 OUTS (outf, dregs (reg));
2356 OUTS (outf, " = W[");
2357 OUTS (outf, pregs (ptr));
2358 OUTS (outf, "] (X)");
2360 else if (aop == 2 && sz == 2 && Z == 0 && W == 0)
2362 OUTS (outf, dregs (reg));
2363 OUTS (outf, " = B[");
2364 OUTS (outf, pregs (ptr));
2365 OUTS (outf, "] (Z)");
2367 else if (aop == 2 && sz == 2 && Z == 1 && W == 0)
2369 OUTS (outf, dregs (reg));
2370 OUTS (outf, " = B[");
2371 OUTS (outf, pregs (ptr));
2372 OUTS (outf, "] (X)");
2374 else if (aop == 0 && sz == 0 && Z == 0 && W == 1)
2377 OUTS (outf, pregs (ptr));
2378 OUTS (outf, "++] = ");
2379 OUTS (outf, dregs (reg));
2381 else if (aop == 0 && sz == 0 && Z == 1 && W == 1)
2384 OUTS (outf, pregs (ptr));
2385 OUTS (outf, "++] = ");
2386 OUTS (outf, pregs (reg));
2388 else if (aop == 0 && sz == 1 && Z == 0 && W == 1)
2391 OUTS (outf, pregs (ptr));
2392 OUTS (outf, "++] = ");
2393 OUTS (outf, dregs (reg));
2395 else if (aop == 0 && sz == 2 && Z == 0 && W == 1)
2398 OUTS (outf, pregs (ptr));
2399 OUTS (outf, "++] = ");
2400 OUTS (outf, dregs (reg));
2402 else if (aop == 1 && sz == 0 && Z == 0 && W == 1)
2405 OUTS (outf, pregs (ptr));
2406 OUTS (outf, "--] = ");
2407 OUTS (outf, dregs (reg));
2409 else if (aop == 1 && sz == 0 && Z == 1 && W == 1)
2412 OUTS (outf, pregs (ptr));
2413 OUTS (outf, "--] = ");
2414 OUTS (outf, pregs (reg));
2416 else if (aop == 1 && sz == 1 && Z == 0 && W == 1)
2419 OUTS (outf, pregs (ptr));
2420 OUTS (outf, "--] = ");
2421 OUTS (outf, dregs (reg));
2423 else if (aop == 1 && sz == 2 && Z == 0 && W == 1)
2426 OUTS (outf, pregs (ptr));
2427 OUTS (outf, "--] = ");
2428 OUTS (outf, dregs (reg));
2430 else if (aop == 2 && sz == 0 && Z == 0 && W == 1)
2433 OUTS (outf, pregs (ptr));
2434 OUTS (outf, "] = ");
2435 OUTS (outf, dregs (reg));
2437 else if (aop == 2 && sz == 0 && Z == 1 && W == 1)
2440 OUTS (outf, pregs (ptr));
2441 OUTS (outf, "] = ");
2442 OUTS (outf, pregs (reg));
2444 else if (aop == 2 && sz == 1 && Z == 0 && W == 1)
2447 OUTS (outf, pregs (ptr));
2448 OUTS (outf, "] = ");
2449 OUTS (outf, dregs (reg));
2451 else if (aop == 2 && sz == 2 && Z == 0 && W == 1)
2454 OUTS (outf, pregs (ptr));
2455 OUTS (outf, "] = ");
2456 OUTS (outf, dregs (reg));
2465 decode_LDSTiiFP_0 (TIword iw0, disassemble_info *outf)
2468 +---+---+---+---|---+---+---+---|---+---+---+---|---+---+---+---+
2469 | 1 | 0 | 1 | 1 | 1 | 0 |.W.|.offset............|.reg...........|
2470 +---+---+---+---|---+---+---+---|---+---+---+---|---+---+---+---+ */
2471 int reg = ((iw0 >> LDSTiiFP_reg_bits) & LDSTiiFP_reg_mask);
2472 int offset = ((iw0 >> LDSTiiFP_offset_bits) & LDSTiiFP_offset_mask);
2473 int W = ((iw0 >> LDSTiiFP_W_bits) & LDSTiiFP_W_mask);
2477 OUTS (outf, dpregs (reg));
2478 OUTS (outf, " = [FP ");
2479 OUTS (outf, negimm5s4 (offset));
2484 OUTS (outf, "[FP ");
2485 OUTS (outf, negimm5s4 (offset));
2486 OUTS (outf, "] = ");
2487 OUTS (outf, dpregs (reg));
2496 decode_LDSTii_0 (TIword iw0, disassemble_info *outf)
2499 +---+---+---+---|---+---+---+---|---+---+---+---|---+---+---+---+
2500 | 1 | 0 | 1 |.W.|.op....|.offset........|.ptr.......|.reg.......|
2501 +---+---+---+---|---+---+---+---|---+---+---+---|---+---+---+---+ */
2502 int reg = ((iw0 >> LDSTii_reg_bit) & LDSTii_reg_mask);
2503 int ptr = ((iw0 >> LDSTii_ptr_bit) & LDSTii_ptr_mask);
2504 int offset = ((iw0 >> LDSTii_offset_bit) & LDSTii_offset_mask);
2505 int op = ((iw0 >> LDSTii_op_bit) & LDSTii_op_mask);
2506 int W = ((iw0 >> LDSTii_W_bit) & LDSTii_W_mask);
2508 if (W == 0 && op == 0)
2510 OUTS (outf, dregs (reg));
2511 OUTS (outf, " = [");
2512 OUTS (outf, pregs (ptr));
2514 OUTS (outf, uimm4s4 (offset));
2517 else if (W == 0 && op == 1)
2519 OUTS (outf, dregs (reg));
2520 OUTS (outf, " = W[");
2521 OUTS (outf, pregs (ptr));
2523 OUTS (outf, uimm4s2 (offset));
2524 OUTS (outf, "] (Z)");
2526 else if (W == 0 && op == 2)
2528 OUTS (outf, dregs (reg));
2529 OUTS (outf, " = W[");
2530 OUTS (outf, pregs (ptr));
2532 OUTS (outf, uimm4s2 (offset));
2533 OUTS (outf, "] (X)");
2535 else if (W == 0 && op == 3)
2537 OUTS (outf, pregs (reg));
2538 OUTS (outf, " = [");
2539 OUTS (outf, pregs (ptr));
2541 OUTS (outf, uimm4s4 (offset));
2544 else if (W == 1 && op == 0)
2547 OUTS (outf, pregs (ptr));
2549 OUTS (outf, uimm4s4 (offset));
2550 OUTS (outf, "] = ");
2551 OUTS (outf, dregs (reg));
2553 else if (W == 1 && op == 1)
2556 OUTS (outf, pregs (ptr));
2558 OUTS (outf, uimm4s2 (offset));
2559 OUTS (outf, "] = ");
2560 OUTS (outf, dregs (reg));
2562 else if (W == 1 && op == 3)
2565 OUTS (outf, pregs (ptr));
2567 OUTS (outf, uimm4s4 (offset));
2568 OUTS (outf, "] = ");
2569 OUTS (outf, pregs (reg));
2578 decode_LoopSetup_0 (TIword iw0, TIword iw1, bfd_vma pc, disassemble_info *outf)
2581 +---+---+---+---|---+---+---+---|---+---+---+---|---+---+---+---+
2582 | 1 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 1 |.rop...|.c.|.soffset.......|
2583 |.reg...........| - | - |.eoffset...............................|
2584 +---+---+---+---|---+---+---+---|---+---+---+---|---+---+---+---+ */
2585 int c = ((iw0 >> (LoopSetup_c_bits - 16)) & LoopSetup_c_mask);
2586 int reg = ((iw1 >> LoopSetup_reg_bits) & LoopSetup_reg_mask);
2587 int rop = ((iw0 >> (LoopSetup_rop_bits - 16)) & LoopSetup_rop_mask);
2588 int soffset = ((iw0 >> (LoopSetup_soffset_bits - 16)) & LoopSetup_soffset_mask);
2589 int eoffset = ((iw1 >> LoopSetup_eoffset_bits) & LoopSetup_eoffset_mask);
2599 OUTS (outf, "LSETUP");
2601 OUTS (outf, pcrel4 (soffset));
2602 OUTS (outf, ", 0x");
2603 OUTS (outf, lppcrel10 (eoffset));
2605 OUTS (outf, counters (c));
2609 OUTS (outf, "LSETUP");
2611 OUTS (outf, pcrel4 (soffset));
2612 OUTS (outf, ", 0x");
2613 OUTS (outf, lppcrel10 (eoffset));
2615 OUTS (outf, counters (c));
2617 OUTS (outf, pregs (reg));
2621 OUTS (outf, "LSETUP");
2623 OUTS (outf, pcrel4 (soffset));
2624 OUTS (outf, ", 0x");
2625 OUTS (outf, lppcrel10 (eoffset));
2627 OUTS (outf, counters (c));
2629 OUTS (outf, pregs (reg));
2630 OUTS (outf, " >> 0x1");
2639 decode_LDIMMhalf_0 (TIword iw0, TIword iw1, disassemble_info *outf)
2642 +---+---+---+---|---+---+---+---|---+---+---+---|---+---+---+---+
2643 | 1 | 1 | 1 | 0 | 0 | 0 | 0 | 1 |.Z.|.H.|.S.|.grp...|.reg.......|
2644 |.hword.........................................................|
2645 +---+---+---+---|---+---+---+---|---+---+---+---|---+---+---+---+ */
2646 int H = ((iw0 >> (LDIMMhalf_H_bits - 16)) & LDIMMhalf_H_mask);
2647 int Z = ((iw0 >> (LDIMMhalf_Z_bits - 16)) & LDIMMhalf_Z_mask);
2648 int S = ((iw0 >> (LDIMMhalf_S_bits - 16)) & LDIMMhalf_S_mask);
2649 int reg = ((iw0 >> (LDIMMhalf_reg_bits - 16)) & LDIMMhalf_reg_mask);
2650 int grp = ((iw0 >> (LDIMMhalf_grp_bits - 16)) & LDIMMhalf_grp_mask);
2651 int hword = ((iw1 >> LDIMMhalf_hword_bits) & LDIMMhalf_hword_mask);
2653 bu32 *pval = get_allreg (grp, reg);
2658 /* Since we don't have 32-bit immediate loads, we allow the disassembler
2659 to combine them, so it prints out the right values.
2660 Here we keep track of the registers. */
2661 if (H == 0 && S == 1 && Z == 0)
2663 /* regs = imm16 (x) */
2664 *pval = imm16_val (hword);
2666 *pval |= 0xFFFF0000;
2670 else if (H == 0 && S == 0 && Z == 1)
2672 /* regs = luimm16 (Z) */
2673 *pval = luimm16_val (hword);
2676 else if (H == 0 && S == 0 && Z == 0)
2678 /* regs_lo = luimm16 */
2679 *pval &= 0xFFFF0000;
2680 *pval |= luimm16_val (hword);
2682 else if (H == 1 && S == 0 && Z == 0)
2684 /* regs_hi = huimm16 */
2686 *pval |= luimm16_val (hword) << 16;
2689 /* Here we do the disassembly */
2690 if (grp == 0 && H == 0 && S == 0 && Z == 0)
2692 OUTS (outf, dregs_lo (reg));
2694 OUTS (outf, uimm16 (hword));
2696 else if (grp == 0 && H == 1 && S == 0 && Z == 0)
2698 OUTS (outf, dregs_hi (reg));
2700 OUTS (outf, uimm16 (hword));
2702 else if (grp == 0 && H == 0 && S == 1 && Z == 0)
2704 OUTS (outf, dregs (reg));
2706 OUTS (outf, imm16 (hword));
2707 OUTS (outf, " (X)");
2709 else if (H == 0 && S == 1 && Z == 0)
2711 OUTS (outf, regs (reg, grp));
2713 OUTS (outf, imm16 (hword));
2714 OUTS (outf, " (X)");
2716 else if (H == 0 && S == 0 && Z == 1)
2718 OUTS (outf, regs (reg, grp));
2720 OUTS (outf, uimm16 (hword));
2721 OUTS (outf, " (Z)");
2723 else if (H == 0 && S == 0 && Z == 0)
2725 OUTS (outf, regs_lo (reg, grp));
2727 OUTS (outf, uimm16 (hword));
2729 else if (H == 1 && S == 0 && Z == 0)
2731 OUTS (outf, regs_hi (reg, grp));
2733 OUTS (outf, uimm16 (hword));
2738 /* And we print out the 32-bit value if it is a pointer. */
2739 if (S == 0 && Z == 0)
2741 OUTS (outf, ";\t\t/* (");
2742 OUTS (outf, imm16d (hword));
2745 /* If it is an MMR, don't print the symbol. */
2746 if (*pval < 0xFFC00000 && grp == 1)
2748 OUTS (outf, regs (reg, grp));
2750 OUTS (outf, huimm32e (*pval));
2754 OUTS (outf, regs (reg, grp));
2756 OUTS (outf, huimm32e (*pval));
2758 OUTS (outf, imm32 (*pval));
2765 if (S == 1 || Z == 1)
2767 OUTS (outf, ";\t\t/*\t\t");
2768 OUTS (outf, regs (reg, grp));
2770 OUTS (outf, huimm32e (*pval));
2772 OUTS (outf, imm32 (*pval));
2773 OUTS (outf, ") */");
2780 decode_CALLa_0 (TIword iw0, TIword iw1, bfd_vma pc, disassemble_info *outf)
2783 +---+---+---+---|---+---+---+---|---+---+---+---|---+---+---+---+
2784 | 1 | 1 | 1 | 0 | 0 | 0 | 1 |.S.|.msw...........................|
2785 |.lsw...........................................................|
2786 +---+---+---+---|---+---+---+---|---+---+---+---|---+---+---+---+ */
2787 int S = ((iw0 >> (CALLa_S_bits - 16)) & CALLa_S_mask);
2788 int lsw = ((iw1 >> 0) & 0xffff);
2789 int msw = ((iw0 >> 0) & 0xff);
2795 OUTS (outf, "CALL 0x");
2797 OUTS (outf, "JUMP.L 0x");
2801 OUTS (outf, pcrel24 (((msw) << 16) | (lsw)));
2806 decode_LDSTidxI_0 (TIword iw0, TIword iw1, disassemble_info *outf)
2809 +---+---+---+---|---+---+---+---|---+---+---+---|---+---+---+---+
2810 | 1 | 1 | 1 | 0 | 0 | 1 |.W.|.Z.|.sz....|.ptr.......|.reg.......|
2811 |.offset........................................................|
2812 +---+---+---+---|---+---+---+---|---+---+---+---|---+---+---+---+ */
2813 int Z = ((iw0 >> (LDSTidxI_Z_bits - 16)) & LDSTidxI_Z_mask);
2814 int W = ((iw0 >> (LDSTidxI_W_bits - 16)) & LDSTidxI_W_mask);
2815 int sz = ((iw0 >> (LDSTidxI_sz_bits - 16)) & LDSTidxI_sz_mask);
2816 int reg = ((iw0 >> (LDSTidxI_reg_bits - 16)) & LDSTidxI_reg_mask);
2817 int ptr = ((iw0 >> (LDSTidxI_ptr_bits - 16)) & LDSTidxI_ptr_mask);
2818 int offset = ((iw1 >> LDSTidxI_offset_bits) & LDSTidxI_offset_mask);
2820 if (W == 0 && sz == 0 && Z == 0)
2822 OUTS (outf, dregs (reg));
2823 OUTS (outf, " = [");
2824 OUTS (outf, pregs (ptr));
2826 OUTS (outf, imm16s4 (offset));
2829 else if (W == 0 && sz == 0 && Z == 1)
2831 OUTS (outf, pregs (reg));
2832 OUTS (outf, " = [");
2833 OUTS (outf, pregs (ptr));
2835 OUTS (outf, imm16s4 (offset));
2838 else if (W == 0 && sz == 1 && Z == 0)
2840 OUTS (outf, dregs (reg));
2841 OUTS (outf, " = W[");
2842 OUTS (outf, pregs (ptr));
2844 OUTS (outf, imm16s2 (offset));
2845 OUTS (outf, "] (Z)");
2847 else if (W == 0 && sz == 1 && Z == 1)
2849 OUTS (outf, dregs (reg));
2850 OUTS (outf, " = W[");
2851 OUTS (outf, pregs (ptr));
2853 OUTS (outf, imm16s2 (offset));
2854 OUTS (outf, "] (X)");
2856 else if (W == 0 && sz == 2 && Z == 0)
2858 OUTS (outf, dregs (reg));
2859 OUTS (outf, " = B[");
2860 OUTS (outf, pregs (ptr));
2862 OUTS (outf, imm16 (offset));
2863 OUTS (outf, "] (Z)");
2865 else if (W == 0 && sz == 2 && Z == 1)
2867 OUTS (outf, dregs (reg));
2868 OUTS (outf, " = B[");
2869 OUTS (outf, pregs (ptr));
2871 OUTS (outf, imm16 (offset));
2872 OUTS (outf, "] (X)");
2874 else if (W == 1 && sz == 0 && Z == 0)
2877 OUTS (outf, pregs (ptr));
2879 OUTS (outf, imm16s4 (offset));
2880 OUTS (outf, "] = ");
2881 OUTS (outf, dregs (reg));
2883 else if (W == 1 && sz == 0 && Z == 1)
2886 OUTS (outf, pregs (ptr));
2888 OUTS (outf, imm16s4 (offset));
2889 OUTS (outf, "] = ");
2890 OUTS (outf, pregs (reg));
2892 else if (W == 1 && sz == 1 && Z == 0)
2895 OUTS (outf, pregs (ptr));
2897 OUTS (outf, imm16s2 (offset));
2898 OUTS (outf, "] = ");
2899 OUTS (outf, dregs (reg));
2901 else if (W == 1 && sz == 2 && Z == 0)
2904 OUTS (outf, pregs (ptr));
2906 OUTS (outf, imm16 (offset));
2907 OUTS (outf, "] = ");
2908 OUTS (outf, dregs (reg));
2917 decode_linkage_0 (TIword iw0, TIword iw1, disassemble_info *outf)
2920 +---+---+---+---|---+---+---+---|---+---+---+---|---+---+---+---+
2921 | 1 | 1 | 1 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |.R.|
2922 |.framesize.....................................................|
2923 +---+---+---+---|---+---+---+---|---+---+---+---|---+---+---+---+ */
2924 int R = ((iw0 >> (Linkage_R_bits - 16)) & Linkage_R_mask);
2925 int framesize = ((iw1 >> Linkage_framesize_bits) & Linkage_framesize_mask);
2932 OUTS (outf, "LINK ");
2933 OUTS (outf, uimm16s4 (framesize));
2934 OUTS (outf, ";\t\t/* (");
2935 OUTS (outf, uimm16s4d (framesize));
2936 OUTS (outf, ") */");
2940 OUTS (outf, "UNLINK");
2948 decode_dsp32mac_0 (TIword iw0, TIword iw1, disassemble_info *outf)
2951 +---+---+---+---|---+---+---+---|---+---+---+---|---+---+---+---+
2952 | 1 | 1 | 0 | 0 |.M.| 0 | 0 |.mmod..........|.MM|.P.|.w1|.op1...|
2953 |.h01|.h11|.w0|.op0...|.h00|.h10|.dst.......|.src0......|.src1..|
2954 +---+---+---+---|---+---+---+---|---+---+---+---|---+---+---+---+ */
2955 int op1 = ((iw0 >> (DSP32Mac_op1_bits - 16)) & DSP32Mac_op1_mask);
2956 int w1 = ((iw0 >> (DSP32Mac_w1_bits - 16)) & DSP32Mac_w1_mask);
2957 int P = ((iw0 >> (DSP32Mac_p_bits - 16)) & DSP32Mac_p_mask);
2958 int MM = ((iw0 >> (DSP32Mac_MM_bits - 16)) & DSP32Mac_MM_mask);
2959 int mmod = ((iw0 >> (DSP32Mac_mmod_bits - 16)) & DSP32Mac_mmod_mask);
2960 int w0 = ((iw1 >> DSP32Mac_w0_bits) & DSP32Mac_w0_mask);
2961 int src0 = ((iw1 >> DSP32Mac_src0_bits) & DSP32Mac_src0_mask);
2962 int src1 = ((iw1 >> DSP32Mac_src1_bits) & DSP32Mac_src1_mask);
2963 int dst = ((iw1 >> DSP32Mac_dst_bits) & DSP32Mac_dst_mask);
2964 int h10 = ((iw1 >> DSP32Mac_h10_bits) & DSP32Mac_h10_mask);
2965 int h00 = ((iw1 >> DSP32Mac_h00_bits) & DSP32Mac_h00_mask);
2966 int op0 = ((iw1 >> DSP32Mac_op0_bits) & DSP32Mac_op0_mask);
2967 int h11 = ((iw1 >> DSP32Mac_h11_bits) & DSP32Mac_h11_mask);
2968 int h01 = ((iw1 >> DSP32Mac_h01_bits) & DSP32Mac_h01_mask);
2970 if (w0 == 0 && w1 == 0 && op1 == 3 && op0 == 3)
2976 if ((w1 || w0) && mmod == M_W32)
2979 if (((1 << mmod) & (P ? 0x131b : 0x1b5f)) == 0)
2982 if (w1 == 1 || op1 != 3)
2985 OUTS (outf, P ? dregs (dst + 1) : dregs_hi (dst));
2988 OUTS (outf, " = A1");
2992 OUTS (outf, " = (");
2993 decode_macfunc (1, op1, h01, h11, src0, src1, outf);
2998 if (w0 == 1 || op0 != 3)
3001 OUTS (outf, " (M)");
3006 if (w0 == 1 || op0 != 3)
3008 /* Clear MM option since it only matters for MAC1, and if we made
3009 it this far, we've already shown it or we want to ignore it. */
3013 OUTS (outf, P ? dregs (dst) : dregs_lo (dst));
3016 OUTS (outf, " = A0");
3020 OUTS (outf, " = (");
3021 decode_macfunc (0, op0, h00, h10, src0, src1, outf);
3027 decode_optmode (mmod, MM, outf);
3033 decode_dsp32mult_0 (TIword iw0, TIword iw1, disassemble_info *outf)
3036 +---+---+---+---|---+---+---+---|---+---+---+---|---+---+---+---+
3037 | 1 | 1 | 0 | 0 |.M.| 0 | 1 |.mmod..........|.MM|.P.|.w1|.op1...|
3038 |.h01|.h11|.w0|.op0...|.h00|.h10|.dst.......|.src0......|.src1..|
3039 +---+---+---+---|---+---+---+---|---+---+---+---|---+---+---+---+ */
3040 int w1 = ((iw0 >> (DSP32Mac_w1_bits - 16)) & DSP32Mac_w1_mask);
3041 int P = ((iw0 >> (DSP32Mac_p_bits - 16)) & DSP32Mac_p_mask);
3042 int MM = ((iw0 >> (DSP32Mac_MM_bits - 16)) & DSP32Mac_MM_mask);
3043 int mmod = ((iw0 >> (DSP32Mac_mmod_bits - 16)) & DSP32Mac_mmod_mask);
3044 int w0 = ((iw1 >> DSP32Mac_w0_bits) & DSP32Mac_w0_mask);
3045 int src0 = ((iw1 >> DSP32Mac_src0_bits) & DSP32Mac_src0_mask);
3046 int src1 = ((iw1 >> DSP32Mac_src1_bits) & DSP32Mac_src1_mask);
3047 int dst = ((iw1 >> DSP32Mac_dst_bits) & DSP32Mac_dst_mask);
3048 int h10 = ((iw1 >> DSP32Mac_h10_bits) & DSP32Mac_h10_mask);
3049 int h00 = ((iw1 >> DSP32Mac_h00_bits) & DSP32Mac_h00_mask);
3050 int h11 = ((iw1 >> DSP32Mac_h11_bits) & DSP32Mac_h11_mask);
3051 int h01 = ((iw1 >> DSP32Mac_h01_bits) & DSP32Mac_h01_mask);
3053 if (w1 == 0 && w0 == 0)
3056 if (((1 << mmod) & (P ? 0x313 : 0x1b57)) == 0)
3061 OUTS (outf, P ? dregs (dst + 1) : dregs_hi (dst));
3063 decode_multfunc (h01, h11, src0, src1, outf);
3068 OUTS (outf, " (M)");
3076 OUTS (outf, P ? dregs (dst) : dregs_lo (dst));
3078 decode_multfunc (h00, h10, src0, src1, outf);
3081 decode_optmode (mmod, MM, outf);
3086 decode_dsp32alu_0 (TIword iw0, TIword iw1, disassemble_info *outf)
3089 +---+---+---+---|---+---+---+---|---+---+---+---|---+---+---+---+
3090 | 1 | 1 | 0 | 0 |.M.| 1 | 0 | - | - | - |.HL|.aopcde............|
3091 |.aop...|.s.|.x.|.dst0......|.dst1......|.src0......|.src1......|
3092 +---+---+---+---|---+---+---+---|---+---+---+---|---+---+---+---+ */
3093 int s = ((iw1 >> DSP32Alu_s_bits) & DSP32Alu_s_mask);
3094 int x = ((iw1 >> DSP32Alu_x_bits) & DSP32Alu_x_mask);
3095 int aop = ((iw1 >> DSP32Alu_aop_bits) & DSP32Alu_aop_mask);
3096 int src0 = ((iw1 >> DSP32Alu_src0_bits) & DSP32Alu_src0_mask);
3097 int src1 = ((iw1 >> DSP32Alu_src1_bits) & DSP32Alu_src1_mask);
3098 int dst0 = ((iw1 >> DSP32Alu_dst0_bits) & DSP32Alu_dst0_mask);
3099 int dst1 = ((iw1 >> DSP32Alu_dst1_bits) & DSP32Alu_dst1_mask);
3100 int HL = ((iw0 >> (DSP32Alu_HL_bits - 16)) & DSP32Alu_HL_mask);
3101 int aopcde = ((iw0 >> (DSP32Alu_aopcde_bits - 16)) & DSP32Alu_aopcde_mask);
3103 if (aop == 0 && aopcde == 9 && HL == 0 && s == 0)
3105 OUTS (outf, "A0.L = ");
3106 OUTS (outf, dregs_lo (src0));
3108 else if (aop == 2 && aopcde == 9 && HL == 1 && s == 0)
3110 OUTS (outf, "A1.H = ");
3111 OUTS (outf, dregs_hi (src0));
3113 else if (aop == 2 && aopcde == 9 && HL == 0 && s == 0)
3115 OUTS (outf, "A1.L = ");
3116 OUTS (outf, dregs_lo (src0));
3118 else if (aop == 0 && aopcde == 9 && HL == 1 && s == 0)
3120 OUTS (outf, "A0.H = ");
3121 OUTS (outf, dregs_hi (src0));
3123 else if (x == 1 && HL == 1 && aop == 3 && aopcde == 5)
3125 OUTS (outf, dregs_hi (dst0));
3127 OUTS (outf, dregs (src0));
3129 OUTS (outf, dregs (src1));
3130 OUTS (outf, " (RND20)");
3132 else if (x == 1 && HL == 1 && aop == 2 && aopcde == 5)
3134 OUTS (outf, dregs_hi (dst0));
3136 OUTS (outf, dregs (src0));
3138 OUTS (outf, dregs (src1));
3139 OUTS (outf, " (RND20)");
3141 else if (x == 0 && HL == 0 && aop == 1 && aopcde == 5)
3143 OUTS (outf, dregs_lo (dst0));
3145 OUTS (outf, dregs (src0));
3147 OUTS (outf, dregs (src1));
3148 OUTS (outf, " (RND12)");
3150 else if (x == 0 && HL == 0 && aop == 0 && aopcde == 5)
3152 OUTS (outf, dregs_lo (dst0));
3154 OUTS (outf, dregs (src0));
3156 OUTS (outf, dregs (src1));
3157 OUTS (outf, " (RND12)");
3159 else if (x == 1 && HL == 0 && aop == 3 && aopcde == 5)
3161 OUTS (outf, dregs_lo (dst0));
3163 OUTS (outf, dregs (src0));
3165 OUTS (outf, dregs (src1));
3166 OUTS (outf, " (RND20)");
3168 else if (x == 0 && HL == 1 && aop == 0 && aopcde == 5)
3170 OUTS (outf, dregs_hi (dst0));
3172 OUTS (outf, dregs (src0));
3174 OUTS (outf, dregs (src1));
3175 OUTS (outf, " (RND12)");
3177 else if (x == 1 && HL == 0 && aop == 2 && aopcde == 5)
3179 OUTS (outf, dregs_lo (dst0));
3181 OUTS (outf, dregs (src0));
3183 OUTS (outf, dregs (src1));
3184 OUTS (outf, " (RND20)");
3186 else if (x == 0 && HL == 1 && aop == 1 && aopcde == 5)
3188 OUTS (outf, dregs_hi (dst0));
3190 OUTS (outf, dregs (src0));
3192 OUTS (outf, dregs (src1));
3193 OUTS (outf, " (RND12)");
3195 else if (HL == 1 && aop == 0 && aopcde == 2)
3197 OUTS (outf, dregs_hi (dst0));
3199 OUTS (outf, dregs_lo (src0));
3201 OUTS (outf, dregs_lo (src1));
3204 else if (HL == 1 && aop == 1 && aopcde == 2)
3206 OUTS (outf, dregs_hi (dst0));
3208 OUTS (outf, dregs_lo (src0));
3210 OUTS (outf, dregs_hi (src1));
3213 else if (HL == 1 && aop == 2 && aopcde == 2)
3215 OUTS (outf, dregs_hi (dst0));
3217 OUTS (outf, dregs_hi (src0));
3219 OUTS (outf, dregs_lo (src1));
3222 else if (HL == 1 && aop == 3 && aopcde == 2)
3224 OUTS (outf, dregs_hi (dst0));
3226 OUTS (outf, dregs_hi (src0));
3228 OUTS (outf, dregs_hi (src1));
3231 else if (HL == 0 && aop == 0 && aopcde == 3)
3233 OUTS (outf, dregs_lo (dst0));
3235 OUTS (outf, dregs_lo (src0));
3237 OUTS (outf, dregs_lo (src1));
3240 else if (HL == 0 && aop == 1 && aopcde == 3)
3242 OUTS (outf, dregs_lo (dst0));
3244 OUTS (outf, dregs_lo (src0));
3246 OUTS (outf, dregs_hi (src1));
3249 else if (HL == 0 && aop == 3 && aopcde == 2)
3251 OUTS (outf, dregs_lo (dst0));
3253 OUTS (outf, dregs_hi (src0));
3255 OUTS (outf, dregs_hi (src1));
3258 else if (HL == 1 && aop == 0 && aopcde == 3)
3260 OUTS (outf, dregs_hi (dst0));
3262 OUTS (outf, dregs_lo (src0));
3264 OUTS (outf, dregs_lo (src1));
3267 else if (HL == 1 && aop == 1 && aopcde == 3)
3269 OUTS (outf, dregs_hi (dst0));
3271 OUTS (outf, dregs_lo (src0));
3273 OUTS (outf, dregs_hi (src1));
3276 else if (HL == 1 && aop == 2 && aopcde == 3)
3278 OUTS (outf, dregs_hi (dst0));
3280 OUTS (outf, dregs_hi (src0));
3282 OUTS (outf, dregs_lo (src1));
3285 else if (HL == 1 && aop == 3 && aopcde == 3)
3287 OUTS (outf, dregs_hi (dst0));
3289 OUTS (outf, dregs_hi (src0));
3291 OUTS (outf, dregs_hi (src1));
3294 else if (HL == 0 && aop == 2 && aopcde == 2)
3296 OUTS (outf, dregs_lo (dst0));
3298 OUTS (outf, dregs_hi (src0));
3300 OUTS (outf, dregs_lo (src1));
3303 else if (HL == 0 && aop == 1 && aopcde == 2)
3305 OUTS (outf, dregs_lo (dst0));
3307 OUTS (outf, dregs_lo (src0));
3309 OUTS (outf, dregs_hi (src1));
3312 else if (HL == 0 && aop == 2 && aopcde == 3)
3314 OUTS (outf, dregs_lo (dst0));
3316 OUTS (outf, dregs_hi (src0));
3318 OUTS (outf, dregs_lo (src1));
3321 else if (HL == 0 && aop == 3 && aopcde == 3)
3323 OUTS (outf, dregs_lo (dst0));
3325 OUTS (outf, dregs_hi (src0));
3327 OUTS (outf, dregs_hi (src1));
3330 else if (HL == 0 && aop == 0 && aopcde == 2)
3332 OUTS (outf, dregs_lo (dst0));
3334 OUTS (outf, dregs_lo (src0));
3336 OUTS (outf, dregs_lo (src1));
3339 else if (aop == 0 && aopcde == 9 && s == 1)
3341 OUTS (outf, "A0 = ");
3342 OUTS (outf, dregs (src0));
3344 else if (aop == 3 && aopcde == 11 && s == 0)
3345 OUTS (outf, "A0 -= A1");
3347 else if (aop == 3 && aopcde == 11 && s == 1)
3348 OUTS (outf, "A0 -= A1 (W32)");
3350 else if (aop == 1 && aopcde == 22 && HL == 1)
3352 OUTS (outf, dregs (dst0));
3353 OUTS (outf, " = BYTEOP2P (");
3354 OUTS (outf, dregs (src0 + 1));
3356 OUTS (outf, imm5d (src0));
3358 OUTS (outf, dregs (src1 + 1));
3360 OUTS (outf, imm5d (src1));
3361 OUTS (outf, ") (TH");
3363 OUTS (outf, ", R)");
3367 else if (aop == 1 && aopcde == 22 && HL == 0)
3369 OUTS (outf, dregs (dst0));
3370 OUTS (outf, " = BYTEOP2P (");
3371 OUTS (outf, dregs (src0 + 1));
3373 OUTS (outf, imm5d (src0));
3375 OUTS (outf, dregs (src1 + 1));
3377 OUTS (outf, imm5d (src1));
3378 OUTS (outf, ") (TL");
3380 OUTS (outf, ", R)");
3384 else if (aop == 0 && aopcde == 22 && HL == 1)
3386 OUTS (outf, dregs (dst0));
3387 OUTS (outf, " = BYTEOP2P (");
3388 OUTS (outf, dregs (src0 + 1));
3390 OUTS (outf, imm5d (src0));
3392 OUTS (outf, dregs (src1 + 1));
3394 OUTS (outf, imm5d (src1));
3395 OUTS (outf, ") (RNDH");
3397 OUTS (outf, ", R)");
3401 else if (aop == 0 && aopcde == 22 && HL == 0)
3403 OUTS (outf, dregs (dst0));
3404 OUTS (outf, " = BYTEOP2P (");
3405 OUTS (outf, dregs (src0 + 1));
3407 OUTS (outf, imm5d (src0));
3409 OUTS (outf, dregs (src1 + 1));
3411 OUTS (outf, imm5d (src1));
3412 OUTS (outf, ") (RNDL");
3414 OUTS (outf, ", R)");
3418 else if (aop == 0 && s == 0 && aopcde == 8)
3419 OUTS (outf, "A0 = 0");
3421 else if (aop == 0 && s == 1 && aopcde == 8)
3422 OUTS (outf, "A0 = A0 (S)");
3424 else if (aop == 1 && s == 0 && aopcde == 8)
3425 OUTS (outf, "A1 = 0");
3427 else if (aop == 1 && s == 1 && aopcde == 8)
3428 OUTS (outf, "A1 = A1 (S)");
3430 else if (aop == 2 && s == 0 && aopcde == 8)
3431 OUTS (outf, "A1 = A0 = 0");
3433 else if (aop == 2 && s == 1 && aopcde == 8)
3434 OUTS (outf, "A1 = A1 (S), A0 = A0 (S)");
3436 else if (aop == 3 && s == 0 && aopcde == 8)
3437 OUTS (outf, "A0 = A1");
3439 else if (aop == 3 && s == 1 && aopcde == 8)
3440 OUTS (outf, "A1 = A0");
3442 else if (aop == 1 && aopcde == 9 && s == 0)
3444 OUTS (outf, "A0.X = ");
3445 OUTS (outf, dregs_lo (src0));
3447 else if (aop == 1 && HL == 0 && aopcde == 11)
3449 OUTS (outf, dregs_lo (dst0));
3450 OUTS (outf, " = (A0 += A1)");
3452 else if (aop == 3 && HL == 0 && aopcde == 16)
3453 OUTS (outf, "A1 = ABS A1, A0 = ABS A0");
3455 else if (aop == 0 && aopcde == 23 && HL == 1)
3457 OUTS (outf, dregs (dst0));
3458 OUTS (outf, " = BYTEOP3P (");
3459 OUTS (outf, dregs (src0 + 1));
3461 OUTS (outf, imm5d (src0));
3463 OUTS (outf, dregs (src1 + 1));
3465 OUTS (outf, imm5d (src1));
3466 OUTS (outf, ") (HI");
3468 OUTS (outf, ", R)");
3472 else if (aop == 3 && aopcde == 9 && s == 0)
3474 OUTS (outf, "A1.X = ");
3475 OUTS (outf, dregs_lo (src0));
3477 else if (aop == 1 && HL == 1 && aopcde == 16)
3478 OUTS (outf, "A1 = ABS A1");
3480 else if (aop == 0 && HL == 1 && aopcde == 16)
3481 OUTS (outf, "A1 = ABS A0");
3483 else if (aop == 2 && aopcde == 9 && s == 1)
3485 OUTS (outf, "A1 = ");
3486 OUTS (outf, dregs (src0));
3488 else if (HL == 0 && aop == 3 && aopcde == 12)
3490 OUTS (outf, dregs_lo (dst0));
3492 OUTS (outf, dregs (src0));
3493 OUTS (outf, " (RND)");
3495 else if (aop == 1 && HL == 0 && aopcde == 16)
3496 OUTS (outf, "A0 = ABS A1");
3498 else if (aop == 0 && HL == 0 && aopcde == 16)
3499 OUTS (outf, "A0 = ABS A0");
3501 else if (aop == 3 && HL == 0 && aopcde == 15)
3503 OUTS (outf, dregs (dst0));
3504 OUTS (outf, " = -");
3505 OUTS (outf, dregs (src0));
3506 OUTS (outf, " (V)");
3508 else if (aop == 3 && s == 1 && HL == 0 && aopcde == 7)
3510 OUTS (outf, dregs (dst0));
3511 OUTS (outf, " = -");
3512 OUTS (outf, dregs (src0));
3513 OUTS (outf, " (S)");
3515 else if (aop == 3 && s == 0 && HL == 0 && aopcde == 7)
3517 OUTS (outf, dregs (dst0));
3518 OUTS (outf, " = -");
3519 OUTS (outf, dregs (src0));
3520 OUTS (outf, " (NS)");
3522 else if (aop == 1 && HL == 1 && aopcde == 11)
3524 OUTS (outf, dregs_hi (dst0));
3525 OUTS (outf, " = (A0 += A1)");
3527 else if (aop == 2 && aopcde == 11 && s == 0)
3528 OUTS (outf, "A0 += A1");
3530 else if (aop == 2 && aopcde == 11 && s == 1)
3531 OUTS (outf, "A0 += A1 (W32)");
3533 else if (aop == 3 && HL == 0 && aopcde == 14)
3534 OUTS (outf, "A1 = -A1, A0 = -A0");
3536 else if (HL == 1 && aop == 3 && aopcde == 12)
3538 OUTS (outf, dregs_hi (dst0));
3540 OUTS (outf, dregs (src0));
3541 OUTS (outf, " (RND)");
3543 else if (aop == 0 && aopcde == 23 && HL == 0)
3545 OUTS (outf, dregs (dst0));
3546 OUTS (outf, " = BYTEOP3P (");
3547 OUTS (outf, dregs (src0 + 1));
3549 OUTS (outf, imm5d (src0));
3551 OUTS (outf, dregs (src1 + 1));
3553 OUTS (outf, imm5d (src1));
3554 OUTS (outf, ") (LO");
3556 OUTS (outf, ", R)");
3560 else if (aop == 0 && HL == 0 && aopcde == 14)
3561 OUTS (outf, "A0 = -A0");
3563 else if (aop == 1 && HL == 0 && aopcde == 14)
3564 OUTS (outf, "A0 = -A1");
3566 else if (aop == 0 && HL == 1 && aopcde == 14)
3567 OUTS (outf, "A1 = -A0");
3569 else if (aop == 1 && HL == 1 && aopcde == 14)
3570 OUTS (outf, "A1 = -A1");
3572 else if (aop == 0 && aopcde == 12)
3574 OUTS (outf, dregs_hi (dst0));
3576 OUTS (outf, dregs_lo (dst0));
3577 OUTS (outf, " = SIGN (");
3578 OUTS (outf, dregs_hi (src0));
3579 OUTS (outf, ") * ");
3580 OUTS (outf, dregs_hi (src1));
3581 OUTS (outf, " + SIGN (");
3582 OUTS (outf, dregs_lo (src0));
3583 OUTS (outf, ") * ");
3584 OUTS (outf, dregs_lo (src1));
3586 else if (aop == 2 && aopcde == 0)
3588 OUTS (outf, dregs (dst0));
3590 OUTS (outf, dregs (src0));
3591 OUTS (outf, " -|+ ");
3592 OUTS (outf, dregs (src1));
3595 else if (aop == 1 && aopcde == 12)
3597 OUTS (outf, dregs (dst1));
3598 OUTS (outf, " = A1.L + A1.H, ");
3599 OUTS (outf, dregs (dst0));
3600 OUTS (outf, " = A0.L + A0.H");
3602 else if (aop == 2 && aopcde == 4)
3604 OUTS (outf, dregs (dst1));
3606 OUTS (outf, dregs (src0));
3608 OUTS (outf, dregs (src1));
3610 OUTS (outf, dregs (dst0));
3612 OUTS (outf, dregs (src0));
3614 OUTS (outf, dregs (src1));
3617 else if (HL == 0 && aopcde == 1)
3619 OUTS (outf, dregs (dst1));
3621 OUTS (outf, dregs (src0));
3622 OUTS (outf, " +|+ ");
3623 OUTS (outf, dregs (src1));
3625 OUTS (outf, dregs (dst0));
3627 OUTS (outf, dregs (src0));
3628 OUTS (outf, " -|- ");
3629 OUTS (outf, dregs (src1));
3630 amod0amod2 (s, x, aop, outf);
3632 else if (aop == 0 && aopcde == 11)
3634 OUTS (outf, dregs (dst0));
3635 OUTS (outf, " = (A0 += A1)");
3637 else if (aop == 0 && aopcde == 10)
3639 OUTS (outf, dregs_lo (dst0));
3640 OUTS (outf, " = A0.X");
3642 else if (aop == 1 && aopcde == 10)
3644 OUTS (outf, dregs_lo (dst0));
3645 OUTS (outf, " = A1.X");
3647 else if (aop == 1 && aopcde == 0)
3649 OUTS (outf, dregs (dst0));
3651 OUTS (outf, dregs (src0));
3652 OUTS (outf, " +|- ");
3653 OUTS (outf, dregs (src1));
3656 else if (aop == 3 && aopcde == 0)
3658 OUTS (outf, dregs (dst0));
3660 OUTS (outf, dregs (src0));
3661 OUTS (outf, " -|- ");
3662 OUTS (outf, dregs (src1));
3665 else if (aop == 1 && aopcde == 4)
3667 OUTS (outf, dregs (dst0));
3669 OUTS (outf, dregs (src0));
3671 OUTS (outf, dregs (src1));
3674 else if (aop == 0 && aopcde == 17)
3676 OUTS (outf, dregs (dst1));
3677 OUTS (outf, " = A1 + A0, ");
3678 OUTS (outf, dregs (dst0));
3679 OUTS (outf, " = A1 - A0");
3682 else if (aop == 1 && aopcde == 17)
3684 OUTS (outf, dregs (dst1));
3685 OUTS (outf, " = A0 + A1, ");
3686 OUTS (outf, dregs (dst0));
3687 OUTS (outf, " = A0 - A1");
3690 else if (aop == 0 && aopcde == 18)
3692 OUTS (outf, "SAA (");
3693 OUTS (outf, dregs (src0 + 1));
3695 OUTS (outf, imm5d (src0));
3697 OUTS (outf, dregs (src1 + 1));
3699 OUTS (outf, imm5d (src1));
3703 else if (aop == 3 && aopcde == 18)
3704 OUTS (outf, "DISALGNEXCPT");
3706 else if (aop == 0 && aopcde == 20)
3708 OUTS (outf, dregs (dst0));
3709 OUTS (outf, " = BYTEOP1P (");
3710 OUTS (outf, dregs (src0 + 1));
3712 OUTS (outf, imm5d (src0));
3714 OUTS (outf, dregs (src1 + 1));
3716 OUTS (outf, imm5d (src1));
3720 else if (aop == 1 && aopcde == 20)
3722 OUTS (outf, dregs (dst0));
3723 OUTS (outf, " = BYTEOP1P (");
3724 OUTS (outf, dregs (src0 + 1));
3726 OUTS (outf, imm5d (src0));
3728 OUTS (outf, dregs (src1 + 1));
3730 OUTS (outf, imm5d (src1));
3731 OUTS (outf, ") (T");
3733 OUTS (outf, ", R)");
3737 else if (aop == 0 && aopcde == 21)
3740 OUTS (outf, dregs (dst1));
3742 OUTS (outf, dregs (dst0));
3743 OUTS (outf, ") = BYTEOP16P (");
3744 OUTS (outf, dregs (src0 + 1));
3746 OUTS (outf, imm5d (src0));
3748 OUTS (outf, dregs (src1 + 1));
3750 OUTS (outf, imm5d (src1));
3754 else if (aop == 1 && aopcde == 21)
3757 OUTS (outf, dregs (dst1));
3759 OUTS (outf, dregs (dst0));
3760 OUTS (outf, ") = BYTEOP16M (");
3761 OUTS (outf, dregs (src0 + 1));
3763 OUTS (outf, imm5d (src0));
3765 OUTS (outf, dregs (src1 + 1));
3767 OUTS (outf, imm5d (src1));
3771 else if (aop == 2 && aopcde == 7)
3773 OUTS (outf, dregs (dst0));
3774 OUTS (outf, " = ABS ");
3775 OUTS (outf, dregs (src0));
3777 else if (aop == 1 && aopcde == 7)
3779 OUTS (outf, dregs (dst0));
3780 OUTS (outf, " = MIN (");
3781 OUTS (outf, dregs (src0));
3783 OUTS (outf, dregs (src1));
3786 else if (aop == 0 && aopcde == 7)
3788 OUTS (outf, dregs (dst0));
3789 OUTS (outf, " = MAX (");
3790 OUTS (outf, dregs (src0));
3792 OUTS (outf, dregs (src1));
3795 else if (aop == 2 && aopcde == 6)
3797 OUTS (outf, dregs (dst0));
3798 OUTS (outf, " = ABS ");
3799 OUTS (outf, dregs (src0));
3800 OUTS (outf, " (V)");
3802 else if (aop == 1 && aopcde == 6)
3804 OUTS (outf, dregs (dst0));
3805 OUTS (outf, " = MIN (");
3806 OUTS (outf, dregs (src0));
3808 OUTS (outf, dregs (src1));
3809 OUTS (outf, ") (V)");
3811 else if (aop == 0 && aopcde == 6)
3813 OUTS (outf, dregs (dst0));
3814 OUTS (outf, " = MAX (");
3815 OUTS (outf, dregs (src0));
3817 OUTS (outf, dregs (src1));
3818 OUTS (outf, ") (V)");
3820 else if (HL == 1 && aopcde == 1)
3822 OUTS (outf, dregs (dst1));
3824 OUTS (outf, dregs (src0));
3825 OUTS (outf, " +|- ");
3826 OUTS (outf, dregs (src1));
3828 OUTS (outf, dregs (dst0));
3830 OUTS (outf, dregs (src0));
3831 OUTS (outf, " -|+ ");
3832 OUTS (outf, dregs (src1));
3833 amod0amod2 (s, x, aop, outf);
3835 else if (aop == 0 && aopcde == 4)
3837 OUTS (outf, dregs (dst0));
3839 OUTS (outf, dregs (src0));
3841 OUTS (outf, dregs (src1));
3844 else if (aop == 0 && aopcde == 0)
3846 OUTS (outf, dregs (dst0));
3848 OUTS (outf, dregs (src0));
3849 OUTS (outf, " +|+ ");
3850 OUTS (outf, dregs (src1));
3853 else if (aop == 0 && aopcde == 24)
3855 OUTS (outf, dregs (dst0));
3856 OUTS (outf, " = BYTEPACK (");
3857 OUTS (outf, dregs (src0));
3859 OUTS (outf, dregs (src1));
3862 else if (aop == 1 && aopcde == 24)
3865 OUTS (outf, dregs (dst1));
3867 OUTS (outf, dregs (dst0));
3868 OUTS (outf, ") = BYTEUNPACK ");
3869 OUTS (outf, dregs (src0 + 1));
3871 OUTS (outf, imm5d (src0));
3874 else if (aopcde == 13)
3877 OUTS (outf, dregs (dst1));
3879 OUTS (outf, dregs (dst0));
3880 OUTS (outf, ") = SEARCH ");
3881 OUTS (outf, dregs (src0));
3883 searchmod (aop, outf);
3893 decode_dsp32shift_0 (TIword iw0, TIword iw1, disassemble_info *outf)
3896 +---+---+---+---|---+---+---+---|---+---+---+---|---+---+---+---+
3897 | 1 | 1 | 0 | 0 |.M.| 1 | 1 | 0 | 0 | - | - |.sopcde............|
3898 |.sop...|.HLs...|.dst0......| - | - | - |.src0......|.src1......|
3899 +---+---+---+---|---+---+---+---|---+---+---+---|---+---+---+---+ */
3900 int HLs = ((iw1 >> DSP32Shift_HLs_bits) & DSP32Shift_HLs_mask);
3901 int sop = ((iw1 >> DSP32Shift_sop_bits) & DSP32Shift_sop_mask);
3902 int src0 = ((iw1 >> DSP32Shift_src0_bits) & DSP32Shift_src0_mask);
3903 int src1 = ((iw1 >> DSP32Shift_src1_bits) & DSP32Shift_src1_mask);
3904 int dst0 = ((iw1 >> DSP32Shift_dst0_bits) & DSP32Shift_dst0_mask);
3905 int sopcde = ((iw0 >> (DSP32Shift_sopcde_bits - 16)) & DSP32Shift_sopcde_mask);
3906 const char *acc01 = (HLs & 1) == 0 ? "A0" : "A1";
3908 if (HLs == 0 && sop == 0 && sopcde == 0)
3910 OUTS (outf, dregs_lo (dst0));
3911 OUTS (outf, " = ASHIFT ");
3912 OUTS (outf, dregs_lo (src1));
3913 OUTS (outf, " BY ");
3914 OUTS (outf, dregs_lo (src0));
3916 else if (HLs == 1 && sop == 0 && sopcde == 0)
3918 OUTS (outf, dregs_lo (dst0));
3919 OUTS (outf, " = ASHIFT ");
3920 OUTS (outf, dregs_hi (src1));
3921 OUTS (outf, " BY ");
3922 OUTS (outf, dregs_lo (src0));
3924 else if (HLs == 2 && sop == 0 && sopcde == 0)
3926 OUTS (outf, dregs_hi (dst0));
3927 OUTS (outf, " = ASHIFT ");
3928 OUTS (outf, dregs_lo (src1));
3929 OUTS (outf, " BY ");
3930 OUTS (outf, dregs_lo (src0));
3932 else if (HLs == 3 && sop == 0 && sopcde == 0)
3934 OUTS (outf, dregs_hi (dst0));
3935 OUTS (outf, " = ASHIFT ");
3936 OUTS (outf, dregs_hi (src1));
3937 OUTS (outf, " BY ");
3938 OUTS (outf, dregs_lo (src0));
3940 else if (HLs == 0 && sop == 1 && sopcde == 0)
3942 OUTS (outf, dregs_lo (dst0));
3943 OUTS (outf, " = ASHIFT ");
3944 OUTS (outf, dregs_lo (src1));
3945 OUTS (outf, " BY ");
3946 OUTS (outf, dregs_lo (src0));
3947 OUTS (outf, " (S)");
3949 else if (HLs == 1 && sop == 1 && sopcde == 0)
3951 OUTS (outf, dregs_lo (dst0));
3952 OUTS (outf, " = ASHIFT ");
3953 OUTS (outf, dregs_hi (src1));
3954 OUTS (outf, " BY ");
3955 OUTS (outf, dregs_lo (src0));
3956 OUTS (outf, " (S)");
3958 else if (HLs == 2 && sop == 1 && sopcde == 0)
3960 OUTS (outf, dregs_hi (dst0));
3961 OUTS (outf, " = ASHIFT ");
3962 OUTS (outf, dregs_lo (src1));
3963 OUTS (outf, " BY ");
3964 OUTS (outf, dregs_lo (src0));
3965 OUTS (outf, " (S)");
3967 else if (HLs == 3 && sop == 1 && sopcde == 0)
3969 OUTS (outf, dregs_hi (dst0));
3970 OUTS (outf, " = ASHIFT ");
3971 OUTS (outf, dregs_hi (src1));
3972 OUTS (outf, " BY ");
3973 OUTS (outf, dregs_lo (src0));
3974 OUTS (outf, " (S)");
3976 else if (sop == 2 && sopcde == 0)
3978 OUTS (outf, (HLs & 2) == 0 ? dregs_lo (dst0) : dregs_hi (dst0));
3979 OUTS (outf, " = LSHIFT ");
3980 OUTS (outf, (HLs & 1) == 0 ? dregs_lo (src1) : dregs_hi (src1));
3981 OUTS (outf, " BY ");
3982 OUTS (outf, dregs_lo (src0));
3984 else if (sop == 0 && sopcde == 3)
3987 OUTS (outf, " = ASHIFT ");
3989 OUTS (outf, " BY ");
3990 OUTS (outf, dregs_lo (src0));
3992 else if (sop == 1 && sopcde == 3)
3995 OUTS (outf, " = LSHIFT ");
3997 OUTS (outf, " BY ");
3998 OUTS (outf, dregs_lo (src0));
4000 else if (sop == 2 && sopcde == 3)
4003 OUTS (outf, " = ROT ");
4005 OUTS (outf, " BY ");
4006 OUTS (outf, dregs_lo (src0));
4008 else if (sop == 3 && sopcde == 3)
4010 OUTS (outf, dregs (dst0));
4011 OUTS (outf, " = ROT ");
4012 OUTS (outf, dregs (src1));
4013 OUTS (outf, " BY ");
4014 OUTS (outf, dregs_lo (src0));
4016 else if (sop == 1 && sopcde == 1)
4018 OUTS (outf, dregs (dst0));
4019 OUTS (outf, " = ASHIFT ");
4020 OUTS (outf, dregs (src1));
4021 OUTS (outf, " BY ");
4022 OUTS (outf, dregs_lo (src0));
4023 OUTS (outf, " (V, S)");
4025 else if (sop == 0 && sopcde == 1)
4027 OUTS (outf, dregs (dst0));
4028 OUTS (outf, " = ASHIFT ");
4029 OUTS (outf, dregs (src1));
4030 OUTS (outf, " BY ");
4031 OUTS (outf, dregs_lo (src0));
4032 OUTS (outf, " (V)");
4034 else if (sop == 0 && sopcde == 2)
4036 OUTS (outf, dregs (dst0));
4037 OUTS (outf, " = ASHIFT ");
4038 OUTS (outf, dregs (src1));
4039 OUTS (outf, " BY ");
4040 OUTS (outf, dregs_lo (src0));
4042 else if (sop == 1 && sopcde == 2)
4044 OUTS (outf, dregs (dst0));
4045 OUTS (outf, " = ASHIFT ");
4046 OUTS (outf, dregs (src1));
4047 OUTS (outf, " BY ");
4048 OUTS (outf, dregs_lo (src0));
4049 OUTS (outf, " (S)");
4051 else if (sop == 2 && sopcde == 2)
4053 OUTS (outf, dregs (dst0));
4054 OUTS (outf, " = LSHIFT ");
4055 OUTS (outf, dregs (src1));
4056 OUTS (outf, " BY ");
4057 OUTS (outf, dregs_lo (src0));
4059 else if (sop == 3 && sopcde == 2)
4061 OUTS (outf, dregs (dst0));
4062 OUTS (outf, " = ROT ");
4063 OUTS (outf, dregs (src1));
4064 OUTS (outf, " BY ");
4065 OUTS (outf, dregs_lo (src0));
4067 else if (sop == 2 && sopcde == 1)
4069 OUTS (outf, dregs (dst0));
4070 OUTS (outf, " = LSHIFT ");
4071 OUTS (outf, dregs (src1));
4072 OUTS (outf, " BY ");
4073 OUTS (outf, dregs_lo (src0));
4074 OUTS (outf, " (V)");
4076 else if (sop == 0 && sopcde == 4)
4078 OUTS (outf, dregs (dst0));
4079 OUTS (outf, " = PACK (");
4080 OUTS (outf, dregs_lo (src1));
4082 OUTS (outf, dregs_lo (src0));
4085 else if (sop == 1 && sopcde == 4)
4087 OUTS (outf, dregs (dst0));
4088 OUTS (outf, " = PACK (");
4089 OUTS (outf, dregs_lo (src1));
4091 OUTS (outf, dregs_hi (src0));
4094 else if (sop == 2 && sopcde == 4)
4096 OUTS (outf, dregs (dst0));
4097 OUTS (outf, " = PACK (");
4098 OUTS (outf, dregs_hi (src1));
4100 OUTS (outf, dregs_lo (src0));
4103 else if (sop == 3 && sopcde == 4)
4105 OUTS (outf, dregs (dst0));
4106 OUTS (outf, " = PACK (");
4107 OUTS (outf, dregs_hi (src1));
4109 OUTS (outf, dregs_hi (src0));
4112 else if (sop == 0 && sopcde == 5)
4114 OUTS (outf, dregs_lo (dst0));
4115 OUTS (outf, " = SIGNBITS ");
4116 OUTS (outf, dregs (src1));
4118 else if (sop == 1 && sopcde == 5)
4120 OUTS (outf, dregs_lo (dst0));
4121 OUTS (outf, " = SIGNBITS ");
4122 OUTS (outf, dregs_lo (src1));
4124 else if (sop == 2 && sopcde == 5)
4126 OUTS (outf, dregs_lo (dst0));
4127 OUTS (outf, " = SIGNBITS ");
4128 OUTS (outf, dregs_hi (src1));
4130 else if (sop == 0 && sopcde == 6)
4132 OUTS (outf, dregs_lo (dst0));
4133 OUTS (outf, " = SIGNBITS A0");
4135 else if (sop == 1 && sopcde == 6)
4137 OUTS (outf, dregs_lo (dst0));
4138 OUTS (outf, " = SIGNBITS A1");
4140 else if (sop == 3 && sopcde == 6)
4142 OUTS (outf, dregs_lo (dst0));
4143 OUTS (outf, " = ONES ");
4144 OUTS (outf, dregs (src1));
4146 else if (sop == 0 && sopcde == 7)
4148 OUTS (outf, dregs_lo (dst0));
4149 OUTS (outf, " = EXPADJ (");
4150 OUTS (outf, dregs (src1));
4152 OUTS (outf, dregs_lo (src0));
4155 else if (sop == 1 && sopcde == 7)
4157 OUTS (outf, dregs_lo (dst0));
4158 OUTS (outf, " = EXPADJ (");
4159 OUTS (outf, dregs (src1));
4161 OUTS (outf, dregs_lo (src0));
4162 OUTS (outf, ") (V)");
4164 else if (sop == 2 && sopcde == 7)
4166 OUTS (outf, dregs_lo (dst0));
4167 OUTS (outf, " = EXPADJ (");
4168 OUTS (outf, dregs_lo (src1));
4170 OUTS (outf, dregs_lo (src0));
4173 else if (sop == 3 && sopcde == 7)
4175 OUTS (outf, dregs_lo (dst0));
4176 OUTS (outf, " = EXPADJ (");
4177 OUTS (outf, dregs_hi (src1));
4179 OUTS (outf, dregs_lo (src0));
4182 else if (sop == 0 && sopcde == 8)
4184 OUTS (outf, "BITMUX (");
4185 OUTS (outf, dregs (src0));
4187 OUTS (outf, dregs (src1));
4188 OUTS (outf, ", A0) (ASR)");
4190 else if (sop == 1 && sopcde == 8)
4192 OUTS (outf, "BITMUX (");
4193 OUTS (outf, dregs (src0));
4195 OUTS (outf, dregs (src1));
4196 OUTS (outf, ", A0) (ASL)");
4198 else if (sop == 0 && sopcde == 9)
4200 OUTS (outf, dregs_lo (dst0));
4201 OUTS (outf, " = VIT_MAX (");
4202 OUTS (outf, dregs (src1));
4203 OUTS (outf, ") (ASL)");
4205 else if (sop == 1 && sopcde == 9)
4207 OUTS (outf, dregs_lo (dst0));
4208 OUTS (outf, " = VIT_MAX (");
4209 OUTS (outf, dregs (src1));
4210 OUTS (outf, ") (ASR)");
4212 else if (sop == 2 && sopcde == 9)
4214 OUTS (outf, dregs (dst0));
4215 OUTS (outf, " = VIT_MAX (");
4216 OUTS (outf, dregs (src1));
4218 OUTS (outf, dregs (src0));
4219 OUTS (outf, ") (ASL)");
4221 else if (sop == 3 && sopcde == 9)
4223 OUTS (outf, dregs (dst0));
4224 OUTS (outf, " = VIT_MAX (");
4225 OUTS (outf, dregs (src1));
4227 OUTS (outf, dregs (src0));
4228 OUTS (outf, ") (ASR)");
4230 else if (sop == 0 && sopcde == 10)
4232 OUTS (outf, dregs (dst0));
4233 OUTS (outf, " = EXTRACT (");
4234 OUTS (outf, dregs (src1));
4236 OUTS (outf, dregs_lo (src0));
4237 OUTS (outf, ") (Z)");
4239 else if (sop == 1 && sopcde == 10)
4241 OUTS (outf, dregs (dst0));
4242 OUTS (outf, " = EXTRACT (");
4243 OUTS (outf, dregs (src1));
4245 OUTS (outf, dregs_lo (src0));
4246 OUTS (outf, ") (X)");
4248 else if (sop == 2 && sopcde == 10)
4250 OUTS (outf, dregs (dst0));
4251 OUTS (outf, " = DEPOSIT (");
4252 OUTS (outf, dregs (src1));
4254 OUTS (outf, dregs (src0));
4257 else if (sop == 3 && sopcde == 10)
4259 OUTS (outf, dregs (dst0));
4260 OUTS (outf, " = DEPOSIT (");
4261 OUTS (outf, dregs (src1));
4263 OUTS (outf, dregs (src0));
4264 OUTS (outf, ") (X)");
4266 else if (sop == 0 && sopcde == 11)
4268 OUTS (outf, dregs_lo (dst0));
4269 OUTS (outf, " = CC = BXORSHIFT (A0, ");
4270 OUTS (outf, dregs (src0));
4273 else if (sop == 1 && sopcde == 11)
4275 OUTS (outf, dregs_lo (dst0));
4276 OUTS (outf, " = CC = BXOR (A0, ");
4277 OUTS (outf, dregs (src0));
4280 else if (sop == 0 && sopcde == 12)
4281 OUTS (outf, "A0 = BXORSHIFT (A0, A1, CC)");
4283 else if (sop == 1 && sopcde == 12)
4285 OUTS (outf, dregs_lo (dst0));
4286 OUTS (outf, " = CC = BXOR (A0, A1, CC)");
4288 else if (sop == 0 && sopcde == 13)
4290 OUTS (outf, dregs (dst0));
4291 OUTS (outf, " = ALIGN8 (");
4292 OUTS (outf, dregs (src1));
4294 OUTS (outf, dregs (src0));
4297 else if (sop == 1 && sopcde == 13)
4299 OUTS (outf, dregs (dst0));
4300 OUTS (outf, " = ALIGN16 (");
4301 OUTS (outf, dregs (src1));
4303 OUTS (outf, dregs (src0));
4306 else if (sop == 2 && sopcde == 13)
4308 OUTS (outf, dregs (dst0));
4309 OUTS (outf, " = ALIGN24 (");
4310 OUTS (outf, dregs (src1));
4312 OUTS (outf, dregs (src0));
4322 decode_dsp32shiftimm_0 (TIword iw0, TIword iw1, disassemble_info *outf)
4325 +---+---+---+---|---+---+---+---|---+---+---+---|---+---+---+---+
4326 | 1 | 1 | 0 | 0 |.M.| 1 | 1 | 0 | 1 | - | - |.sopcde............|
4327 |.sop...|.HLs...|.dst0......|.immag.................|.src1......|
4328 +---+---+---+---|---+---+---+---|---+---+---+---|---+---+---+---+ */
4329 int src1 = ((iw1 >> DSP32ShiftImm_src1_bits) & DSP32ShiftImm_src1_mask);
4330 int sop = ((iw1 >> DSP32ShiftImm_sop_bits) & DSP32ShiftImm_sop_mask);
4331 int bit8 = ((iw1 >> 8) & 0x1);
4332 int immag = ((iw1 >> DSP32ShiftImm_immag_bits) & DSP32ShiftImm_immag_mask);
4333 int newimmag = (-(iw1 >> DSP32ShiftImm_immag_bits) & DSP32ShiftImm_immag_mask);
4334 int dst0 = ((iw1 >> DSP32ShiftImm_dst0_bits) & DSP32ShiftImm_dst0_mask);
4335 int sopcde = ((iw0 >> (DSP32ShiftImm_sopcde_bits - 16)) & DSP32ShiftImm_sopcde_mask);
4336 int HLs = ((iw1 >> DSP32ShiftImm_HLs_bits) & DSP32ShiftImm_HLs_mask);
4338 if (sop == 0 && sopcde == 0)
4340 OUTS (outf, (HLs & 2) ? dregs_hi (dst0) : dregs_lo (dst0));
4342 OUTS (outf, (HLs & 1) ? dregs_hi (src1) : dregs_lo (src1));
4343 OUTS (outf, " >>> ");
4344 OUTS (outf, uimm4 (newimmag));
4346 else if (sop == 1 && sopcde == 0 && bit8 == 0)
4348 OUTS (outf, (HLs & 2) ? dregs_hi (dst0) : dregs_lo (dst0));
4350 OUTS (outf, (HLs & 1) ? dregs_hi (src1) : dregs_lo (src1));
4351 OUTS (outf, " << ");
4352 OUTS (outf, uimm4 (immag));
4353 OUTS (outf, " (S)");
4355 else if (sop == 1 && sopcde == 0 && bit8 == 1)
4357 OUTS (outf, (HLs & 2) ? dregs_hi (dst0) : dregs_lo (dst0));
4359 OUTS (outf, (HLs & 1) ? dregs_hi (src1) : dregs_lo (src1));
4360 OUTS (outf, " >>> ");
4361 OUTS (outf, uimm4 (newimmag));
4362 OUTS (outf, " (S)");
4364 else if (sop == 2 && sopcde == 0 && bit8 == 0)
4366 OUTS (outf, (HLs & 2) ? dregs_hi (dst0) : dregs_lo (dst0));
4368 OUTS (outf, (HLs & 1) ? dregs_hi (src1) : dregs_lo (src1));
4369 OUTS (outf, " << ");
4370 OUTS (outf, uimm4 (immag));
4372 else if (sop == 2 && sopcde == 0 && bit8 == 1)
4374 OUTS (outf, (HLs & 2) ? dregs_hi (dst0) : dregs_lo (dst0));
4376 OUTS (outf, (HLs & 1) ? dregs_hi (src1) : dregs_lo (src1));
4377 OUTS (outf, " >> ");
4378 OUTS (outf, uimm4 (newimmag));
4380 else if (sop == 2 && sopcde == 3 && HLs == 1)
4382 OUTS (outf, "A1 = ROT A1 BY ");
4383 OUTS (outf, imm6 (immag));
4385 else if (sop == 0 && sopcde == 3 && HLs == 0 && bit8 == 0)
4387 OUTS (outf, "A0 = A0 << ");
4388 OUTS (outf, uimm5 (immag));
4390 else if (sop == 0 && sopcde == 3 && HLs == 0 && bit8 == 1)
4392 OUTS (outf, "A0 = A0 >>> ");
4393 OUTS (outf, uimm5 (newimmag));
4395 else if (sop == 0 && sopcde == 3 && HLs == 1 && bit8 == 0)
4397 OUTS (outf, "A1 = A1 << ");
4398 OUTS (outf, uimm5 (immag));
4400 else if (sop == 0 && sopcde == 3 && HLs == 1 && bit8 == 1)
4402 OUTS (outf, "A1 = A1 >>> ");
4403 OUTS (outf, uimm5 (newimmag));
4405 else if (sop == 1 && sopcde == 3 && HLs == 0)
4407 OUTS (outf, "A0 = A0 >> ");
4408 OUTS (outf, uimm5 (newimmag));
4410 else if (sop == 1 && sopcde == 3 && HLs == 1)
4412 OUTS (outf, "A1 = A1 >> ");
4413 OUTS (outf, uimm5 (newimmag));
4415 else if (sop == 2 && sopcde == 3 && HLs == 0)
4417 OUTS (outf, "A0 = ROT A0 BY ");
4418 OUTS (outf, imm6 (immag));
4420 else if (sop == 1 && sopcde == 1 && bit8 == 0)
4422 OUTS (outf, dregs (dst0));
4424 OUTS (outf, dregs (src1));
4425 OUTS (outf, " << ");
4426 OUTS (outf, uimm5 (immag));
4427 OUTS (outf, " (V, S)");
4429 else if (sop == 1 && sopcde == 1 && bit8 == 1)
4431 OUTS (outf, dregs (dst0));
4433 OUTS (outf, dregs (src1));
4434 OUTS (outf, " >>> ");
4435 OUTS (outf, imm5 (-immag));
4436 OUTS (outf, " (V, S)");
4438 else if (sop == 2 && sopcde == 1 && bit8 == 1)
4440 OUTS (outf, dregs (dst0));
4442 OUTS (outf, dregs (src1));
4443 OUTS (outf, " >> ");
4444 OUTS (outf, uimm5 (newimmag));
4445 OUTS (outf, " (V)");
4447 else if (sop == 2 && sopcde == 1 && bit8 == 0)
4449 OUTS (outf, dregs (dst0));
4451 OUTS (outf, dregs (src1));
4452 OUTS (outf, " << ");
4453 OUTS (outf, imm5 (immag));
4454 OUTS (outf, " (V)");
4456 else if (sop == 0 && sopcde == 1)
4458 OUTS (outf, dregs (dst0));
4460 OUTS (outf, dregs (src1));
4461 OUTS (outf, " >>> ");
4462 OUTS (outf, uimm5 (newimmag));
4463 OUTS (outf, " (V)");
4465 else if (sop == 1 && sopcde == 2)
4467 OUTS (outf, dregs (dst0));
4469 OUTS (outf, dregs (src1));
4470 OUTS (outf, " << ");
4471 OUTS (outf, uimm5 (immag));
4472 OUTS (outf, " (S)");
4474 else if (sop == 2 && sopcde == 2 && bit8 == 1)
4476 OUTS (outf, dregs (dst0));
4478 OUTS (outf, dregs (src1));
4479 OUTS (outf, " >> ");
4480 OUTS (outf, uimm5 (newimmag));
4482 else if (sop == 2 && sopcde == 2 && bit8 == 0)
4484 OUTS (outf, dregs (dst0));
4486 OUTS (outf, dregs (src1));
4487 OUTS (outf, " << ");
4488 OUTS (outf, uimm5 (immag));
4490 else if (sop == 3 && sopcde == 2)
4492 OUTS (outf, dregs (dst0));
4493 OUTS (outf, " = ROT ");
4494 OUTS (outf, dregs (src1));
4495 OUTS (outf, " BY ");
4496 OUTS (outf, imm6 (immag));
4498 else if (sop == 0 && sopcde == 2)
4500 OUTS (outf, dregs (dst0));
4502 OUTS (outf, dregs (src1));
4503 OUTS (outf, " >>> ");
4504 OUTS (outf, uimm5 (newimmag));
4513 decode_pseudoDEBUG_0 (TIword iw0, disassemble_info *outf)
4516 +---+---+---+---|---+---+---+---|---+---+---+---|---+---+---+---+
4517 | 1 | 1 | 1 | 1 | 1 | 0 | 0 | 0 |.fn....|.grp.......|.reg.......|
4518 +---+---+---+---|---+---+---+---|---+---+---+---|---+---+---+---+ */
4519 int fn = ((iw0 >> PseudoDbg_fn_bits) & PseudoDbg_fn_mask);
4520 int grp = ((iw0 >> PseudoDbg_grp_bits) & PseudoDbg_grp_mask);
4521 int reg = ((iw0 >> PseudoDbg_reg_bits) & PseudoDbg_reg_mask);
4526 if (reg == 0 && fn == 3)
4527 OUTS (outf, "DBG A0");
4529 else if (reg == 1 && fn == 3)
4530 OUTS (outf, "DBG A1");
4532 else if (reg == 3 && fn == 3)
4533 OUTS (outf, "ABORT");
4535 else if (reg == 4 && fn == 3)
4538 else if (reg == 5 && fn == 3)
4539 OUTS (outf, "DBGHALT");
4541 else if (reg == 6 && fn == 3)
4543 OUTS (outf, "DBGCMPLX (");
4544 OUTS (outf, dregs (grp));
4547 else if (reg == 7 && fn == 3)
4550 else if (grp == 0 && fn == 2)
4552 OUTS (outf, "OUTC ");
4553 OUTS (outf, dregs (reg));
4557 OUTS (outf, "DBG ");
4558 OUTS (outf, allregs (reg, grp));
4562 OUTS (outf, "PRNT ");
4563 OUTS (outf, allregs (reg, grp));
4572 decode_pseudoOChar_0 (TIword iw0, disassemble_info *outf)
4575 +---+---+---+---|---+---+---+---|---+---+---+---|---+---+---+---+
4576 | 1 | 1 | 1 | 1 | 1 | 0 | 0 | 1 |.ch............................|
4577 +---+---+---+---|---+---+---+---|---+---+---+---|---+---+---+---+ */
4578 int ch = ((iw0 >> PseudoChr_ch_bits) & PseudoChr_ch_mask);
4583 OUTS (outf, "OUTC ");
4584 OUTS (outf, uimm8 (ch));
4590 decode_pseudodbg_assert_0 (TIword iw0, TIword iw1, disassemble_info *outf)
4593 +---+---+---+---|---+---+---+---|---+---+---+---|---+---+---+---+
4594 | 1 | 1 | 1 | 1 | 0 | - | - | - | dbgop |.grp.......|.regtest...|
4595 |.expected......................................................|
4596 +---+---+---+---|---+---+---+---|---+---+---+---|---+---+---+---+ */
4597 int expected = ((iw1 >> PseudoDbg_Assert_expected_bits) & PseudoDbg_Assert_expected_mask);
4598 int dbgop = ((iw0 >> (PseudoDbg_Assert_dbgop_bits - 16)) & PseudoDbg_Assert_dbgop_mask);
4599 int grp = ((iw0 >> (PseudoDbg_Assert_grp_bits - 16)) & PseudoDbg_Assert_grp_mask);
4600 int regtest = ((iw0 >> (PseudoDbg_Assert_regtest_bits - 16)) & PseudoDbg_Assert_regtest_mask);
4607 OUTS (outf, "DBGA (");
4608 OUTS (outf, regs_lo (regtest, grp));
4610 OUTS (outf, uimm16 (expected));
4613 else if (dbgop == 1)
4615 OUTS (outf, "DBGA (");
4616 OUTS (outf, regs_hi (regtest, grp));
4618 OUTS (outf, uimm16 (expected));
4621 else if (dbgop == 2)
4623 OUTS (outf, "DBGAL (");
4624 OUTS (outf, allregs (regtest, grp));
4626 OUTS (outf, uimm16 (expected));
4629 else if (dbgop == 3)
4631 OUTS (outf, "DBGAH (");
4632 OUTS (outf, allregs (regtest, grp));
4634 OUTS (outf, uimm16 (expected));
4643 _print_insn_bfin (bfd_vma pc, disassemble_info *outf)
4651 status = (*outf->read_memory_func) (pc & ~0x1, buf, 2, outf);
4654 status = (*outf->read_memory_func) ((pc + 2) & ~0x1, buf + 2, 2, outf);
4658 iw0 = bfd_getl16 (buf);
4659 iw1 = bfd_getl16 (buf + 2);
4661 if ((iw0 & 0xf7ff) == 0xc003 && iw1 == 0x1800)
4665 OUTS (outf, "ILLEGAL");
4668 OUTS (outf, "MNOP");
4671 else if ((iw0 & 0xff00) == 0x0000)
4672 rv = decode_ProgCtrl_0 (iw0, outf);
4673 else if ((iw0 & 0xffc0) == 0x0240)
4674 rv = decode_CaCTRL_0 (iw0, outf);
4675 else if ((iw0 & 0xff80) == 0x0100)
4676 rv = decode_PushPopReg_0 (iw0, outf);
4677 else if ((iw0 & 0xfe00) == 0x0400)
4678 rv = decode_PushPopMultiple_0 (iw0, outf);
4679 else if ((iw0 & 0xfe00) == 0x0600)
4680 rv = decode_ccMV_0 (iw0, outf);
4681 else if ((iw0 & 0xf800) == 0x0800)
4682 rv = decode_CCflag_0 (iw0, outf);
4683 else if ((iw0 & 0xffe0) == 0x0200)
4684 rv = decode_CC2dreg_0 (iw0, outf);
4685 else if ((iw0 & 0xff00) == 0x0300)
4686 rv = decode_CC2stat_0 (iw0, outf);
4687 else if ((iw0 & 0xf000) == 0x1000)
4688 rv = decode_BRCC_0 (iw0, pc, outf);
4689 else if ((iw0 & 0xf000) == 0x2000)
4690 rv = decode_UJUMP_0 (iw0, pc, outf);
4691 else if ((iw0 & 0xf000) == 0x3000)
4692 rv = decode_REGMV_0 (iw0, outf);
4693 else if ((iw0 & 0xfc00) == 0x4000)
4694 rv = decode_ALU2op_0 (iw0, outf);
4695 else if ((iw0 & 0xfe00) == 0x4400)
4696 rv = decode_PTR2op_0 (iw0, outf);
4697 else if ((iw0 & 0xf800) == 0x4800)
4698 rv = decode_LOGI2op_0 (iw0, outf);
4699 else if ((iw0 & 0xf000) == 0x5000)
4700 rv = decode_COMP3op_0 (iw0, outf);
4701 else if ((iw0 & 0xf800) == 0x6000)
4702 rv = decode_COMPI2opD_0 (iw0, outf);
4703 else if ((iw0 & 0xf800) == 0x6800)
4704 rv = decode_COMPI2opP_0 (iw0, outf);
4705 else if ((iw0 & 0xf000) == 0x8000)
4706 rv = decode_LDSTpmod_0 (iw0, outf);
4707 else if ((iw0 & 0xff60) == 0x9e60)
4708 rv = decode_dagMODim_0 (iw0, outf);
4709 else if ((iw0 & 0xfff0) == 0x9f60)
4710 rv = decode_dagMODik_0 (iw0, outf);
4711 else if ((iw0 & 0xfc00) == 0x9c00)
4712 rv = decode_dspLDST_0 (iw0, outf);
4713 else if ((iw0 & 0xf000) == 0x9000)
4714 rv = decode_LDST_0 (iw0, outf);
4715 else if ((iw0 & 0xfc00) == 0xb800)
4716 rv = decode_LDSTiiFP_0 (iw0, outf);
4717 else if ((iw0 & 0xe000) == 0xA000)
4718 rv = decode_LDSTii_0 (iw0, outf);
4719 else if ((iw0 & 0xff80) == 0xe080 && (iw1 & 0x0C00) == 0x0000)
4720 rv = decode_LoopSetup_0 (iw0, iw1, pc, outf);
4721 else if ((iw0 & 0xff00) == 0xe100 && (iw1 & 0x0000) == 0x0000)
4722 rv = decode_LDIMMhalf_0 (iw0, iw1, outf);
4723 else if ((iw0 & 0xfe00) == 0xe200 && (iw1 & 0x0000) == 0x0000)
4724 rv = decode_CALLa_0 (iw0, iw1, pc, outf);
4725 else if ((iw0 & 0xfc00) == 0xe400 && (iw1 & 0x0000) == 0x0000)
4726 rv = decode_LDSTidxI_0 (iw0, iw1, outf);
4727 else if ((iw0 & 0xfffe) == 0xe800 && (iw1 & 0x0000) == 0x0000)
4728 rv = decode_linkage_0 (iw0, iw1, outf);
4729 else if ((iw0 & 0xf600) == 0xc000 && (iw1 & 0x0000) == 0x0000)
4730 rv = decode_dsp32mac_0 (iw0, iw1, outf);
4731 else if ((iw0 & 0xf600) == 0xc200 && (iw1 & 0x0000) == 0x0000)
4732 rv = decode_dsp32mult_0 (iw0, iw1, outf);
4733 else if ((iw0 & 0xf7c0) == 0xc400 && (iw1 & 0x0000) == 0x0000)
4734 rv = decode_dsp32alu_0 (iw0, iw1, outf);
4735 else if ((iw0 & 0xf780) == 0xc600 && (iw1 & 0x01c0) == 0x0000)
4736 rv = decode_dsp32shift_0 (iw0, iw1, outf);
4737 else if ((iw0 & 0xf780) == 0xc680 && (iw1 & 0x0000) == 0x0000)
4738 rv = decode_dsp32shiftimm_0 (iw0, iw1, outf);
4739 else if ((iw0 & 0xff00) == 0xf800)
4740 rv = decode_pseudoDEBUG_0 (iw0, outf);
4741 else if ((iw0 & 0xFF00) == 0xF900)
4742 rv = decode_pseudoOChar_0 (iw0, outf);
4743 else if ((iw0 & 0xFF00) == 0xf000 && (iw1 & 0x0000) == 0x0000)
4744 rv = decode_pseudodbg_assert_0 (iw0, iw1, outf);
4747 OUTS (outf, "ILLEGAL");
4753 print_insn_bfin (bfd_vma pc, disassemble_info *outf)
4760 status = (*outf->read_memory_func) (pc & ~0x01, buf, 2, outf);
4763 iw0 = bfd_getl16 (buf);
4765 count += _print_insn_bfin (pc, outf);
4767 /* Proper display of multiple issue instructions. */
4769 if (count == 4 && (iw0 & 0xc000) == 0xc000 && (iw0 & BIT_MULTI_INS)
4770 && ((iw0 & 0xe800) != 0xe800 /* Not Linkage. */ ))
4776 OUTS (outf, " || ");
4777 len = _print_insn_bfin (pc + 4, outf);
4778 OUTS (outf, " || ");
4781 len = _print_insn_bfin (pc + 6, outf);
4789 OUTS (outf, ";\t\t/* ILLEGAL PARALLEL INSTRUCTION */");