1 /* Disassemble WDC 65816 instructions.
2 Copyright (C) 1995-2018 Free Software Foundation, Inc.
4 This file is part of the GNU opcodes library.
6 This library is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3, or (at your option)
11 It is distributed in the hope that it will be useful, but WITHOUT
12 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
14 License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
19 MA 02110-1301, USA. */
28 #include "disassemble.h"
30 static fprintf_ftype fpr;
32 static struct disassemble_info *local_info;
35 print_operand (int lookup, char *format, int *args)
42 switch (c = *format++)
45 val = args[(*format++) - '0'];
47 local_info->print_address_func (val, local_info);
49 fpr (stream, "0x%x", val);
53 fpr (stream, "%c", c);
60 print_insn_w65 (bfd_vma memaddr, struct disassemble_info *info)
63 unsigned char insn[4];
64 const struct opinfo *op;
70 stream = info->stream;
71 fpr = info->fprintf_func;
74 for (i = 0; i < 4 && status == 0; i++)
75 status = info->read_memory_func (memaddr + i, insn + i, 1, info);
77 for (op = optable; op->val != insn[0]; op++)
80 fpr (stream, "%s", op->name);
82 /* Prepare all the posible operand values. */
85 int asR_W65_ABS8 = insn[1];
86 int asR_W65_ABS16 = (insn[2] << 8) + asR_W65_ABS8;
87 int asR_W65_ABS24 = (insn[3] << 16) + asR_W65_ABS16;
88 int asR_W65_PCR8 = ((char) (asR_W65_ABS8)) + memaddr + 2;
89 int asR_W65_PCR16 = ((short) (asR_W65_ABS16)) + memaddr + 3;