-
Notifications
You must be signed in to change notification settings - Fork 1
/
dis.h
180 lines (139 loc) · 4.22 KB
/
dis.h
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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
#ifndef _DIS6502_H
#define _DIS6502_H
/*
* dis6502 by Robert Bond, Udi Finkelstein, and Eric Smith
*
* $Id: dis.h 26 2004-01-17 23:28:23Z eric $
* Copyright 2000-2003 Eric Smith <eric@brouhaha.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation. Note that permission is
* not granted to redistribute this program under the terms of any
* other version of the General Public License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA
*/
#include <stdint.h>
#include <stdio.h>
#include <stdnoreturn.h>
extern int sevenbit; /* if true, mask character data with 0x7f
to ignore MSB */
typedef uint16_t addr_t;
#define NPREDEF 10
extern char *predef[];
extern int npredef;
extern char *global_file;
extern char *progname;
extern int bopt;
enum boot_mode { UNKNOWN, RAW_BINARY, ATARI_LOAD, C64_LOAD, ATARI_BOOT };
extern int global_base_address, global_vector_address;
extern int asmout;
extern unsigned char f[];
extern unsigned char d[];
extern long offset[];
#define getword(x) (d[x] + (d[x + 1] << 8))
#define getbyte(x) (d[x])
/* f bits */
#define LOADED (1 << 0) /* Location loaded */
#define JREF (1 << 1) /* Referenced as jump/branch dest */
#define DREF (1 << 2) /* Referenced as data */
#define SREF (1 << 3) /* Referenced as subroutine dest */
#define NAMED (1 << 4) /* Has a name */
#define TDONE (1 << 5) /* Has been traced */
#define ISOP (1 << 6) /* Is a valid instruction opcode */
#define OFFSET (1 << 7) /* should be printed as an offset */
struct mnemonic {
char name[4]; /* three-letter mnemonic name */
int length; /* number of bytes */
int flags; /* control flow and addressing mode */
};
extern const struct mnemonic optbl[];
/* Flags */
/* Where control goes */
#define NORM (1 << 0)
#define JUMP (1 << 1)
#define FORK (1 << 2)
#define STOP (1 << 3)
#define CTLMASK (NORM|JUMP|FORK|STOP)
#define CMOS (1 << 4)
/* Instruction format */
#define IMM (1 << 5)
#define ABS (1 << 6)
#define ACC (1 << 7)
#define IMP (1 << 8)
#define INX (1 << 9)
#define INY (1 << 10)
#define ZPX (1 << 11)
#define ABX (1 << 12)
#define ABY (1 << 13)
#define REL (1 << 14)
#define IND (1 << 15)
#define ZPY (1 << 16)
#define ZPG (1 << 17)
#define ZPI (1 << 18)
#define ILL (1 << 19)
#define ADRMASK (IMM|ABS|ACC|IMP|INX|INY|ZPX|ABX|ABY|REL|IND|ZPY|ZPG|ZPI|ILL)
struct ref_chain {
struct ref_chain *next;
int who;
};
struct ref_chain *get_ref(addr_t loc);
char *get_name(addr_t loc);
struct print_cfg {
const char *lab;
const char *byte;
const char *word;
const char *imm;
const char *acc;
const char *equ;
const char *org;
const char *data;
};
extern struct print_cfg pf_orig, pf_beebasm, pf_lanc, pf_ca65, pf_as, *pf_selected;
/* lex junk */
#define EQ 256
#define NUMBER 257
#define NAME 258
#define COMMENT 259
#define LI 260
#define TSTART 261
#define TSTOP 262
#define TRTSTAB 263
#define TJTAB2 264
#define EQS 265
#define OFS 266
#define TJTAB 267
#define TRTSTAB2 268
extern FILE *yyin;
extern int lineno;
typedef union {
int ival;
char *sval;
} VALUE;
extern VALUE token;
/* in scanner generated from lex.l: */
int yylex (void);
/* in initopts.c: */
void initopts (int argc, char *argv[]);
/* in print.c: */
void dumpitout (void);
/* in ref.c: */
void save_ref (addr_t refer, addr_t refee);
void save_name (addr_t loc, char *name);
/* in trace_queue.c: */
void init_trace_queue (void);
int trace_queue_empty (void);
void push_trace_queue (addr_t addr);
addr_t pop_trace_queue (void);
/* in main.c: */
noreturn void crash (const char *fmt, ...) __attribute__ ((format(printf, 1, 2)));
void *emalloc(size_t bytes) __attribute__((malloc));
#endif /* _DIS6502_H */