* v850-dis.c: New file. Skeleton for disassembler support.
[deliverable/binutils-gdb.git] / opcodes / v850-dis.c
1 /* Disassemble V850 instructions.
2 Copyright (C) 1996 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
19 #include <stdio.h>
20
21 #include "ansidecl.h"
22 #include "opcode/v850.h"
23 #include "dis-asm.h"
24
25 int
26 print_insn_v850 (memaddr, info)
27 bfd_vma memaddr;
28 struct disassemble_info *info;
29 {
30 int status;
31 bfd_byte buffer[4];
32 unsigned long insn;
33
34 status = (*info->read_memory_func) (memaddr, buffer, 4, info);
35 if (status != 0)
36 {
37 (*info->memory_error_func) (status, memaddr, info);
38 return -1;
39 }
40 insn = bfd_getl32 (buffer);
41
42 disassemble (insn, info);
43 if ((insn & 0x0600) == 0x0600)
44 return 4;
45 else
46 return 2;
47 }
48
49 disassemble (insn, info)
50 unsigned long insn;
51 struct disassemble_info *info;
52 {
53 struct v850_opcode *op = (struct v850_opcode *)v850_opcodes;
54 int match = 0;
55 /* If this is a two byte insn, then mask off the high bits. */
56 if ((insn & 0x0600) != 0x0600)
57 insn &= 0xffff;
58
59 /* Find the opcode. */
60 while (op->name)
61 {
62 if ((op->mask & insn) == op->opcode)
63 {
64 match = 1;
65 (*info->fprintf_func) (info->stream, "%s\t", op->name);
66 break;
67 }
68 op++;
69 }
70
71 if (!match)
72 {
73 if ((insn & 0x0600) != 0x0600)
74 (*info->fprintf_func) (info->stream, ".short\t0x%04x", insn);
75 else
76 (*info->fprintf_func) (info->stream, ".long\t0x%08x", insn);
77 }
78 }
This page took 0.031454 seconds and 5 git commands to generate.