1 /* Disassemble WDC 65816 instructions.
2 Copyright (C) 1995 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., 675 Mass Ave, Cambridge, MA 02139, USA. */
25 static fprintf_ftype fpr;
27 static struct disassemble_info *local_info;
29 static char *lname[] = {"r0","r1","r2","r3","r4","r5","r6","r7","s0"};
31 static char *findname (val)
34 if (val >= 0x10 && val <= 0x20)
35 return lname[(val - 0x10) / 2];
40 print_operand (lookup, format, args)
50 switch ( c = *format++)
53 val = args[(*format++) - '0'];
59 fpr(stream, "%s", name);
62 local_info->print_address_func (val, local_info);
65 fpr (stream, "0x%x", val);
75 print_insn_w65(memaddr, info)
77 struct disassemble_info *info;
82 unsigned char insn[4];
83 register struct opinfo *op;
88 stream = info->stream;
89 fpr = info->fprintf_func;
91 for (i = 0; i <4 && status == 0; i++)
93 status = info->read_memory_func(memaddr+i, insn + i, 1, info);
97 for (op = optable; op->val != insn[0]; op++)
100 fpr(stream,"%s", op->name);
102 /* Prepare all the posible operand values */
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;
108 int asR_W65_PCR8 = ((char)(asR_W65_ABS8)) + memaddr + 2;
109 int asR_W65_PCR16 = ((short)(asR_W65_ABS16)) + memaddr + 3;