disassembler.h
5.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
/*
* Copyright (C) 1998 by the Board of Trustees
* of Leland Stanford Junior University.
* Copyright (C) 1998 Digital Equipment Corporation
*
* This file is part of the SimOS distribution.
* See LICENSE file for terms of the license.
*
*/
/*
* bugnion:
* would not compile because of bogus pascal comment
* cpp died
*/
/*
* *****************************************************************
* * *
* * Copyright (c) Digital Equipment Corporation, 1991, 1995 *
* * *
* * All Rights Reserved. Unpublished rights reserved under *
* * the copyright laws of the United States. *
* * *
* * The software contained on this media is proprietary to *
* * and embodies the confidential technology of Digital *
* * Equipment Corporation. Possession, use, duplication or *
* * dissemination of the software and media is authorized only *
* * pursuant to a valid written license from Digital Equipment *
* * Corporation. *
* * *
* * RESTRICTED RIGHTS LEGEND Use, duplication, or disclosure *
* * by the U.S. Government is subject to restrictions as set *
* * forth in Subparagraph (c)(1)(ii) of DFARS 252.227-7013, *
* * or in FAR 52.227-19, as applicable. *
* * *
* *****************************************************************
*/
/*
* HISTORY
*/
/*
* |-----------------------------------------------------------|
* | Copyright (c) 1991 MIPS Computer Systems, Inc. |
* | All Rights Reserved |
* |-----------------------------------------------------------|
* | Restricted Rights Legend |
* | Use, duplication, or disclosure by the Government is |
* | subject to restrictions as set forth in |
* | subparagraph (c)(1)(ii) of the Rights in Technical |
* | Data and Computer Software Clause of DFARS 52.227-7013. |
* | MIPS Computer Systems, Inc. |
* | 950 DeGuigne Drive |
* | Sunnyvale, CA 94086 |
* |-----------------------------------------------------------|
*/
/* $Header: /root/leakn64/depot/rf/sw/bbplayer/simos/cpus-alpha/gamma/disassembler.h,v 1.1.1.1 2002/05/29 01:09:11 blythe Exp $ */
/* Disassembler package */
/* Three sets of register names which people might want to use:
compiler: zero, at, v0, ...
hardware: r0, r1, r2, ...
assembler: $0, $at, $2,...
*/
#define COMPILER_NAMES dis_reg_names[0]
#define HARDWARE_NAMES dis_reg_names[1]
#define ASSEMBLER_NAMES dis_reg_names[2]
#ifdef __LANGUAGE_C__
extern char *dis_reg_names[3][32];
/* Initialize disassembler and set options for disassembly.
"addr_format" and "value_format" specify in the style of "printf" the
null-terminated formats for printing the address and value of the
instruction. If nil, they default to "%#010x\t"; if they are the empty
string, we omit to print these items.
"reg_names" is a pointer to an array of 32 strings which we will use to
represent the general-purpose registers. The *_NAMES macros above give
three common choices; if nil, we use compiler names.
print_jal_targets tells us whether to print the targets of jal
instructions numerically.
*/
void
dis_init(/*
char *addr_format;
char *value_format;
char *reg_names[];
int print_jal_targets;
*/);
/* Given a null-terminated buffer (presumably from "disasm"), we append an
ascii representation of register values in the form "\t<$5=0x50,$7=0x44,...>".
"regmask" is a bitmask of registers as in "disasm", "reg_values" an array
(with empty slots for the registers not indicated in the mask) of their
values */
void
dis_regs(/*
char *buffer;
unsigned regmask;
unsigned reg_values[]
*/);
/* Disassemble instruction, putting null-terminated result into "buffer"
(no trailing newline). Details governed by "dis_init".
buffer: array of characters allocated by the caller; 64 bytes should be
more than enough.
address: byte address
iword: the instruction
regmask: returns a bitmask of the gp registers the instruction uses,
with the LSB indicating register 0 regardless of endianness.
symbol_value: for a jal instruction, the target value; for a load or
store, the immediate value
ls_register: for a load or store, the number of the base register
return value: -1 for a load or store, 1 for a jal, 2 for a j, jr, jalr,
or branch, 0 for others
*/
int
disasm(/*
char *buffer;
unsigned address, iword, *regmask, *symbol_value, *ls_register
*/);
/* Older interface, which always prints on stdout */
int
disassembler(/* unsigned iadr; int regstyle; char *(*get_symname)();
int (*get_regvalue)(); long (*get_bytes)(); void (*print_header)()
*/);
#endif