]> sigrok.org Git - libsigrokdecode.git/blob - decoders/z80/tables.py
z80: Format hex numbers with leading zero if necessary.
[libsigrokdecode.git] / decoders / z80 / tables.py
1 ##
2 ## This file is part of the libsigrokdecode project.
3 ##
4 ## Copyright (C) 2014 Daniel Elstner <daniel.kitta@gmail.com>
5 ##
6 ## This program is free software; you can redistribute it and/or modify
7 ## it under the terms of the GNU General Public License as published by
8 ## the Free Software Foundation; either version 3 of the License, or
9 ## (at your option) any later version.
10 ##
11 ## This program is distributed in the hope that it will be useful,
12 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
13 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 ## GNU General Public License for more details.
15 ##
16 ## You should have received a copy of the GNU General Public License
17 ## along with this program; if not, see <http://www.gnu.org/licenses/>.
18 ##
19
20 '''
21 Instruction tuple: (d, i, ro, wo, rep, format string)
22
23   The placeholders d and i are the number of bytes in the instruction
24   used for the displacement and the immediate operand, respectively. An
25   operand consisting of more than one byte is assembled in little endian
26   order.
27   The format string should refer to the {d} and {i} operands by name.
28   Displacements are interpreted as signed integers, whereas immediate
29   operands are always read as unsigned. The tables for instructions
30   operating on the IX/IY index registers additionally use {r} in the
31   format string as a placeholder for the register name.
32   The placeholders ro and wo are the number of bytes the instruction
33   is expected to read or write, respectively. These counts are used
34   for both memory and I/O access, but not for immediate operands.
35   A negative value indicates that the operand byte order is big endian
36   rather than the usual little endian.
37   The placeholder rep is a boolean used to mark repeating instructions.
38 '''
39
40 # Instructions without a prefix
41 main_instructions = {
42     0x00: (0, 0, 0, 0, False, 'NOP'),
43     0x01: (0, 2, 0, 0, False, 'LD BC,{i:04H}h'),
44     0x02: (0, 0, 0, 1, False, 'LD (BC),A'),
45     0x03: (0, 0, 0, 0, False, 'INC BC'),
46     0x04: (0, 0, 0, 0, False, 'INC B'),
47     0x05: (0, 0, 0, 0, False, 'DEC B'),
48     0x06: (0, 1, 0, 0, False, 'LD B,{i:02H}h'),
49     0x07: (0, 0, 0, 0, False, 'RLCA'),
50     0x08: (0, 0, 0, 0, False, 'EX AF,AF\''),
51     0x09: (0, 0, 0, 0, False, 'ADD HL,BC'),
52     0x0A: (0, 0, 1, 0, False, 'LD A,(BC)'),
53     0x0B: (0, 0, 0, 0, False, 'DEC BC'),
54     0x0C: (0, 0, 0, 0, False, 'INC C'),
55     0x0D: (0, 0, 0, 0, False, 'DEC C'),
56     0x0E: (0, 1, 0, 0, False, 'LD C,{i:02H}h'),
57     0x0F: (0, 0, 0, 0, False, 'RRCA'),
58
59     0x10: (1, 0, 0, 0, False, 'DJNZ {d:+d}'),
60     0x11: (0, 2, 0, 0, False, 'LD DE,{i:04H}h'),
61     0x12: (0, 0, 0, 1, False, 'LD (DE),A'),
62     0x13: (0, 0, 0, 0, False, 'INC DE'),
63     0x14: (0, 0, 0, 0, False, 'INC D'),
64     0x15: (0, 0, 0, 0, False, 'DEC D'),
65     0x16: (0, 1, 0, 0, False, 'LD D,{i:02H}h'),
66     0x17: (0, 0, 0, 0, False, 'RLA'),
67     0x18: (1, 0, 0, 0, False, 'JR {d:+d}'),
68     0x19: (0, 0, 0, 0, False, 'ADD HL,DE'),
69     0x1A: (0, 0, 1, 0, False, 'LD A,(DE)'),
70     0x1B: (0, 0, 0, 0, False, 'DEC DE'),
71     0x1C: (0, 0, 0, 0, False, 'INC E'),
72     0x1D: (0, 0, 0, 0, False, 'DEC E'),
73     0x1E: (0, 1, 0, 0, False, 'LD E,{i:02H}h'),
74     0x1F: (0, 0, 0, 0, False, 'RRA'),
75
76     0x20: (1, 0, 0, 0, False, 'JR NZ,{d:+d}'),
77     0x21: (0, 2, 0, 0, False, 'LD HL,{i:04H}h'),
78     0x22: (0, 2, 0, 2, False, 'LD ({i:04H}h),HL'),
79     0x23: (0, 0, 0, 0, False, 'INC HL'),
80     0x24: (0, 0, 0, 0, False, 'INC H'),
81     0x25: (0, 0, 0, 0, False, 'DEC H'),
82     0x26: (0, 1, 0, 0, False, 'LD H,{i:02H}h'),
83     0x27: (0, 0, 0, 0, False, 'DAA'),
84     0x28: (1, 0, 0, 0, False, 'JR Z,{d:+d}'),
85     0x29: (0, 0, 0, 0, False, 'ADD HL,HL'),
86     0x2A: (0, 2, 2, 0, False, 'LD HL,({i:04H}h)'),
87     0x2B: (0, 0, 0, 0, False, 'DEC HL'),
88     0x2C: (0, 0, 0, 0, False, 'INC L'),
89     0x2D: (0, 0, 0, 0, False, 'DEC L'),
90     0x2E: (0, 1, 0, 0, False, 'LD L,{i:02H}h'),
91     0x2F: (0, 0, 0, 0, False, 'CPL'),
92
93     0x30: (1, 0, 0, 0, False, 'JR NC,{d:+d}'),
94     0x31: (0, 2, 0, 0, False, 'LD SP,{i:04H}h'),
95     0x32: (0, 2, 0, 1, False, 'LD ({i:04H}h),A'),
96     0x33: (0, 0, 0, 0, False, 'INC SP'),
97     0x34: (0, 0, 1, 1, False, 'INC (HL)'),
98     0x35: (0, 0, 1, 1, False, 'DEC (HL)'),
99     0x36: (0, 1, 0, 1, False, 'LD (HL),{i:02H}h'),
100     0x37: (0, 0, 0, 0, False, 'SCF'),
101     0x38: (1, 0, 0, 0, False, 'JR C,{d:+d}'),
102     0x39: (0, 0, 0, 0, False, 'ADD HL,SP'),
103     0x3A: (0, 2, 1, 0, False, 'LD A,({i:04H}h)'),
104     0x3B: (0, 0, 0, 0, False, 'DEC SP'),
105     0x3C: (0, 0, 0, 0, False, 'INC A'),
106     0x3D: (0, 0, 0, 0, False, 'DEC A'),
107     0x3E: (0, 1, 0, 0, False, 'LD A,{i:02H}h'),
108     0x3F: (0, 0, 0, 0, False, 'CCF'),
109
110     0x40: (0, 0, 0, 0, False, 'LD B,B'),
111     0x41: (0, 0, 0, 0, False, 'LD B,C'),
112     0x42: (0, 0, 0, 0, False, 'LD B,D'),
113     0x43: (0, 0, 0, 0, False, 'LD B,E'),
114     0x44: (0, 0, 0, 0, False, 'LD B,H'),
115     0x45: (0, 0, 0, 0, False, 'LD B,L'),
116     0x46: (0, 0, 1, 0, False, 'LD B,(HL)'),
117     0x47: (0, 0, 0, 0, False, 'LD B,A'),
118     0x48: (0, 0, 0, 0, False, 'LD C,B'),
119     0x49: (0, 0, 0, 0, False, 'LD C,C'),
120     0x4A: (0, 0, 0, 0, False, 'LD C,D'),
121     0x4B: (0, 0, 0, 0, False, 'LD C,E'),
122     0x4C: (0, 0, 0, 0, False, 'LD C,H'),
123     0x4D: (0, 0, 0, 0, False, 'LD C,L'),
124     0x4E: (0, 0, 1, 0, False, 'LD C,(HL)'),
125     0x4F: (0, 0, 0, 0, False, 'LD C,A'),
126
127     0x50: (0, 0, 0, 0, False, 'LD D,B'),
128     0x51: (0, 0, 0, 0, False, 'LD D,C'),
129     0x52: (0, 0, 0, 0, False, 'LD D,D'),
130     0x53: (0, 0, 0, 0, False, 'LD D,E'),
131     0x54: (0, 0, 0, 0, False, 'LD D,H'),
132     0x55: (0, 0, 0, 0, False, 'LD D,L'),
133     0x56: (0, 0, 1, 0, False, 'LD D,(HL)'),
134     0x57: (0, 0, 0, 0, False, 'LD D,A'),
135     0x58: (0, 0, 0, 0, False, 'LD E,B'),
136     0x59: (0, 0, 0, 0, False, 'LD E,C'),
137     0x5A: (0, 0, 0, 0, False, 'LD E,D'),
138     0x5B: (0, 0, 0, 0, False, 'LD E,E'),
139     0x5C: (0, 0, 0, 0, False, 'LD E,H'),
140     0x5D: (0, 0, 0, 0, False, 'LD E,L'),
141     0x5E: (0, 0, 1, 0, False, 'LD E,(HL)'),
142     0x5F: (0, 0, 0, 0, False, 'LD E,A'),
143
144     0x60: (0, 0, 0, 0, False, 'LD H,B'),
145     0x61: (0, 0, 0, 0, False, 'LD H,C'),
146     0x62: (0, 0, 0, 0, False, 'LD H,D'),
147     0x63: (0, 0, 0, 0, False, 'LD H,E'),
148     0x64: (0, 0, 0, 0, False, 'LD H,H'),
149     0x65: (0, 0, 0, 0, False, 'LD H,L'),
150     0x66: (0, 0, 1, 0, False, 'LD H,(HL)'),
151     0x67: (0, 0, 0, 0, False, 'LD H,A'),
152     0x68: (0, 0, 0, 0, False, 'LD L,B'),
153     0x69: (0, 0, 0, 0, False, 'LD L,C'),
154     0x6A: (0, 0, 0, 0, False, 'LD L,D'),
155     0x6B: (0, 0, 0, 0, False, 'LD L,E'),
156     0x6C: (0, 0, 0, 0, False, 'LD L,H'),
157     0x6D: (0, 0, 0, 0, False, 'LD L,L'),
158     0x6E: (0, 0, 1, 0, False, 'LD L,(HL)'),
159     0x6F: (0, 0, 0, 0, False, 'LD L,A'),
160
161     0x70: (0, 0, 0, 1, False, 'LD (HL),B'),
162     0x71: (0, 0, 0, 1, False, 'LD (HL),C'),
163     0x72: (0, 0, 0, 1, False, 'LD (HL),D'),
164     0x73: (0, 0, 0, 1, False, 'LD (HL),E'),
165     0x74: (0, 0, 0, 1, False, 'LD (HL),H'),
166     0x75: (0, 0, 0, 1, False, 'LD (HL),L'),
167     0x76: (0, 0, 0, 0, False, 'HALT'),
168     0x77: (0, 0, 0, 1, False, 'LD (HL),A'),
169     0x78: (0, 0, 0, 0, False, 'LD A,B'),
170     0x79: (0, 0, 0, 0, False, 'LD A,C'),
171     0x7A: (0, 0, 0, 0, False, 'LD A,D'),
172     0x7B: (0, 0, 0, 0, False, 'LD A,E'),
173     0x7C: (0, 0, 0, 0, False, 'LD A,H'),
174     0x7D: (0, 0, 0, 0, False, 'LD A,L'),
175     0x7E: (0, 0, 1, 0, False, 'LD A,(HL)'),
176     0x7F: (0, 0, 0, 0, False, 'LD A,A'),
177
178     0x80: (0, 0, 0, 0, False, 'ADD A,B'),
179     0x81: (0, 0, 0, 0, False, 'ADD A,C'),
180     0x82: (0, 0, 0, 0, False, 'ADD A,D'),
181     0x83: (0, 0, 0, 0, False, 'ADD A,E'),
182     0x84: (0, 0, 0, 0, False, 'ADD A,H'),
183     0x85: (0, 0, 0, 0, False, 'ADD A,L'),
184     0x86: (0, 0, 1, 0, False, 'ADD A,(HL)'),
185     0x87: (0, 0, 0, 0, False, 'ADD A,A'),
186     0x88: (0, 0, 0, 0, False, 'ADC A,B'),
187     0x89: (0, 0, 0, 0, False, 'ADC A,C'),
188     0x8A: (0, 0, 0, 0, False, 'ADC A,D'),
189     0x8B: (0, 0, 0, 0, False, 'ADC A,E'),
190     0x8C: (0, 0, 0, 0, False, 'ADC A,H'),
191     0x8D: (0, 0, 0, 0, False, 'ADC A,L'),
192     0x8E: (0, 0, 1, 0, False, 'ADC A,(HL)'),
193     0x8F: (0, 0, 0, 0, False, 'ADC A,A'),
194
195     0x90: (0, 0, 0, 0, False, 'SUB B'),
196     0x91: (0, 0, 0, 0, False, 'SUB C'),
197     0x92: (0, 0, 0, 0, False, 'SUB D'),
198     0x93: (0, 0, 0, 0, False, 'SUB E'),
199     0x94: (0, 0, 0, 0, False, 'SUB H'),
200     0x95: (0, 0, 0, 0, False, 'SUB L'),
201     0x96: (0, 0, 1, 0, False, 'SUB (HL)'),
202     0x97: (0, 0, 0, 0, False, 'SUB A'),
203     0x98: (0, 0, 0, 0, False, 'SBC A,B'),
204     0x99: (0, 0, 0, 0, False, 'SBC A,C'),
205     0x9A: (0, 0, 0, 0, False, 'SBC A,D'),
206     0x9B: (0, 0, 0, 0, False, 'SBC A,E'),
207     0x9C: (0, 0, 0, 0, False, 'SBC A,H'),
208     0x9D: (0, 0, 0, 0, False, 'SBC A,L'),
209     0x9E: (0, 0, 1, 0, False, 'SBC A,(HL)'),
210     0x9F: (0, 0, 0, 0, False, 'SBC A,A'),
211
212     0xA0: (0, 0, 0, 0, False, 'AND B'),
213     0xA1: (0, 0, 0, 0, False, 'AND C'),
214     0xA2: (0, 0, 0, 0, False, 'AND D'),
215     0xA3: (0, 0, 0, 0, False, 'AND E'),
216     0xA4: (0, 0, 0, 0, False, 'AND H'),
217     0xA5: (0, 0, 0, 0, False, 'AND L'),
218     0xA6: (0, 0, 1, 0, False, 'AND (HL)'),
219     0xA7: (0, 0, 0, 0, False, 'AND A'),
220     0xA8: (0, 0, 0, 0, False, 'XOR B'),
221     0xA9: (0, 0, 0, 0, False, 'XOR C'),
222     0xAA: (0, 0, 0, 0, False, 'XOR D'),
223     0xAB: (0, 0, 0, 0, False, 'XOR E'),
224     0xAC: (0, 0, 0, 0, False, 'XOR H'),
225     0xAD: (0, 0, 0, 0, False, 'XOR L'),
226     0xAE: (0, 0, 1, 0, False, 'XOR (HL)'),
227     0xAF: (0, 0, 0, 0, False, 'XOR A'),
228
229     0xB0: (0, 0, 0, 0, False, 'OR B'),
230     0xB1: (0, 0, 0, 0, False, 'OR C'),
231     0xB2: (0, 0, 0, 0, False, 'OR D'),
232     0xB3: (0, 0, 0, 0, False, 'OR E'),
233     0xB4: (0, 0, 0, 0, False, 'OR H'),
234     0xB5: (0, 0, 0, 0, False, 'OR L'),
235     0xB6: (0, 0, 1, 0, False, 'OR (HL)'),
236     0xB7: (0, 0, 0, 0, False, 'OR A'),
237     0xB8: (0, 0, 0, 0, False, 'CP B'),
238     0xB9: (0, 0, 0, 0, False, 'CP C'),
239     0xBA: (0, 0, 0, 0, False, 'CP D'),
240     0xBB: (0, 0, 0, 0, False, 'CP E'),
241     0xBC: (0, 0, 0, 0, False, 'CP H'),
242     0xBD: (0, 0, 0, 0, False, 'CP L'),
243     0xBE: (0, 0, 1, 0, False, 'CP (HL)'),
244     0xBF: (0, 0, 0, 0, False, 'CP A'),
245
246     0xC0: (0, 0, 2, 0, False, 'RET NZ'),
247     0xC1: (0, 0, 2, 0, False, 'POP BC'),
248     0xC2: (0, 2, 0, 0, False, 'JP NZ,{i:04H}h'),
249     0xC3: (0, 2, 0, 0, False, 'JP {i:04H}h'),
250     0xC4: (0, 2, 0,-2, False, 'CALL NZ,{i:04H}h'),
251     0xC5: (0, 0, 0,-2, False, 'PUSH BC'),
252     0xC6: (0, 1, 0, 0, False, 'ADD A,{i:02H}h'),
253     0xC7: (0, 0, 0,-2, False, 'RST 00h'),
254     0xC8: (0, 0, 2, 0, False, 'RET Z'),
255     0xC9: (0, 0, 2, 0, False, 'RET'),
256     0xCA: (0, 2, 0, 0, False, 'JP Z,{i:04H}h'),
257
258     0xCC: (0, 2, 0,-2, False, 'CALL Z,{i:04H}h'),
259     0xCD: (0, 2, 0,-2, False, 'CALL {i:04H}h'),
260     0xCE: (0, 1, 0, 0, False, 'ADC A,{i:02H}h'),
261     0xCF: (0, 0, 0,-2, False, 'RST 08h'),
262
263     0xD0: (0, 0, 2, 0, False, 'RET NC'),
264     0xD1: (0, 0, 2, 0, False, 'POP DE'),
265     0xD2: (0, 2, 0, 0, False, 'JP NC,{i:04H}h'),
266     0xD3: (0, 1, 0, 1, False, 'OUT ({i:02H}h),A'),
267     0xD4: (0, 2, 0,-2, False, 'CALL NC,{i:04H}h'),
268     0xD5: (0, 0, 0,-2, False, 'PUSH DE'),
269     0xD6: (0, 1, 0, 0, False, 'SUB {i:02H}h'),
270     0xD7: (0, 0, 0,-2, False, 'RST 10h'),
271     0xD8: (0, 0, 2, 0, False, 'RET C'),
272     0xD9: (0, 0, 0, 0, False, 'EXX'),
273     0xDA: (0, 2, 0, 0, False, 'JP C,{i:04H}h'),
274     0xDB: (0, 1, 1, 0, False, 'IN A,({i:02H}h)'),
275     0xDC: (0, 2, 0,-2, False, 'CALL C,{i:04H}h'),
276
277     0xDE: (0, 1, 0, 0, False, 'SBC A,{i:02H}h'),
278     0xDF: (0, 0, 0,-2, False, 'RST 18h'),
279
280     0xE0: (0, 0, 2, 0, False, 'RET PO'),
281     0xE1: (0, 0, 2, 0, False, 'POP HL'),
282     0xE2: (0, 2, 0, 0, False, 'JP PO,{i:04H}h'),
283     0xE3: (0, 0, 2, 2, False, 'EX (SP),HL'),
284     0xE4: (0, 2, 0,-2, False, 'CALL PO,{i:04H}h'),
285     0xE5: (0, 0, 0,-2, False, 'PUSH HL'),
286     0xE6: (0, 1, 0, 0, False, 'AND {i:02H}h'),
287     0xE7: (0, 0, 0,-2, False, 'RST 20h'),
288     0xE8: (0, 0, 2, 0, False, 'RET PE'),
289     0xE9: (0, 0, 0, 0, False, 'JP (HL)'),
290     0xEA: (0, 2, 0, 0, False, 'JP PE,{i:04H}h'),
291     0xEB: (0, 0, 0, 0, False, 'EX DE,HL'),
292     0xEC: (0, 2, 0,-2, False, 'CALL PE,{i:04H}h'),
293
294     0xEE: (0, 1, 0, 0, False, 'XOR {i:02H}h'),
295     0xEF: (0, 0, 0,-2, False, 'RST 28h'),
296
297     0xF0: (0, 0, 2, 0, False, 'RET P'),
298     0xF1: (0, 0, 2, 0, False, 'POP AF'),
299     0xF2: (0, 2, 0, 0, False, 'JP P,{i:04H}h'),
300     0xF3: (0, 0, 0, 0, False, 'DI'),
301     0xF4: (0, 2, 0,-2, False, 'CALL P,{i:04H}h'),
302     0xF5: (0, 0, 0,-2, False, 'PUSH AF'),
303     0xF6: (0, 1, 0, 0, False, 'OR {i:02H}h'),
304     0xF7: (0, 0, 0,-2, False, 'RST 30h'),
305     0xF8: (0, 0, 2, 0, False, 'RET M'),
306     0xF9: (0, 0, 0, 0, False, 'LD SP,HL'),
307     0xFA: (0, 2, 0, 0, False, 'JP M,{i:04H}h'),
308     0xFB: (0, 0, 0, 0, False, 'EI'),
309     0xFC: (0, 2, 0,-2, False, 'CALL M,{i:04H}h'),
310
311     0xFE: (0, 1, 0, 0, False, 'CP {i:02H}h'),
312     0xFF: (0, 0, 0,-2, False, 'RST 38h')
313 }
314
315 # Instructions with ED prefix
316 extended_instructions = {
317     0x40: (0, 0, 1, 0, False, 'IN B,(C)'),
318     0x41: (0, 0, 0, 1, False, 'OUT (C),B'),
319     0x42: (0, 0, 0, 0, False, 'SBC HL,BC'),
320     0x43: (0, 2, 0, 2, False, 'LD ({i:04H}h),BC'),
321     0x44: (0, 0, 0, 0, False, 'NEG'),
322     0x45: (0, 0, 2, 0, False, 'RETN'),
323     0x46: (0, 0, 0, 0, False, 'IM 0'),
324     0x47: (0, 0, 0, 0, False, 'LD I,A'),
325     0x48: (0, 0, 1, 0, False, 'IN C,(C)'),
326     0x49: (0, 0, 0, 1, False, 'OUT (C),C'),
327     0x4A: (0, 0, 0, 0, False, 'ADC HL,BC'),
328     0x4B: (0, 2, 2, 0, False, 'LD BC,({i:04H}h)'),
329     0x4C: (0, 0, 0, 0, False, 'NEG'),
330     0x4D: (0, 0, 2, 0, False, 'RETI'),
331     0x4E: (0, 0, 0, 0, False, 'IM 0/1'),
332     0x4F: (0, 0, 0, 0, False, 'LD R,A'),
333
334     0x50: (0, 0, 1, 0, False, 'IN D,(C)'),
335     0x51: (0, 0, 0, 1, False, 'OUT (C),D'),
336     0x52: (0, 0, 0, 0, False, 'SBC HL,DE'),
337     0x53: (0, 2, 0, 2, False, 'LD ({i:04H}h),DE'),
338     0x54: (0, 0, 0, 0, False, 'NEG'),
339     0x55: (0, 0, 2, 0, False, 'RETN'),
340     0x56: (0, 0, 0, 0, False, 'IM 1'),
341     0x57: (0, 0, 0, 0, False, 'LD A,I'),
342     0x58: (0, 0, 1, 0, False, 'IN E,(C)'),
343     0x59: (0, 0, 0, 1, False, 'OUT (C),E'),
344     0x5A: (0, 0, 0, 0, False, 'ADC HL,DE'),
345     0x5B: (0, 2, 2, 0, False, 'LD DE,({i:04H}h)'),
346     0x5C: (0, 0, 0, 0, False, 'NEG'),
347     0x5D: (0, 0, 2, 0, False, 'RETN'),
348     0x5E: (0, 0, 0, 0, False, 'IM 2'),
349     0x5F: (0, 0, 0, 0, False, 'LD A,R'),
350
351     0x60: (0, 0, 1, 0, False, 'IN H,(C)'),
352     0x61: (0, 0, 0, 1, False, 'OUT (C),H'),
353     0x62: (0, 0, 0, 0, False, 'SBC HL,HL'),
354     0x63: (0, 2, 0, 2, False, 'LD ({i:04H}h),HL'),
355     0x64: (0, 0, 0, 0, False, 'NEG'),
356     0x65: (0, 0, 2, 0, False, 'RETN'),
357     0x66: (0, 0, 0, 0, False, 'IM 0'),
358     0x67: (0, 0, 1, 1, False, 'RRD'),
359     0x68: (0, 0, 1, 0, False, 'IN L,(C)'),
360     0x69: (0, 0, 0, 1, False, 'OUT (C),L'),
361     0x6A: (0, 0, 0, 0, False, 'ADC HL,HL'),
362     0x6B: (0, 2, 2, 0, False, 'LD HL,({i:04H}h)'),
363     0x6C: (0, 0, 0, 0, False, 'NEG'),
364     0x6D: (0, 0, 2, 0, False, 'RETN'),
365     0x6E: (0, 0, 0, 0, False, 'IM 0/1'),
366     0x6F: (0, 0, 1, 1, False, 'RLD'),
367
368     0x70: (0, 0, 1, 0, False, 'IN (C)'),
369     0x71: (0, 0, 0, 1, False, 'OUT (C),0'),
370     0x72: (0, 0, 0, 0, False, 'SBC HL,SP'),
371     0x73: (0, 2, 0, 2, False, 'LD ({i:04H}h),SP'),
372     0x74: (0, 0, 0, 0, False, 'NEG'),
373     0x75: (0, 0, 2, 0, False, 'RETN'),
374     0x76: (0, 0, 0, 0, False, 'IM 1'),
375
376     0x78: (0, 0, 1, 0, False, 'IN A,(C)'),
377     0x79: (0, 0, 0, 1, False, 'OUT (C),A'),
378     0x7A: (0, 0, 0, 0, False, 'ADC HL,SP'),
379     0x7B: (0, 2, 2, 0, False, 'LD SP,({i:04H}h)'),
380     0x7C: (0, 0, 0, 0, False, 'NEG'),
381     0x7D: (0, 0, 2, 0, False, 'RETN'),
382     0x7E: (0, 0, 0, 0, False, 'IM 2'),
383
384     0xA0: (0, 0, 1, 1, False, 'LDI'),
385     0xA1: (0, 0, 1, 0, False, 'CPI'),
386     0xA2: (0, 0, 1, 1, False, 'INI'),
387     0xA3: (0, 0, 1, 1, False, 'OUTI'),
388
389     0xA8: (0, 0, 1, 1, False, 'LDD'),
390     0xA9: (0, 0, 1, 0, False, 'CPD'),
391     0xAA: (0, 0, 1, 1, False, 'IND'),
392     0xAB: (0, 0, 1, 1, False, 'OUTD'),
393
394     0xB0: (0, 0, 1, 1, True,  'LDIR'),
395     0xB1: (0, 0, 1, 0, True,  'CPIR'),
396     0xB2: (0, 0, 1, 1, True,  'INIR'),
397     0xB3: (0, 0, 1, 1, True,  'OTIR'),
398
399     0xB8: (0, 0, 1, 1, True,  'LDDR'),
400     0xB9: (0, 0, 1, 0, True,  'CPDR'),
401     0xBA: (0, 0, 1, 1, True,  'INDR'),
402     0xBB: (0, 0, 1, 1, True,  'OTDR')
403 }
404
405 # Instructions with CB prefix
406 bit_instructions = {
407     0x00: (0, 0, 0, 0, False, 'RLC B'),
408     0x01: (0, 0, 0, 0, False, 'RLC C'),
409     0x02: (0, 0, 0, 0, False, 'RLC D'),
410     0x03: (0, 0, 0, 0, False, 'RLC E'),
411     0x04: (0, 0, 0, 0, False, 'RLC H'),
412     0x05: (0, 0, 0, 0, False, 'RLC L'),
413     0x06: (0, 0, 1, 1, False, 'RLC (HL)'),
414     0x07: (0, 0, 0, 0, False, 'RLC A'),
415     0x08: (0, 0, 0, 0, False, 'RRC B'),
416     0x09: (0, 0, 0, 0, False, 'RRC C'),
417     0x0A: (0, 0, 0, 0, False, 'RRC D'),
418     0x0B: (0, 0, 0, 0, False, 'RRC E'),
419     0x0C: (0, 0, 0, 0, False, 'RRC H'),
420     0x0D: (0, 0, 0, 0, False, 'RRC L'),
421     0x0E: (0, 0, 1, 1, False, 'RRC (HL)'),
422     0x0F: (0, 0, 0, 0, False, 'RRC A'),
423
424     0x10: (0, 0, 0, 0, False, 'RL B'),
425     0x11: (0, 0, 0, 0, False, 'RL C'),
426     0x12: (0, 0, 0, 0, False, 'RL D'),
427     0x13: (0, 0, 0, 0, False, 'RL E'),
428     0x14: (0, 0, 0, 0, False, 'RL H'),
429     0x15: (0, 0, 0, 0, False, 'RL L'),
430     0x16: (0, 0, 1, 1, False, 'RL (HL)'),
431     0x17: (0, 0, 0, 0, False, 'RL A'),
432     0x18: (0, 0, 0, 0, False, 'RR B'),
433     0x19: (0, 0, 0, 0, False, 'RR C'),
434     0x1A: (0, 0, 0, 0, False, 'RR D'),
435     0x1B: (0, 0, 0, 0, False, 'RR E'),
436     0x1C: (0, 0, 0, 0, False, 'RR H'),
437     0x1D: (0, 0, 0, 0, False, 'RR L'),
438     0x1E: (0, 0, 1, 1, False, 'RR (HL)'),
439     0x1F: (0, 0, 0, 0, False, 'RR A'),
440
441     0x20: (0, 0, 0, 0, False, 'SLA B'),
442     0x21: (0, 0, 0, 0, False, 'SLA C'),
443     0x22: (0, 0, 0, 0, False, 'SLA D'),
444     0x23: (0, 0, 0, 0, False, 'SLA E'),
445     0x24: (0, 0, 0, 0, False, 'SLA H'),
446     0x25: (0, 0, 0, 0, False, 'SLA L'),
447     0x26: (0, 0, 1, 1, False, 'SLA (HL)'),
448     0x27: (0, 0, 0, 0, False, 'SLA A'),
449     0x28: (0, 0, 0, 0, False, 'SRA B'),
450     0x29: (0, 0, 0, 0, False, 'SRA C'),
451     0x2A: (0, 0, 0, 0, False, 'SRA D'),
452     0x2B: (0, 0, 0, 0, False, 'SRA E'),
453     0x2C: (0, 0, 0, 0, False, 'SRA H'),
454     0x2D: (0, 0, 0, 0, False, 'SRA L'),
455     0x2E: (0, 0, 1, 1, False, 'SRA (HL)'),
456     0x2F: (0, 0, 0, 0, False, 'SRA A'),
457
458     0x30: (0, 0, 0, 0, False, 'SLL B'),
459     0x31: (0, 0, 0, 0, False, 'SLL C'),
460     0x32: (0, 0, 0, 0, False, 'SLL D'),
461     0x33: (0, 0, 0, 0, False, 'SLL E'),
462     0x34: (0, 0, 0, 0, False, 'SLL H'),
463     0x35: (0, 0, 0, 0, False, 'SLL L'),
464     0x36: (0, 0, 1, 1, False, 'SLL (HL)'),
465     0x37: (0, 0, 0, 0, False, 'SLL A'),
466     0x38: (0, 0, 0, 0, False, 'SRL B'),
467     0x39: (0, 0, 0, 0, False, 'SRL C'),
468     0x3A: (0, 0, 0, 0, False, 'SRL D'),
469     0x3B: (0, 0, 0, 0, False, 'SRL E'),
470     0x3C: (0, 0, 0, 0, False, 'SRL H'),
471     0x3D: (0, 0, 0, 0, False, 'SRL L'),
472     0x3E: (0, 0, 1, 1, False, 'SRL (HL)'),
473     0x3F: (0, 0, 0, 0, False, 'SRL A'),
474
475     0x40: (0, 0, 0, 0, False, 'BIT 0,B'),
476     0x41: (0, 0, 0, 0, False, 'BIT 0,C'),
477     0x42: (0, 0, 0, 0, False, 'BIT 0,D'),
478     0x43: (0, 0, 0, 0, False, 'BIT 0,E'),
479     0x44: (0, 0, 0, 0, False, 'BIT 0,H'),
480     0x45: (0, 0, 0, 0, False, 'BIT 0,L'),
481     0x46: (0, 0, 1, 0, False, 'BIT 0,(HL)'),
482     0x47: (0, 0, 0, 0, False, 'BIT 0,A'),
483     0x48: (0, 0, 0, 0, False, 'BIT 1,B'),
484     0x49: (0, 0, 0, 0, False, 'BIT 1,C'),
485     0x4A: (0, 0, 0, 0, False, 'BIT 1,D'),
486     0x4B: (0, 0, 0, 0, False, 'BIT 1,E'),
487     0x4C: (0, 0, 0, 0, False, 'BIT 1,H'),
488     0x4D: (0, 0, 0, 0, False, 'BIT 1,L'),
489     0x4E: (0, 0, 1, 0, False, 'BIT 1,(HL)'),
490     0x4F: (0, 0, 0, 0, False, 'BIT 1,A'),
491
492     0x50: (0, 0, 0, 0, False, 'BIT 2,B'),
493     0x51: (0, 0, 0, 0, False, 'BIT 2,C'),
494     0x52: (0, 0, 0, 0, False, 'BIT 2,D'),
495     0x53: (0, 0, 0, 0, False, 'BIT 2,E'),
496     0x54: (0, 0, 0, 0, False, 'BIT 2,H'),
497     0x55: (0, 0, 0, 0, False, 'BIT 2,L'),
498     0x56: (0, 0, 1, 0, False, 'BIT 2,(HL)'),
499     0x57: (0, 0, 0, 0, False, 'BIT 2,A'),
500     0x58: (0, 0, 0, 0, False, 'BIT 3,B'),
501     0x59: (0, 0, 0, 0, False, 'BIT 3,C'),
502     0x5A: (0, 0, 0, 0, False, 'BIT 3,D'),
503     0x5B: (0, 0, 0, 0, False, 'BIT 3,E'),
504     0x5C: (0, 0, 0, 0, False, 'BIT 3,H'),
505     0x5D: (0, 0, 0, 0, False, 'BIT 3,L'),
506     0x5E: (0, 0, 1, 0, False, 'BIT 3,(HL)'),
507     0x5F: (0, 0, 0, 0, False, 'BIT 3,A'),
508
509     0x60: (0, 0, 0, 0, False, 'BIT 4,B'),
510     0x61: (0, 0, 0, 0, False, 'BIT 4,C'),
511     0x62: (0, 0, 0, 0, False, 'BIT 4,D'),
512     0x63: (0, 0, 0, 0, False, 'BIT 4,E'),
513     0x64: (0, 0, 0, 0, False, 'BIT 4,H'),
514     0x65: (0, 0, 0, 0, False, 'BIT 4,L'),
515     0x66: (0, 0, 1, 0, False, 'BIT 4,(HL)'),
516     0x67: (0, 0, 0, 0, False, 'BIT 4,A'),
517     0x68: (0, 0, 0, 0, False, 'BIT 5,B'),
518     0x69: (0, 0, 0, 0, False, 'BIT 5,C'),
519     0x6A: (0, 0, 0, 0, False, 'BIT 5,D'),
520     0x6B: (0, 0, 0, 0, False, 'BIT 5,E'),
521     0x6C: (0, 0, 0, 0, False, 'BIT 5,H'),
522     0x6D: (0, 0, 0, 0, False, 'BIT 5,L'),
523     0x6E: (0, 0, 1, 0, False, 'BIT 5,(HL)'),
524     0x6F: (0, 0, 0, 0, False, 'BIT 5,A'),
525
526     0x70: (0, 0, 0, 0, False, 'BIT 6,B'),
527     0x71: (0, 0, 0, 0, False, 'BIT 6,C'),
528     0x72: (0, 0, 0, 0, False, 'BIT 6,D'),
529     0x73: (0, 0, 0, 0, False, 'BIT 6,E'),
530     0x74: (0, 0, 0, 0, False, 'BIT 6,H'),
531     0x75: (0, 0, 0, 0, False, 'BIT 6,L'),
532     0x76: (0, 0, 1, 0, False, 'BIT 6,(HL)'),
533     0x77: (0, 0, 0, 0, False, 'BIT 6,A'),
534     0x78: (0, 0, 0, 0, False, 'BIT 7,B'),
535     0x79: (0, 0, 0, 0, False, 'BIT 7,C'),
536     0x7A: (0, 0, 0, 0, False, 'BIT 7,D'),
537     0x7B: (0, 0, 0, 0, False, 'BIT 7,E'),
538     0x7C: (0, 0, 0, 0, False, 'BIT 7,H'),
539     0x7D: (0, 0, 0, 0, False, 'BIT 7,L'),
540     0x7E: (0, 0, 1, 0, False, 'BIT 7,(HL)'),
541     0x7F: (0, 0, 0, 0, False, 'BIT 7,A'),
542
543     0x80: (0, 0, 0, 0, False, 'RES 0,B'),
544     0x81: (0, 0, 0, 0, False, 'RES 0,C'),
545     0x82: (0, 0, 0, 0, False, 'RES 0,D'),
546     0x83: (0, 0, 0, 0, False, 'RES 0,E'),
547     0x84: (0, 0, 0, 0, False, 'RES 0,H'),
548     0x85: (0, 0, 0, 0, False, 'RES 0,L'),
549     0x86: (0, 0, 1, 1, False, 'RES 0,(HL)'),
550     0x87: (0, 0, 0, 0, False, 'RES 0,A'),
551     0x88: (0, 0, 0, 0, False, 'RES 1,B'),
552     0x89: (0, 0, 0, 0, False, 'RES 1,C'),
553     0x8A: (0, 0, 0, 0, False, 'RES 1,D'),
554     0x8B: (0, 0, 0, 0, False, 'RES 1,E'),
555     0x8C: (0, 0, 0, 0, False, 'RES 1,H'),
556     0x8D: (0, 0, 0, 0, False, 'RES 1,L'),
557     0x8E: (0, 0, 1, 1, False, 'RES 1,(HL)'),
558     0x8F: (0, 0, 0, 0, False, 'RES 1,A'),
559
560     0x90: (0, 0, 0, 0, False, 'RES 2,B'),
561     0x91: (0, 0, 0, 0, False, 'RES 2,C'),
562     0x92: (0, 0, 0, 0, False, 'RES 2,D'),
563     0x93: (0, 0, 0, 0, False, 'RES 2,E'),
564     0x94: (0, 0, 0, 0, False, 'RES 2,H'),
565     0x95: (0, 0, 0, 0, False, 'RES 2,L'),
566     0x96: (0, 0, 1, 1, False, 'RES 2,(HL)'),
567     0x97: (0, 0, 0, 0, False, 'RES 2,A'),
568     0x98: (0, 0, 0, 0, False, 'RES 3,B'),
569     0x99: (0, 0, 0, 0, False, 'RES 3,C'),
570     0x9A: (0, 0, 0, 0, False, 'RES 3,D'),
571     0x9B: (0, 0, 0, 0, False, 'RES 3,E'),
572     0x9C: (0, 0, 0, 0, False, 'RES 3,H'),
573     0x9D: (0, 0, 0, 0, False, 'RES 3,L'),
574     0x9E: (0, 0, 1, 1, False, 'RES 3,(HL)'),
575     0x9F: (0, 0, 0, 0, False, 'RES 3,A'),
576
577     0xA0: (0, 0, 0, 0, False, 'RES 4,B'),
578     0xA1: (0, 0, 0, 0, False, 'RES 4,C'),
579     0xA2: (0, 0, 0, 0, False, 'RES 4,D'),
580     0xA3: (0, 0, 0, 0, False, 'RES 4,E'),
581     0xA4: (0, 0, 0, 0, False, 'RES 4,H'),
582     0xA5: (0, 0, 0, 0, False, 'RES 4,L'),
583     0xA6: (0, 0, 1, 1, False, 'RES 4,(HL)'),
584     0xA7: (0, 0, 0, 0, False, 'RES 4,A'),
585     0xA8: (0, 0, 0, 0, False, 'RES 5,B'),
586     0xA9: (0, 0, 0, 0, False, 'RES 5,C'),
587     0xAA: (0, 0, 0, 0, False, 'RES 5,D'),
588     0xAB: (0, 0, 0, 0, False, 'RES 5,E'),
589     0xAC: (0, 0, 0, 0, False, 'RES 5,H'),
590     0xAD: (0, 0, 0, 0, False, 'RES 5,L'),
591     0xAE: (0, 0, 1, 1, False, 'RES 5,(HL)'),
592     0xAF: (0, 0, 0, 0, False, 'RES 5,A'),
593
594     0xB0: (0, 0, 0, 0, False, 'RES 6,B'),
595     0xB1: (0, 0, 0, 0, False, 'RES 6,C'),
596     0xB2: (0, 0, 0, 0, False, 'RES 6,D'),
597     0xB3: (0, 0, 0, 0, False, 'RES 6,E'),
598     0xB4: (0, 0, 0, 0, False, 'RES 6,H'),
599     0xB5: (0, 0, 0, 0, False, 'RES 6,L'),
600     0xB6: (0, 0, 1, 1, False, 'RES 6,(HL)'),
601     0xB7: (0, 0, 0, 0, False, 'RES 6,A'),
602     0xB8: (0, 0, 0, 0, False, 'RES 7,B'),
603     0xB9: (0, 0, 0, 0, False, 'RES 7,C'),
604     0xBA: (0, 0, 0, 0, False, 'RES 7,D'),
605     0xBB: (0, 0, 0, 0, False, 'RES 7,E'),
606     0xBC: (0, 0, 0, 0, False, 'RES 7,H'),
607     0xBD: (0, 0, 0, 0, False, 'RES 7,L'),
608     0xBE: (0, 0, 1, 1, False, 'RES 7,(HL)'),
609     0xBF: (0, 0, 0, 0, False, 'RES 7,A'),
610
611     0xC0: (0, 0, 0, 0, False, 'SET 0,B'),
612     0xC1: (0, 0, 0, 0, False, 'SET 0,C'),
613     0xC2: (0, 0, 0, 0, False, 'SET 0,D'),
614     0xC3: (0, 0, 0, 0, False, 'SET 0,E'),
615     0xC4: (0, 0, 0, 0, False, 'SET 0,H'),
616     0xC5: (0, 0, 0, 0, False, 'SET 0,L'),
617     0xC6: (0, 0, 1, 1, False, 'SET 0,(HL)'),
618     0xC7: (0, 0, 0, 0, False, 'SET 0,A'),
619     0xC8: (0, 0, 0, 0, False, 'SET 1,B'),
620     0xC9: (0, 0, 0, 0, False, 'SET 1,C'),
621     0xCA: (0, 0, 0, 0, False, 'SET 1,D'),
622     0xCB: (0, 0, 0, 0, False, 'SET 1,E'),
623     0xCC: (0, 0, 0, 0, False, 'SET 1,H'),
624     0xCD: (0, 0, 0, 0, False, 'SET 1,L'),
625     0xCE: (0, 0, 1, 1, False, 'SET 1,(HL)'),
626     0xCF: (0, 0, 0, 0, False, 'SET 1,A'),
627
628     0xD0: (0, 0, 0, 0, False, 'SET 2,B'),
629     0xD1: (0, 0, 0, 0, False, 'SET 2,C'),
630     0xD2: (0, 0, 0, 0, False, 'SET 2,D'),
631     0xD3: (0, 0, 0, 0, False, 'SET 2,E'),
632     0xD4: (0, 0, 0, 0, False, 'SET 2,H'),
633     0xD5: (0, 0, 0, 0, False, 'SET 2,L'),
634     0xD6: (0, 0, 1, 1, False, 'SET 2,(HL)'),
635     0xD7: (0, 0, 0, 0, False, 'SET 2,A'),
636     0xD8: (0, 0, 0, 0, False, 'SET 3,B'),
637     0xD9: (0, 0, 0, 0, False, 'SET 3,C'),
638     0xDA: (0, 0, 0, 0, False, 'SET 3,D'),
639     0xDB: (0, 0, 0, 0, False, 'SET 3,E'),
640     0xDC: (0, 0, 0, 0, False, 'SET 3,H'),
641     0xDD: (0, 0, 0, 0, False, 'SET 3,L'),
642     0xDE: (0, 0, 1, 1, False, 'SET 3,(HL)'),
643     0xDF: (0, 0, 0, 0, False, 'SET 3,A'),
644
645     0xE0: (0, 0, 0, 0, False, 'SET 4,B'),
646     0xE1: (0, 0, 0, 0, False, 'SET 4,C'),
647     0xE2: (0, 0, 0, 0, False, 'SET 4,D'),
648     0xE3: (0, 0, 0, 0, False, 'SET 4,E'),
649     0xE4: (0, 0, 0, 0, False, 'SET 4,H'),
650     0xE5: (0, 0, 0, 0, False, 'SET 4,L'),
651     0xE6: (0, 0, 1, 1, False, 'SET 4,(HL)'),
652     0xE7: (0, 0, 0, 0, False, 'SET 4,A'),
653     0xE8: (0, 0, 0, 0, False, 'SET 5,B'),
654     0xE9: (0, 0, 0, 0, False, 'SET 5,C'),
655     0xEA: (0, 0, 0, 0, False, 'SET 5,D'),
656     0xEB: (0, 0, 0, 0, False, 'SET 5,E'),
657     0xEC: (0, 0, 0, 0, False, 'SET 5,H'),
658     0xED: (0, 0, 0, 0, False, 'SET 5,L'),
659     0xEE: (0, 0, 1, 1, False, 'SET 5,(HL)'),
660     0xEF: (0, 0, 0, 0, False, 'SET 5,A'),
661
662     0xF0: (0, 0, 0, 0, False, 'SET 6,B'),
663     0xF1: (0, 0, 0, 0, False, 'SET 6,C'),
664     0xF2: (0, 0, 0, 0, False, 'SET 6,D'),
665     0xF3: (0, 0, 0, 0, False, 'SET 6,E'),
666     0xF4: (0, 0, 0, 0, False, 'SET 6,H'),
667     0xF5: (0, 0, 0, 0, False, 'SET 6,L'),
668     0xF6: (0, 0, 1, 1, False, 'SET 6,(HL)'),
669     0xF7: (0, 0, 0, 0, False, 'SET 6,A'),
670     0xF8: (0, 0, 0, 0, False, 'SET 7,B'),
671     0xF9: (0, 0, 0, 0, False, 'SET 7,C'),
672     0xFA: (0, 0, 0, 0, False, 'SET 7,D'),
673     0xFB: (0, 0, 0, 0, False, 'SET 7,E'),
674     0xFC: (0, 0, 0, 0, False, 'SET 7,H'),
675     0xFD: (0, 0, 0, 0, False, 'SET 7,L'),
676     0xFE: (0, 0, 1, 1, False, 'SET 7,(HL)'),
677     0xFF: (0, 0, 0, 0, False, 'SET 7,A')
678 }
679
680 # Instructions with DD or FD prefix
681 index_instructions = {
682     0x09: (0, 0, 0, 0, False, 'ADD {r},BC'),
683
684     0x19: (0, 0, 0, 0, False, 'ADD {r},DE'),
685
686     0x21: (0, 2, 0, 0, False, 'LD {r},{i:04H}h'),
687     0x22: (0, 2, 0, 2, False, 'LD ({i:04H}h),{r}'),
688     0x23: (0, 0, 0, 0, False, 'INC {r}'),
689     0x24: (0, 0, 0, 0, False, 'INC {r}h'),
690     0x25: (0, 0, 0, 0, False, 'DEC {r}h'),
691     0x26: (0, 1, 0, 0, False, 'LD {r}h,{i:02H}h'),
692
693     0x29: (0, 0, 0, 0, False, 'ADD {r},{r}'),
694     0x2A: (0, 2, 2, 0, False, 'LD {r},({i:04H}h)'),
695     0x2B: (0, 0, 0, 0, False, 'DEC {r}'),
696     0x2C: (0, 0, 0, 0, False, 'INC {r}l'),
697     0x2D: (0, 0, 0, 0, False, 'DEC {r}l'),
698     0x2E: (0, 1, 0, 0, False, 'LD {r}l,{i:02H}h'),
699
700     0x34: (1, 0, 1, 1, False, 'INC ({r}{d:+d})'),
701     0x35: (1, 0, 1, 1, False, 'DEC ({r}{d:+d})'),
702     0x36: (1, 1, 0, 1, False, 'LD ({r}{d:+d}),{i:02H}h'),
703
704     0x39: (0, 0, 0, 0, False, 'ADD {r},SP'),
705
706     0x44: (0, 0, 0, 0, False, 'LD B,{r}h'),
707     0x45: (0, 0, 0, 0, False, 'LD B,{r}l'),
708     0x46: (1, 0, 1, 0, False, 'LD B,({r}{d:+d})'),
709
710     0x4C: (0, 0, 0, 0, False, 'LD C,{r}h'),
711     0x4D: (0, 0, 0, 0, False, 'LD C,{r}l'),
712     0x4E: (1, 0, 1, 0, False, 'LD C,({r}{d:+d})'),
713
714     0x54: (0, 0, 0, 0, False, 'LD D,{r}h'),
715     0x55: (0, 0, 0, 0, False, 'LD D,{r}l'),
716     0x56: (1, 0, 1, 0, False, 'LD D,({r}{d:+d})'),
717
718     0x5C: (0, 0, 0, 0, False, 'LD E,{r}h'),
719     0x5D: (0, 0, 0, 0, False, 'LD E,{r}l'),
720     0x5E: (1, 0, 1, 0, False, 'LD E,({r}{d:+d})'),
721
722     0x60: (0, 0, 0, 0, False, 'LD {r}h,B'),
723     0x61: (0, 0, 0, 0, False, 'LD {r}h,C'),
724     0x62: (0, 0, 0, 0, False, 'LD {r}h,D'),
725     0x63: (0, 0, 0, 0, False, 'LD {r}h,E'),
726     0x64: (0, 0, 0, 0, False, 'LD {r}h,{r}h'),
727     0x65: (0, 0, 0, 0, False, 'LD {r}h,{r}l'),
728     0x66: (1, 0, 1, 0, False, 'LD H,({r}{d:+d})'),
729     0x67: (0, 0, 0, 0, False, 'LD {r}h,A'),
730     0x68: (0, 0, 0, 0, False, 'LD {r}l,B'),
731     0x69: (0, 0, 0, 0, False, 'LD {r}l,C'),
732     0x6A: (0, 0, 0, 0, False, 'LD {r}l,D'),
733     0x6B: (0, 0, 0, 0, False, 'LD {r}l,E'),
734     0x6C: (0, 0, 0, 0, False, 'LD {r}l,{r}h'),
735     0x6D: (0, 0, 0, 0, False, 'LD {r}l,{r}l'),
736     0x6E: (1, 0, 1, 0, False, 'LD L,({r}{d:+d})'),
737     0x6F: (0, 0, 0, 0, False, 'LD {r}l,A'),
738
739     0x70: (1, 0, 0, 1, False, 'LD ({r}{d:+d}),B'),
740     0x71: (1, 0, 0, 1, False, 'LD ({r}{d:+d}),C'),
741     0x72: (1, 0, 0, 1, False, 'LD ({r}{d:+d}),D'),
742     0x73: (1, 0, 0, 1, False, 'LD ({r}{d:+d}),E'),
743     0x74: (1, 0, 0, 1, False, 'LD ({r}{d:+d}),H'),
744     0x75: (1, 0, 0, 1, False, 'LD ({r}{d:+d}),L'),
745
746     0x77: (1, 0, 0, 1, False, 'LD ({r}{d:+d}),A'),
747
748     0x7C: (0, 0, 0, 0, False, 'LD A,{r}h'),
749     0x7D: (0, 0, 0, 0, False, 'LD A,{r}l'),
750     0x7E: (1, 0, 1, 0, False, 'LD A,({r}{d:+d})'),
751
752     0x84: (0, 0, 0, 0, False, 'ADD A,{r}h'),
753     0x85: (0, 0, 0, 0, False, 'ADD A,{r}l'),
754     0x86: (1, 0, 1, 0, False, 'ADD A,({r}{d:+d})'),
755
756     0x8C: (0, 0, 0, 0, False, 'ADC A,{r}h'),
757     0x8D: (0, 0, 0, 0, False, 'ADC A,{r}l'),
758     0x8E: (1, 0, 1, 0, False, 'ADC A,({r}{d:+d})'),
759
760     0x94: (0, 0, 0, 0, False, 'SUB {r}h'),
761     0x95: (0, 0, 0, 0, False, 'SUB {r}l'),
762     0x96: (1, 0, 1, 0, False, 'SUB ({r}{d:+d})'),
763
764     0x9C: (0, 0, 0, 0, False, 'SBC A,{r}h'),
765     0x9D: (0, 0, 0, 0, False, 'SBC A,{r}l'),
766     0x9E: (1, 0, 1, 0, False, 'SBC A,({r}{d:+d})'),
767
768     0xA4: (0, 0, 0, 0, False, 'AND {r}h'),
769     0xA5: (0, 0, 0, 0, False, 'AND {r}l'),
770     0xA6: (1, 0, 1, 0, False, 'AND ({r}{d:+d})'),
771
772     0xAC: (0, 0, 0, 0, False, 'XOR {r}h'),
773     0xAD: (0, 0, 0, 0, False, 'XOR {r}l'),
774     0xAE: (1, 0, 1, 0, False, 'XOR ({r}{d:+d})'),
775
776     0xB4: (0, 0, 0, 0, False, 'OR {r}h'),
777     0xB5: (0, 0, 0, 0, False, 'OR {r}l'),
778     0xB6: (1, 0, 1, 0, False, 'OR ({r}{d:+d})'),
779
780     0xBC: (0, 0, 0, 0, False, 'CP {r}h'),
781     0xBD: (0, 0, 0, 0, False, 'CP {r}l'),
782     0xBE: (1, 0, 1, 0, False, 'CP ({r}{d:+d})'),
783
784     0xE1: (0, 0, 2, 0, False, 'POP {r}'),
785
786     0xE3: (0, 0, 2, 2, False, 'EX (SP),{r}'),
787
788     0xE5: (0, 0, 0,-2, False, 'PUSH {r}'),
789
790     0xE9: (0, 0, 0, 0, False, 'JP ({r})'),
791
792     0xF9: (0, 0, 0, 0, False, 'LD SP,{r}')
793 }
794
795 # Instructions with DD CB or FD CB prefix.
796 # For these instructions, the displacement precedes the opcode byte.
797 # This is handled as a special case in the code, and thus the entries
798 # in this table specify 0 for the displacement length.
799 index_bit_instructions = {
800     0x00: (0, 0, 1, 1, False, 'RLC ({r}{d:+d}),B'),
801     0x01: (0, 0, 1, 1, False, 'RLC ({r}{d:+d}),C'),
802     0x02: (0, 0, 1, 1, False, 'RLC ({r}{d:+d}),D'),
803     0x03: (0, 0, 1, 1, False, 'RLC ({r}{d:+d}),E'),
804     0x04: (0, 0, 1, 1, False, 'RLC ({r}{d:+d}),H'),
805     0x05: (0, 0, 1, 1, False, 'RLC ({r}{d:+d}),L'),
806     0x06: (0, 0, 1, 1, False, 'RLC ({r}{d:+d})'),
807     0x07: (0, 0, 1, 1, False, 'RLC ({r}{d:+d}),A'),
808     0x08: (0, 0, 1, 1, False, 'RRC ({r}{d:+d}),B'),
809     0x09: (0, 0, 1, 1, False, 'RRC ({r}{d:+d}),C'),
810     0x0A: (0, 0, 1, 1, False, 'RRC ({r}{d:+d}),D'),
811     0x0B: (0, 0, 1, 1, False, 'RRC ({r}{d:+d}),E'),
812     0x0C: (0, 0, 1, 1, False, 'RRC ({r}{d:+d}),H'),
813     0x0D: (0, 0, 1, 1, False, 'RRC ({r}{d:+d}),L'),
814     0x0E: (0, 0, 1, 1, False, 'RRC ({r}{d:+d})'),
815     0x0F: (0, 0, 1, 1, False, 'RRC ({r}{d:+d}),A'),
816
817     0x10: (0, 0, 1, 1, False, 'RL ({r}{d:+d}),B'),
818     0x11: (0, 0, 1, 1, False, 'RL ({r}{d:+d}),C'),
819     0x12: (0, 0, 1, 1, False, 'RL ({r}{d:+d}),D'),
820     0x13: (0, 0, 1, 1, False, 'RL ({r}{d:+d}),E'),
821     0x14: (0, 0, 1, 1, False, 'RL ({r}{d:+d}),H'),
822     0x15: (0, 0, 1, 1, False, 'RL ({r}{d:+d}),L'),
823     0x16: (0, 0, 1, 1, False, 'RL ({r}{d:+d})'),
824     0x17: (0, 0, 1, 1, False, 'RL ({r}{d:+d}),A'),
825     0x18: (0, 0, 1, 1, False, 'RR ({r}{d:+d}),B'),
826     0x19: (0, 0, 1, 1, False, 'RR ({r}{d:+d}),C'),
827     0x1A: (0, 0, 1, 1, False, 'RR ({r}{d:+d}),D'),
828     0x1B: (0, 0, 1, 1, False, 'RR ({r}{d:+d}),E'),
829     0x1C: (0, 0, 1, 1, False, 'RR ({r}{d:+d}),H'),
830     0x1D: (0, 0, 1, 1, False, 'RR ({r}{d:+d}),L'),
831     0x1E: (0, 0, 1, 1, False, 'RR ({r}{d:+d})'),
832     0x1F: (0, 0, 1, 1, False, 'RR ({r}{d:+d}),A'),
833
834     0x20: (0, 0, 1, 1, False, 'SLA ({r}{d:+d}),B'),
835     0x21: (0, 0, 1, 1, False, 'SLA ({r}{d:+d}),C'),
836     0x22: (0, 0, 1, 1, False, 'SLA ({r}{d:+d}),D'),
837     0x23: (0, 0, 1, 1, False, 'SLA ({r}{d:+d}),E'),
838     0x24: (0, 0, 1, 1, False, 'SLA ({r}{d:+d}),H'),
839     0x25: (0, 0, 1, 1, False, 'SLA ({r}{d:+d}),L'),
840     0x26: (0, 0, 1, 1, False, 'SLA ({r}{d:+d})'),
841     0x27: (0, 0, 1, 1, False, 'SLA ({r}{d:+d}),A'),
842     0x28: (0, 0, 1, 1, False, 'SRA ({r}{d:+d}),B'),
843     0x29: (0, 0, 1, 1, False, 'SRA ({r}{d:+d}),C'),
844     0x2A: (0, 0, 1, 1, False, 'SRA ({r}{d:+d}),D'),
845     0x2B: (0, 0, 1, 1, False, 'SRA ({r}{d:+d}),E'),
846     0x2C: (0, 0, 1, 1, False, 'SRA ({r}{d:+d}),H'),
847     0x2D: (0, 0, 1, 1, False, 'SRA ({r}{d:+d}),L'),
848     0x2E: (0, 0, 1, 1, False, 'SRA ({r}{d:+d})'),
849     0x2F: (0, 0, 1, 1, False, 'SRA ({r}{d:+d}),A'),
850
851     0x30: (0, 0, 1, 1, False, 'SLL ({r}{d:+d}),B'),
852     0x31: (0, 0, 1, 1, False, 'SLL ({r}{d:+d}),C'),
853     0x32: (0, 0, 1, 1, False, 'SLL ({r}{d:+d}),D'),
854     0x33: (0, 0, 1, 1, False, 'SLL ({r}{d:+d}),E'),
855     0x34: (0, 0, 1, 1, False, 'SLL ({r}{d:+d}),H'),
856     0x35: (0, 0, 1, 1, False, 'SLL ({r}{d:+d}),L'),
857     0x36: (0, 0, 1, 1, False, 'SLL ({r}{d:+d})'),
858     0x37: (0, 0, 1, 1, False, 'SLL ({r}{d:+d}),A'),
859     0x38: (0, 0, 1, 1, False, 'SRL ({r}{d:+d}),B'),
860     0x39: (0, 0, 1, 1, False, 'SRL ({r}{d:+d}),C'),
861     0x3A: (0, 0, 1, 1, False, 'SRL ({r}{d:+d}),D'),
862     0x3B: (0, 0, 1, 1, False, 'SRL ({r}{d:+d}),E'),
863     0x3C: (0, 0, 1, 1, False, 'SRL ({r}{d:+d}),H'),
864     0x3D: (0, 0, 1, 1, False, 'SRL ({r}{d:+d}),L'),
865     0x3E: (0, 0, 1, 1, False, 'SRL ({r}{d:+d})'),
866     0x3F: (0, 0, 1, 1, False, 'SRL ({r}{d:+d}),A'),
867
868     0x40: (0, 0, 1, 0, False, 'BIT 0,({r}{d:+d})'),
869     0x41: (0, 0, 1, 0, False, 'BIT 0,({r}{d:+d})'),
870     0x42: (0, 0, 1, 0, False, 'BIT 0,({r}{d:+d})'),
871     0x43: (0, 0, 1, 0, False, 'BIT 0,({r}{d:+d})'),
872     0x44: (0, 0, 1, 0, False, 'BIT 0,({r}{d:+d})'),
873     0x45: (0, 0, 1, 0, False, 'BIT 0,({r}{d:+d})'),
874     0x46: (0, 0, 1, 0, False, 'BIT 0,({r}{d:+d})'),
875     0x47: (0, 0, 1, 0, False, 'BIT 0,({r}{d:+d})'),
876     0x48: (0, 0, 1, 0, False, 'BIT 1,({r}{d:+d})'),
877     0x49: (0, 0, 1, 0, False, 'BIT 1,({r}{d:+d})'),
878     0x4A: (0, 0, 1, 0, False, 'BIT 1,({r}{d:+d})'),
879     0x4B: (0, 0, 1, 0, False, 'BIT 1,({r}{d:+d})'),
880     0x4C: (0, 0, 1, 0, False, 'BIT 1,({r}{d:+d})'),
881     0x4D: (0, 0, 1, 0, False, 'BIT 1,({r}{d:+d})'),
882     0x4E: (0, 0, 1, 0, False, 'BIT 1,({r}{d:+d})'),
883     0x4F: (0, 0, 1, 0, False, 'BIT 1,({r}{d:+d})'),
884
885     0x50: (0, 0, 1, 0, False, 'BIT 2,({r}{d:+d})'),
886     0x51: (0, 0, 1, 0, False, 'BIT 2,({r}{d:+d})'),
887     0x52: (0, 0, 1, 0, False, 'BIT 2,({r}{d:+d})'),
888     0x53: (0, 0, 1, 0, False, 'BIT 2,({r}{d:+d})'),
889     0x54: (0, 0, 1, 0, False, 'BIT 2,({r}{d:+d})'),
890     0x55: (0, 0, 1, 0, False, 'BIT 2,({r}{d:+d})'),
891     0x56: (0, 0, 1, 0, False, 'BIT 2,({r}{d:+d})'),
892     0x57: (0, 0, 1, 0, False, 'BIT 2,({r}{d:+d})'),
893     0x58: (0, 0, 1, 0, False, 'BIT 3,({r}{d:+d})'),
894     0x59: (0, 0, 1, 0, False, 'BIT 3,({r}{d:+d})'),
895     0x5A: (0, 0, 1, 0, False, 'BIT 3,({r}{d:+d})'),
896     0x5B: (0, 0, 1, 0, False, 'BIT 3,({r}{d:+d})'),
897     0x5C: (0, 0, 1, 0, False, 'BIT 3,({r}{d:+d})'),
898     0x5D: (0, 0, 1, 0, False, 'BIT 3,({r}{d:+d})'),
899     0x5E: (0, 0, 1, 0, False, 'BIT 3,({r}{d:+d})'),
900     0x5F: (0, 0, 1, 0, False, 'BIT 3,({r}{d:+d})'),
901
902     0x60: (0, 0, 1, 0, False, 'BIT 4,({r}{d:+d})'),
903     0x61: (0, 0, 1, 0, False, 'BIT 4,({r}{d:+d})'),
904     0x62: (0, 0, 1, 0, False, 'BIT 4,({r}{d:+d})'),
905     0x63: (0, 0, 1, 0, False, 'BIT 4,({r}{d:+d})'),
906     0x64: (0, 0, 1, 0, False, 'BIT 4,({r}{d:+d})'),
907     0x65: (0, 0, 1, 0, False, 'BIT 4,({r}{d:+d})'),
908     0x66: (0, 0, 1, 0, False, 'BIT 4,({r}{d:+d})'),
909     0x67: (0, 0, 1, 0, False, 'BIT 4,({r}{d:+d})'),
910     0x68: (0, 0, 1, 0, False, 'BIT 5,({r}{d:+d})'),
911     0x69: (0, 0, 1, 0, False, 'BIT 5,({r}{d:+d})'),
912     0x6A: (0, 0, 1, 0, False, 'BIT 5,({r}{d:+d})'),
913     0x6B: (0, 0, 1, 0, False, 'BIT 5,({r}{d:+d})'),
914     0x6C: (0, 0, 1, 0, False, 'BIT 5,({r}{d:+d})'),
915     0x6D: (0, 0, 1, 0, False, 'BIT 5,({r}{d:+d})'),
916     0x6E: (0, 0, 1, 0, False, 'BIT 5,({r}{d:+d})'),
917     0x6F: (0, 0, 1, 0, False, 'BIT 5,({r}{d:+d})'),
918
919     0x70: (0, 0, 1, 0, False, 'BIT 6,({r}{d:+d})'),
920     0x71: (0, 0, 1, 0, False, 'BIT 6,({r}{d:+d})'),
921     0x72: (0, 0, 1, 0, False, 'BIT 6,({r}{d:+d})'),
922     0x73: (0, 0, 1, 0, False, 'BIT 6,({r}{d:+d})'),
923     0x74: (0, 0, 1, 0, False, 'BIT 6,({r}{d:+d})'),
924     0x75: (0, 0, 1, 0, False, 'BIT 6,({r}{d:+d})'),
925     0x76: (0, 0, 1, 0, False, 'BIT 6,({r}{d:+d})'),
926     0x77: (0, 0, 1, 0, False, 'BIT 6,({r}{d:+d})'),
927     0x78: (0, 0, 1, 0, False, 'BIT 7,({r}{d:+d})'),
928     0x79: (0, 0, 1, 0, False, 'BIT 7,({r}{d:+d})'),
929     0x7A: (0, 0, 1, 0, False, 'BIT 7,({r}{d:+d})'),
930     0x7B: (0, 0, 1, 0, False, 'BIT 7,({r}{d:+d})'),
931     0x7C: (0, 0, 1, 0, False, 'BIT 7,({r}{d:+d})'),
932     0x7D: (0, 0, 1, 0, False, 'BIT 7,({r}{d:+d})'),
933     0x7E: (0, 0, 1, 0, False, 'BIT 7,({r}{d:+d})'),
934     0x7F: (0, 0, 1, 0, False, 'BIT 7,({r}{d:+d})'),
935
936     0x80: (0, 0, 1, 1, False, 'RES 0,({r}{d:+d}),B'),
937     0x81: (0, 0, 1, 1, False, 'RES 0,({r}{d:+d}),C'),
938     0x82: (0, 0, 1, 1, False, 'RES 0,({r}{d:+d}),D'),
939     0x83: (0, 0, 1, 1, False, 'RES 0,({r}{d:+d}),E'),
940     0x84: (0, 0, 1, 1, False, 'RES 0,({r}{d:+d}),H'),
941     0x85: (0, 0, 1, 1, False, 'RES 0,({r}{d:+d}),L'),
942     0x86: (0, 0, 1, 1, False, 'RES 0,({r}{d:+d})'),
943     0x87: (0, 0, 1, 1, False, 'RES 0,({r}{d:+d}),A'),
944     0x88: (0, 0, 1, 1, False, 'RES 1,({r}{d:+d}),B'),
945     0x89: (0, 0, 1, 1, False, 'RES 1,({r}{d:+d}),C'),
946     0x8A: (0, 0, 1, 1, False, 'RES 1,({r}{d:+d}),D'),
947     0x8B: (0, 0, 1, 1, False, 'RES 1,({r}{d:+d}),E'),
948     0x8C: (0, 0, 1, 1, False, 'RES 1,({r}{d:+d}),H'),
949     0x8D: (0, 0, 1, 1, False, 'RES 1,({r}{d:+d}),L'),
950     0x8E: (0, 0, 1, 1, False, 'RES 1,({r}{d:+d})'),
951     0x8F: (0, 0, 1, 1, False, 'RES 1,({r}{d:+d}),A'),
952
953     0x90: (0, 0, 1, 1, False, 'RES 2,({r}{d:+d}),B'),
954     0x91: (0, 0, 1, 1, False, 'RES 2,({r}{d:+d}),C'),
955     0x92: (0, 0, 1, 1, False, 'RES 2,({r}{d:+d}),D'),
956     0x93: (0, 0, 1, 1, False, 'RES 2,({r}{d:+d}),E'),
957     0x94: (0, 0, 1, 1, False, 'RES 2,({r}{d:+d}),H'),
958     0x95: (0, 0, 1, 1, False, 'RES 2,({r}{d:+d}),L'),
959     0x96: (0, 0, 1, 1, False, 'RES 2,({r}{d:+d})'),
960     0x97: (0, 0, 1, 1, False, 'RES 2,({r}{d:+d}),A'),
961     0x98: (0, 0, 1, 1, False, 'RES 3,({r}{d:+d}),B'),
962     0x99: (0, 0, 1, 1, False, 'RES 3,({r}{d:+d}),C'),
963     0x9A: (0, 0, 1, 1, False, 'RES 3,({r}{d:+d}),D'),
964     0x9B: (0, 0, 1, 1, False, 'RES 3,({r}{d:+d}),E'),
965     0x9C: (0, 0, 1, 1, False, 'RES 3,({r}{d:+d}),H'),
966     0x9D: (0, 0, 1, 1, False, 'RES 3,({r}{d:+d}),L'),
967     0x9E: (0, 0, 1, 1, False, 'RES 3,({r}{d:+d})'),
968     0x9F: (0, 0, 1, 1, False, 'RES 3,({r}{d:+d}),A'),
969
970     0xA0: (0, 0, 1, 1, False, 'RES 4,({r}{d:+d}),B'),
971     0xA1: (0, 0, 1, 1, False, 'RES 4,({r}{d:+d}),C'),
972     0xA2: (0, 0, 1, 1, False, 'RES 4,({r}{d:+d}),D'),
973     0xA3: (0, 0, 1, 1, False, 'RES 4,({r}{d:+d}),E'),
974     0xA4: (0, 0, 1, 1, False, 'RES 4,({r}{d:+d}),H'),
975     0xA5: (0, 0, 1, 1, False, 'RES 4,({r}{d:+d}),L'),
976     0xA6: (0, 0, 1, 1, False, 'RES 4,({r}{d:+d})'),
977     0xA7: (0, 0, 1, 1, False, 'RES 4,({r}{d:+d}),A'),
978     0xA8: (0, 0, 1, 1, False, 'RES 5,({r}{d:+d}),B'),
979     0xA9: (0, 0, 1, 1, False, 'RES 5,({r}{d:+d}),C'),
980     0xAA: (0, 0, 1, 1, False, 'RES 5,({r}{d:+d}),D'),
981     0xAB: (0, 0, 1, 1, False, 'RES 5,({r}{d:+d}),E'),
982     0xAC: (0, 0, 1, 1, False, 'RES 5,({r}{d:+d}),H'),
983     0xAD: (0, 0, 1, 1, False, 'RES 5,({r}{d:+d}),L'),
984     0xAE: (0, 0, 1, 1, False, 'RES 5,({r}{d:+d})'),
985     0xAF: (0, 0, 1, 1, False, 'RES 5,({r}{d:+d}),A'),
986
987     0xB0: (0, 0, 1, 1, False, 'RES 6,({r}{d:+d}),B'),
988     0xB1: (0, 0, 1, 1, False, 'RES 6,({r}{d:+d}),C'),
989     0xB2: (0, 0, 1, 1, False, 'RES 6,({r}{d:+d}),D'),
990     0xB3: (0, 0, 1, 1, False, 'RES 6,({r}{d:+d}),E'),
991     0xB4: (0, 0, 1, 1, False, 'RES 6,({r}{d:+d}),H'),
992     0xB5: (0, 0, 1, 1, False, 'RES 6,({r}{d:+d}),L'),
993     0xB6: (0, 0, 1, 1, False, 'RES 6,({r}{d:+d})'),
994     0xB7: (0, 0, 1, 1, False, 'RES 6,({r}{d:+d}),A'),
995     0xB8: (0, 0, 1, 1, False, 'RES 7,({r}{d:+d}),B'),
996     0xB9: (0, 0, 1, 1, False, 'RES 7,({r}{d:+d}),C'),
997     0xBA: (0, 0, 1, 1, False, 'RES 7,({r}{d:+d}),D'),
998     0xBB: (0, 0, 1, 1, False, 'RES 7,({r}{d:+d}),E'),
999     0xBC: (0, 0, 1, 1, False, 'RES 7,({r}{d:+d}),H'),
1000     0xBD: (0, 0, 1, 1, False, 'RES 7,({r}{d:+d}),L'),
1001     0xBE: (0, 0, 1, 1, False, 'RES 7,({r}{d:+d})'),
1002     0xBF: (0, 0, 1, 1, False, 'RES 7,({r}{d:+d}),A'),
1003
1004     0xC0: (0, 0, 1, 1, False, 'SET 0,({r}{d:+d}),B'),
1005     0xC1: (0, 0, 1, 1, False, 'SET 0,({r}{d:+d}),C'),
1006     0xC2: (0, 0, 1, 1, False, 'SET 0,({r}{d:+d}),D'),
1007     0xC3: (0, 0, 1, 1, False, 'SET 0,({r}{d:+d}),E'),
1008     0xC4: (0, 0, 1, 1, False, 'SET 0,({r}{d:+d}),H'),
1009     0xC5: (0, 0, 1, 1, False, 'SET 0,({r}{d:+d}),L'),
1010     0xC6: (0, 0, 1, 1, False, 'SET 0,({r}{d:+d})'),
1011     0xC7: (0, 0, 1, 1, False, 'SET 0,({r}{d:+d}),A'),
1012     0xC8: (0, 0, 1, 1, False, 'SET 1,({r}{d:+d}),B'),
1013     0xC9: (0, 0, 1, 1, False, 'SET 1,({r}{d:+d}),C'),
1014     0xCA: (0, 0, 1, 1, False, 'SET 1,({r}{d:+d}),D'),
1015     0xCB: (0, 0, 1, 1, False, 'SET 1,({r}{d:+d}),E'),
1016     0xCC: (0, 0, 1, 1, False, 'SET 1,({r}{d:+d}),H'),
1017     0xCD: (0, 0, 1, 1, False, 'SET 1,({r}{d:+d}),L'),
1018     0xCE: (0, 0, 1, 1, False, 'SET 1,({r}{d:+d})'),
1019     0xCF: (0, 0, 1, 1, False, 'SET 1,({r}{d:+d}),A'),
1020
1021     0xD0: (0, 0, 1, 1, False, 'SET 2,({r}{d:+d}),B'),
1022     0xD1: (0, 0, 1, 1, False, 'SET 2,({r}{d:+d}),C'),
1023     0xD2: (0, 0, 1, 1, False, 'SET 2,({r}{d:+d}),D'),
1024     0xD3: (0, 0, 1, 1, False, 'SET 2,({r}{d:+d}),E'),
1025     0xD4: (0, 0, 1, 1, False, 'SET 2,({r}{d:+d}),H'),
1026     0xD5: (0, 0, 1, 1, False, 'SET 2,({r}{d:+d}),L'),
1027     0xD6: (0, 0, 1, 1, False, 'SET 2,({r}{d:+d})'),
1028     0xD7: (0, 0, 1, 1, False, 'SET 2,({r}{d:+d}),A'),
1029     0xD8: (0, 0, 1, 1, False, 'SET 3,({r}{d:+d}),B'),
1030     0xD9: (0, 0, 1, 1, False, 'SET 3,({r}{d:+d}),C'),
1031     0xDA: (0, 0, 1, 1, False, 'SET 3,({r}{d:+d}),D'),
1032     0xDB: (0, 0, 1, 1, False, 'SET 3,({r}{d:+d}),E'),
1033     0xDC: (0, 0, 1, 1, False, 'SET 3,({r}{d:+d}),H'),
1034     0xDD: (0, 0, 1, 1, False, 'SET 3,({r}{d:+d}),L'),
1035     0xDE: (0, 0, 1, 1, False, 'SET 3,({r}{d:+d})'),
1036     0xDF: (0, 0, 1, 1, False, 'SET 3,({r}{d:+d}),A'),
1037
1038     0xE0: (0, 0, 1, 1, False, 'SET 4,({r}{d:+d}),B'),
1039     0xE1: (0, 0, 1, 1, False, 'SET 4,({r}{d:+d}),C'),
1040     0xE2: (0, 0, 1, 1, False, 'SET 4,({r}{d:+d}),D'),
1041     0xE3: (0, 0, 1, 1, False, 'SET 4,({r}{d:+d}),E'),
1042     0xE4: (0, 0, 1, 1, False, 'SET 4,({r}{d:+d}),H'),
1043     0xE5: (0, 0, 1, 1, False, 'SET 4,({r}{d:+d}),L'),
1044     0xE6: (0, 0, 1, 1, False, 'SET 4,({r}{d:+d})'),
1045     0xE7: (0, 0, 1, 1, False, 'SET 4,({r}{d:+d}),A'),
1046     0xE8: (0, 0, 1, 1, False, 'SET 5,({r}{d:+d}),B'),
1047     0xE9: (0, 0, 1, 1, False, 'SET 5,({r}{d:+d}),C'),
1048     0xEA: (0, 0, 1, 1, False, 'SET 5,({r}{d:+d}),D'),
1049     0xEB: (0, 0, 1, 1, False, 'SET 5,({r}{d:+d}),E'),
1050     0xEC: (0, 0, 1, 1, False, 'SET 5,({r}{d:+d}),H'),
1051     0xED: (0, 0, 1, 1, False, 'SET 5,({r}{d:+d}),L'),
1052     0xEE: (0, 0, 1, 1, False, 'SET 5,({r}{d:+d})'),
1053     0xEF: (0, 0, 1, 1, False, 'SET 5,({r}{d:+d}),A'),
1054
1055     0xF0: (0, 0, 1, 1, False, 'SET 6,({r}{d:+d}),B'),
1056     0xF1: (0, 0, 1, 1, False, 'SET 6,({r}{d:+d}),C'),
1057     0xF2: (0, 0, 1, 1, False, 'SET 6,({r}{d:+d}),D'),
1058     0xF3: (0, 0, 1, 1, False, 'SET 6,({r}{d:+d}),E'),
1059     0xF4: (0, 0, 1, 1, False, 'SET 6,({r}{d:+d}),H'),
1060     0xF5: (0, 0, 1, 1, False, 'SET 6,({r}{d:+d}),L'),
1061     0xF6: (0, 0, 1, 1, False, 'SET 6,({r}{d:+d})'),
1062     0xF7: (0, 0, 1, 1, False, 'SET 6,({r}{d:+d}),A'),
1063     0xF8: (0, 0, 1, 1, False, 'SET 7,({r}{d:+d}),B'),
1064     0xF9: (0, 0, 1, 1, False, 'SET 7,({r}{d:+d}),C'),
1065     0xFA: (0, 0, 1, 1, False, 'SET 7,({r}{d:+d}),D'),
1066     0xFB: (0, 0, 1, 1, False, 'SET 7,({r}{d:+d}),E'),
1067     0xFC: (0, 0, 1, 1, False, 'SET 7,({r}{d:+d}),H'),
1068     0xFD: (0, 0, 1, 1, False, 'SET 7,({r}{d:+d}),L'),
1069     0xFE: (0, 0, 1, 1, False, 'SET 7,({r}{d:+d})'),
1070     0xFF: (0, 0, 1, 1, False, 'SET 7,({r}{d:+d}),A')
1071 }
1072
1073 instr_table_by_prefix = {
1074     0:      (main_instructions,      ''),
1075     0xED:   (extended_instructions,  ''),
1076     0xCB:   (bit_instructions,       ''),
1077     0xDD:   (index_instructions,     'IX'),
1078     0xFD:   (index_instructions,     'IY'),
1079     0xDDCB: (index_bit_instructions, 'IX'),
1080     0xFDCB: (index_bit_instructions, 'IY')
1081 }