2006-08-10 Andrew Stubbs <andrew.stubbs@st.com>
[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 4
47b0e7ad
NC
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
252b5132 9
47b0e7ad
NC
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
252b5132 14
47b0e7ad
NC
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
18 MA 02110-1301, USA. */
252b5132
RH
19
20#include <stdio.h>
0d8dfecf 21#include "sysdep.h"
252b5132
RH
22#define STATIC_TABLE
23#define DEFINE_TABLE
24
25#include "w65-opc.h"
26#include "dis-asm.h"
27
7d352fc8
KH
28static fprintf_ftype fpr;
29static void *stream;
30static struct disassemble_info *local_info;
d83c6548 31
252b5132 32static void
47b0e7ad 33print_operand (int lookup, char *format, int *args)
252b5132
RH
34{
35 int val;
36 int c;
37
38 while (*format)
39 {
7d352fc8 40 switch (c = *format++)
252b5132
RH
41 {
42 case '$':
43 val = args[(*format++) - '0'];
7d352fc8 44 if (lookup)
47b0e7ad 45 local_info->print_address_func (val, local_info);
252b5132
RH
46 else
47 fpr (stream, "0x%x", val);
48
49 break;
50 default:
7d352fc8 51 fpr (stream, "%c", c);
252b5132
RH
52 break;
53 }
54 }
55}
7d352fc8
KH
56
57int
47b0e7ad 58print_insn_w65 (bfd_vma memaddr, struct disassemble_info *info)
252b5132 59{
252b5132
RH
60 int status = 0;
61 unsigned char insn[4];
6a51a8a8 62 const struct opinfo *op;
252b5132 63 int i;
7d352fc8 64 int X = 0;
252b5132
RH
65 int M = 0;
66 int args[2];
47b0e7ad 67
7d352fc8 68 stream = info->stream;
252b5132 69 fpr = info->fprintf_func;
7d352fc8 70 local_info = info;
47b0e7ad 71
7d352fc8 72 for (i = 0; i < 4 && status == 0; i++)
47b0e7ad 73 status = info->read_memory_func (memaddr + i, insn + i, 1, info);
252b5132 74
7d352fc8 75 for (op = optable; op->val != insn[0]; op++)
252b5132
RH
76 ;
77
7d352fc8
KH
78 fpr (stream, "%s", op->name);
79
80 /* Prepare all the posible operand values. */
252b5132
RH
81 {
82 int size = 1;
83 int asR_W65_ABS8 = insn[1];
84 int asR_W65_ABS16 = (insn[2] << 8) + asR_W65_ABS8;
85 int asR_W65_ABS24 = (insn[3] << 16) + asR_W65_ABS16;
7d352fc8
KH
86 int asR_W65_PCR8 = ((char) (asR_W65_ABS8)) + memaddr + 2;
87 int asR_W65_PCR16 = ((short) (asR_W65_ABS16)) + memaddr + 3;
252b5132 88
7d352fc8
KH
89 switch (op->amode)
90 {
91 DISASM ();
92 }
252b5132 93
7d352fc8 94 return size;
252b5132 95 }
252b5132 96}
This page took 0.30251 seconds and 4 git commands to generate.