1*3d8817e4Smiod /* Disassemble i80960 instructions.
2*3d8817e4Smiod Copyright 1990, 1991, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, 2003
3*3d8817e4Smiod Free Software Foundation, Inc.
4*3d8817e4Smiod
5*3d8817e4Smiod This program is free software; you can redistribute it and/or modify
6*3d8817e4Smiod it under the terms of the GNU General Public License as published by
7*3d8817e4Smiod the Free Software Foundation; either version 2, or (at your option)
8*3d8817e4Smiod any later version.
9*3d8817e4Smiod
10*3d8817e4Smiod This program is distributed in the hope that it will be useful,
11*3d8817e4Smiod but WITHOUT ANY WARRANTY; without even the implied warranty of
12*3d8817e4Smiod MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13*3d8817e4Smiod GNU General Public License for more details.
14*3d8817e4Smiod
15*3d8817e4Smiod You should have received a copy of the GNU General Public License
16*3d8817e4Smiod along with this program; see the file COPYING. If not, write to the
17*3d8817e4Smiod Free Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA
18*3d8817e4Smiod 02110-1301, USA. */
19*3d8817e4Smiod
20*3d8817e4Smiod #include "sysdep.h"
21*3d8817e4Smiod #include "dis-asm.h"
22*3d8817e4Smiod
23*3d8817e4Smiod static const char *const reg_names[] = {
24*3d8817e4Smiod /* 0 */ "pfp", "sp", "rip", "r3", "r4", "r5", "r6", "r7",
25*3d8817e4Smiod /* 8 */ "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15",
26*3d8817e4Smiod /* 16 */ "g0", "g1", "g2", "g3", "g4", "g5", "g6", "g7",
27*3d8817e4Smiod /* 24 */ "g8", "g9", "g10", "g11", "g12", "g13", "g14", "fp",
28*3d8817e4Smiod /* 32 */ "pc", "ac", "ip", "tc", "fp0", "fp1", "fp2", "fp3"
29*3d8817e4Smiod };
30*3d8817e4Smiod
31*3d8817e4Smiod
32*3d8817e4Smiod static FILE *stream; /* Output goes here */
33*3d8817e4Smiod static struct disassemble_info *info;
34*3d8817e4Smiod static void print_addr (bfd_vma);
35*3d8817e4Smiod static void ctrl (bfd_vma, unsigned long, unsigned long);
36*3d8817e4Smiod static void cobr (bfd_vma, unsigned long, unsigned long);
37*3d8817e4Smiod static void reg (unsigned long);
38*3d8817e4Smiod static int mem (bfd_vma, unsigned long, unsigned long, int);
39*3d8817e4Smiod static void ea (bfd_vma, int, const char *, const char *, int, unsigned int);
40*3d8817e4Smiod static void dstop (int, int, int);
41*3d8817e4Smiod static void regop (int, int, int, int);
42*3d8817e4Smiod static void invalid (int);
43*3d8817e4Smiod static int pinsn (bfd_vma, unsigned long, unsigned long);
44*3d8817e4Smiod static void put_abs (unsigned long, unsigned long);
45*3d8817e4Smiod
46*3d8817e4Smiod
47*3d8817e4Smiod /* Print the i960 instruction at address 'memaddr' in debugged memory,
48*3d8817e4Smiod on INFO->STREAM. Returns length of the instruction, in bytes. */
49*3d8817e4Smiod
50*3d8817e4Smiod int
print_insn_i960(bfd_vma memaddr,struct disassemble_info * info_arg)51*3d8817e4Smiod print_insn_i960 (bfd_vma memaddr, struct disassemble_info *info_arg)
52*3d8817e4Smiod {
53*3d8817e4Smiod unsigned int word1, word2 = 0xdeadbeef;
54*3d8817e4Smiod bfd_byte buffer[8];
55*3d8817e4Smiod int status;
56*3d8817e4Smiod
57*3d8817e4Smiod info = info_arg;
58*3d8817e4Smiod stream = info->stream;
59*3d8817e4Smiod
60*3d8817e4Smiod /* Read word1. Only read word2 if the instruction
61*3d8817e4Smiod needs it, to prevent reading past the end of a section. */
62*3d8817e4Smiod
63*3d8817e4Smiod status = (*info->read_memory_func) (memaddr, (bfd_byte *) buffer, 4, info);
64*3d8817e4Smiod if (status != 0)
65*3d8817e4Smiod {
66*3d8817e4Smiod (*info->memory_error_func) (status, memaddr, info);
67*3d8817e4Smiod return -1;
68*3d8817e4Smiod }
69*3d8817e4Smiod
70*3d8817e4Smiod word1 = bfd_getl32 (buffer);
71*3d8817e4Smiod
72*3d8817e4Smiod /* Divide instruction set into classes based on high 4 bits of opcode. */
73*3d8817e4Smiod switch ( (word1 >> 28) & 0xf )
74*3d8817e4Smiod {
75*3d8817e4Smiod default:
76*3d8817e4Smiod break;
77*3d8817e4Smiod case 0x8:
78*3d8817e4Smiod case 0x9:
79*3d8817e4Smiod case 0xa:
80*3d8817e4Smiod case 0xb:
81*3d8817e4Smiod case 0xc:
82*3d8817e4Smiod /* Read word2. */
83*3d8817e4Smiod status = (*info->read_memory_func)
84*3d8817e4Smiod (memaddr + 4, (bfd_byte *) (buffer + 4), 4, info);
85*3d8817e4Smiod if (status != 0)
86*3d8817e4Smiod {
87*3d8817e4Smiod (*info->memory_error_func) (status, memaddr, info);
88*3d8817e4Smiod return -1;
89*3d8817e4Smiod }
90*3d8817e4Smiod word2 = bfd_getl32 (buffer + 4);
91*3d8817e4Smiod break;
92*3d8817e4Smiod }
93*3d8817e4Smiod
94*3d8817e4Smiod return pinsn( memaddr, word1, word2 );
95*3d8817e4Smiod }
96*3d8817e4Smiod
97*3d8817e4Smiod #define IN_GDB
98*3d8817e4Smiod
99*3d8817e4Smiod /*****************************************************************************
100*3d8817e4Smiod * All code below this point should be identical with that of
101*3d8817e4Smiod * the disassembler in gdmp960.
102*3d8817e4Smiod
103*3d8817e4Smiod A noble sentiment, but at least in cosmetic ways (info->fprintf_func), it
104*3d8817e4Smiod just ain't so. -kingdon, 31 Mar 93
105*3d8817e4Smiod *****************************************************************************/
106*3d8817e4Smiod
107*3d8817e4Smiod struct tabent {
108*3d8817e4Smiod char *name;
109*3d8817e4Smiod short numops;
110*3d8817e4Smiod };
111*3d8817e4Smiod
112*3d8817e4Smiod struct sparse_tabent {
113*3d8817e4Smiod int opcode;
114*3d8817e4Smiod char *name;
115*3d8817e4Smiod short numops;
116*3d8817e4Smiod };
117*3d8817e4Smiod
118*3d8817e4Smiod static int
pinsn(bfd_vma memaddr,unsigned long word1,unsigned long word2)119*3d8817e4Smiod pinsn (bfd_vma memaddr, unsigned long word1, unsigned long word2)
120*3d8817e4Smiod {
121*3d8817e4Smiod int instr_len;
122*3d8817e4Smiod
123*3d8817e4Smiod instr_len = 4;
124*3d8817e4Smiod put_abs (word1, word2);
125*3d8817e4Smiod
126*3d8817e4Smiod /* Divide instruction set into classes based on high 4 bits of opcode. */
127*3d8817e4Smiod switch ((word1 >> 28) & 0xf)
128*3d8817e4Smiod {
129*3d8817e4Smiod case 0x0:
130*3d8817e4Smiod case 0x1:
131*3d8817e4Smiod ctrl (memaddr, word1, word2);
132*3d8817e4Smiod break;
133*3d8817e4Smiod case 0x2:
134*3d8817e4Smiod case 0x3:
135*3d8817e4Smiod cobr (memaddr, word1, word2);
136*3d8817e4Smiod break;
137*3d8817e4Smiod case 0x5:
138*3d8817e4Smiod case 0x6:
139*3d8817e4Smiod case 0x7:
140*3d8817e4Smiod reg (word1);
141*3d8817e4Smiod break;
142*3d8817e4Smiod case 0x8:
143*3d8817e4Smiod case 0x9:
144*3d8817e4Smiod case 0xa:
145*3d8817e4Smiod case 0xb:
146*3d8817e4Smiod case 0xc:
147*3d8817e4Smiod instr_len = mem (memaddr, word1, word2, 0);
148*3d8817e4Smiod break;
149*3d8817e4Smiod default:
150*3d8817e4Smiod /* Invalid instruction, print as data word. */
151*3d8817e4Smiod invalid (word1);
152*3d8817e4Smiod break;
153*3d8817e4Smiod }
154*3d8817e4Smiod return instr_len;
155*3d8817e4Smiod }
156*3d8817e4Smiod
157*3d8817e4Smiod /* CTRL format.. */
158*3d8817e4Smiod
159*3d8817e4Smiod static void
ctrl(bfd_vma memaddr,unsigned long word1,unsigned long word2 ATTRIBUTE_UNUSED)160*3d8817e4Smiod ctrl (bfd_vma memaddr, unsigned long word1, unsigned long word2 ATTRIBUTE_UNUSED)
161*3d8817e4Smiod {
162*3d8817e4Smiod int i;
163*3d8817e4Smiod static const struct tabent ctrl_tab[] = {
164*3d8817e4Smiod { NULL, 0, }, /* 0x00 */
165*3d8817e4Smiod { NULL, 0, }, /* 0x01 */
166*3d8817e4Smiod { NULL, 0, }, /* 0x02 */
167*3d8817e4Smiod { NULL, 0, }, /* 0x03 */
168*3d8817e4Smiod { NULL, 0, }, /* 0x04 */
169*3d8817e4Smiod { NULL, 0, }, /* 0x05 */
170*3d8817e4Smiod { NULL, 0, }, /* 0x06 */
171*3d8817e4Smiod { NULL, 0, }, /* 0x07 */
172*3d8817e4Smiod { "b", 1, }, /* 0x08 */
173*3d8817e4Smiod { "call", 1, }, /* 0x09 */
174*3d8817e4Smiod { "ret", 0, }, /* 0x0a */
175*3d8817e4Smiod { "bal", 1, }, /* 0x0b */
176*3d8817e4Smiod { NULL, 0, }, /* 0x0c */
177*3d8817e4Smiod { NULL, 0, }, /* 0x0d */
178*3d8817e4Smiod { NULL, 0, }, /* 0x0e */
179*3d8817e4Smiod { NULL, 0, }, /* 0x0f */
180*3d8817e4Smiod { "bno", 1, }, /* 0x10 */
181*3d8817e4Smiod { "bg", 1, }, /* 0x11 */
182*3d8817e4Smiod { "be", 1, }, /* 0x12 */
183*3d8817e4Smiod { "bge", 1, }, /* 0x13 */
184*3d8817e4Smiod { "bl", 1, }, /* 0x14 */
185*3d8817e4Smiod { "bne", 1, }, /* 0x15 */
186*3d8817e4Smiod { "ble", 1, }, /* 0x16 */
187*3d8817e4Smiod { "bo", 1, }, /* 0x17 */
188*3d8817e4Smiod { "faultno", 0, }, /* 0x18 */
189*3d8817e4Smiod { "faultg", 0, }, /* 0x19 */
190*3d8817e4Smiod { "faulte", 0, }, /* 0x1a */
191*3d8817e4Smiod { "faultge", 0, }, /* 0x1b */
192*3d8817e4Smiod { "faultl", 0, }, /* 0x1c */
193*3d8817e4Smiod { "faultne", 0, }, /* 0x1d */
194*3d8817e4Smiod { "faultle", 0, }, /* 0x1e */
195*3d8817e4Smiod { "faulto", 0, }, /* 0x1f */
196*3d8817e4Smiod };
197*3d8817e4Smiod
198*3d8817e4Smiod i = (word1 >> 24) & 0xff;
199*3d8817e4Smiod if ((ctrl_tab[i].name == NULL) || ((word1 & 1) != 0))
200*3d8817e4Smiod {
201*3d8817e4Smiod invalid (word1);
202*3d8817e4Smiod return;
203*3d8817e4Smiod }
204*3d8817e4Smiod
205*3d8817e4Smiod (*info->fprintf_func) (stream, ctrl_tab[i].name);
206*3d8817e4Smiod if (word1 & 2)
207*3d8817e4Smiod /* Predicts branch not taken. */
208*3d8817e4Smiod (*info->fprintf_func) (stream, ".f");
209*3d8817e4Smiod
210*3d8817e4Smiod if (ctrl_tab[i].numops == 1)
211*3d8817e4Smiod {
212*3d8817e4Smiod /* Extract displacement and convert to address. */
213*3d8817e4Smiod word1 &= 0x00ffffff;
214*3d8817e4Smiod
215*3d8817e4Smiod if (word1 & 0x00800000)
216*3d8817e4Smiod {
217*3d8817e4Smiod /* Sign bit is set. */
218*3d8817e4Smiod word1 |= (-1 & ~0xffffff); /* Sign extend. */
219*3d8817e4Smiod }
220*3d8817e4Smiod
221*3d8817e4Smiod (*info->fprintf_func) (stream, "\t");
222*3d8817e4Smiod print_addr (word1 + memaddr);
223*3d8817e4Smiod }
224*3d8817e4Smiod }
225*3d8817e4Smiod
226*3d8817e4Smiod /* COBR format. */
227*3d8817e4Smiod
228*3d8817e4Smiod static void
cobr(bfd_vma memaddr,unsigned long word1,unsigned long word2 ATTRIBUTE_UNUSED)229*3d8817e4Smiod cobr (bfd_vma memaddr, unsigned long word1, unsigned long word2 ATTRIBUTE_UNUSED)
230*3d8817e4Smiod {
231*3d8817e4Smiod int src1;
232*3d8817e4Smiod int src2;
233*3d8817e4Smiod int i;
234*3d8817e4Smiod
235*3d8817e4Smiod static const struct tabent cobr_tab[] = {
236*3d8817e4Smiod { "testno", 1, }, /* 0x20 */
237*3d8817e4Smiod { "testg", 1, }, /* 0x21 */
238*3d8817e4Smiod { "teste", 1, }, /* 0x22 */
239*3d8817e4Smiod { "testge", 1, }, /* 0x23 */
240*3d8817e4Smiod { "testl", 1, }, /* 0x24 */
241*3d8817e4Smiod { "testne", 1, }, /* 0x25 */
242*3d8817e4Smiod { "testle", 1, }, /* 0x26 */
243*3d8817e4Smiod { "testo", 1, }, /* 0x27 */
244*3d8817e4Smiod { NULL, 0, }, /* 0x28 */
245*3d8817e4Smiod { NULL, 0, }, /* 0x29 */
246*3d8817e4Smiod { NULL, 0, }, /* 0x2a */
247*3d8817e4Smiod { NULL, 0, }, /* 0x2b */
248*3d8817e4Smiod { NULL, 0, }, /* 0x2c */
249*3d8817e4Smiod { NULL, 0, }, /* 0x2d */
250*3d8817e4Smiod { NULL, 0, }, /* 0x2e */
251*3d8817e4Smiod { NULL, 0, }, /* 0x2f */
252*3d8817e4Smiod { "bbc", 3, }, /* 0x30 */
253*3d8817e4Smiod { "cmpobg", 3, }, /* 0x31 */
254*3d8817e4Smiod { "cmpobe", 3, }, /* 0x32 */
255*3d8817e4Smiod { "cmpobge",3, }, /* 0x33 */
256*3d8817e4Smiod { "cmpobl", 3, }, /* 0x34 */
257*3d8817e4Smiod { "cmpobne",3, }, /* 0x35 */
258*3d8817e4Smiod { "cmpoble",3, }, /* 0x36 */
259*3d8817e4Smiod { "bbs", 3, }, /* 0x37 */
260*3d8817e4Smiod { "cmpibno",3, }, /* 0x38 */
261*3d8817e4Smiod { "cmpibg", 3, }, /* 0x39 */
262*3d8817e4Smiod { "cmpibe", 3, }, /* 0x3a */
263*3d8817e4Smiod { "cmpibge",3, }, /* 0x3b */
264*3d8817e4Smiod { "cmpibl", 3, }, /* 0x3c */
265*3d8817e4Smiod { "cmpibne",3, }, /* 0x3d */
266*3d8817e4Smiod { "cmpible",3, }, /* 0x3e */
267*3d8817e4Smiod { "cmpibo", 3, }, /* 0x3f */
268*3d8817e4Smiod };
269*3d8817e4Smiod
270*3d8817e4Smiod i = ((word1 >> 24) & 0xff) - 0x20;
271*3d8817e4Smiod if (cobr_tab[i].name == NULL)
272*3d8817e4Smiod {
273*3d8817e4Smiod invalid (word1);
274*3d8817e4Smiod return;
275*3d8817e4Smiod }
276*3d8817e4Smiod
277*3d8817e4Smiod (*info->fprintf_func) (stream, cobr_tab[i].name);
278*3d8817e4Smiod
279*3d8817e4Smiod /* Predicts branch not taken. */
280*3d8817e4Smiod if (word1 & 2)
281*3d8817e4Smiod (*info->fprintf_func) (stream, ".f");
282*3d8817e4Smiod
283*3d8817e4Smiod (*info->fprintf_func) (stream, "\t");
284*3d8817e4Smiod
285*3d8817e4Smiod src1 = (word1 >> 19) & 0x1f;
286*3d8817e4Smiod src2 = (word1 >> 14) & 0x1f;
287*3d8817e4Smiod
288*3d8817e4Smiod if (word1 & 0x02000)
289*3d8817e4Smiod /* M1 is 1 */
290*3d8817e4Smiod (*info->fprintf_func) (stream, "%d", src1);
291*3d8817e4Smiod else
292*3d8817e4Smiod (*info->fprintf_func) (stream, reg_names[src1]);
293*3d8817e4Smiod
294*3d8817e4Smiod if (cobr_tab[i].numops > 1)
295*3d8817e4Smiod {
296*3d8817e4Smiod if (word1 & 1)
297*3d8817e4Smiod /* S2 is 1. */
298*3d8817e4Smiod (*info->fprintf_func) (stream, ",sf%d,", src2);
299*3d8817e4Smiod else
300*3d8817e4Smiod /* S1 is 0. */
301*3d8817e4Smiod (*info->fprintf_func) (stream, ",%s,", reg_names[src2]);
302*3d8817e4Smiod
303*3d8817e4Smiod /* Extract displacement and convert to address. */
304*3d8817e4Smiod word1 &= 0x00001ffc;
305*3d8817e4Smiod if (word1 & 0x00001000)
306*3d8817e4Smiod /* Negative displacement. */
307*3d8817e4Smiod word1 |= (-1 & ~0x1fff); /* Sign extend. */
308*3d8817e4Smiod
309*3d8817e4Smiod print_addr (memaddr + word1);
310*3d8817e4Smiod }
311*3d8817e4Smiod }
312*3d8817e4Smiod
313*3d8817e4Smiod /* MEM format. */
314*3d8817e4Smiod /* Returns instruction length: 4 or 8. */
315*3d8817e4Smiod
316*3d8817e4Smiod static int
mem(bfd_vma memaddr,unsigned long word1,unsigned long word2,int noprint)317*3d8817e4Smiod mem (bfd_vma memaddr, unsigned long word1, unsigned long word2, int noprint)
318*3d8817e4Smiod {
319*3d8817e4Smiod int i, j;
320*3d8817e4Smiod int len;
321*3d8817e4Smiod int mode;
322*3d8817e4Smiod int offset;
323*3d8817e4Smiod const char *reg1, *reg2, *reg3;
324*3d8817e4Smiod
325*3d8817e4Smiod /* This lookup table is too sparse to make it worth typing in, but not
326*3d8817e4Smiod so large as to make a sparse array necessary. We create the table
327*3d8817e4Smiod at runtime. */
328*3d8817e4Smiod
329*3d8817e4Smiod /* NOTE: In this table, the meaning of 'numops' is:
330*3d8817e4Smiod 1: single operand
331*3d8817e4Smiod 2: 2 operands, load instruction
332*3d8817e4Smiod -2: 2 operands, store instruction. */
333*3d8817e4Smiod static struct tabent *mem_tab;
334*3d8817e4Smiod /* Opcodes of 0x8X, 9X, aX, bX, and cX must be in the table. */
335*3d8817e4Smiod #define MEM_MIN 0x80
336*3d8817e4Smiod #define MEM_MAX 0xcf
337*3d8817e4Smiod #define MEM_SIZ ( * sizeof(struct tabent))
338*3d8817e4Smiod
339*3d8817e4Smiod static const struct sparse_tabent mem_init[] = {
340*3d8817e4Smiod { 0x80, "ldob", 2 },
341*3d8817e4Smiod { 0x82, "stob", -2 },
342*3d8817e4Smiod { 0x84, "bx", 1 },
343*3d8817e4Smiod { 0x85, "balx", 2 },
344*3d8817e4Smiod { 0x86, "callx", 1 },
345*3d8817e4Smiod { 0x88, "ldos", 2 },
346*3d8817e4Smiod { 0x8a, "stos", -2 },
347*3d8817e4Smiod { 0x8c, "lda", 2 },
348*3d8817e4Smiod { 0x90, "ld", 2 },
349*3d8817e4Smiod { 0x92, "st", -2 },
350*3d8817e4Smiod { 0x98, "ldl", 2 },
351*3d8817e4Smiod { 0x9a, "stl", -2 },
352*3d8817e4Smiod { 0xa0, "ldt", 2 },
353*3d8817e4Smiod { 0xa2, "stt", -2 },
354*3d8817e4Smiod { 0xac, "dcinva", 1 },
355*3d8817e4Smiod { 0xb0, "ldq", 2 },
356*3d8817e4Smiod { 0xb2, "stq", -2 },
357*3d8817e4Smiod { 0xc0, "ldib", 2 },
358*3d8817e4Smiod { 0xc2, "stib", -2 },
359*3d8817e4Smiod { 0xc8, "ldis", 2 },
360*3d8817e4Smiod { 0xca, "stis", -2 },
361*3d8817e4Smiod { 0, NULL, 0 }
362*3d8817e4Smiod };
363*3d8817e4Smiod static struct tabent mem_tab_buf[MEM_MAX - MEM_MIN + 1];
364*3d8817e4Smiod
365*3d8817e4Smiod if (mem_tab == NULL)
366*3d8817e4Smiod {
367*3d8817e4Smiod mem_tab = mem_tab_buf;
368*3d8817e4Smiod
369*3d8817e4Smiod for (i = 0; mem_init[i].opcode != 0; i++)
370*3d8817e4Smiod {
371*3d8817e4Smiod j = mem_init[i].opcode - MEM_MIN;
372*3d8817e4Smiod mem_tab[j].name = mem_init[i].name;
373*3d8817e4Smiod mem_tab[j].numops = mem_init[i].numops;
374*3d8817e4Smiod }
375*3d8817e4Smiod }
376*3d8817e4Smiod
377*3d8817e4Smiod i = ((word1 >> 24) & 0xff) - MEM_MIN;
378*3d8817e4Smiod mode = (word1 >> 10) & 0xf;
379*3d8817e4Smiod
380*3d8817e4Smiod if ((mem_tab[i].name != NULL) /* Valid instruction */
381*3d8817e4Smiod && ((mode == 5) || (mode >= 12)))
382*3d8817e4Smiod /* With 32-bit displacement. */
383*3d8817e4Smiod len = 8;
384*3d8817e4Smiod else
385*3d8817e4Smiod len = 4;
386*3d8817e4Smiod
387*3d8817e4Smiod if (noprint)
388*3d8817e4Smiod return len;
389*3d8817e4Smiod
390*3d8817e4Smiod if ((mem_tab[i].name == NULL) || (mode == 6))
391*3d8817e4Smiod {
392*3d8817e4Smiod invalid (word1);
393*3d8817e4Smiod return len;
394*3d8817e4Smiod }
395*3d8817e4Smiod
396*3d8817e4Smiod (*info->fprintf_func) (stream, "%s\t", mem_tab[i].name);
397*3d8817e4Smiod
398*3d8817e4Smiod reg1 = reg_names[ (word1 >> 19) & 0x1f ]; /* MEMB only */
399*3d8817e4Smiod reg2 = reg_names[ (word1 >> 14) & 0x1f ];
400*3d8817e4Smiod reg3 = reg_names[ word1 & 0x1f ]; /* MEMB only */
401*3d8817e4Smiod offset = word1 & 0xfff; /* MEMA only */
402*3d8817e4Smiod
403*3d8817e4Smiod switch (mem_tab[i].numops)
404*3d8817e4Smiod {
405*3d8817e4Smiod case 2: /* LOAD INSTRUCTION */
406*3d8817e4Smiod if (mode & 4)
407*3d8817e4Smiod { /* MEMB FORMAT */
408*3d8817e4Smiod ea (memaddr, mode, reg2, reg3, word1, word2);
409*3d8817e4Smiod (*info->fprintf_func) (stream, ",%s", reg1);
410*3d8817e4Smiod }
411*3d8817e4Smiod else
412*3d8817e4Smiod { /* MEMA FORMAT */
413*3d8817e4Smiod (*info->fprintf_func) (stream, "0x%x", (unsigned) offset);
414*3d8817e4Smiod
415*3d8817e4Smiod if (mode & 8)
416*3d8817e4Smiod (*info->fprintf_func) (stream, "(%s)", reg2);
417*3d8817e4Smiod
418*3d8817e4Smiod (*info->fprintf_func)(stream, ",%s", reg1);
419*3d8817e4Smiod }
420*3d8817e4Smiod break;
421*3d8817e4Smiod
422*3d8817e4Smiod case -2: /* STORE INSTRUCTION */
423*3d8817e4Smiod if (mode & 4)
424*3d8817e4Smiod {
425*3d8817e4Smiod /* MEMB FORMAT */
426*3d8817e4Smiod (*info->fprintf_func) (stream, "%s,", reg1);
427*3d8817e4Smiod ea (memaddr, mode, reg2, reg3, word1, word2);
428*3d8817e4Smiod }
429*3d8817e4Smiod else
430*3d8817e4Smiod {
431*3d8817e4Smiod /* MEMA FORMAT */
432*3d8817e4Smiod (*info->fprintf_func) (stream, "%s,0x%x", reg1, (unsigned) offset);
433*3d8817e4Smiod
434*3d8817e4Smiod if (mode & 8)
435*3d8817e4Smiod (*info->fprintf_func) (stream, "(%s)", reg2);
436*3d8817e4Smiod }
437*3d8817e4Smiod break;
438*3d8817e4Smiod
439*3d8817e4Smiod case 1: /* BX/CALLX INSTRUCTION */
440*3d8817e4Smiod if (mode & 4)
441*3d8817e4Smiod {
442*3d8817e4Smiod /* MEMB FORMAT */
443*3d8817e4Smiod ea (memaddr, mode, reg2, reg3, word1, word2);
444*3d8817e4Smiod }
445*3d8817e4Smiod else
446*3d8817e4Smiod {
447*3d8817e4Smiod /* MEMA FORMAT */
448*3d8817e4Smiod (*info->fprintf_func) (stream, "0x%x", (unsigned) offset);
449*3d8817e4Smiod if (mode & 8)
450*3d8817e4Smiod (*info->fprintf_func) (stream, "(%s)", reg2);
451*3d8817e4Smiod }
452*3d8817e4Smiod break;
453*3d8817e4Smiod }
454*3d8817e4Smiod
455*3d8817e4Smiod return len;
456*3d8817e4Smiod }
457*3d8817e4Smiod
458*3d8817e4Smiod /* REG format. */
459*3d8817e4Smiod
460*3d8817e4Smiod static void
reg(unsigned long word1)461*3d8817e4Smiod reg (unsigned long word1)
462*3d8817e4Smiod {
463*3d8817e4Smiod int i, j;
464*3d8817e4Smiod int opcode;
465*3d8817e4Smiod int fp;
466*3d8817e4Smiod int m1, m2, m3;
467*3d8817e4Smiod int s1, s2;
468*3d8817e4Smiod int src, src2, dst;
469*3d8817e4Smiod char *mnemp;
470*3d8817e4Smiod
471*3d8817e4Smiod /* This lookup table is too sparse to make it worth typing in, but not
472*3d8817e4Smiod so large as to make a sparse array necessary. We create the table
473*3d8817e4Smiod at runtime. */
474*3d8817e4Smiod
475*3d8817e4Smiod /* NOTE: In this table, the meaning of 'numops' is:
476*3d8817e4Smiod 1: single operand, which is NOT a destination.
477*3d8817e4Smiod -1: single operand, which IS a destination.
478*3d8817e4Smiod 2: 2 operands, the 2nd of which is NOT a destination.
479*3d8817e4Smiod -2: 2 operands, the 2nd of which IS a destination.
480*3d8817e4Smiod 3: 3 operands
481*3d8817e4Smiod
482*3d8817e4Smiod If an opcode mnemonic begins with "F", it is a floating-point
483*3d8817e4Smiod opcode (the "F" is not printed). */
484*3d8817e4Smiod
485*3d8817e4Smiod static struct tabent *reg_tab;
486*3d8817e4Smiod static const struct sparse_tabent reg_init[] =
487*3d8817e4Smiod {
488*3d8817e4Smiod #define REG_MIN 0x580
489*3d8817e4Smiod { 0x580, "notbit", 3 },
490*3d8817e4Smiod { 0x581, "and", 3 },
491*3d8817e4Smiod { 0x582, "andnot", 3 },
492*3d8817e4Smiod { 0x583, "setbit", 3 },
493*3d8817e4Smiod { 0x584, "notand", 3 },
494*3d8817e4Smiod { 0x586, "xor", 3 },
495*3d8817e4Smiod { 0x587, "or", 3 },
496*3d8817e4Smiod { 0x588, "nor", 3 },
497*3d8817e4Smiod { 0x589, "xnor", 3 },
498*3d8817e4Smiod { 0x58a, "not", -2 },
499*3d8817e4Smiod { 0x58b, "ornot", 3 },
500*3d8817e4Smiod { 0x58c, "clrbit", 3 },
501*3d8817e4Smiod { 0x58d, "notor", 3 },
502*3d8817e4Smiod { 0x58e, "nand", 3 },
503*3d8817e4Smiod { 0x58f, "alterbit", 3 },
504*3d8817e4Smiod { 0x590, "addo", 3 },
505*3d8817e4Smiod { 0x591, "addi", 3 },
506*3d8817e4Smiod { 0x592, "subo", 3 },
507*3d8817e4Smiod { 0x593, "subi", 3 },
508*3d8817e4Smiod { 0x594, "cmpob", 2 },
509*3d8817e4Smiod { 0x595, "cmpib", 2 },
510*3d8817e4Smiod { 0x596, "cmpos", 2 },
511*3d8817e4Smiod { 0x597, "cmpis", 2 },
512*3d8817e4Smiod { 0x598, "shro", 3 },
513*3d8817e4Smiod { 0x59a, "shrdi", 3 },
514*3d8817e4Smiod { 0x59b, "shri", 3 },
515*3d8817e4Smiod { 0x59c, "shlo", 3 },
516*3d8817e4Smiod { 0x59d, "rotate", 3 },
517*3d8817e4Smiod { 0x59e, "shli", 3 },
518*3d8817e4Smiod { 0x5a0, "cmpo", 2 },
519*3d8817e4Smiod { 0x5a1, "cmpi", 2 },
520*3d8817e4Smiod { 0x5a2, "concmpo", 2 },
521*3d8817e4Smiod { 0x5a3, "concmpi", 2 },
522*3d8817e4Smiod { 0x5a4, "cmpinco", 3 },
523*3d8817e4Smiod { 0x5a5, "cmpinci", 3 },
524*3d8817e4Smiod { 0x5a6, "cmpdeco", 3 },
525*3d8817e4Smiod { 0x5a7, "cmpdeci", 3 },
526*3d8817e4Smiod { 0x5ac, "scanbyte", 2 },
527*3d8817e4Smiod { 0x5ad, "bswap", -2 },
528*3d8817e4Smiod { 0x5ae, "chkbit", 2 },
529*3d8817e4Smiod { 0x5b0, "addc", 3 },
530*3d8817e4Smiod { 0x5b2, "subc", 3 },
531*3d8817e4Smiod { 0x5b4, "intdis", 0 },
532*3d8817e4Smiod { 0x5b5, "inten", 0 },
533*3d8817e4Smiod { 0x5cc, "mov", -2 },
534*3d8817e4Smiod { 0x5d8, "eshro", 3 },
535*3d8817e4Smiod { 0x5dc, "movl", -2 },
536*3d8817e4Smiod { 0x5ec, "movt", -2 },
537*3d8817e4Smiod { 0x5fc, "movq", -2 },
538*3d8817e4Smiod { 0x600, "synmov", 2 },
539*3d8817e4Smiod { 0x601, "synmovl", 2 },
540*3d8817e4Smiod { 0x602, "synmovq", 2 },
541*3d8817e4Smiod { 0x603, "cmpstr", 3 },
542*3d8817e4Smiod { 0x604, "movqstr", 3 },
543*3d8817e4Smiod { 0x605, "movstr", 3 },
544*3d8817e4Smiod { 0x610, "atmod", 3 },
545*3d8817e4Smiod { 0x612, "atadd", 3 },
546*3d8817e4Smiod { 0x613, "inspacc", -2 },
547*3d8817e4Smiod { 0x614, "ldphy", -2 },
548*3d8817e4Smiod { 0x615, "synld", -2 },
549*3d8817e4Smiod { 0x617, "fill", 3 },
550*3d8817e4Smiod { 0x630, "sdma", 3 },
551*3d8817e4Smiod { 0x631, "udma", 0 },
552*3d8817e4Smiod { 0x640, "spanbit", -2 },
553*3d8817e4Smiod { 0x641, "scanbit", -2 },
554*3d8817e4Smiod { 0x642, "daddc", 3 },
555*3d8817e4Smiod { 0x643, "dsubc", 3 },
556*3d8817e4Smiod { 0x644, "dmovt", -2 },
557*3d8817e4Smiod { 0x645, "modac", 3 },
558*3d8817e4Smiod { 0x646, "condrec", -2 },
559*3d8817e4Smiod { 0x650, "modify", 3 },
560*3d8817e4Smiod { 0x651, "extract", 3 },
561*3d8817e4Smiod { 0x654, "modtc", 3 },
562*3d8817e4Smiod { 0x655, "modpc", 3 },
563*3d8817e4Smiod { 0x656, "receive", -2 },
564*3d8817e4Smiod { 0x658, "intctl", -2 },
565*3d8817e4Smiod { 0x659, "sysctl", 3 },
566*3d8817e4Smiod { 0x65b, "icctl", 3 },
567*3d8817e4Smiod { 0x65c, "dcctl", 3 },
568*3d8817e4Smiod { 0x65d, "halt", 0 },
569*3d8817e4Smiod { 0x660, "calls", 1 },
570*3d8817e4Smiod { 0x662, "send", 3 },
571*3d8817e4Smiod { 0x663, "sendserv", 1 },
572*3d8817e4Smiod { 0x664, "resumprcs", 1 },
573*3d8817e4Smiod { 0x665, "schedprcs", 1 },
574*3d8817e4Smiod { 0x666, "saveprcs", 0 },
575*3d8817e4Smiod { 0x668, "condwait", 1 },
576*3d8817e4Smiod { 0x669, "wait", 1 },
577*3d8817e4Smiod { 0x66a, "signal", 1 },
578*3d8817e4Smiod { 0x66b, "mark", 0 },
579*3d8817e4Smiod { 0x66c, "fmark", 0 },
580*3d8817e4Smiod { 0x66d, "flushreg", 0 },
581*3d8817e4Smiod { 0x66f, "syncf", 0 },
582*3d8817e4Smiod { 0x670, "emul", 3 },
583*3d8817e4Smiod { 0x671, "ediv", 3 },
584*3d8817e4Smiod { 0x673, "ldtime", -1 },
585*3d8817e4Smiod { 0x674, "Fcvtir", -2 },
586*3d8817e4Smiod { 0x675, "Fcvtilr", -2 },
587*3d8817e4Smiod { 0x676, "Fscalerl", 3 },
588*3d8817e4Smiod { 0x677, "Fscaler", 3 },
589*3d8817e4Smiod { 0x680, "Fatanr", 3 },
590*3d8817e4Smiod { 0x681, "Flogepr", 3 },
591*3d8817e4Smiod { 0x682, "Flogr", 3 },
592*3d8817e4Smiod { 0x683, "Fremr", 3 },
593*3d8817e4Smiod { 0x684, "Fcmpor", 2 },
594*3d8817e4Smiod { 0x685, "Fcmpr", 2 },
595*3d8817e4Smiod { 0x688, "Fsqrtr", -2 },
596*3d8817e4Smiod { 0x689, "Fexpr", -2 },
597*3d8817e4Smiod { 0x68a, "Flogbnr", -2 },
598*3d8817e4Smiod { 0x68b, "Froundr", -2 },
599*3d8817e4Smiod { 0x68c, "Fsinr", -2 },
600*3d8817e4Smiod { 0x68d, "Fcosr", -2 },
601*3d8817e4Smiod { 0x68e, "Ftanr", -2 },
602*3d8817e4Smiod { 0x68f, "Fclassr", 1 },
603*3d8817e4Smiod { 0x690, "Fatanrl", 3 },
604*3d8817e4Smiod { 0x691, "Flogeprl", 3 },
605*3d8817e4Smiod { 0x692, "Flogrl", 3 },
606*3d8817e4Smiod { 0x693, "Fremrl", 3 },
607*3d8817e4Smiod { 0x694, "Fcmporl", 2 },
608*3d8817e4Smiod { 0x695, "Fcmprl", 2 },
609*3d8817e4Smiod { 0x698, "Fsqrtrl", -2 },
610*3d8817e4Smiod { 0x699, "Fexprl", -2 },
611*3d8817e4Smiod { 0x69a, "Flogbnrl", -2 },
612*3d8817e4Smiod { 0x69b, "Froundrl", -2 },
613*3d8817e4Smiod { 0x69c, "Fsinrl", -2 },
614*3d8817e4Smiod { 0x69d, "Fcosrl", -2 },
615*3d8817e4Smiod { 0x69e, "Ftanrl", -2 },
616*3d8817e4Smiod { 0x69f, "Fclassrl", 1 },
617*3d8817e4Smiod { 0x6c0, "Fcvtri", -2 },
618*3d8817e4Smiod { 0x6c1, "Fcvtril", -2 },
619*3d8817e4Smiod { 0x6c2, "Fcvtzri", -2 },
620*3d8817e4Smiod { 0x6c3, "Fcvtzril", -2 },
621*3d8817e4Smiod { 0x6c9, "Fmovr", -2 },
622*3d8817e4Smiod { 0x6d9, "Fmovrl", -2 },
623*3d8817e4Smiod { 0x6e1, "Fmovre", -2 },
624*3d8817e4Smiod { 0x6e2, "Fcpysre", 3 },
625*3d8817e4Smiod { 0x6e3, "Fcpyrsre", 3 },
626*3d8817e4Smiod { 0x701, "mulo", 3 },
627*3d8817e4Smiod { 0x708, "remo", 3 },
628*3d8817e4Smiod { 0x70b, "divo", 3 },
629*3d8817e4Smiod { 0x741, "muli", 3 },
630*3d8817e4Smiod { 0x748, "remi", 3 },
631*3d8817e4Smiod { 0x749, "modi", 3 },
632*3d8817e4Smiod { 0x74b, "divi", 3 },
633*3d8817e4Smiod { 0x780, "addono", 3 },
634*3d8817e4Smiod { 0x781, "addino", 3 },
635*3d8817e4Smiod { 0x782, "subono", 3 },
636*3d8817e4Smiod { 0x783, "subino", 3 },
637*3d8817e4Smiod { 0x784, "selno", 3 },
638*3d8817e4Smiod { 0x78b, "Fdivr", 3 },
639*3d8817e4Smiod { 0x78c, "Fmulr", 3 },
640*3d8817e4Smiod { 0x78d, "Fsubr", 3 },
641*3d8817e4Smiod { 0x78f, "Faddr", 3 },
642*3d8817e4Smiod { 0x790, "addog", 3 },
643*3d8817e4Smiod { 0x791, "addig", 3 },
644*3d8817e4Smiod { 0x792, "subog", 3 },
645*3d8817e4Smiod { 0x793, "subig", 3 },
646*3d8817e4Smiod { 0x794, "selg", 3 },
647*3d8817e4Smiod { 0x79b, "Fdivrl", 3 },
648*3d8817e4Smiod { 0x79c, "Fmulrl", 3 },
649*3d8817e4Smiod { 0x79d, "Fsubrl", 3 },
650*3d8817e4Smiod { 0x79f, "Faddrl", 3 },
651*3d8817e4Smiod { 0x7a0, "addoe", 3 },
652*3d8817e4Smiod { 0x7a1, "addie", 3 },
653*3d8817e4Smiod { 0x7a2, "suboe", 3 },
654*3d8817e4Smiod { 0x7a3, "subie", 3 },
655*3d8817e4Smiod { 0x7a4, "sele", 3 },
656*3d8817e4Smiod { 0x7b0, "addoge", 3 },
657*3d8817e4Smiod { 0x7b1, "addige", 3 },
658*3d8817e4Smiod { 0x7b2, "suboge", 3 },
659*3d8817e4Smiod { 0x7b3, "subige", 3 },
660*3d8817e4Smiod { 0x7b4, "selge", 3 },
661*3d8817e4Smiod { 0x7c0, "addol", 3 },
662*3d8817e4Smiod { 0x7c1, "addil", 3 },
663*3d8817e4Smiod { 0x7c2, "subol", 3 },
664*3d8817e4Smiod { 0x7c3, "subil", 3 },
665*3d8817e4Smiod { 0x7c4, "sell", 3 },
666*3d8817e4Smiod { 0x7d0, "addone", 3 },
667*3d8817e4Smiod { 0x7d1, "addine", 3 },
668*3d8817e4Smiod { 0x7d2, "subone", 3 },
669*3d8817e4Smiod { 0x7d3, "subine", 3 },
670*3d8817e4Smiod { 0x7d4, "selne", 3 },
671*3d8817e4Smiod { 0x7e0, "addole", 3 },
672*3d8817e4Smiod { 0x7e1, "addile", 3 },
673*3d8817e4Smiod { 0x7e2, "subole", 3 },
674*3d8817e4Smiod { 0x7e3, "subile", 3 },
675*3d8817e4Smiod { 0x7e4, "selle", 3 },
676*3d8817e4Smiod { 0x7f0, "addoo", 3 },
677*3d8817e4Smiod { 0x7f1, "addio", 3 },
678*3d8817e4Smiod { 0x7f2, "suboo", 3 },
679*3d8817e4Smiod { 0x7f3, "subio", 3 },
680*3d8817e4Smiod { 0x7f4, "selo", 3 },
681*3d8817e4Smiod #define REG_MAX 0x7f4
682*3d8817e4Smiod { 0, NULL, 0 }
683*3d8817e4Smiod };
684*3d8817e4Smiod static struct tabent reg_tab_buf[REG_MAX - REG_MIN + 1];
685*3d8817e4Smiod
686*3d8817e4Smiod if (reg_tab == NULL)
687*3d8817e4Smiod {
688*3d8817e4Smiod reg_tab = reg_tab_buf;
689*3d8817e4Smiod
690*3d8817e4Smiod for (i = 0; reg_init[i].opcode != 0; i++)
691*3d8817e4Smiod {
692*3d8817e4Smiod j = reg_init[i].opcode - REG_MIN;
693*3d8817e4Smiod reg_tab[j].name = reg_init[i].name;
694*3d8817e4Smiod reg_tab[j].numops = reg_init[i].numops;
695*3d8817e4Smiod }
696*3d8817e4Smiod }
697*3d8817e4Smiod
698*3d8817e4Smiod opcode = ((word1 >> 20) & 0xff0) | ((word1 >> 7) & 0xf);
699*3d8817e4Smiod i = opcode - REG_MIN;
700*3d8817e4Smiod
701*3d8817e4Smiod if ((opcode<REG_MIN) || (opcode>REG_MAX) || (reg_tab[i].name==NULL))
702*3d8817e4Smiod {
703*3d8817e4Smiod invalid (word1);
704*3d8817e4Smiod return;
705*3d8817e4Smiod }
706*3d8817e4Smiod
707*3d8817e4Smiod mnemp = reg_tab[i].name;
708*3d8817e4Smiod if (*mnemp == 'F')
709*3d8817e4Smiod {
710*3d8817e4Smiod fp = 1;
711*3d8817e4Smiod mnemp++;
712*3d8817e4Smiod }
713*3d8817e4Smiod else
714*3d8817e4Smiod {
715*3d8817e4Smiod fp = 0;
716*3d8817e4Smiod }
717*3d8817e4Smiod
718*3d8817e4Smiod (*info->fprintf_func) (stream, mnemp);
719*3d8817e4Smiod
720*3d8817e4Smiod s1 = (word1 >> 5) & 1;
721*3d8817e4Smiod s2 = (word1 >> 6) & 1;
722*3d8817e4Smiod m1 = (word1 >> 11) & 1;
723*3d8817e4Smiod m2 = (word1 >> 12) & 1;
724*3d8817e4Smiod m3 = (word1 >> 13) & 1;
725*3d8817e4Smiod src = word1 & 0x1f;
726*3d8817e4Smiod src2 = (word1 >> 14) & 0x1f;
727*3d8817e4Smiod dst = (word1 >> 19) & 0x1f;
728*3d8817e4Smiod
729*3d8817e4Smiod if (reg_tab[i].numops != 0)
730*3d8817e4Smiod {
731*3d8817e4Smiod (*info->fprintf_func) (stream, "\t");
732*3d8817e4Smiod
733*3d8817e4Smiod switch (reg_tab[i].numops)
734*3d8817e4Smiod {
735*3d8817e4Smiod case 1:
736*3d8817e4Smiod regop (m1, s1, src, fp);
737*3d8817e4Smiod break;
738*3d8817e4Smiod case -1:
739*3d8817e4Smiod dstop (m3, dst, fp);
740*3d8817e4Smiod break;
741*3d8817e4Smiod case 2:
742*3d8817e4Smiod regop (m1, s1, src, fp);
743*3d8817e4Smiod (*info->fprintf_func) (stream, ",");
744*3d8817e4Smiod regop (m2, s2, src2, fp);
745*3d8817e4Smiod break;
746*3d8817e4Smiod case -2:
747*3d8817e4Smiod regop (m1, s1, src, fp);
748*3d8817e4Smiod (*info->fprintf_func) (stream, ",");
749*3d8817e4Smiod dstop (m3, dst, fp);
750*3d8817e4Smiod break;
751*3d8817e4Smiod case 3:
752*3d8817e4Smiod regop (m1, s1, src, fp);
753*3d8817e4Smiod (*info->fprintf_func) (stream, ",");
754*3d8817e4Smiod regop (m2, s2, src2, fp);
755*3d8817e4Smiod (*info->fprintf_func) (stream, ",");
756*3d8817e4Smiod dstop (m3, dst, fp);
757*3d8817e4Smiod break;
758*3d8817e4Smiod }
759*3d8817e4Smiod }
760*3d8817e4Smiod }
761*3d8817e4Smiod
762*3d8817e4Smiod /* Print out effective address for memb instructions. */
763*3d8817e4Smiod
764*3d8817e4Smiod static void
ea(bfd_vma memaddr,int mode,const char * reg2,const char * reg3,int word1,unsigned int word2)765*3d8817e4Smiod ea (bfd_vma memaddr, int mode, const char *reg2, const char *reg3, int word1,
766*3d8817e4Smiod unsigned int word2)
767*3d8817e4Smiod {
768*3d8817e4Smiod int scale;
769*3d8817e4Smiod static const int scale_tab[] = { 1, 2, 4, 8, 16 };
770*3d8817e4Smiod
771*3d8817e4Smiod scale = (word1 >> 7) & 0x07;
772*3d8817e4Smiod
773*3d8817e4Smiod if ((scale > 4) || (((word1 >> 5) & 0x03) != 0))
774*3d8817e4Smiod {
775*3d8817e4Smiod invalid (word1);
776*3d8817e4Smiod return;
777*3d8817e4Smiod }
778*3d8817e4Smiod scale = scale_tab[scale];
779*3d8817e4Smiod
780*3d8817e4Smiod switch (mode)
781*3d8817e4Smiod {
782*3d8817e4Smiod case 4: /* (reg) */
783*3d8817e4Smiod (*info->fprintf_func)( stream, "(%s)", reg2 );
784*3d8817e4Smiod break;
785*3d8817e4Smiod case 5: /* displ+8(ip) */
786*3d8817e4Smiod print_addr (word2 + 8 + memaddr);
787*3d8817e4Smiod break;
788*3d8817e4Smiod case 7: /* (reg)[index*scale] */
789*3d8817e4Smiod if (scale == 1)
790*3d8817e4Smiod (*info->fprintf_func) (stream, "(%s)[%s]", reg2, reg3);
791*3d8817e4Smiod else
792*3d8817e4Smiod (*info->fprintf_func) (stream, "(%s)[%s*%d]", reg2, reg3, scale);
793*3d8817e4Smiod break;
794*3d8817e4Smiod case 12: /* displacement */
795*3d8817e4Smiod print_addr ((bfd_vma) word2);
796*3d8817e4Smiod break;
797*3d8817e4Smiod case 13: /* displ(reg) */
798*3d8817e4Smiod print_addr ((bfd_vma) word2);
799*3d8817e4Smiod (*info->fprintf_func) (stream, "(%s)", reg2);
800*3d8817e4Smiod break;
801*3d8817e4Smiod case 14: /* displ[index*scale] */
802*3d8817e4Smiod print_addr ((bfd_vma) word2);
803*3d8817e4Smiod if (scale == 1)
804*3d8817e4Smiod (*info->fprintf_func) (stream, "[%s]", reg3);
805*3d8817e4Smiod else
806*3d8817e4Smiod (*info->fprintf_func) (stream, "[%s*%d]", reg3, scale);
807*3d8817e4Smiod break;
808*3d8817e4Smiod case 15: /* displ(reg)[index*scale] */
809*3d8817e4Smiod print_addr ((bfd_vma) word2);
810*3d8817e4Smiod if (scale == 1)
811*3d8817e4Smiod (*info->fprintf_func) (stream, "(%s)[%s]", reg2, reg3);
812*3d8817e4Smiod else
813*3d8817e4Smiod (*info->fprintf_func) (stream, "(%s)[%s*%d]", reg2, reg3, scale);
814*3d8817e4Smiod break;
815*3d8817e4Smiod default:
816*3d8817e4Smiod invalid (word1);
817*3d8817e4Smiod return;
818*3d8817e4Smiod }
819*3d8817e4Smiod }
820*3d8817e4Smiod
821*3d8817e4Smiod
822*3d8817e4Smiod /* Register Instruction Operand. */
823*3d8817e4Smiod
824*3d8817e4Smiod static void
regop(int mode,int spec,int reg,int fp)825*3d8817e4Smiod regop (int mode, int spec, int reg, int fp)
826*3d8817e4Smiod {
827*3d8817e4Smiod if (fp)
828*3d8817e4Smiod {
829*3d8817e4Smiod /* Floating point instruction. */
830*3d8817e4Smiod if (mode == 1)
831*3d8817e4Smiod {
832*3d8817e4Smiod /* FP operand. */
833*3d8817e4Smiod switch (reg)
834*3d8817e4Smiod {
835*3d8817e4Smiod case 0: (*info->fprintf_func) (stream, "fp0");
836*3d8817e4Smiod break;
837*3d8817e4Smiod case 1: (*info->fprintf_func) (stream, "fp1");
838*3d8817e4Smiod break;
839*3d8817e4Smiod case 2: (*info->fprintf_func) (stream, "fp2");
840*3d8817e4Smiod break;
841*3d8817e4Smiod case 3: (*info->fprintf_func) (stream, "fp3");
842*3d8817e4Smiod break;
843*3d8817e4Smiod case 16: (*info->fprintf_func) (stream, "0f0.0");
844*3d8817e4Smiod break;
845*3d8817e4Smiod case 22: (*info->fprintf_func) (stream, "0f1.0");
846*3d8817e4Smiod break;
847*3d8817e4Smiod default: (*info->fprintf_func) (stream, "?");
848*3d8817e4Smiod break;
849*3d8817e4Smiod }
850*3d8817e4Smiod }
851*3d8817e4Smiod else
852*3d8817e4Smiod {
853*3d8817e4Smiod /* Non-FP register. */
854*3d8817e4Smiod (*info->fprintf_func) (stream, reg_names[reg]);
855*3d8817e4Smiod }
856*3d8817e4Smiod }
857*3d8817e4Smiod else
858*3d8817e4Smiod {
859*3d8817e4Smiod /* Not floating point. */
860*3d8817e4Smiod if (mode == 1)
861*3d8817e4Smiod {
862*3d8817e4Smiod /* Literal. */
863*3d8817e4Smiod (*info->fprintf_func) (stream, "%d", reg);
864*3d8817e4Smiod }
865*3d8817e4Smiod else
866*3d8817e4Smiod {
867*3d8817e4Smiod /* Register. */
868*3d8817e4Smiod if (spec == 0)
869*3d8817e4Smiod (*info->fprintf_func) (stream, reg_names[reg]);
870*3d8817e4Smiod else
871*3d8817e4Smiod (*info->fprintf_func) (stream, "sf%d", reg);
872*3d8817e4Smiod }
873*3d8817e4Smiod }
874*3d8817e4Smiod }
875*3d8817e4Smiod
876*3d8817e4Smiod /* Register Instruction Destination Operand. */
877*3d8817e4Smiod
878*3d8817e4Smiod static void
dstop(int mode,int reg,int fp)879*3d8817e4Smiod dstop (int mode, int reg, int fp)
880*3d8817e4Smiod {
881*3d8817e4Smiod /* 'dst' operand can't be a literal. On non-FP instructions, register
882*3d8817e4Smiod mode is assumed and "m3" acts as if were "s3"; on FP-instructions,
883*3d8817e4Smiod sf registers are not allowed so m3 acts normally. */
884*3d8817e4Smiod if (fp)
885*3d8817e4Smiod regop (mode, 0, reg, fp);
886*3d8817e4Smiod else
887*3d8817e4Smiod regop (0, mode, reg, fp);
888*3d8817e4Smiod }
889*3d8817e4Smiod
890*3d8817e4Smiod static void
invalid(int word1)891*3d8817e4Smiod invalid (int word1)
892*3d8817e4Smiod {
893*3d8817e4Smiod (*info->fprintf_func) (stream, ".word\t0x%08x", (unsigned) word1);
894*3d8817e4Smiod }
895*3d8817e4Smiod
896*3d8817e4Smiod static void
print_addr(bfd_vma a)897*3d8817e4Smiod print_addr (bfd_vma a)
898*3d8817e4Smiod {
899*3d8817e4Smiod (*info->print_address_func) (a, info);
900*3d8817e4Smiod }
901*3d8817e4Smiod
902*3d8817e4Smiod static void
put_abs(unsigned long word1 ATTRIBUTE_UNUSED,unsigned long word2 ATTRIBUTE_UNUSED)903*3d8817e4Smiod put_abs (unsigned long word1 ATTRIBUTE_UNUSED,
904*3d8817e4Smiod unsigned long word2 ATTRIBUTE_UNUSED)
905*3d8817e4Smiod {
906*3d8817e4Smiod #ifdef IN_GDB
907*3d8817e4Smiod return;
908*3d8817e4Smiod #else
909*3d8817e4Smiod int len;
910*3d8817e4Smiod
911*3d8817e4Smiod switch ((word1 >> 28) & 0xf)
912*3d8817e4Smiod {
913*3d8817e4Smiod case 0x8:
914*3d8817e4Smiod case 0x9:
915*3d8817e4Smiod case 0xa:
916*3d8817e4Smiod case 0xb:
917*3d8817e4Smiod case 0xc:
918*3d8817e4Smiod /* MEM format instruction. */
919*3d8817e4Smiod len = mem (0, word1, word2, 1);
920*3d8817e4Smiod break;
921*3d8817e4Smiod default:
922*3d8817e4Smiod len = 4;
923*3d8817e4Smiod break;
924*3d8817e4Smiod }
925*3d8817e4Smiod
926*3d8817e4Smiod if (len == 8)
927*3d8817e4Smiod (*info->fprintf_func) (stream, "%08x %08x\t", word1, word2);
928*3d8817e4Smiod else
929*3d8817e4Smiod (*info->fprintf_func) (stream, "%08x \t", word1);
930*3d8817e4Smiod #endif
931*3d8817e4Smiod }
932