| 1 | /* Disassemble h8300 instructions.
|
|---|
| 2 | Copyright 1993, 1994, 1996, 1998, 2000 Free Software Foundation, Inc.
|
|---|
| 3 |
|
|---|
| 4 | This program is free software; you can redistribute it and/or modify
|
|---|
| 5 | it under the terms of the GNU General Public License as published by
|
|---|
| 6 | the Free Software Foundation; either version 2 of the License, or
|
|---|
| 7 | (at your option) any later version.
|
|---|
| 8 |
|
|---|
| 9 | This program is distributed in the hope that it will be useful,
|
|---|
| 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|---|
| 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|---|
| 12 | GNU General Public License for more details.
|
|---|
| 13 |
|
|---|
| 14 | You should have received a copy of the GNU General Public License
|
|---|
| 15 | along with this program; if not, write to the Free Software
|
|---|
| 16 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
|---|
| 17 |
|
|---|
| 18 | #define DEFINE_TABLE
|
|---|
| 19 |
|
|---|
| 20 | #include "sysdep.h"
|
|---|
| 21 | #define h8_opcodes h8ops
|
|---|
| 22 | #include "opcode/h8300.h"
|
|---|
| 23 | #include "dis-asm.h"
|
|---|
| 24 | #include "opintl.h"
|
|---|
| 25 |
|
|---|
| 26 | /* Run through the opcodes and sort them into order to make them easy
|
|---|
| 27 | to disassemble. */
|
|---|
| 28 | static void
|
|---|
| 29 | bfd_h8_disassemble_init ()
|
|---|
| 30 | {
|
|---|
| 31 | unsigned int i;
|
|---|
| 32 | struct h8_opcode *p;
|
|---|
| 33 |
|
|---|
| 34 | for (p = h8_opcodes; p->name; p++)
|
|---|
| 35 | {
|
|---|
| 36 | int n1 = 0;
|
|---|
| 37 | int n2 = 0;
|
|---|
| 38 |
|
|---|
| 39 | if ((int) p->data.nib[0] < 16)
|
|---|
| 40 | n1 = (int) p->data.nib[0];
|
|---|
| 41 | else
|
|---|
| 42 | n1 = 0;
|
|---|
| 43 |
|
|---|
| 44 | if ((int) p->data.nib[1] < 16)
|
|---|
| 45 | n2 = (int) p->data.nib[1];
|
|---|
| 46 | else
|
|---|
| 47 | n2 = 0;
|
|---|
| 48 |
|
|---|
| 49 | /* Just make sure there are an even number of nibbles in it, and
|
|---|
| 50 | that the count is the same as the length. */
|
|---|
| 51 | for (i = 0; p->data.nib[i] != E; i++)
|
|---|
| 52 | ;
|
|---|
| 53 |
|
|---|
| 54 | if (i & 1)
|
|---|
| 55 | abort ();
|
|---|
| 56 |
|
|---|
| 57 | p->length = i / 2;
|
|---|
| 58 | }
|
|---|
| 59 | }
|
|---|
| 60 |
|
|---|
| 61 | unsigned int
|
|---|
| 62 | bfd_h8_disassemble (addr, info, mode)
|
|---|
| 63 | bfd_vma addr;
|
|---|
| 64 | disassemble_info *info;
|
|---|
| 65 | int mode;
|
|---|
| 66 | {
|
|---|
| 67 | /* Find the first entry in the table for this opcode. */
|
|---|
| 68 | static CONST char *regnames[] =
|
|---|
| 69 | {
|
|---|
| 70 | "r0h", "r1h", "r2h", "r3h", "r4h", "r5h", "r6h", "r7h",
|
|---|
| 71 | "r0l", "r1l", "r2l", "r3l", "r4l", "r5l", "r6l", "r7l"
|
|---|
| 72 | };
|
|---|
| 73 | static CONST char *wregnames[] =
|
|---|
| 74 | {
|
|---|
| 75 | "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7",
|
|---|
| 76 | "e0", "e1", "e2", "e3", "e4", "e5", "e6", "e7"
|
|---|
| 77 | };
|
|---|
| 78 | static CONST char *lregnames[] =
|
|---|
| 79 | {
|
|---|
| 80 | "er0", "er1", "er2", "er3", "er4", "er5", "er6", "er7",
|
|---|
| 81 | "er0", "er1", "er2", "er3", "er4", "er5", "er6", "er7"
|
|---|
| 82 | };
|
|---|
| 83 | int rs = 0;
|
|---|
|
|---|