c8b3ba9e359271dd6024218437b93a3c359587ad
[cacao.git] / src / vm / jit / sparc64 / disass.c
1 /* src/vm/jit/i386/disass.c - wrapper functions for GNU binutils disassembler
2
3    Copyright (C) 1996-2005, 2006 R. Grafl, A. Krall, C. Kruegel,
4    C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
5    E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,
6    J. Wenninger, Institut f. Computersprachen - TU Wien
7
8    This file is part of CACAO.
9
10    This program is free software; you can redistribute it and/or
11    modify it under the terms of the GNU General Public License as
12    published by the Free Software Foundation; either version 2, or (at
13    your option) any later version.
14
15    This program is distributed in the hope that it will be useful, but
16    WITHOUT ANY WARRANTY; without even the implied warranty of
17    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18    General Public License for more details.
19
20    You should have received a copy of the GNU General Public License
21    along with this program; if not, write to the Free Software
22    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
23    02110-1301, USA.
24
25    Contact: cacao@cacaojvm.org
26
27    Authors: Andreas  Krall
28             Reinhard Grafl
29             Christian Thalinger
30             Alexander Jordan
31
32    Changes:      
33
34    $Id: disass.c 4357 2006-01-22 23:33:38Z twisti $
35
36 */
37
38
39 #include "config.h"
40
41 #include <assert.h>
42 #include <dis-asm.h>
43 #include <stdarg.h>
44
45 #include "vm/types.h"
46
47 #include "vm/global.h"
48 #include "vm/jit/disass.h"
49
50 char *regs[] = {
51         "g0",
52         "g1",
53         "g2",
54         "g3",
55         "g4",
56         "g5",
57         "g6",
58         "g7",
59         "o0",
60         "o1",
61         "o2",
62         "o3",
63         "o4",
64         "o5",
65         "o6",
66         "o7",
67         "l0",
68         "l1",
69         "l2",
70         "l3",
71         "l4",
72         "l5",
73         "l6",
74         "l7",
75         "l0",
76         "i1",
77         "i2",
78         "i3",
79         "i4",
80         "i5",
81         "i6",
82         "i7"
83 };
84
85 /* disassinstr *****************************************************************
86
87    Outputs a disassembler listing of one machine code instruction on
88    'stdout'.
89
90    code: instructions machine code
91
92 *******************************************************************************/
93
94 u1 *disassinstr(u1 *code)
95 {
96         if (!disass_initialized) {
97                 INIT_DISASSEMBLE_INFO(info, NULL, disass_printf);
98
99                 /* setting the struct members must be done after
100                    INIT_DISASSEMBLE_INFO */
101
102                 info.mach             = bfd_mach_sparc_v9;
103                 info.endian           = BFD_ENDIAN_BIG;
104                 info.read_memory_func = &disass_buffer_read_memory;
105
106                 disass_initialized = 1;
107         }
108
109         printf("0x%016lx:   %08x    ", (s8) code, *((u4 *) code));
110
111         print_insn_sparc((bfd_vma) code, &info);
112
113         printf("\n");
114
115         return code + 4;
116 }
117
118
119 /*
120  * These are local overrides for various environment variables in Emacs.
121  * Please do not remove this and leave it at the end of the file, where
122  * Emacs will automagically detect them.
123  * ---------------------------------------------------------------------
124  * Local variables:
125  * mode: c
126  * indent-tabs-mode: t
127  * c-basic-offset: 4
128  * tab-width: 4
129  * End:
130  */