Fix typo last entry
[deliverable/binutils-gdb.git] / opcodes / w65-dis.c
CommitLineData
252b5132 1/* Disassemble WDC 65816 instructions.
d83c6548 2 Copyright 1995, 1998, 2000, 2001 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;
d83c6548
AJ
29
30static void print_operand PARAMS ((int, char *, unsigned int *));
31
252b5132 32#if 0
7d352fc8 33static char *lname[] = { "r0","r1","r2","r3","r4","r5","r6","r7","s0" };
252b5132 34
7d352fc8
KH
35static char *
36findname (val)
252b5132
RH
37 unsigned int val;
38{
39 if (val >= 0x10 && val <= 0x20)
40 return lname[(val - 0x10) / 2];
41 return 0;
42}
43#endif
44static void
45print_operand (lookup, format, args)
46 int lookup;
47 char *format;
7d352fc8 48 unsigned int *args;
252b5132
RH
49{
50 int val;
51 int c;
52
53 while (*format)
54 {
7d352fc8 55 switch (c = *format++)
252b5132
RH
56 {
57 case '$':
58 val = args[(*format++) - '0'];
7d352fc8 59 if (lookup)
252b5132
RH
60 {
61#if 0
7d352fc8 62 name = findname (val);
252b5132 63 if (name)
7d352fc8 64 fpr (stream, "%s", name);
252b5132
RH
65 else
66#endif
7d352fc8 67 local_info->print_address_func (val, local_info);
252b5132
RH
68 }
69 else
70 fpr (stream, "0x%x", val);
71
72 break;
73 default:
7d352fc8 74 fpr (stream, "%c", c);
252b5132
RH
75 break;
76 }
77 }
78}
7d352fc8
KH
79
80int
81print_insn_w65 (memaddr, info)
252b5132
RH
82 bfd_vma memaddr;
83 struct disassemble_info *info;
84{
252b5132
RH
85 int status = 0;
86 unsigned char insn[4];
87 register struct opinfo *op;
88 int i;
7d352fc8 89 int X = 0;
252b5132
RH
90 int M = 0;
91 int args[2];
7d352fc8 92 stream = info->stream;
252b5132 93 fpr = info->fprintf_func;
7d352fc8
KH
94 local_info = info;
95 for (i = 0; i < 4 && status == 0; i++)
252b5132 96 {
7d352fc8
KH
97 status = info->read_memory_func (memaddr + i, insn + i, 1, info);
98 }
252b5132 99
7d352fc8 100 for (op = optable; op->val != insn[0]; op++)
252b5132
RH
101 ;
102
7d352fc8
KH
103 fpr (stream, "%s", op->name);
104
105 /* Prepare all the posible operand values. */
252b5132
RH
106 {
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;
7d352fc8
KH
111 int asR_W65_PCR8 = ((char) (asR_W65_ABS8)) + memaddr + 2;
112 int asR_W65_PCR16 = ((short) (asR_W65_ABS16)) + memaddr + 3;
252b5132 113
7d352fc8
KH
114 switch (op->amode)
115 {
116 DISASM ();
117 }
252b5132 118
7d352fc8 119 return size;
252b5132 120 }
252b5132 121}
This page took 0.159721 seconds and 4 git commands to generate.