Rizin
unix-like reverse engineering framework and cli tools
gb_op_table.h
Go to the documentation of this file.
1
// SPDX-FileCopyrightText: 2013-2014 condret <condret@runas-racer.com>
2
// SPDX-License-Identifier: LGPL-3.0-only
3
4
#define GB_8BIT 1
5
#define GB_16BIT 2
6
#define ARG_8 4
7
#define ARG_16 8
8
#define GB_IO 16
// Most io (Joypad, Sound, Screen ...)
9
10
typedef
struct
{
11
const
char
*
name
;
12
const
int
type
;
13
}
gb_opcode
;
14
15
static
const
char
*
cb_ops
[] = {
"rlc"
,
"rrc"
,
"rl"
,
"rr"
,
"sla"
,
"sra"
,
"swap"
,
"srl"
,
16
"bit 0,"
,
"bit 1,"
,
"bit 2,"
,
"bit 3,"
,
"bit 4,"
,
"bit 5,"
,
"bit 6,"
,
"bit 7,"
,
17
"res 0,"
,
"res 1,"
,
"res 2,"
,
"res 3,"
,
"res 4,"
,
"res 5,"
,
"res 6,"
,
"res 7,"
,
18
"set 0,"
,
"set 1,"
,
"set 2,"
,
"set 3,"
,
"set 4,"
,
"set 5,"
,
"set 6,"
,
"set 7,"
};
19
20
static
const
char
*
cb_regs
[] = {
"b"
,
"c"
,
"d"
,
"e"
,
"h"
,
"l"
,
"[hl]"
,
"a"
};
21
22
static
gb_opcode
gb_op
[] = {
23
{
"nop"
,
GB_8BIT
},
// 0x00
24
{
"ld bc, 0x%04x"
,
GB_8BIT
+
ARG_16
},
25
{
"ld [bc], a"
,
GB_8BIT
},
26
{
"inc bc"
,
GB_8BIT
},
27
{
"inc b"
,
GB_8BIT
},
28
{
"dec b"
,
GB_8BIT
},
29
{
"ld b, 0x%02x"
,
GB_8BIT
+
ARG_8
},
30
{
"rlca"
,
GB_8BIT
},
31
{
"ld [0x%04x], sp"
,
GB_8BIT
+
ARG_16
},
// word or byte?
32
{
"add hl, bc"
,
GB_8BIT
},
33
{
"ld a, [bc]"
,
GB_8BIT
},
34
{
"dec bc"
,
GB_8BIT
},
35
{
"inc c"
,
GB_8BIT
},
36
{
"dec c"
,
GB_8BIT
},
37
{
"ld c, 0x%02x"
,
GB_8BIT
+
ARG_8
},
38
{
"rrca"
,
GB_8BIT
},
39
40
{
"stop"
,
GB_8BIT
},
// 0x10
41
{
"ld de, 0x%04x"
,
GB_8BIT
+
ARG_16
},
42
{
"ld [de], a"
,
GB_8BIT
},
43
{
"inc de"
,
GB_8BIT
},
44
{
"inc d"
,
GB_8BIT
},
45
{
"dec d"
,
GB_8BIT
},
46
{
"ld d, 0x%02x"
,
GB_8BIT
+
ARG_8
},
47
{
"rla"
,
GB_8BIT
},
48
{
"jr 0x%02x"
,
GB_8BIT
+
ARG_8
},
// signed
49
{
"add hl, de"
,
GB_8BIT
},
50
{
"ld a, [de]"
,
GB_8BIT
},
51
{
"dec de"
,
GB_8BIT
},
52
{
"inc e"
,
GB_8BIT
},
53
{
"dec e"
,
GB_8BIT
},
54
{
"ld e, 0x%02x"
,
GB_8BIT
+
ARG_8
},
55
{
"rra"
,
GB_8BIT
},
56
57
{
"jr nZ, 0x%02x"
,
GB_8BIT
+
ARG_8
},
// 0x20 //signed
58
{
"ld hl, 0x%04x"
,
GB_8BIT
+
ARG_16
},
59
{
"ldi [hl], a"
,
GB_8BIT
},
60
{
"inc hl"
,
GB_8BIT
},
61
{
"inc h"
,
GB_8BIT
},
62
{
"dec h"
,
GB_8BIT
},
63
{
"ld h, 0x%02x"
,
GB_8BIT
+
ARG_8
},
64
{
"daa"
,
GB_8BIT
},
65
{
"jr Z, 0x%02x"
,
GB_8BIT
+
ARG_8
},
// signed
66
{
"add hl, hl"
,
GB_8BIT
},
67
{
"ldi a, [hl]"
,
GB_8BIT
},
68
{
"dec hl"
,
GB_8BIT
},
69
{
"inc l"
,
GB_8BIT
},
70
{
"dec l"
,
GB_8BIT
},
71
{
"ld l, 0x%02x"
,
GB_8BIT
+
ARG_8
},
72
{
"cpl"
,
GB_8BIT
},
73
74
{
"jr nC, 0x%02x"
,
GB_8BIT
+
ARG_8
},
// 0x30 //signed
75
{
"ld sp, 0x%04x"
,
GB_8BIT
+
ARG_16
},
76
{
"ldd [hl], a"
,
GB_8BIT
},
77
{
"inc sp"
,
GB_8BIT
},
78
{
"inc [hl]"
,
GB_8BIT
},
79
{
"dec [hl]"
,
GB_8BIT
},
80
{
"ld [hl], 0x%02x"
,
GB_8BIT
+
ARG_8
},
81
{
"scf"
,
GB_8BIT
},
82
{
"jr C, 0x%02x"
,
GB_8BIT
+
ARG_8
},
// signed
83
{
"add hl, sp"
,
GB_8BIT
},
84
{
"ldd a, [hl]"
,
GB_8BIT
},
85
{
"dec sp"
,
GB_8BIT
},
86
{
"inc a"
,
GB_8BIT
},
87
{
"dec a"
,
GB_8BIT
},
88
{
"ld a, 0x%02x"
,
GB_8BIT
+
ARG_8
},
89
{
"ccf"
,
GB_8BIT
},
90
91
{
"ld b, b"
,
GB_8BIT
},
// 0x40
92
{
"ld b, c"
,
GB_8BIT
},
93
{
"ld b, d"
,
GB_8BIT
},
94
{
"ld b, e"
,
GB_8BIT
},
95
{
"ld b, h"
,
GB_8BIT
},
96
{
"ld b, l"
,
GB_8BIT
},
97
{
"ld b, [hl]"
,
GB_8BIT
},
98
{
"ld b, a"
,
GB_8BIT
},
99
{
"ld c, b"
,
GB_8BIT
},
100
{
"ld c, c"
,
GB_8BIT
},
101
{
"ld c, d"
,
GB_8BIT
},
102
{
"ld c, e"
,
GB_8BIT
},
103
{
"ld c, h"
,
GB_8BIT
},
104
{
"ld c, l"
,
GB_8BIT
},
105
{
"ld c, [hl]"
,
GB_8BIT
},
106
{
"ld c, a"
,
GB_8BIT
},
107
108
{
"ld d, b"
,
GB_8BIT
},
// 0x50
109
{
"ld d, c"
,
GB_8BIT
},
110
{
"ld d, d"
,
GB_8BIT
},
111
{
"ld d, e"
,
GB_8BIT
},
112
{
"ld d, h"
,
GB_8BIT
},
113
{
"ld d, l"
,
GB_8BIT
},
114
{
"ld d, [hl]"
,
GB_8BIT
},
115
{
"ld d, a"
,
GB_8BIT
},
116
{
"ld e, b"
,
GB_8BIT
},
117
{
"ld e, c"
,
GB_8BIT
},
118
{
"ld e, d"
,
GB_8BIT
},
119
{
"ld e, e"
,
GB_8BIT
},
120
{
"ld e, h"
,
GB_8BIT
},
121
{
"ld e, l"
,
GB_8BIT
},
122
{
"ld e, [hl]"
,
GB_8BIT
},
123
{
"ld e, a"
,
GB_8BIT
},
124
125
{
"ld h, b"
,
GB_8BIT
},
// 0x60
126
{
"ld h, c"
,
GB_8BIT
},
127
{
"ld h, d"
,
GB_8BIT
},
128
{
"ld h, e"
,
GB_8BIT
},
129
{
"ld h, h"
,
GB_8BIT
},
130
{
"ld h, l"
,
GB_8BIT
},
131
{
"ld h, [hl]"
,
GB_8BIT
},
132
{
"ld h, a"
,
GB_8BIT
},
133
{
"ld l, b"
,
GB_8BIT
},
134
{
"ld l, c"
,
GB_8BIT
},
135
{
"ld l, d"
,
GB_8BIT
},
136
{
"ld l, e"
,
GB_8BIT
},
137
{
"ld l, h"
,
GB_8BIT
},
138
{
"ld l, l"
,
GB_8BIT
},
139
{
"ld l, [hl]"
,
GB_8BIT
},
140
{
"ld l, a"
,
GB_8BIT
},
141
142
{
"ld [hl], b"
,
GB_8BIT
},
// 0X70
143
{
"ld [hl], c"
,
GB_8BIT
},
144
{
"ld [hl], d"
,
GB_8BIT
},
145
{
"ld [hl], e"
,
GB_8BIT
},
146
{
"ld [hl], h"
,
GB_8BIT
},
147
{
"ld [hl], l"
,
GB_8BIT
},
148
{
"halt"
,
GB_8BIT
},
149
{
"ld [hl], a"
,
GB_8BIT
},
150
{
"ld a, b"
,
GB_8BIT
},
151
{
"ld a, c"
,
GB_8BIT
},
152
{
"ld a, d"
,
GB_8BIT
},
153
{
"ld a, e"
,
GB_8BIT
},
154
{
"ld a, h"
,
GB_8BIT
},
155
{
"ld a, l"
,
GB_8BIT
},
156
{
"ld a, [hl]"
,
GB_8BIT
},
157
{
"ld a, a"
,
GB_8BIT
},
158
159
{
"add b"
,
GB_8BIT
},
// 0x80
160
{
"add c"
,
GB_8BIT
},
161
{
"add d"
,
GB_8BIT
},
162
{
"add e"
,
GB_8BIT
},
163
{
"add h"
,
GB_8BIT
},
164
{
"add l"
,
GB_8BIT
},
165
{
"add [hl]"
,
GB_8BIT
},
166
{
"add a"
,
GB_8BIT
},
167
{
"adc b"
,
GB_8BIT
},
168
{
"adc c"
,
GB_8BIT
},
169
{
"adc d"
,
GB_8BIT
},
170
{
"adc e"
,
GB_8BIT
},
171
{
"adc h"
,
GB_8BIT
},
172
{
"adc l"
,
GB_8BIT
},
173
{
"adc [hl]"
,
GB_8BIT
},
174
{
"adc a"
,
GB_8BIT
},
175
176
{
"sub b"
,
GB_8BIT
},
// 0x90
177
{
"sub c"
,
GB_8BIT
},
178
{
"sub d"
,
GB_8BIT
},
179
{
"sub e"
,
GB_8BIT
},
180
{
"sub h"
,
GB_8BIT
},
181
{
"sub l"
,
GB_8BIT
},
182
{
"sub [hl]"
,
GB_8BIT
},
183
{
"sub a"
,
GB_8BIT
},
184
{
"sbc b"
,
GB_8BIT
},
185
{
"sbc c"
,
GB_8BIT
},
186
{
"sbc d"
,
GB_8BIT
},
187
{
"sbc e"
,
GB_8BIT
},
188
{
"sbc h"
,
GB_8BIT
},
189
{
"sbc l"
,
GB_8BIT
},
190
{
"sbc [hl]"
,
GB_8BIT
},
191
{
"sbc a"
,
GB_8BIT
},
192
193
{
"and b"
,
GB_8BIT
},
// 0xa0
194
{
"and c"
,
GB_8BIT
},
195
{
"and d"
,
GB_8BIT
},
196
{
"and e"
,
GB_8BIT
},
197
{
"and h"
,
GB_8BIT
},
198
{
"and l"
,
GB_8BIT
},
199
{
"and [hl]"
,
GB_8BIT
},
200
{
"and a"
,
GB_8BIT
},
201
{
"xor b"
,
GB_8BIT
},
202
{
"xor c"
,
GB_8BIT
},
203
{
"xor d"
,
GB_8BIT
},
204
{
"xor e"
,
GB_8BIT
},
205
{
"xor h"
,
GB_8BIT
},
206
{
"xor l"
,
GB_8BIT
},
207
{
"xor [hl]"
,
GB_8BIT
},
208
{
"xor a"
,
GB_8BIT
},
209
210
{
"or b"
,
GB_8BIT
},
// 0xb0
211
{
"or c"
,
GB_8BIT
},
212
{
"or d"
,
GB_8BIT
},
213
{
"or e"
,
GB_8BIT
},
214
{
"or h"
,
GB_8BIT
},
215
{
"or l"
,
GB_8BIT
},
216
{
"or [hl]"
,
GB_8BIT
},
217
{
"or a"
,
GB_8BIT
},
218
{
"cp b"
,
GB_8BIT
},
219
{
"cp c"
,
GB_8BIT
},
220
{
"cp d"
,
GB_8BIT
},
221
{
"cp e"
,
GB_8BIT
},
222
{
"cp h"
,
GB_8BIT
},
223
{
"cp l"
,
GB_8BIT
},
224
{
"cp [hl]"
,
GB_8BIT
},
225
{
"cp a"
,
GB_8BIT
},
226
227
{
"ret nZ"
,
GB_8BIT
},
// 0xc0
228
{
"pop bc"
,
GB_8BIT
},
229
{
"jp nZ, 0x%04x"
,
GB_8BIT
+
ARG_16
},
230
{
"jp 0x%04x"
,
GB_8BIT
+
ARG_16
},
231
{
"call nZ, 0x%04x"
,
GB_8BIT
+
ARG_16
},
232
{
"push bc"
,
GB_8BIT
},
233
{
"add 0x%02x"
,
GB_8BIT
+
ARG_8
},
234
{
"rst 0"
,
GB_8BIT
},
235
{
"ret Z"
,
GB_8BIT
},
236
{
"ret"
,
GB_8BIT
},
237
{
"jp Z, 0x%04x"
,
GB_8BIT
+
ARG_16
},
238
{
""
,
GB_16BIT
},
239
{
"call Z, 0x%04x"
,
GB_8BIT
+
ARG_16
},
240
{
"call 0x%04x"
,
GB_8BIT
+
ARG_16
},
241
{
"adc 0x%02x"
,
GB_8BIT
+
ARG_8
},
242
{
"rst 8"
,
GB_8BIT
},
243
244
{
"ret nC"
,
GB_8BIT
},
// 0xd0
245
{
"pop de"
,
GB_8BIT
},
246
{
"jp nC, 0x%04x"
,
GB_8BIT
+
ARG_16
},
247
{
"invalid"
,
GB_8BIT
},
248
{
"call nC, 0x%04x"
,
GB_8BIT
+
ARG_16
},
249
{
"push de"
,
GB_8BIT
},
250
{
"sub 0x%02x"
,
GB_8BIT
+
ARG_8
},
251
{
"rst 16"
,
GB_8BIT
},
252
{
"ret C"
,
GB_8BIT
},
253
{
"reti"
,
GB_8BIT
},
254
{
"jp C, 0x%04x"
,
GB_8BIT
+
ARG_16
},
255
{
"invalid"
,
GB_8BIT
},
256
{
"call C, 0x%04x"
,
GB_8BIT
+
ARG_16
},
257
{
"invalid"
,
GB_8BIT
},
258
{
"sbc 0x%02x"
,
GB_8BIT
+
ARG_8
},
259
{
"rst 24"
,
GB_8BIT
},
260
261
{
"ld [%s], a"
,
GB_8BIT
+
ARG_8
+
GB_IO
},
// 0xe0
262
{
"pop hl"
,
GB_8BIT
},
263
{
"ld [0xff00 + c], a"
,
GB_8BIT
},
264
{
"invalid"
,
GB_8BIT
},
265
{
"invalid"
,
GB_8BIT
},
266
{
"push hl"
,
GB_8BIT
},
267
{
"and 0x%02x"
,
GB_8BIT
+
ARG_8
},
268
{
"rst 32"
,
GB_8BIT
},
269
{
"add sp, 0x%02x"
,
GB_8BIT
+
ARG_8
},
// signed
270
{
"jp hl"
,
GB_8BIT
},
271
{
"ld [0x%04x], a"
,
GB_8BIT
+
ARG_16
},
// signed
272
{
"invalid"
,
GB_8BIT
},
273
{
"invalid"
,
GB_8BIT
},
274
{
"invalid"
,
GB_8BIT
},
275
{
"xor 0x%02x"
,
GB_8BIT
+
ARG_8
},
276
{
"rst 40"
,
GB_8BIT
},
277
278
{
"ld a, [%s]"
,
GB_8BIT
+
ARG_8
+
GB_IO
},
// 0xf0
279
{
"pop af"
,
GB_8BIT
},
280
{
"ld a, [0xff00 + c]"
,
GB_8BIT
},
281
{
"di"
,
GB_8BIT
},
282
{
"invalid"
,
GB_8BIT
},
283
{
"push af"
,
GB_8BIT
},
284
{
"or 0x%02x"
,
GB_8BIT
+
ARG_8
},
285
{
"rst 48"
,
GB_8BIT
},
286
{
"ld hl, sp + 0x%02x"
,
GB_8BIT
+
ARG_8
},
// signed
287
{
"ld sp, hl"
,
GB_8BIT
},
288
{
"ld a, [0x%04x]"
,
GB_8BIT
+
ARG_16
},
289
{
"ei"
,
GB_8BIT
},
290
{
"invalid"
,
GB_8BIT
},
291
{
"invalid"
,
GB_8BIT
},
292
{
"cp 0x%02x"
,
GB_8BIT
+
ARG_8
},
293
{
"rst 56"
,
GB_8BIT
},
294
};
GB_IO
#define GB_IO
Definition:
gb_op_table.h:8
cb_ops
static const char * cb_ops[]
Definition:
gb_op_table.h:15
GB_16BIT
#define GB_16BIT
Definition:
gb_op_table.h:5
ARG_16
#define ARG_16
Definition:
gb_op_table.h:7
ARG_8
#define ARG_8
Definition:
gb_op_table.h:6
cb_regs
static const char * cb_regs[]
Definition:
gb_op_table.h:20
gb_op
static gb_opcode gb_op[]
Definition:
gb_op_table.h:22
GB_8BIT
#define GB_8BIT
Definition:
gb_op_table.h:4
gb_opcode
Definition:
gb_op_table.h:10
gb_opcode::name
const char * name
Definition:
gb_op_table.h:11
gb_opcode::type
const int type
Definition:
gb_op_table.h:12
librz
asm
arch
gb
gb_op_table.h
Generated by
1.9.1