Commit | Line | Data |
---|---|---|
252b5132 | 1 | /* Disassemble WDC 65816 instructions. |
b90efa5b | 2 | Copyright (C) 1995-2015 Free Software Foundation, Inc. |
252b5132 | 3 | |
9b201bb5 NC |
4 | This file is part of the GNU opcodes library. |
5 | ||
6 | This library is free software; you can redistribute it and/or modify | |
47b0e7ad | 7 | it under the terms of the GNU General Public License as published by |
9b201bb5 NC |
8 | the Free Software Foundation; either version 3, or (at your option) |
9 | any later version. | |
252b5132 | 10 | |
9b201bb5 NC |
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. | |
252b5132 | 15 | |
47b0e7ad NC |
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. */ | |
252b5132 | 20 | |
0d8dfecf | 21 | #include "sysdep.h" |
df7b86aa NC |
22 | #include <stdio.h> |
23 | ||
252b5132 RH |
24 | #define STATIC_TABLE |
25 | #define DEFINE_TABLE | |
26 | ||
27 | #include "w65-opc.h" | |
28 | #include "dis-asm.h" | |
29 | ||
7d352fc8 KH |
30 | static fprintf_ftype fpr; |
31 | static void *stream; | |
32 | static struct disassemble_info *local_info; | |
d83c6548 | 33 | |
252b5132 | 34 | static void |
47b0e7ad | 35 | print_operand (int lookup, char *format, int *args) |
252b5132 RH |
36 | { |
37 | int val; | |
38 | int c; | |
39 | ||
40 | while (*format) | |
41 | { | |
7d352fc8 | 42 | switch (c = *format++) |
252b5132 RH |
43 | { |
44 | case '$': | |
45 | val = args[(*format++) - '0']; | |
7d352fc8 | 46 | if (lookup) |
47b0e7ad | 47 | local_info->print_address_func (val, local_info); |
252b5132 RH |
48 | else |
49 | fpr (stream, "0x%x", val); | |
50 | ||
51 | break; | |
52 | default: | |
7d352fc8 | 53 | fpr (stream, "%c", c); |
252b5132 RH |
54 | break; |
55 | } | |
56 | } | |
57 | } | |
7d352fc8 KH |
58 | |
59 | int | |
47b0e7ad | 60 | print_insn_w65 (bfd_vma memaddr, struct disassemble_info *info) |
252b5132 | 61 | { |
252b5132 RH |
62 | int status = 0; |
63 | unsigned char insn[4]; | |
6a51a8a8 | 64 | const struct opinfo *op; |
252b5132 | 65 | int i; |
7d352fc8 | 66 | int X = 0; |
252b5132 RH |
67 | int M = 0; |
68 | int args[2]; | |
47b0e7ad | 69 | |
7d352fc8 | 70 | stream = info->stream; |
252b5132 | 71 | fpr = info->fprintf_func; |
7d352fc8 | 72 | local_info = info; |
47b0e7ad | 73 | |
7d352fc8 | 74 | for (i = 0; i < 4 && status == 0; i++) |
47b0e7ad | 75 | status = info->read_memory_func (memaddr + i, insn + i, 1, info); |
252b5132 | 76 | |
7d352fc8 | 77 | for (op = optable; op->val != insn[0]; op++) |
252b5132 RH |
78 | ; |
79 | ||
7d352fc8 KH |
80 | fpr (stream, "%s", op->name); |
81 | ||
82 | /* Prepare all the posible operand values. */ | |
252b5132 RH |
83 | { |
84 | int size = 1; | |
85 | int asR_W65_ABS8 = insn[1]; | |
86 | int asR_W65_ABS16 = (insn[2] << 8) + asR_W65_ABS8; | |
87 | int asR_W65_ABS24 = (insn[3] << 16) + asR_W65_ABS16; | |
7d352fc8 KH |
88 | int asR_W65_PCR8 = ((char) (asR_W65_ABS8)) + memaddr + 2; |
89 | int asR_W65_PCR16 = ((short) (asR_W65_ABS16)) + memaddr + 3; | |
252b5132 | 90 | |
7d352fc8 KH |
91 | switch (op->amode) |
92 | { | |
93 | DISASM (); | |
94 | } | |
252b5132 | 95 | |
7d352fc8 | 96 | return size; |
252b5132 | 97 | } |
252b5132 | 98 | } |