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

Subversion Repositories or1k_old

[/] [or1k_old/] [trunk/] [insight/] [opcodes/] [w65-dis.c] - Blame information for rev 578

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

Line No. Rev Author Line
1 578 markom
/* Disassemble WDC 65816 instructions.
2
   Copyright 1995, 1998, 2000 Free Software Foundation, Inc.
3
 
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.
8
 
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.
13
 
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
17
 
18
#include <stdio.h>
19
#include "sysdep.h"
20
#define STATIC_TABLE
21
#define DEFINE_TABLE
22
 
23
#include "w65-opc.h"
24
#include "dis-asm.h"
25
 
26
static fprintf_ftype fpr;
27
static void *stream;
28
static struct disassemble_info *local_info;
29
#if 0
30
static char *lname[] = { "r0","r1","r2","r3","r4","r5","r6","r7","s0" };
31
 
32
static char *
33
findname (val)
34
     unsigned int val;
35
{
36
  if (val >= 0x10 && val <= 0x20)
37
    return lname[(val - 0x10) / 2];
38
  return 0;
39
}
40
#endif
41
static void
42
print_operand (lookup, format, args)
43
     int lookup;
44
     char *format;
45
     unsigned int *args;
46
{
47
  int val;
48
  int c;
49
 
50
  while (*format)
51
    {
52
      switch (c = *format++)
53
        {
54
        case '$':
55
          val = args[(*format++) - '0'];
56
          if (lookup)
57
            {
58
#if 0
59
              name = findname (val);
60
              if (name)
61
                fpr (stream, "%s", name);
62
              else
63
#endif
64
                local_info->print_address_func (val, local_info);
65
            }
66
          else
67
            fpr (stream, "0x%x", val);
68
 
69
          break;
70
        default:
71
          fpr (stream, "%c", c);
72
          break;
73
        }
74
    }
75
}
76
 
77
int
78
print_insn_w65 (memaddr, info)
79
     bfd_vma memaddr;
80
     struct disassemble_info *info;
81
{
82
  int status = 0;
83
  unsigned char insn[4];
84
  register struct opinfo *op;
85
  int i;
86
  int X = 0;
87
  int M = 0;
88
  int args[2];
89
  stream = info->stream;
90
  fpr = info->fprintf_func;
91
  local_info = info;
92
  for (i = 0; i < 4 && status == 0; i++)
93
    {
94
      status = info->read_memory_func (memaddr + i, insn + i, 1, info);
95
    }
96
 
97
  for (op = optable; op->val != insn[0]; op++)
98
    ;
99
 
100
  fpr (stream, "%s", op->name);
101
 
102
  /* Prepare all the posible operand values.  */
103
  {
104
    int size = 1;
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;
110
 
111
    switch (op->amode)
112
      {
113
        DISASM ();
114
      }
115
 
116
    return size;
117
  }
118
}

powered by: WebSVN 2.1.0

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