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

Subversion Repositories or1k

[/] [or1k/] [tags/] [start/] [gdb-5.0/] [opcodes/] [w65-dis.c] - Blame information for rev 1778

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

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

powered by: WebSVN 2.1.0

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