OpenCores
URL https://opencores.org/ocsvn/open8_urisc/open8_urisc/trunk

Subversion Repositories open8_urisc

[/] [open8_urisc/] [trunk/] [gnu/] [binutils/] [opcodes/] [w65-dis.c] - Blame information for rev 229

Go to most recent revision | Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.