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