Commit | Line | Data |
---|---|---|
252b5132 | 1 | /* Disassemble WDC 65816 instructions. |
df7b86aa | 2 | Copyright 1995, 1998, 2000, 2001, 2002, 2005, 2007, 2012 |
53c9ebc5 | 3 | Free Software Foundation, Inc. |
252b5132 | 4 | |
9b201bb5 NC |
5 | This file is part of the GNU opcodes library. |
6 | ||
7 | This library is free software; you can redistribute it and/or modify | |
47b0e7ad | 8 | it under the terms of the GNU General Public License as published by |
9b201bb5 NC |
9 | the Free Software Foundation; either version 3, or (at your option) |
10 | any later version. | |
252b5132 | 11 | |
9b201bb5 NC |
12 | It is distributed in the hope that it will be useful, but WITHOUT |
13 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY | |
14 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public | |
15 | License for more details. | |
252b5132 | 16 | |
47b0e7ad NC |
17 | You should have received a copy of the GNU General Public License |
18 | along with this program; if not, write to the Free Software | |
19 | Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, | |
20 | MA 02110-1301, USA. */ | |
252b5132 | 21 | |
0d8dfecf | 22 | #include "sysdep.h" |
df7b86aa NC |
23 | #include <stdio.h> |
24 | ||
252b5132 RH |
25 | #define STATIC_TABLE |
26 | #define DEFINE_TABLE | |
27 | ||
28 | #include "w65-opc.h" | |
29 | #include "dis-asm.h" | |
30 | ||
7d352fc8 KH |
31 | static fprintf_ftype fpr; |
32 | static void *stream; | |
33 | static struct disassemble_info *local_info; | |
d83c6548 | 34 | |
252b5132 | 35 | static void |
47b0e7ad | 36 | print_operand (int lookup, char *format, int *args) |
252b5132 RH |
37 | { |
38 | int val; | |
39 | int c; | |
40 | ||
41 | while (*format) | |
42 | { | |
7d352fc8 | 43 | switch (c = *format++) |
252b5132 RH |
44 | { |
45 | case '$': | |
46 | val = args[(*format++) - '0']; | |
7d352fc8 | 47 | if (lookup) |
47b0e7ad | 48 | local_info->print_address_func (val, local_info); |
252b5132 RH |
49 | else |
50 | fpr (stream, "0x%x", val); | |
51 | ||
52 | break; | |
53 | default: | |
7d352fc8 | 54 | fpr (stream, "%c", c); |
252b5132 RH |
55 | break; |
56 | } | |
57 | } | |
58 | } | |
7d352fc8 KH |
59 | |
60 | int | |
47b0e7ad | 61 | print_insn_w65 (bfd_vma memaddr, struct disassemble_info *info) |
252b5132 | 62 | { |
252b5132 RH |
63 | int status = 0; |
64 | unsigned char insn[4]; | |
6a51a8a8 | 65 | const struct opinfo *op; |
252b5132 | 66 | int i; |
7d352fc8 | 67 | int X = 0; |
252b5132 RH |
68 | int M = 0; |
69 | int args[2]; | |
47b0e7ad | 70 | |
7d352fc8 | 71 | stream = info->stream; |
252b5132 | 72 | fpr = info->fprintf_func; |
7d352fc8 | 73 | local_info = info; |
47b0e7ad | 74 | |
7d352fc8 | 75 | for (i = 0; i < 4 && status == 0; i++) |
47b0e7ad | 76 | status = info->read_memory_func (memaddr + i, insn + i, 1, info); |
252b5132 | 77 | |
7d352fc8 | 78 | for (op = optable; op->val != insn[0]; op++) |
252b5132 RH |
79 | ; |
80 | ||
7d352fc8 KH |
81 | fpr (stream, "%s", op->name); |
82 | ||
83 | /* Prepare all the posible operand values. */ | |
252b5132 RH |
84 | { |
85 | int size = 1; | |
86 | int asR_W65_ABS8 = insn[1]; | |
87 | int asR_W65_ABS16 = (insn[2] << 8) + asR_W65_ABS8; | |
88 | int asR_W65_ABS24 = (insn[3] << 16) + asR_W65_ABS16; | |
7d352fc8 KH |
89 | int asR_W65_PCR8 = ((char) (asR_W65_ABS8)) + memaddr + 2; |
90 | int asR_W65_PCR16 = ((short) (asR_W65_ABS16)) + memaddr + 3; | |
252b5132 | 91 | |
7d352fc8 KH |
92 | switch (op->amode) |
93 | { | |
94 | DISASM (); | |
95 | } | |
252b5132 | 96 | |
7d352fc8 | 97 | return size; |
252b5132 | 98 | } |
252b5132 | 99 | } |