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