12159047fSniklas /* Disassemble i80960 instructions.
2*007c2a45Smiod Copyright 1990, 1991, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, 2003
3b55d4692Sfgsch Free Software Foundation, Inc.
42159047fSniklas
52159047fSniklas This program is free software; you can redistribute it and/or modify
62159047fSniklas it under the terms of the GNU General Public License as published by
72159047fSniklas the Free Software Foundation; either version 2, or (at your option)
82159047fSniklas any later version.
92159047fSniklas
102159047fSniklas This program is distributed in the hope that it will be useful,
112159047fSniklas but WITHOUT ANY WARRANTY; without even the implied warranty of
122159047fSniklas MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
132159047fSniklas GNU General Public License for more details.
142159047fSniklas
152159047fSniklas You should have received a copy of the GNU General Public License
16b305b0f1Sespie along with this program; see the file COPYING. If not, write to the
17b305b0f1Sespie Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
18b305b0f1Sespie 02111-1307, USA. */
192159047fSniklas
20b305b0f1Sespie #include "sysdep.h"
212159047fSniklas #include "dis-asm.h"
222159047fSniklas
232159047fSniklas static const char *const reg_names[] = {
242159047fSniklas /* 0 */ "pfp", "sp", "rip", "r3", "r4", "r5", "r6", "r7",
252159047fSniklas /* 8 */ "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15",
262159047fSniklas /* 16 */ "g0", "g1", "g2", "g3", "g4", "g5", "g6", "g7",
272159047fSniklas /* 24 */ "g8", "g9", "g10", "g11", "g12", "g13", "g14", "fp",
282159047fSniklas /* 32 */ "pc", "ac", "ip", "tc", "fp0", "fp1", "fp2", "fp3"
292159047fSniklas };
302159047fSniklas
312159047fSniklas
322159047fSniklas static FILE *stream; /* Output goes here */
332159047fSniklas static struct disassemble_info *info;
34*007c2a45Smiod static void print_addr (bfd_vma);
35*007c2a45Smiod static void ctrl (bfd_vma, unsigned long, unsigned long);
36*007c2a45Smiod static void cobr (bfd_vma, unsigned long, unsigned long);
37*007c2a45Smiod static void reg (unsigned long);
38*007c2a45Smiod static int mem (bfd_vma, unsigned long, unsigned long, int);
39*007c2a45Smiod static void ea (bfd_vma, int, const char *, const char *, int, unsigned int);
40*007c2a45Smiod static void dstop (int, int, int);
41*007c2a45Smiod static void regop (int, int, int, int);
42*007c2a45Smiod static void invalid (int);
43*007c2a45Smiod static int pinsn (bfd_vma, unsigned long, unsigned long);
44*007c2a45Smiod static void put_abs (unsigned long, unsigned long);
452159047fSniklas
462159047fSniklas
472159047fSniklas /* Print the i960 instruction at address 'memaddr' in debugged memory,
482159047fSniklas on INFO->STREAM. Returns length of the instruction, in bytes. */
492159047fSniklas
502159047fSniklas int
print_insn_i960(bfd_vma memaddr,struct disassemble_info * info_arg)51*007c2a45Smiod print_insn_i960 (bfd_vma memaddr, struct disassemble_info *info_arg)
522159047fSniklas {
532159047fSniklas unsigned int word1, word2 = 0xdeadbeef;
542159047fSniklas bfd_byte buffer[8];
552159047fSniklas int status;
562159047fSniklas
572159047fSniklas info = info_arg;
582159047fSniklas stream = info->stream;
592159047fSniklas
602159047fSniklas /* Read word1. Only read word2 if the instruction
612159047fSniklas needs it, to prevent reading past the end of a section. */
622159047fSniklas
632159047fSniklas status = (*info->read_memory_func) (memaddr, (bfd_byte *) buffer, 4, info);
642159047fSniklas if (status != 0)
652159047fSniklas {
662159047fSniklas (*info->memory_error_func) (status, memaddr, info);
672159047fSniklas return -1;
682159047fSniklas }
692159047fSniklas
702159047fSniklas word1 = bfd_getl32 (buffer);
712159047fSniklas
722159047fSniklas /* Divide instruction set into classes based on high 4 bits of opcode. */
732159047fSniklas switch ( (word1 >> 28) & 0xf )
742159047fSniklas {
752159047fSniklas default:
762159047fSniklas break;
772159047fSniklas case 0x8:
782159047fSniklas case 0x9:
792159047fSniklas case 0xa:
802159047fSniklas case 0xb:
812159047fSniklas case 0xc:
822159047fSniklas /* Read word2. */
832159047fSniklas status = (*info->read_memory_func)
842159047fSniklas (memaddr + 4, (bfd_byte *) (buffer + 4), 4, info);
852159047fSniklas if (status != 0)
862159047fSniklas {
872159047fSniklas (*info->memory_error_func) (status, memaddr, info);
882159047fSniklas return -1;
892159047fSniklas }
902159047fSniklas word2 = bfd_getl32 (buffer + 4);
912159047fSniklas break;
922159047fSniklas }
932159047fSniklas
942159047fSniklas return pinsn( memaddr, word1, word2 );
952159047fSniklas }
962159047fSniklas
972159047fSniklas #define IN_GDB
982159047fSniklas
992159047fSniklas /*****************************************************************************
1002159047fSniklas * All code below this point should be identical with that of
1012159047fSniklas * the disassembler in gdmp960.
1022159047fSniklas
1032159047fSniklas A noble sentiment, but at least in cosmetic ways (info->fprintf_func), it
1042159047fSniklas just ain't so. -kingdon, 31 Mar 93
1052159047fSniklas *****************************************************************************/
1062159047fSniklas
1072159047fSniklas struct tabent {
1082159047fSniklas char *name;
1092159047fSniklas short numops;
1102159047fSniklas };
1112159047fSniklas
1122159047fSniklas struct sparse_tabent {
1132159047fSniklas int opcode;
1142159047fSniklas char *name;
1152159047fSniklas short numops;
1162159047fSniklas };
1172159047fSniklas
1182159047fSniklas static int
pinsn(bfd_vma memaddr,unsigned long word1,unsigned long word2)119*007c2a45Smiod pinsn (bfd_vma memaddr, unsigned long word1, unsigned long word2)
1202159047fSniklas {
1212159047fSniklas int instr_len;
1222159047fSniklas
1232159047fSniklas instr_len = 4;
1242159047fSniklas put_abs (word1, word2);
1252159047fSniklas
126c074d1c9Sdrahn /* Divide instruction set into classes based on high 4 bits of opcode. */
127c074d1c9Sdrahn switch ((word1 >> 28) & 0xf)
128c074d1c9Sdrahn {
1292159047fSniklas case 0x0:
1302159047fSniklas case 0x1:
1312159047fSniklas ctrl (memaddr, word1, word2);
1322159047fSniklas break;
1332159047fSniklas case 0x2:
1342159047fSniklas case 0x3:
1352159047fSniklas cobr (memaddr, word1, word2);
1362159047fSniklas break;
1372159047fSniklas case 0x5:
1382159047fSniklas case 0x6:
1392159047fSniklas case 0x7:
1402159047fSniklas reg (word1);
1412159047fSniklas break;
1422159047fSniklas case 0x8:
1432159047fSniklas case 0x9:
1442159047fSniklas case 0xa:
1452159047fSniklas case 0xb:
1462159047fSniklas case 0xc:
1472159047fSniklas instr_len = mem (memaddr, word1, word2, 0);
1482159047fSniklas break;
1492159047fSniklas default:
150c074d1c9Sdrahn /* Invalid instruction, print as data word. */
1512159047fSniklas invalid (word1);
1522159047fSniklas break;
1532159047fSniklas }
1542159047fSniklas return instr_len;
1552159047fSniklas }
1562159047fSniklas
157c074d1c9Sdrahn /* CTRL format.. */
158c074d1c9Sdrahn
1592159047fSniklas static void
ctrl(bfd_vma memaddr,unsigned long word1,unsigned long word2 ATTRIBUTE_UNUSED)160*007c2a45Smiod ctrl (bfd_vma memaddr, unsigned long word1, unsigned long word2 ATTRIBUTE_UNUSED)
1612159047fSniklas {
1622159047fSniklas int i;
1632159047fSniklas static const struct tabent ctrl_tab[] = {
164b305b0f1Sespie { NULL, 0, }, /* 0x00 */
165b305b0f1Sespie { NULL, 0, }, /* 0x01 */
166b305b0f1Sespie { NULL, 0, }, /* 0x02 */
167b305b0f1Sespie { NULL, 0, }, /* 0x03 */
168b305b0f1Sespie { NULL, 0, }, /* 0x04 */
169b305b0f1Sespie { NULL, 0, }, /* 0x05 */
170b305b0f1Sespie { NULL, 0, }, /* 0x06 */
171b305b0f1Sespie { NULL, 0, }, /* 0x07 */
172b305b0f1Sespie { "b", 1, }, /* 0x08 */
173b305b0f1Sespie { "call", 1, }, /* 0x09 */
174b305b0f1Sespie { "ret", 0, }, /* 0x0a */
175b305b0f1Sespie { "bal", 1, }, /* 0x0b */
176b305b0f1Sespie { NULL, 0, }, /* 0x0c */
177b305b0f1Sespie { NULL, 0, }, /* 0x0d */
178b305b0f1Sespie { NULL, 0, }, /* 0x0e */
179b305b0f1Sespie { NULL, 0, }, /* 0x0f */
180b305b0f1Sespie { "bno", 1, }, /* 0x10 */
181b305b0f1Sespie { "bg", 1, }, /* 0x11 */
182b305b0f1Sespie { "be", 1, }, /* 0x12 */
183b305b0f1Sespie { "bge", 1, }, /* 0x13 */
184b305b0f1Sespie { "bl", 1, }, /* 0x14 */
185b305b0f1Sespie { "bne", 1, }, /* 0x15 */
186b305b0f1Sespie { "ble", 1, }, /* 0x16 */
187b305b0f1Sespie { "bo", 1, }, /* 0x17 */
188b305b0f1Sespie { "faultno", 0, }, /* 0x18 */
189b305b0f1Sespie { "faultg", 0, }, /* 0x19 */
190b305b0f1Sespie { "faulte", 0, }, /* 0x1a */
191b305b0f1Sespie { "faultge", 0, }, /* 0x1b */
192b305b0f1Sespie { "faultl", 0, }, /* 0x1c */
193b305b0f1Sespie { "faultne", 0, }, /* 0x1d */
194b305b0f1Sespie { "faultle", 0, }, /* 0x1e */
195b305b0f1Sespie { "faulto", 0, }, /* 0x1f */
1962159047fSniklas };
1972159047fSniklas
1982159047fSniklas i = (word1 >> 24) & 0xff;
199c074d1c9Sdrahn if ((ctrl_tab[i].name == NULL) || ((word1 & 1) != 0))
200c074d1c9Sdrahn {
2012159047fSniklas invalid (word1);
2022159047fSniklas return;
2032159047fSniklas }
2042159047fSniklas
2052159047fSniklas (*info->fprintf_func) (stream, ctrl_tab[i].name);
206c074d1c9Sdrahn if (word1 & 2)
207c074d1c9Sdrahn /* Predicts branch not taken. */
2082159047fSniklas (*info->fprintf_func) (stream, ".f");
209c074d1c9Sdrahn
210c074d1c9Sdrahn if (ctrl_tab[i].numops == 1)
211c074d1c9Sdrahn {
212c074d1c9Sdrahn /* Extract displacement and convert to address. */
213c074d1c9Sdrahn word1 &= 0x00ffffff;
214c074d1c9Sdrahn
215c074d1c9Sdrahn if (word1 & 0x00800000)
216c074d1c9Sdrahn {
217c074d1c9Sdrahn /* Sign bit is set. */
218c074d1c9Sdrahn word1 |= (-1 & ~0xffffff); /* Sign extend. */
2192159047fSniklas }
2202159047fSniklas
2212159047fSniklas (*info->fprintf_func) (stream, "\t");
2222159047fSniklas print_addr (word1 + memaddr);
2232159047fSniklas }
2242159047fSniklas }
2252159047fSniklas
226c074d1c9Sdrahn /* COBR format. */
227c074d1c9Sdrahn
2282159047fSniklas static void
cobr(bfd_vma memaddr,unsigned long word1,unsigned long word2 ATTRIBUTE_UNUSED)229*007c2a45Smiod cobr (bfd_vma memaddr, unsigned long word1, unsigned long word2 ATTRIBUTE_UNUSED)
2302159047fSniklas {
2312159047fSniklas int src1;
2322159047fSniklas int src2;
2332159047fSniklas int i;
2342159047fSniklas
2352159047fSniklas static const struct tabent cobr_tab[] = {
236b305b0f1Sespie { "testno", 1, }, /* 0x20 */
237b305b0f1Sespie { "testg", 1, }, /* 0x21 */
238b305b0f1Sespie { "teste", 1, }, /* 0x22 */
239b305b0f1Sespie { "testge", 1, }, /* 0x23 */
240b305b0f1Sespie { "testl", 1, }, /* 0x24 */
241b305b0f1Sespie { "testne", 1, }, /* 0x25 */
242b305b0f1Sespie { "testle", 1, }, /* 0x26 */
243b305b0f1Sespie { "testo", 1, }, /* 0x27 */
244b305b0f1Sespie { NULL, 0, }, /* 0x28 */
245b305b0f1Sespie { NULL, 0, }, /* 0x29 */
246b305b0f1Sespie { NULL, 0, }, /* 0x2a */
247b305b0f1Sespie { NULL, 0, }, /* 0x2b */
248b305b0f1Sespie { NULL, 0, }, /* 0x2c */
249b305b0f1Sespie { NULL, 0, }, /* 0x2d */
250b305b0f1Sespie { NULL, 0, }, /* 0x2e */
251b305b0f1Sespie { NULL, 0, }, /* 0x2f */
252b305b0f1Sespie { "bbc", 3, }, /* 0x30 */
253b305b0f1Sespie { "cmpobg", 3, }, /* 0x31 */
254b305b0f1Sespie { "cmpobe", 3, }, /* 0x32 */
255b305b0f1Sespie { "cmpobge",3, }, /* 0x33 */
256b305b0f1Sespie { "cmpobl", 3, }, /* 0x34 */
257b305b0f1Sespie { "cmpobne",3, }, /* 0x35 */
258b305b0f1Sespie { "cmpoble",3, }, /* 0x36 */
259b305b0f1Sespie { "bbs", 3, }, /* 0x37 */
260b305b0f1Sespie { "cmpibno",3, }, /* 0x38 */
261b305b0f1Sespie { "cmpibg", 3, }, /* 0x39 */
262b305b0f1Sespie { "cmpibe", 3, }, /* 0x3a */
263b305b0f1Sespie { "cmpibge",3, }, /* 0x3b */
264b305b0f1Sespie { "cmpibl", 3, }, /* 0x3c */
265b305b0f1Sespie { "cmpibne",3, }, /* 0x3d */
266b305b0f1Sespie { "cmpible",3, }, /* 0x3e */
267b305b0f1Sespie { "cmpibo", 3, }, /* 0x3f */
2682159047fSniklas };
2692159047fSniklas
2702159047fSniklas i = ((word1 >> 24) & 0xff) - 0x20;
271c074d1c9Sdrahn if (cobr_tab[i].name == NULL)
272c074d1c9Sdrahn {
2732159047fSniklas invalid (word1);
2742159047fSniklas return;
2752159047fSniklas }
2762159047fSniklas
2772159047fSniklas (*info->fprintf_func) (stream, cobr_tab[i].name);
278c074d1c9Sdrahn
279c074d1c9Sdrahn /* Predicts branch not taken. */
280c074d1c9Sdrahn if (word1 & 2)
2812159047fSniklas (*info->fprintf_func) (stream, ".f");
282c074d1c9Sdrahn
2832159047fSniklas (*info->fprintf_func) (stream, "\t");
2842159047fSniklas
2852159047fSniklas src1 = (word1 >> 19) & 0x1f;
2862159047fSniklas src2 = (word1 >> 14) & 0x1f;
2872159047fSniklas
288c074d1c9Sdrahn if (word1 & 0x02000)
289c074d1c9Sdrahn /* M1 is 1 */
2902159047fSniklas (*info->fprintf_func) (stream, "%d", src1);
291c074d1c9Sdrahn else
2922159047fSniklas (*info->fprintf_func) (stream, reg_names[src1]);
2932159047fSniklas
294c074d1c9Sdrahn if (cobr_tab[i].numops > 1)
295c074d1c9Sdrahn {
296c074d1c9Sdrahn if (word1 & 1)
297c074d1c9Sdrahn /* S2 is 1. */
2982159047fSniklas (*info->fprintf_func) (stream, ",sf%d,", src2);
299c074d1c9Sdrahn else
300c074d1c9Sdrahn /* S1 is 0. */
3012159047fSniklas (*info->fprintf_func) (stream, ",%s,", reg_names[src2]);
3022159047fSniklas
303c074d1c9Sdrahn /* Extract displacement and convert to address. */
3042159047fSniklas word1 &= 0x00001ffc;
305c074d1c9Sdrahn if (word1 & 0x00001000)
306c074d1c9Sdrahn /* Negative displacement. */
307c074d1c9Sdrahn word1 |= (-1 & ~0x1fff); /* Sign extend. */
308c074d1c9Sdrahn
3092159047fSniklas print_addr (memaddr + word1);
3102159047fSniklas }
3112159047fSniklas }
3122159047fSniklas
313c074d1c9Sdrahn /* MEM format. */
314c074d1c9Sdrahn /* Returns instruction length: 4 or 8. */
315c074d1c9Sdrahn
316c074d1c9Sdrahn static int
mem(bfd_vma memaddr,unsigned long word1,unsigned long word2,int noprint)317*007c2a45Smiod mem (bfd_vma memaddr, unsigned long word1, unsigned long word2, int noprint)
3182159047fSniklas {
3192159047fSniklas int i, j;
3202159047fSniklas int len;
3212159047fSniklas int mode;
3222159047fSniklas int offset;
3232159047fSniklas const char *reg1, *reg2, *reg3;
3242159047fSniklas
3252159047fSniklas /* This lookup table is too sparse to make it worth typing in, but not
3262159047fSniklas so large as to make a sparse array necessary. We create the table
3272159047fSniklas at runtime. */
3282159047fSniklas
329c074d1c9Sdrahn /* NOTE: In this table, the meaning of 'numops' is:
330c074d1c9Sdrahn 1: single operand
331c074d1c9Sdrahn 2: 2 operands, load instruction
332c074d1c9Sdrahn -2: 2 operands, store instruction. */
3332159047fSniklas static struct tabent *mem_tab;
3342159047fSniklas /* Opcodes of 0x8X, 9X, aX, bX, and cX must be in the table. */
3352159047fSniklas #define MEM_MIN 0x80
3362159047fSniklas #define MEM_MAX 0xcf
3372159047fSniklas #define MEM_SIZ ( * sizeof(struct tabent))
3382159047fSniklas
3392159047fSniklas static const struct sparse_tabent mem_init[] = {
340b305b0f1Sespie { 0x80, "ldob", 2 },
341b305b0f1Sespie { 0x82, "stob", -2 },
342b305b0f1Sespie { 0x84, "bx", 1 },
343b305b0f1Sespie { 0x85, "balx", 2 },
344b305b0f1Sespie { 0x86, "callx", 1 },
345b305b0f1Sespie { 0x88, "ldos", 2 },
346b305b0f1Sespie { 0x8a, "stos", -2 },
347b305b0f1Sespie { 0x8c, "lda", 2 },
348b305b0f1Sespie { 0x90, "ld", 2 },
349b305b0f1Sespie { 0x92, "st", -2 },
350b305b0f1Sespie { 0x98, "ldl", 2 },
351b305b0f1Sespie { 0x9a, "stl", -2 },
352b305b0f1Sespie { 0xa0, "ldt", 2 },
353b305b0f1Sespie { 0xa2, "stt", -2 },
354b305b0f1Sespie { 0xac, "dcinva", 1 },
355b305b0f1Sespie { 0xb0, "ldq", 2 },
356b305b0f1Sespie { 0xb2, "stq", -2 },
357b305b0f1Sespie { 0xc0, "ldib", 2 },
358b305b0f1Sespie { 0xc2, "stib", -2 },
359b305b0f1Sespie { 0xc8, "ldis", 2 },
360b305b0f1Sespie { 0xca, "stis", -2 },
361b305b0f1Sespie { 0, NULL, 0 }
3622159047fSniklas };
3632159047fSniklas static struct tabent mem_tab_buf[MEM_MAX - MEM_MIN + 1];
3642159047fSniklas
365c074d1c9Sdrahn if (mem_tab == NULL)
366c074d1c9Sdrahn {
3672159047fSniklas mem_tab = mem_tab_buf;
368c074d1c9Sdrahn
369c074d1c9Sdrahn for (i = 0; mem_init[i].opcode != 0; i++)
370c074d1c9Sdrahn {
3712159047fSniklas j = mem_init[i].opcode - MEM_MIN;
3722159047fSniklas mem_tab[j].name = mem_init[i].name;
3732159047fSniklas mem_tab[j].numops = mem_init[i].numops;
3742159047fSniklas }
3752159047fSniklas }
3762159047fSniklas
3772159047fSniklas i = ((word1 >> 24) & 0xff) - MEM_MIN;
3782159047fSniklas mode = (word1 >> 10) & 0xf;
3792159047fSniklas
3802159047fSniklas if ((mem_tab[i].name != NULL) /* Valid instruction */
381c074d1c9Sdrahn && ((mode == 5) || (mode >= 12)))
382c074d1c9Sdrahn /* With 32-bit displacement. */
3832159047fSniklas len = 8;
384c074d1c9Sdrahn else
3852159047fSniklas len = 4;
3862159047fSniklas
387c074d1c9Sdrahn if (noprint)
3882159047fSniklas return len;
3892159047fSniklas
390c074d1c9Sdrahn if ((mem_tab[i].name == NULL) || (mode == 6))
391c074d1c9Sdrahn {
3922159047fSniklas invalid (word1);
3932159047fSniklas return len;
3942159047fSniklas }
3952159047fSniklas
3962159047fSniklas (*info->fprintf_func) (stream, "%s\t", mem_tab[i].name);
3972159047fSniklas
3982159047fSniklas reg1 = reg_names[ (word1 >> 19) & 0x1f ]; /* MEMB only */
3992159047fSniklas reg2 = reg_names[ (word1 >> 14) & 0x1f ];
4002159047fSniklas reg3 = reg_names[ word1 & 0x1f ]; /* MEMB only */
4012159047fSniklas offset = word1 & 0xfff; /* MEMA only */
4022159047fSniklas
403c074d1c9Sdrahn switch (mem_tab[i].numops)
404c074d1c9Sdrahn {
4052159047fSniklas case 2: /* LOAD INSTRUCTION */
406c074d1c9Sdrahn if (mode & 4)
407c074d1c9Sdrahn { /* MEMB FORMAT */
4082159047fSniklas ea (memaddr, mode, reg2, reg3, word1, word2);
4092159047fSniklas (*info->fprintf_func) (stream, ",%s", reg1);
4102159047fSniklas }
411c074d1c9Sdrahn else
412c074d1c9Sdrahn { /* MEMA FORMAT */
413c074d1c9Sdrahn (*info->fprintf_func) (stream, "0x%x", (unsigned) offset);
414c074d1c9Sdrahn
415c074d1c9Sdrahn if (mode & 8)
416c074d1c9Sdrahn (*info->fprintf_func) (stream, "(%s)", reg2);
417c074d1c9Sdrahn
4182159047fSniklas (*info->fprintf_func)(stream, ",%s", reg1);
4192159047fSniklas }
4202159047fSniklas break;
4212159047fSniklas
4222159047fSniklas case -2: /* STORE INSTRUCTION */
423c074d1c9Sdrahn if (mode & 4)
424c074d1c9Sdrahn {
425c074d1c9Sdrahn /* MEMB FORMAT */
4262159047fSniklas (*info->fprintf_func) (stream, "%s,", reg1);
4272159047fSniklas ea (memaddr, mode, reg2, reg3, word1, word2);
4282159047fSniklas }
429c074d1c9Sdrahn else
430c074d1c9Sdrahn {
431c074d1c9Sdrahn /* MEMA FORMAT */
432c074d1c9Sdrahn (*info->fprintf_func) (stream, "%s,0x%x", reg1, (unsigned) offset);
433c074d1c9Sdrahn
434c074d1c9Sdrahn if (mode & 8)
435c074d1c9Sdrahn (*info->fprintf_func) (stream, "(%s)", reg2);
4362159047fSniklas }
4372159047fSniklas break;
4382159047fSniklas
4392159047fSniklas case 1: /* BX/CALLX INSTRUCTION */
440c074d1c9Sdrahn if (mode & 4)
441c074d1c9Sdrahn {
442c074d1c9Sdrahn /* MEMB FORMAT */
4432159047fSniklas ea (memaddr, mode, reg2, reg3, word1, word2);
4442159047fSniklas }
445c074d1c9Sdrahn else
446c074d1c9Sdrahn {
447c074d1c9Sdrahn /* MEMA FORMAT */
448c074d1c9Sdrahn (*info->fprintf_func) (stream, "0x%x", (unsigned) offset);
449c074d1c9Sdrahn if (mode & 8)
450c074d1c9Sdrahn (*info->fprintf_func) (stream, "(%s)", reg2);
4512159047fSniklas }
4522159047fSniklas break;
4532159047fSniklas }
4542159047fSniklas
4552159047fSniklas return len;
4562159047fSniklas }
4572159047fSniklas
458c074d1c9Sdrahn /* REG format. */
459c074d1c9Sdrahn
4602159047fSniklas static void
reg(unsigned long word1)461*007c2a45Smiod reg (unsigned long word1)
4622159047fSniklas {
4632159047fSniklas int i, j;
4642159047fSniklas int opcode;
4652159047fSniklas int fp;
4662159047fSniklas int m1, m2, m3;
4672159047fSniklas int s1, s2;
4682159047fSniklas int src, src2, dst;
4692159047fSniklas char *mnemp;
4702159047fSniklas
4712159047fSniklas /* This lookup table is too sparse to make it worth typing in, but not
4722159047fSniklas so large as to make a sparse array necessary. We create the table
4732159047fSniklas at runtime. */
4742159047fSniklas
475c074d1c9Sdrahn /* NOTE: In this table, the meaning of 'numops' is:
476c074d1c9Sdrahn 1: single operand, which is NOT a destination.
477c074d1c9Sdrahn -1: single operand, which IS a destination.
478c074d1c9Sdrahn 2: 2 operands, the 2nd of which is NOT a destination.
479c074d1c9Sdrahn -2: 2 operands, the 2nd of which IS a destination.
480c074d1c9Sdrahn 3: 3 operands
481c074d1c9Sdrahn
482c074d1c9Sdrahn If an opcode mnemonic begins with "F", it is a floating-point
483c074d1c9Sdrahn opcode (the "F" is not printed). */
4842159047fSniklas
4852159047fSniklas static struct tabent *reg_tab;
486c074d1c9Sdrahn static const struct sparse_tabent reg_init[] =
487c074d1c9Sdrahn {
4882159047fSniklas #define REG_MIN 0x580
489b305b0f1Sespie { 0x580, "notbit", 3 },
490b305b0f1Sespie { 0x581, "and", 3 },
491b305b0f1Sespie { 0x582, "andnot", 3 },
492b305b0f1Sespie { 0x583, "setbit", 3 },
493b305b0f1Sespie { 0x584, "notand", 3 },
494b305b0f1Sespie { 0x586, "xor", 3 },
495b305b0f1Sespie { 0x587, "or", 3 },
496b305b0f1Sespie { 0x588, "nor", 3 },
497b305b0f1Sespie { 0x589, "xnor", 3 },
498b305b0f1Sespie { 0x58a, "not", -2 },
499b305b0f1Sespie { 0x58b, "ornot", 3 },
500b305b0f1Sespie { 0x58c, "clrbit", 3 },
501b305b0f1Sespie { 0x58d, "notor", 3 },
502b305b0f1Sespie { 0x58e, "nand", 3 },
503b305b0f1Sespie { 0x58f, "alterbit", 3 },
504b305b0f1Sespie { 0x590, "addo", 3 },
505b305b0f1Sespie { 0x591, "addi", 3 },
506b305b0f1Sespie { 0x592, "subo", 3 },
507b305b0f1Sespie { 0x593, "subi", 3 },
508b305b0f1Sespie { 0x594, "cmpob", 2 },
509b305b0f1Sespie { 0x595, "cmpib", 2 },
510b305b0f1Sespie { 0x596, "cmpos", 2 },
511b305b0f1Sespie { 0x597, "cmpis", 2 },
512b305b0f1Sespie { 0x598, "shro", 3 },
513b305b0f1Sespie { 0x59a, "shrdi", 3 },
514b305b0f1Sespie { 0x59b, "shri", 3 },
515b305b0f1Sespie { 0x59c, "shlo", 3 },
516b305b0f1Sespie { 0x59d, "rotate", 3 },
517b305b0f1Sespie { 0x59e, "shli", 3 },
518b305b0f1Sespie { 0x5a0, "cmpo", 2 },
519b305b0f1Sespie { 0x5a1, "cmpi", 2 },
520b305b0f1Sespie { 0x5a2, "concmpo", 2 },
521b305b0f1Sespie { 0x5a3, "concmpi", 2 },
522b305b0f1Sespie { 0x5a4, "cmpinco", 3 },
523b305b0f1Sespie { 0x5a5, "cmpinci", 3 },
524b305b0f1Sespie { 0x5a6, "cmpdeco", 3 },
525b305b0f1Sespie { 0x5a7, "cmpdeci", 3 },
526b305b0f1Sespie { 0x5ac, "scanbyte", 2 },
527b305b0f1Sespie { 0x5ad, "bswap", -2 },
528b305b0f1Sespie { 0x5ae, "chkbit", 2 },
529b305b0f1Sespie { 0x5b0, "addc", 3 },
530b305b0f1Sespie { 0x5b2, "subc", 3 },
531b305b0f1Sespie { 0x5b4, "intdis", 0 },
532b305b0f1Sespie { 0x5b5, "inten", 0 },
533b305b0f1Sespie { 0x5cc, "mov", -2 },
534b305b0f1Sespie { 0x5d8, "eshro", 3 },
535b305b0f1Sespie { 0x5dc, "movl", -2 },
536b305b0f1Sespie { 0x5ec, "movt", -2 },
537b305b0f1Sespie { 0x5fc, "movq", -2 },
538b305b0f1Sespie { 0x600, "synmov", 2 },
539b305b0f1Sespie { 0x601, "synmovl", 2 },
540b305b0f1Sespie { 0x602, "synmovq", 2 },
541b305b0f1Sespie { 0x603, "cmpstr", 3 },
542b305b0f1Sespie { 0x604, "movqstr", 3 },
543b305b0f1Sespie { 0x605, "movstr", 3 },
544b305b0f1Sespie { 0x610, "atmod", 3 },
545b305b0f1Sespie { 0x612, "atadd", 3 },
546b305b0f1Sespie { 0x613, "inspacc", -2 },
547b305b0f1Sespie { 0x614, "ldphy", -2 },
548b305b0f1Sespie { 0x615, "synld", -2 },
549b305b0f1Sespie { 0x617, "fill", 3 },
550b305b0f1Sespie { 0x630, "sdma", 3 },
551b305b0f1Sespie { 0x631, "udma", 0 },
552b305b0f1Sespie { 0x640, "spanbit", -2 },
553b305b0f1Sespie { 0x641, "scanbit", -2 },
554b305b0f1Sespie { 0x642, "daddc", 3 },
555b305b0f1Sespie { 0x643, "dsubc", 3 },
556b305b0f1Sespie { 0x644, "dmovt", -2 },
557b305b0f1Sespie { 0x645, "modac", 3 },
558b305b0f1Sespie { 0x646, "condrec", -2 },
559b305b0f1Sespie { 0x650, "modify", 3 },
560b305b0f1Sespie { 0x651, "extract", 3 },
561b305b0f1Sespie { 0x654, "modtc", 3 },
562b305b0f1Sespie { 0x655, "modpc", 3 },
563b305b0f1Sespie { 0x656, "receive", -2 },
564b305b0f1Sespie { 0x658, "intctl", -2 },
565b305b0f1Sespie { 0x659, "sysctl", 3 },
566b305b0f1Sespie { 0x65b, "icctl", 3 },
567b305b0f1Sespie { 0x65c, "dcctl", 3 },
568b305b0f1Sespie { 0x65d, "halt", 0 },
569b305b0f1Sespie { 0x660, "calls", 1 },
570b305b0f1Sespie { 0x662, "send", 3 },
571b305b0f1Sespie { 0x663, "sendserv", 1 },
572b305b0f1Sespie { 0x664, "resumprcs", 1 },
573b305b0f1Sespie { 0x665, "schedprcs", 1 },
574b305b0f1Sespie { 0x666, "saveprcs", 0 },
575b305b0f1Sespie { 0x668, "condwait", 1 },
576b305b0f1Sespie { 0x669, "wait", 1 },
577b305b0f1Sespie { 0x66a, "signal", 1 },
578b305b0f1Sespie { 0x66b, "mark", 0 },
579b305b0f1Sespie { 0x66c, "fmark", 0 },
580b305b0f1Sespie { 0x66d, "flushreg", 0 },
581b305b0f1Sespie { 0x66f, "syncf", 0 },
582b305b0f1Sespie { 0x670, "emul", 3 },
583b305b0f1Sespie { 0x671, "ediv", 3 },
584b305b0f1Sespie { 0x673, "ldtime", -1 },
585b305b0f1Sespie { 0x674, "Fcvtir", -2 },
586b305b0f1Sespie { 0x675, "Fcvtilr", -2 },
587b305b0f1Sespie { 0x676, "Fscalerl", 3 },
588b305b0f1Sespie { 0x677, "Fscaler", 3 },
589b305b0f1Sespie { 0x680, "Fatanr", 3 },
590b305b0f1Sespie { 0x681, "Flogepr", 3 },
591b305b0f1Sespie { 0x682, "Flogr", 3 },
592b305b0f1Sespie { 0x683, "Fremr", 3 },
593b305b0f1Sespie { 0x684, "Fcmpor", 2 },
594b305b0f1Sespie { 0x685, "Fcmpr", 2 },
595b305b0f1Sespie { 0x688, "Fsqrtr", -2 },
596b305b0f1Sespie { 0x689, "Fexpr", -2 },
597b305b0f1Sespie { 0x68a, "Flogbnr", -2 },
598b305b0f1Sespie { 0x68b, "Froundr", -2 },
599b305b0f1Sespie { 0x68c, "Fsinr", -2 },
600b305b0f1Sespie { 0x68d, "Fcosr", -2 },
601b305b0f1Sespie { 0x68e, "Ftanr", -2 },
602b305b0f1Sespie { 0x68f, "Fclassr", 1 },
603b305b0f1Sespie { 0x690, "Fatanrl", 3 },
604b305b0f1Sespie { 0x691, "Flogeprl", 3 },
605b305b0f1Sespie { 0x692, "Flogrl", 3 },
606b305b0f1Sespie { 0x693, "Fremrl", 3 },
607b305b0f1Sespie { 0x694, "Fcmporl", 2 },
608b305b0f1Sespie { 0x695, "Fcmprl", 2 },
609b305b0f1Sespie { 0x698, "Fsqrtrl", -2 },
610b305b0f1Sespie { 0x699, "Fexprl", -2 },
611b305b0f1Sespie { 0x69a, "Flogbnrl", -2 },
612b305b0f1Sespie { 0x69b, "Froundrl", -2 },
613b305b0f1Sespie { 0x69c, "Fsinrl", -2 },
614b305b0f1Sespie { 0x69d, "Fcosrl", -2 },
615b305b0f1Sespie { 0x69e, "Ftanrl", -2 },
616b305b0f1Sespie { 0x69f, "Fclassrl", 1 },
617b305b0f1Sespie { 0x6c0, "Fcvtri", -2 },
618b305b0f1Sespie { 0x6c1, "Fcvtril", -2 },
619b305b0f1Sespie { 0x6c2, "Fcvtzri", -2 },
620b305b0f1Sespie { 0x6c3, "Fcvtzril", -2 },
621b305b0f1Sespie { 0x6c9, "Fmovr", -2 },
622b305b0f1Sespie { 0x6d9, "Fmovrl", -2 },
623b305b0f1Sespie { 0x6e1, "Fmovre", -2 },
624b305b0f1Sespie { 0x6e2, "Fcpysre", 3 },
625b305b0f1Sespie { 0x6e3, "Fcpyrsre", 3 },
626b305b0f1Sespie { 0x701, "mulo", 3 },
627b305b0f1Sespie { 0x708, "remo", 3 },
628b305b0f1Sespie { 0x70b, "divo", 3 },
629b305b0f1Sespie { 0x741, "muli", 3 },
630b305b0f1Sespie { 0x748, "remi", 3 },
631b305b0f1Sespie { 0x749, "modi", 3 },
632b305b0f1Sespie { 0x74b, "divi", 3 },
633b305b0f1Sespie { 0x780, "addono", 3 },
634b305b0f1Sespie { 0x781, "addino", 3 },
635b305b0f1Sespie { 0x782, "subono", 3 },
636b305b0f1Sespie { 0x783, "subino", 3 },
637b305b0f1Sespie { 0x784, "selno", 3 },
638b305b0f1Sespie { 0x78b, "Fdivr", 3 },
639b305b0f1Sespie { 0x78c, "Fmulr", 3 },
640b305b0f1Sespie { 0x78d, "Fsubr", 3 },
641b305b0f1Sespie { 0x78f, "Faddr", 3 },
642b305b0f1Sespie { 0x790, "addog", 3 },
643b305b0f1Sespie { 0x791, "addig", 3 },
644b305b0f1Sespie { 0x792, "subog", 3 },
645b305b0f1Sespie { 0x793, "subig", 3 },
646b305b0f1Sespie { 0x794, "selg", 3 },
647b305b0f1Sespie { 0x79b, "Fdivrl", 3 },
648b305b0f1Sespie { 0x79c, "Fmulrl", 3 },
649b305b0f1Sespie { 0x79d, "Fsubrl", 3 },
650b305b0f1Sespie { 0x79f, "Faddrl", 3 },
651b305b0f1Sespie { 0x7a0, "addoe", 3 },
652b305b0f1Sespie { 0x7a1, "addie", 3 },
653b305b0f1Sespie { 0x7a2, "suboe", 3 },
654b305b0f1Sespie { 0x7a3, "subie", 3 },
655b305b0f1Sespie { 0x7a4, "sele", 3 },
656b305b0f1Sespie { 0x7b0, "addoge", 3 },
657b305b0f1Sespie { 0x7b1, "addige", 3 },
658b305b0f1Sespie { 0x7b2, "suboge", 3 },
659b305b0f1Sespie { 0x7b3, "subige", 3 },
660b305b0f1Sespie { 0x7b4, "selge", 3 },
661b305b0f1Sespie { 0x7c0, "addol", 3 },
662b305b0f1Sespie { 0x7c1, "addil", 3 },
663b305b0f1Sespie { 0x7c2, "subol", 3 },
664b305b0f1Sespie { 0x7c3, "subil", 3 },
665b305b0f1Sespie { 0x7c4, "sell", 3 },
666b305b0f1Sespie { 0x7d0, "addone", 3 },
667b305b0f1Sespie { 0x7d1, "addine", 3 },
668b305b0f1Sespie { 0x7d2, "subone", 3 },
669b305b0f1Sespie { 0x7d3, "subine", 3 },
670b305b0f1Sespie { 0x7d4, "selne", 3 },
671b305b0f1Sespie { 0x7e0, "addole", 3 },
672b305b0f1Sespie { 0x7e1, "addile", 3 },
673b305b0f1Sespie { 0x7e2, "subole", 3 },
674b305b0f1Sespie { 0x7e3, "subile", 3 },
675b305b0f1Sespie { 0x7e4, "selle", 3 },
676b305b0f1Sespie { 0x7f0, "addoo", 3 },
677b305b0f1Sespie { 0x7f1, "addio", 3 },
678b305b0f1Sespie { 0x7f2, "suboo", 3 },
679b305b0f1Sespie { 0x7f3, "subio", 3 },
680b305b0f1Sespie { 0x7f4, "selo", 3 },
681c88b1d6cSniklas #define REG_MAX 0x7f4
682b305b0f1Sespie { 0, NULL, 0 }
6832159047fSniklas };
6842159047fSniklas static struct tabent reg_tab_buf[REG_MAX - REG_MIN + 1];
6852159047fSniklas
686c074d1c9Sdrahn if (reg_tab == NULL)
687c074d1c9Sdrahn {
6882159047fSniklas reg_tab = reg_tab_buf;
689c074d1c9Sdrahn
690c074d1c9Sdrahn for (i = 0; reg_init[i].opcode != 0; i++)
691c074d1c9Sdrahn {
6922159047fSniklas j = reg_init[i].opcode - REG_MIN;
6932159047fSniklas reg_tab[j].name = reg_init[i].name;
6942159047fSniklas reg_tab[j].numops = reg_init[i].numops;
6952159047fSniklas }
6962159047fSniklas }
6972159047fSniklas
6982159047fSniklas opcode = ((word1 >> 20) & 0xff0) | ((word1 >> 7) & 0xf);
6992159047fSniklas i = opcode - REG_MIN;
7002159047fSniklas
701c074d1c9Sdrahn if ((opcode<REG_MIN) || (opcode>REG_MAX) || (reg_tab[i].name==NULL))
702c074d1c9Sdrahn {
7032159047fSniklas invalid (word1);
7042159047fSniklas return;
7052159047fSniklas }
7062159047fSniklas
7072159047fSniklas mnemp = reg_tab[i].name;
708c074d1c9Sdrahn if (*mnemp == 'F')
709c074d1c9Sdrahn {
7102159047fSniklas fp = 1;
7112159047fSniklas mnemp++;
712c074d1c9Sdrahn }
713c074d1c9Sdrahn else
714c074d1c9Sdrahn {
7152159047fSniklas fp = 0;
7162159047fSniklas }
7172159047fSniklas
7182159047fSniklas (*info->fprintf_func) (stream, mnemp);
7192159047fSniklas
7202159047fSniklas s1 = (word1 >> 5) & 1;
7212159047fSniklas s2 = (word1 >> 6) & 1;
7222159047fSniklas m1 = (word1 >> 11) & 1;
7232159047fSniklas m2 = (word1 >> 12) & 1;
7242159047fSniklas m3 = (word1 >> 13) & 1;
7252159047fSniklas src = word1 & 0x1f;
7262159047fSniklas src2 = (word1 >> 14) & 0x1f;
7272159047fSniklas dst = (word1 >> 19) & 0x1f;
7282159047fSniklas
729c074d1c9Sdrahn if (reg_tab[i].numops != 0)
730c074d1c9Sdrahn {
7312159047fSniklas (*info->fprintf_func) (stream, "\t");
7322159047fSniklas
733c074d1c9Sdrahn switch (reg_tab[i].numops)
734c074d1c9Sdrahn {
7352159047fSniklas case 1:
7362159047fSniklas regop (m1, s1, src, fp);
7372159047fSniklas break;
7382159047fSniklas case -1:
7392159047fSniklas dstop (m3, dst, fp);
7402159047fSniklas break;
7412159047fSniklas case 2:
7422159047fSniklas regop (m1, s1, src, fp);
7432159047fSniklas (*info->fprintf_func) (stream, ",");
7442159047fSniklas regop (m2, s2, src2, fp);
7452159047fSniklas break;
7462159047fSniklas case -2:
7472159047fSniklas regop (m1, s1, src, fp);
7482159047fSniklas (*info->fprintf_func) (stream, ",");
7492159047fSniklas dstop (m3, dst, fp);
7502159047fSniklas break;
7512159047fSniklas case 3:
7522159047fSniklas regop (m1, s1, src, fp);
7532159047fSniklas (*info->fprintf_func) (stream, ",");
7542159047fSniklas regop (m2, s2, src2, fp);
7552159047fSniklas (*info->fprintf_func) (stream, ",");
7562159047fSniklas dstop (m3, dst, fp);
7572159047fSniklas break;
7582159047fSniklas }
7592159047fSniklas }
7602159047fSniklas }
7612159047fSniklas
762c074d1c9Sdrahn /* Print out effective address for memb instructions. */
7632159047fSniklas
7642159047fSniklas static void
ea(bfd_vma memaddr,int mode,const char * reg2,const char * reg3,int word1,unsigned int word2)765*007c2a45Smiod ea (bfd_vma memaddr, int mode, const char *reg2, const char *reg3, int word1,
766*007c2a45Smiod unsigned int word2)
7672159047fSniklas {
7682159047fSniklas int scale;
7692159047fSniklas static const int scale_tab[] = { 1, 2, 4, 8, 16 };
7702159047fSniklas
7712159047fSniklas scale = (word1 >> 7) & 0x07;
772c074d1c9Sdrahn
773c074d1c9Sdrahn if ((scale > 4) || (((word1 >> 5) & 0x03) != 0))
774c074d1c9Sdrahn {
7752159047fSniklas invalid (word1);
7762159047fSniklas return;
7772159047fSniklas }
7782159047fSniklas scale = scale_tab[scale];
7792159047fSniklas
780c074d1c9Sdrahn switch (mode)
781c074d1c9Sdrahn {
7822159047fSniklas case 4: /* (reg) */
7832159047fSniklas (*info->fprintf_func)( stream, "(%s)", reg2 );
7842159047fSniklas break;
7852159047fSniklas case 5: /* displ+8(ip) */
7862159047fSniklas print_addr (word2 + 8 + memaddr);
7872159047fSniklas break;
7882159047fSniklas case 7: /* (reg)[index*scale] */
789c074d1c9Sdrahn if (scale == 1)
7902159047fSniklas (*info->fprintf_func) (stream, "(%s)[%s]", reg2, reg3);
791c074d1c9Sdrahn else
7922159047fSniklas (*info->fprintf_func) (stream, "(%s)[%s*%d]", reg2, reg3, scale);
7932159047fSniklas break;
7942159047fSniklas case 12: /* displacement */
795b305b0f1Sespie print_addr ((bfd_vma) word2);
7962159047fSniklas break;
7972159047fSniklas case 13: /* displ(reg) */
798b305b0f1Sespie print_addr ((bfd_vma) word2);
7992159047fSniklas (*info->fprintf_func) (stream, "(%s)", reg2);
8002159047fSniklas break;
8012159047fSniklas case 14: /* displ[index*scale] */
802b305b0f1Sespie print_addr ((bfd_vma) word2);
803c074d1c9Sdrahn if (scale == 1)
8042159047fSniklas (*info->fprintf_func) (stream, "[%s]", reg3);
805c074d1c9Sdrahn else
8062159047fSniklas (*info->fprintf_func) (stream, "[%s*%d]", reg3, scale);
8072159047fSniklas break;
8082159047fSniklas case 15: /* displ(reg)[index*scale] */
809b305b0f1Sespie print_addr ((bfd_vma) word2);
810c074d1c9Sdrahn if (scale == 1)
8112159047fSniklas (*info->fprintf_func) (stream, "(%s)[%s]", reg2, reg3);
812c074d1c9Sdrahn else
8132159047fSniklas (*info->fprintf_func) (stream, "(%s)[%s*%d]", reg2, reg3, scale);
8142159047fSniklas break;
8152159047fSniklas default:
8162159047fSniklas invalid (word1);
8172159047fSniklas return;
8182159047fSniklas }
8192159047fSniklas }
8202159047fSniklas
8212159047fSniklas
822c074d1c9Sdrahn /* Register Instruction Operand. */
823c074d1c9Sdrahn
8242159047fSniklas static void
regop(int mode,int spec,int reg,int fp)825*007c2a45Smiod regop (int mode, int spec, int reg, int fp)
8262159047fSniklas {
827c074d1c9Sdrahn if (fp)
828c074d1c9Sdrahn {
829c074d1c9Sdrahn /* Floating point instruction. */
830c074d1c9Sdrahn if (mode == 1)
831c074d1c9Sdrahn {
832c074d1c9Sdrahn /* FP operand. */
833c074d1c9Sdrahn switch (reg)
834c074d1c9Sdrahn {
8352159047fSniklas case 0: (*info->fprintf_func) (stream, "fp0");
8362159047fSniklas break;
8372159047fSniklas case 1: (*info->fprintf_func) (stream, "fp1");
8382159047fSniklas break;
8392159047fSniklas case 2: (*info->fprintf_func) (stream, "fp2");
8402159047fSniklas break;
8412159047fSniklas case 3: (*info->fprintf_func) (stream, "fp3");
8422159047fSniklas break;
8432159047fSniklas case 16: (*info->fprintf_func) (stream, "0f0.0");
8442159047fSniklas break;
8452159047fSniklas case 22: (*info->fprintf_func) (stream, "0f1.0");
8462159047fSniklas break;
8472159047fSniklas default: (*info->fprintf_func) (stream, "?");
8482159047fSniklas break;
8492159047fSniklas }
850c074d1c9Sdrahn }
851c074d1c9Sdrahn else
852c074d1c9Sdrahn {
853c074d1c9Sdrahn /* Non-FP register. */
8542159047fSniklas (*info->fprintf_func) (stream, reg_names[reg]);
8552159047fSniklas }
856c074d1c9Sdrahn }
857c074d1c9Sdrahn else
858c074d1c9Sdrahn {
859c074d1c9Sdrahn /* Not floating point. */
860c074d1c9Sdrahn if (mode == 1)
861c074d1c9Sdrahn {
862c074d1c9Sdrahn /* Literal. */
8632159047fSniklas (*info->fprintf_func) (stream, "%d", reg);
864c074d1c9Sdrahn }
865c074d1c9Sdrahn else
866c074d1c9Sdrahn {
867c074d1c9Sdrahn /* Register. */
868c074d1c9Sdrahn if (spec == 0)
8692159047fSniklas (*info->fprintf_func) (stream, reg_names[reg]);
870c074d1c9Sdrahn else
8712159047fSniklas (*info->fprintf_func) (stream, "sf%d", reg);
8722159047fSniklas }
8732159047fSniklas }
8742159047fSniklas }
8752159047fSniklas
876c074d1c9Sdrahn /* Register Instruction Destination Operand. */
877c074d1c9Sdrahn
8782159047fSniklas static void
dstop(int mode,int reg,int fp)879*007c2a45Smiod dstop (int mode, int reg, int fp)
8802159047fSniklas {
8812159047fSniklas /* 'dst' operand can't be a literal. On non-FP instructions, register
882c074d1c9Sdrahn mode is assumed and "m3" acts as if were "s3"; on FP-instructions,
883c074d1c9Sdrahn sf registers are not allowed so m3 acts normally. */
884c074d1c9Sdrahn if (fp)
8852159047fSniklas regop (mode, 0, reg, fp);
886c074d1c9Sdrahn else
8872159047fSniklas regop (0, mode, reg, fp);
8882159047fSniklas }
8892159047fSniklas
8902159047fSniklas static void
invalid(int word1)891*007c2a45Smiod invalid (int word1)
8922159047fSniklas {
8932159047fSniklas (*info->fprintf_func) (stream, ".word\t0x%08x", (unsigned) word1);
8942159047fSniklas }
8952159047fSniklas
8962159047fSniklas static void
print_addr(bfd_vma a)897*007c2a45Smiod print_addr (bfd_vma a)
8982159047fSniklas {
899b305b0f1Sespie (*info->print_address_func) (a, info);
9002159047fSniklas }
9012159047fSniklas
9022159047fSniklas static void
put_abs(unsigned long word1 ATTRIBUTE_UNUSED,unsigned long word2 ATTRIBUTE_UNUSED)903*007c2a45Smiod put_abs (unsigned long word1 ATTRIBUTE_UNUSED,
904*007c2a45Smiod unsigned long word2 ATTRIBUTE_UNUSED)
9052159047fSniklas {
9062159047fSniklas #ifdef IN_GDB
9072159047fSniklas return;
9082159047fSniklas #else
9092159047fSniklas int len;
9102159047fSniklas
911c074d1c9Sdrahn switch ((word1 >> 28) & 0xf)
912c074d1c9Sdrahn {
9132159047fSniklas case 0x8:
9142159047fSniklas case 0x9:
9152159047fSniklas case 0xa:
9162159047fSniklas case 0xb:
9172159047fSniklas case 0xc:
918c074d1c9Sdrahn /* MEM format instruction. */
9192159047fSniklas len = mem (0, word1, word2, 1);
9202159047fSniklas break;
9212159047fSniklas default:
9222159047fSniklas len = 4;
9232159047fSniklas break;
9242159047fSniklas }
9252159047fSniklas
926c074d1c9Sdrahn if (len == 8)
9272159047fSniklas (*info->fprintf_func) (stream, "%08x %08x\t", word1, word2);
928c074d1c9Sdrahn else
9292159047fSniklas (*info->fprintf_func) (stream, "%08x \t", word1);
9302159047fSniklas #endif
9312159047fSniklas }
932