fixes for host gcc 4.6.1
[zpugcc/jano.git] / toolchain / binutils / opcodes / w65-dis.c
blob3f2affa8082cb6b15f6700dbfdbab200f2fbf041
1 /* Disassemble WDC 65816 instructions.
2 Copyright 1995, 1998, 2000, 2001, 2002 Free Software Foundation, Inc.
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.
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.
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. */
18 #include <stdio.h>
19 #include "sysdep.h"
20 #define STATIC_TABLE
21 #define DEFINE_TABLE
23 #include "w65-opc.h"
24 #include "dis-asm.h"
26 static fprintf_ftype fpr;
27 static void *stream;
28 static struct disassemble_info *local_info;
30 static void print_operand PARAMS ((int, char *, unsigned int *));
32 #if 0
33 static char *lname[] = { "r0","r1","r2","r3","r4","r5","r6","r7","s0" };
35 static char *
36 findname (val)
37 unsigned int val;
39 if (val >= 0x10 && val <= 0x20)
40 return lname[(val - 0x10) / 2];
41 return 0;
43 #endif
44 static void
45 print_operand (lookup, format, args)
46 int lookup;
47 char *format;
48 unsigned int *args;
50 int val;
51 int c;
53 while (*format)
55 switch (c = *format++)
57 case '$':
58 val = args[(*format++) - '0'];
59 if (lookup)
61 #if 0
62 name = findname (val);
63 if (name)
64 fpr (stream, "%s", name);
65 else
66 #endif
67 local_info->print_address_func (val, local_info);
69 else
70 fpr (stream, "0x%x", val);
72 break;
73 default:
74 fpr (stream, "%c", c);
75 break;
80 int
81 print_insn_w65 (memaddr, info)
82 bfd_vma memaddr;
83 struct disassemble_info *info;
85 int status = 0;
86 unsigned char insn[4];
87 const struct opinfo *op;
88 int i;
89 int X = 0;
90 int M = 0;
91 int args[2];
92 stream = info->stream;
93 fpr = info->fprintf_func;
94 local_info = info;
95 for (i = 0; i < 4 && status == 0; i++)
97 status = info->read_memory_func (memaddr + i, insn + i, 1, info);
100 for (op = optable; op->val != insn[0]; op++)
103 fpr (stream, "%s", op->name);
105 /* Prepare all the posible operand values. */
107 int size = 1;
108 int asR_W65_ABS8 = insn[1];
109 int asR_W65_ABS16 = (insn[2] << 8) + asR_W65_ABS8;
110 int asR_W65_ABS24 = (insn[3] << 16) + asR_W65_ABS16;
111 int asR_W65_PCR8 = ((char) (asR_W65_ABS8)) + memaddr + 2;
112 int asR_W65_PCR16 = ((short) (asR_W65_ABS16)) + memaddr + 3;
114 switch (op->amode)
116 DISASM ();
119 return size;