-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathInstrTable.h
567 lines (524 loc) · 35.7 KB
/
InstrTable.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
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
#pragma once
#include <cstdint>
#include <string>
enum AddrMode : uint8_t {
Addr_Implicit,
Addr_Accumulator, // A
Addr_Immediate, // #v
Addr_ZeroPage, // d
Addr_Absolute, // a
Addr_Relative, // label
Addr_Indirect, // (a)
// Indexed addressing modes
Addr_ZeroPageX, // Zero page indexed, val = PEEK((arg + X) % 256)
Addr_ZeroPageY, // Zero page indexed, val = PEEK((arg + Y) % 256)
Addr_AbslX, // Absolute indexed, val = PEEK(arg + X)
Addr_AbslY, // Absolute indexed, val = PEEK(arg + Y)
Addr_IndirX, // Indexed indirect, val = PEEK(PEEK((arg + X) % 256) + PEEK((arg + X + 1) % 256) * 256)
Addr_IndirY, // Indexed indirect, val = PEEK(PEEK(arg) + PEEK((arg + 1) % 256) * 256 + Y)
Addr_Illegal // For illegal instructions
};
struct AddrModeData {
AddrMode mode;
uint8_t size;
std::string_view mnemonic;
std::string_view name;
std::string_view fmt;
std::string_view desc;
};
static constexpr AddrModeData AddrModeDataTable[14] = {
// Mode enum Size Mnemonic Name Nestest Fmt String Description
{ Addr_Implicit, 1, "imp", "Implicit", "{}", "Implicit" },
{ Addr_Accumulator, 1, "ACC", "Accumulator", "{} A", "Accumulator" },
{ Addr_Immediate, 2, "IMM", "Immediate", "{} #${:02X}", "Immediate" },
{ Addr_ZeroPage, 2, "ZP", "Zero Page", "{} ${:02X} = {:02X}", "Zero Page" },
{ Addr_Absolute, 3, "ABS", "Absolute", "{} ${:04X}", "Absolute" },
{ Addr_Relative, 2, "REL", "Relative", "{} ${:04X}", "Relative" },
{ Addr_Indirect, 3, "IND", "Indirect", "{} (${:04X}) = {:04X}", "Indirect" },
{ Addr_ZeroPageX, 2, "ZPX", "Zero Page X", "{} ${:02X},X @ {:02X} = {:02X}", "Zero Page X" },
{ Addr_ZeroPageY, 2, "ZPY", "Zero Page Y", "{} ${:02X},Y @ {:02X} = {:02X}", "Zero Page Y" },
{ Addr_AbslX, 3, "ABX", "Absolute X", "{} ${:04X},X @ {:04X} = {:02X}", "Absolute X" },
{ Addr_AbslY, 3, "ABY", "Absolute Y", "{} ${:04X},Y @ {:04X} = {:02X}", "Absolute Y" },
{ Addr_IndirX, 2, "IDX", "Indexed X", "{} (${:02X},X) @ {:02X} = {:04X} = {:02X}", "Indexed X" },
{ Addr_IndirY, 2, "IDY", "Indexed Y", "{} (${:02X}),Y = {:04X} @ {:04X} = {:02X}", "Indexed Y" },
{ Addr_Illegal, 1, "ILL", "Illegal", "{}", "Illegal" }
};
struct InstrData {
std::string_view mnemonic;
AddrMode mode;
bool illegal;
uint8_t cycles;
uint8_t pageCycles;
bool updatesOperand; // Updates operand (memory or register) after execution
std::string_view desc;
};
static constexpr InstrData InstrDataTable[256] = {
// Opcode Mnemonic Mode Illegal Cycles PageCycles UpdatesOperand Description
/* 0x00 */ { "BRK", Addr_Implicit, false, 7, 0, false, "Force Break" },
/* 0x01 */ { "ORA", Addr_IndirX, false, 6, 0, false, "Or Memory with Accumulator" },
/* 0x02 */ { "*NOP", Addr_Illegal, true, 0, 0, false, "Illegal" },
/* 0x03 */ { "*SLO", Addr_IndirX, true, 8, 0, false, "Illegal" },
/* 0x04 */ { "*NOP", Addr_ZeroPage, true, 3, 0, false, "Test and Set Memory Bits" },
/* 0x05 */ { "ORA", Addr_ZeroPage, false, 3, 0, false, "Or Memory with Accumulator" },
/* 0x06 */ { "ASL", Addr_ZeroPage, false, 5, 0, true, "Arithmetic Shift Left" },
/* 0x07 */ { "*SLO", Addr_ZeroPage, true, 5, 0, false, "Illegal" },
/* 0x08 */ { "PHP", Addr_Implicit, false, 3, 0, false, "Push Processor Status on Stack" },
/* 0x09 */ { "ORA", Addr_Immediate, false, 2, 0, false, "Or Memory with Accumulator" },
/* 0x0A */ { "ASL", Addr_Accumulator, false, 2, 0, true, "Arithmetic Shift Left" },
/* 0x0B */ { "*NOP", Addr_Immediate, true, 2, 0, false, "Illegal" },
/* 0x0C */ { "*NOP", Addr_Absolute, true, 4, 0, false, "Illegal" },
/* 0x0D */ { "ORA", Addr_Absolute, false, 4, 0, false, "Or Memory with Accumulator" },
/* 0x0E */ { "ASL", Addr_Absolute, false, 6, 0, true, "Arithmetic Shift Left" },
/* 0x0F */ { "*SLO", Addr_Absolute, true, 6, 0, false, "Illegal" },
/* 0x10 */ { "BPL", Addr_Relative, false, 2, 1, false, "Branch if Positive" },
/* 0x11 */ { "ORA", Addr_IndirY, false, 5, 1, false, "Or Memory with Accumulator" },
/* 0x12 */ { "*NOP", Addr_Illegal, true, 0, 0, false, "Illegal" },
/* 0x13 */ { "*SLO", Addr_IndirY, true, 8, 0, false, "Illegal" },
/* 0x14 */ { "*NOP", Addr_ZeroPageX, true, 4, 0, false, "Illegal" },
/* 0x15 */ { "ORA", Addr_ZeroPageX, false, 4, 0, false, "Or Memory with Accumulator" },
/* 0x16 */ { "ASL", Addr_ZeroPageX, false, 6, 0, true, "Arithmetic Shift Left" },
/* 0x17 */ { "*SLO", Addr_ZeroPageX, true, 6, 0, false, "Illegal" },
/* 0x18 */ { "CLC", Addr_Implicit, false, 2, 0, false, "Clear Carry Flag" },
/* 0x19 */ { "ORA", Addr_AbslY, false, 4, 1, false, "Or Memory with Accumulator" },
/* 0x1A */ { "*NOP", Addr_Illegal, true, 2, 0, false, "Illegal" },
/* 0x1B */ { "*SLO", Addr_AbslY, true, 7, 0, false, "Illegal" },
/* 0x1C */ { "*NOP", Addr_AbslX, true, 4, 1, false, "Illegal" },
/* 0x1D */ { "ORA", Addr_AbslX, false, 4, 1, false, "Or Memory with Accumulator" },
/* 0x1E */ { "ASL", Addr_AbslX, false, 7, 0, true, "Arithmetic Shift Left" },
/* 0x1F */ { "*SLO", Addr_AbslX, true, 7, 0, false, "Illegal" },
/* 0x20 */ { "JSR", Addr_Absolute, false, 6, 0, false, "Jump to New Location Saving Return Address" },
/* 0x21 */ { "AND", Addr_IndirX, false, 6, 0, false, "And Memory with Accumulator" },
/* 0x22 */ { "*NOP", Addr_Illegal, true, 0, 0, false, "Illegal" },
/* 0x23 */ { "*RLA", Addr_IndirX, true, 8, 0, false, "Illegal" },
/* 0x24 */ { "BIT", Addr_ZeroPage, false, 3, 0, false, "Test Bits in Memory with Accumulator" },
/* 0x25 */ { "AND", Addr_ZeroPage, false, 3, 0, false, "And Memory with Accumulator" },
/* 0x26 */ { "ROL", Addr_ZeroPage, false, 5, 0, true, "Rotate One Bit Left (Memory or Accumulator)" },
/* 0x27 */ { "*RLA", Addr_ZeroPage, true, 5, 0, false, "Illegal" },
/* 0x28 */ { "PLP", Addr_Implicit, false, 4, 0, false, "Pull Processor Status from Stack" },
/* 0x29 */ { "AND", Addr_Immediate, false, 2, 0, false, "And Memory with Accumulator" },
/* 0x2A */ { "ROL", Addr_Accumulator, false, 2, 0, true, "Rotate One Bit Left (Memory or Accumulator)" },
/* 0x2B */ { "*NOP", Addr_Immediate, true, 2, 0, false, "Illegal" },
/* 0x2C */ { "BIT", Addr_Absolute, false, 4, 0, false, "Test Bits in Memory with Accumulator" },
/* 0x2D */ { "AND", Addr_Absolute, false, 4, 0, false, "And Memory with Accumulator" },
/* 0x2E */ { "ROL", Addr_Absolute, false, 6, 0, true, "Rotate One Bit Left (Memory or Accumulator)" },
/* 0x2F */ { "*RLA", Addr_Absolute, true, 6, 0, false, "Illegal" },
/* 0x30 */ { "BMI", Addr_Relative, false, 2, 1, false, "Branch if Minus" },
/* 0x31 */ { "AND", Addr_IndirY, false, 5, 1, false, "And Memory with Accumulator" },
/* 0x32 */ { "*NOP", Addr_Illegal, true, 0, 0, false, "Illegal" },
/* 0x33 */ { "*RLA", Addr_IndirY, true, 8, 0, false, "Illegal" },
/* 0x34 */ { "*NOP", Addr_ZeroPageX, true, 4, 0, false, "Illegal" },
/* 0x35 */ { "AND", Addr_ZeroPageX, false, 4, 0, false, "And Memory with Accumulator" },
/* 0x36 */ { "ROL", Addr_ZeroPageX, false, 6, 0, true, "Rotate One Bit Left (Memory or Accumulator)" },
/* 0x37 */ { "*RLA", Addr_ZeroPageX, true, 6, 0, false, "Illegal" },
/* 0x38 */ { "SEC", Addr_Implicit, false, 2, 0, false, "Set Carry Flag" },
/* 0x39 */ { "AND", Addr_AbslY, false, 4, 1, false, "And Memory with Accumulator" },
/* 0x3A */ { "*NOP", Addr_Illegal, true, 2, 0, false, "Illegal" },
/* 0x3B */ { "*RLA", Addr_AbslY, true, 7, 0, false, "Illegal" },
/* 0x3C */ { "*NOP", Addr_AbslX, true, 4, 1, false, "Illegal" },
/* 0x3D */ { "AND", Addr_AbslX, false, 4, 1, false, "And Memory with Accumulator" },
/* 0x3E */ { "ROL", Addr_AbslX, false, 7, 0, true, "Rotate One Bit Left (Memory or Accumulator)" },
/* 0x3F */ { "*RLA", Addr_AbslX, true, 7, 0, false, "Illegal" },
/* 0x40 */ { "RTI", Addr_Implicit, false, 6, 0, false, "Return from Interrupt" },
/* 0x41 */ { "EOR", Addr_IndirX, false, 6, 0, false, "Exclusive-Or Memory with Accumulator" },
/* 0x42 */ { "*NOP", Addr_Illegal, true, 0, 0, false, "Illegal" },
/* 0x43 */ { "*SRE", Addr_IndirX, true, 8, 0, false, "Illegal" },
/* 0x44 */ { "*NOP", Addr_ZeroPage, true, 3, 0, false, "Illegal" },
/* 0x45 */ { "EOR", Addr_ZeroPage, false, 3, 0, false, "Exclusive-Or Memory with Accumulator" },
/* 0x46 */ { "LSR", Addr_ZeroPage, false, 5, 0, true, "Logical Shift Right" },
/* 0x47 */ { "*SRE", Addr_ZeroPage, true, 5, 0, false, "Illegal" },
/* 0x48 */ { "PHA", Addr_Implicit, false, 3, 0, false, "Push Accumulator on Stack" },
/* 0x49 */ { "EOR", Addr_Immediate, false, 2, 0, false, "Exclusive-Or Memory with Accumulator" },
/* 0x4A */ { "LSR", Addr_Accumulator, false, 2, 0, true, "Logical Shift Right" },
/* 0x4B */ { "*NOP", Addr_Immediate, true, 2, 0, false, "Illegal" },
/* 0x4C */ { "JMP", Addr_Absolute, false, 3, 0, false, "Jump to New Location" },
/* 0x4D */ { "EOR", Addr_Absolute, false, 4, 0, false, "Exclusive-Or Memory with Accumulator" },
/* 0x4E */ { "LSR", Addr_Absolute, false, 6, 0, true, "Logical Shift Right" },
/* 0x4F */ { "*SRE", Addr_Absolute, true, 6, 0, false, "Illegal" },
/* 0x50 */ { "BVC", Addr_Relative, false, 2, 1, false, "Branch if Overflow Clear" },
/* 0x51 */ { "EOR", Addr_IndirY, false, 5, 1, false, "Exclusive-Or Memory with Accumulator" },
/* 0x52 */ { "*NOP", Addr_Illegal, true, 0, 0, false, "Illegal" },
/* 0x53 */ { "*SRE", Addr_IndirY, true, 8, 0, false, "Illegal" },
/* 0x54 */ { "*NOP", Addr_ZeroPageX, true, 4, 0, false, "Illegal" },
/* 0x55 */ { "EOR", Addr_ZeroPageX, false, 4, 0, false, "Exclusive-Or Memory with Accumulator" },
/* 0x56 */ { "LSR", Addr_ZeroPageX, false, 6, 0, true, "Logical Shift Right" },
/* 0x57 */ { "*SRE", Addr_ZeroPageX, true, 6, 0, false, "Illegal" },
/* 0x58 */ { "CLI", Addr_Implicit, false, 2, 0, false, "Clear Interrupt Disable Bit" },
/* 0x59 */ { "EOR", Addr_AbslY, false, 4, 1, false, "Exclusive-Or Memory with Accumulator" },
/* 0x5A */ { "*NOP", Addr_Illegal, true, 2, 0, false, "Illegal" },
/* 0x5B */ { "*SRE", Addr_AbslY, true, 7, 0, false, "Illegal" },
/* 0x5C */ { "*NOP", Addr_AbslX, true, 4, 1, false, "Illegal" },
/* 0x5D */ { "EOR", Addr_AbslX, false, 4, 1, false, "Exclusive-Or Memory with Accumulator" },
/* 0x5E */ { "LSR", Addr_AbslX, false, 7, 0, true, "Logical Shift Right" },
/* 0x5F */ { "*SRE", Addr_AbslX, true, 7, 0, false, "Illegal" },
/* 0x60 */ { "RTS", Addr_Implicit, false, 6, 0, false, "Return from Subroutine" },
/* 0x61 */ { "ADC", Addr_IndirX, false, 6, 0, false, "Add Memory to Accumulator with Carry" },
/* 0x62 */ { "*NOP", Addr_Illegal, true, 0, 0, false, "Illegal" },
/* 0x63 */ { "*RRA", Addr_IndirX, true, 8, 0, true, "Illegal" },
/* 0x64 */ { "*NOP", Addr_ZeroPage, true, 3, 0, false, "Illegal" },
/* 0x65 */ { "ADC", Addr_ZeroPage, false, 3, 0, false, "Add Memory to Accumulator with Carry" },
/* 0x66 */ { "ROR", Addr_ZeroPage, false, 5, 0, true, "Rotate One Bit Right (Memory or Accumulator)" },
/* 0x67 */ { "*RRA", Addr_ZeroPage, true, 5, 0, true, "Illegal" },
/* 0x68 */ { "PLA", Addr_Implicit, false, 4, 0, false, "Pull Accumulator from Stack" },
/* 0x69 */ { "ADC", Addr_Immediate, false, 2, 0, false, "Add Memory to Accumulator with Carry" },
/* 0x6A */ { "ROR", Addr_Accumulator, false, 2, 0, true, "Rotate One Bit Right (Memory or Accumulator)" },
/* 0x6B */ { "*NOP", Addr_Immediate, true, 2, 0, false, "Illegal" },
/* 0x6C */ { "JMP", Addr_Indirect, false, 5, 0, false, "Jump to New Location" },
/* 0x6D */ { "ADC", Addr_Absolute, false, 4, 0, false, "Add Memory to Accumulator with Carry" },
/* 0x6E */ { "ROR", Addr_Absolute, false, 6, 0, true, "Rotate One Bit Right (Memory or Accumulator)" },
/* 0x6F */ { "*RRA", Addr_Absolute, true, 6, 0, true, "Illegal" },
/* 0x70 */ { "BVS", Addr_Relative, false, 2, 1, false, "Branch if Overflow Set" },
/* 0x71 */ { "ADC", Addr_IndirY, false, 5, 1, false, "Add Memory to Accumulator with Carry" },
/* 0x72 */ { "*NOP", Addr_Illegal, true, 0, 0, false, "Illegal" },
/* 0x73 */ { "*RRA", Addr_IndirY, true, 8, 0, true, "Illegal" },
/* 0x74 */ { "*NOP", Addr_ZeroPageX, true, 4, 0, false, "Illegal" },
/* 0x75 */ { "ADC", Addr_ZeroPageX, false, 4, 0, false, "Add Memory to Accumulator with Carry" },
/* 0x76 */ { "ROR", Addr_ZeroPageX, false, 6, 0, true, "Rotate One Bit Right (Memory or Accumulator)" },
/* 0x77 */ { "*RRA", Addr_ZeroPageX, true, 6, 0, true, "Illegal" },
/* 0x78 */ { "SEI", Addr_Implicit, false, 2, 0, false, "Set Interrupt Disable Status" },
/* 0x79 */ { "ADC", Addr_AbslY, false, 4, 1, false, "Add Memory to Accumulator with Carry" },
/* 0x7A */ { "*NOP", Addr_Illegal, true, 2, 0, false, "Illegal" },
/* 0x7B */ { "*RRA", Addr_AbslY, true, 7, 0, true, "Illegal" },
/* 0x7C */ { "*NOP", Addr_AbslX, true, 4, 1, false, "Illegal" },
/* 0x7D */ { "ADC", Addr_AbslX, false, 4, 1, false, "Add Memory to Accumulator with Carry" },
/* 0x7E */ { "ROR", Addr_AbslX, false, 7, 0, true, "Rotate One Bit Right (Memory or Accumulator)" },
/* 0x7F */ { "*RRA", Addr_AbslX, true, 7, 0, true, "Illegal" },
/* 0x80 */ { "*NOP", Addr_Immediate, true, 2, 0, false, "Illegal" },
/* 0x81 */ { "STA", Addr_IndirX, false, 6, 0, false, "Store Accumulator in Memory" },
/* 0x82 */ { "*NOP", Addr_Immediate, true, 2, 0, false, "Illegal" },
/* 0x83 */ { "*SAX", Addr_IndirX, true, 6, 0, false, "Illegal" },
/* 0x84 */ { "STY", Addr_ZeroPage, false, 3, 0, false, "Store Index Y in Memory" },
/* 0x85 */ { "STA", Addr_ZeroPage, false, 3, 0, false, "Store Accumulator in Memory" },
/* 0x86 */ { "STX", Addr_ZeroPage, false, 3, 0, false, "Store Index X in Memory" },
/* 0x87 */ { "*SAX", Addr_ZeroPage, true, 3, 0, false, "Illegal" },
/* 0x88 */ { "DEY", Addr_Implicit, false, 2, 0, false, "Decrement Index Y by One" },
/* 0x89 */ { "*NOP", Addr_Immediate, true, 2, 0, false, "Illegal" },
/* 0x8A */ { "TXA", Addr_Implicit, false, 2, 0, false, "Transfer Index X to Accumulator" },
/* 0x8B */ { "*NOP", Addr_Immediate, true, 2, 0, false, "Illegal" },
/* 0x8C */ { "STY", Addr_Absolute, false, 4, 0, false, "Store Index Y in Memory" },
/* 0x8D */ { "STA", Addr_Absolute, false, 4, 0, false, "Store Accumulator in Memory" },
/* 0x8E */ { "STX", Addr_Absolute, false, 4, 0, false, "Store Index X in Memory" },
/* 0x8F */ { "*SAX", Addr_Absolute, true, 4, 0, false, "Illegal" },
/* 0x90 */ { "BCC", Addr_Relative, false, 2, 1, false, "Branch if Carry Clear" },
/* 0x91 */ { "STA", Addr_IndirY, false, 6, 0, false, "Store Accumulator in Memory" },
/* 0x92 */ { "*NOP", Addr_Illegal, true, 0, 0, false, "Illegal" },
/* 0x93 */ { "*NOP", Addr_IndirY, true, 6, 0, false, "Illegal" },
/* 0x94 */ { "STY", Addr_ZeroPageX, false, 4, 0, false, "Store Index Y in Memory" },
/* 0x95 */ { "STA", Addr_ZeroPageX, false, 4, 0, false, "Store Accumulator in Memory" },
/* 0x96 */ { "STX", Addr_ZeroPageY, false, 4, 0, false, "Store Index X in Memory" },
/* 0x97 */ { "*SAX", Addr_ZeroPageY, true, 4, 0, false, "Illegal" },
/* 0x98 */ { "TYA", Addr_Implicit, false, 2, 0, false, "Transfer Index Y to Accumulator" },
/* 0x99 */ { "STA", Addr_AbslY, false, 5, 0, false, "Store Accumulator in Memory" },
/* 0x9A */ { "TXS", Addr_Implicit, false, 2, 0, false, "Transfer Index X to Stack Pointer" },
/* 0x9B */ { "*NOP", Addr_AbslY, true, 5, 0, false, "Illegal" },
/* 0x9C */ { "*NOP", Addr_AbslX, true, 5, 0, false, "Illegal" },
/* 0x9D */ { "STA", Addr_AbslX, false, 5, 0, false, "Store Accumulator in Memory" },
/* 0x9E */ { "*NOP", Addr_AbslY, true, 5, 0, false, "Illegal" },
/* 0x9F */ { "*NOP", Addr_AbslY, true, 5, 0, false, "Illegal" },
/* 0xA0 */ { "LDY", Addr_Immediate, false, 2, 0, false, "Load Index Y with Memory" },
/* 0xA1 */ { "LDA", Addr_IndirX, false, 6, 0, false, "Load Accumulator with Memory" },
/* 0xA2 */ { "LDX", Addr_Immediate, false, 2, 0, false, "Load Index X with Memory" },
/* 0xA3 */ { "*LAX", Addr_IndirX, true, 6, 0, false, "Illegal" },
/* 0xA4 */ { "LDY", Addr_ZeroPage, false, 3, 0, false, "Load Index Y with Memory" },
/* 0xA5 */ { "LDA", Addr_ZeroPage, false, 3, 0, false, "Load Accumulator with Memory" },
/* 0xA6 */ { "LDX", Addr_ZeroPage, false, 3, 0, false, "Load Index X with Memory" },
/* 0xA7 */ { "*LAX", Addr_ZeroPage, true, 3, 0, false, "Illegal" },
/* 0xA8 */ { "TAY", Addr_Implicit, false, 2, 0, false, "Transfer Accumulator to Index Y" },
/* 0xA9 */ { "LDA", Addr_Immediate, false, 2, 0, false, "Load Accumulator with Memory" },
/* 0xAA */ { "TAX", Addr_Implicit, false, 2, 0, false, "Transfer Accumulator to Index X" },
/* 0xAB */ { "*NOP", Addr_Immediate, true, 2, 0, false, "Illegal" },
/* 0xAC */ { "LDY", Addr_Absolute, false, 4, 0, false, "Load Index Y with Memory" },
/* 0xAD */ { "LDA", Addr_Absolute, false, 4, 0, false, "Load Accumulator with Memory" },
/* 0xAE */ { "LDX", Addr_Absolute, false, 4, 0, false, "Load Index X with Memory" },
/* 0xAF */ { "*LAX", Addr_Absolute, true, 4, 0, false, "Illegal" },
/* 0xB0 */ { "BCS", Addr_Relative, false, 2, 1, false, "Branch if Carry Set" },
/* 0xB1 */ { "LDA", Addr_IndirY, false, 5, 1, false, "Load Accumulator with Memory" },
/* 0xB2 */ { "*NOP", Addr_Illegal, true, 0, 0, false, "Illegal" },
/* 0xB3 */ { "*LAX", Addr_IndirY, true, 5, 1, false, "Illegal" },
/* 0xB4 */ { "LDY", Addr_ZeroPageX, false, 4, 0, false, "Load Index Y with Memory" },
/* 0xB5 */ { "LDA", Addr_ZeroPageX, false, 4, 0, false, "Load Accumulator with Memory" },
/* 0xB6 */ { "LDX", Addr_ZeroPageY, false, 4, 0, false, "Load Index X with Memory" },
/* 0xB7 */ { "*LAX", Addr_ZeroPageY, true, 4, 0, false, "Illegal" },
/* 0xB8 */ { "CLV", Addr_Implicit, false, 2, 0, false, "Clear Overflow Flag" },
/* 0xB9 */ { "LDA", Addr_AbslY, false, 4, 1, false, "Load Accumulator with Memory" },
/* 0xBA */ { "TSX", Addr_Implicit, false, 2, 0, false, "Transfer Stack Pointer to Index X" },
/* 0xBB */ { "*NOP", Addr_AbslY, true, 4, 1, false, "Illegal" },
/* 0xBC */ { "LDY", Addr_AbslX, false, 4, 1, false, "Load Index Y with Memory" },
/* 0xBD */ { "LDA", Addr_AbslX, false, 4, 1, false, "Load Accumulator with Memory" },
/* 0xBE */ { "LDX", Addr_AbslY, false, 4, 1, false, "Load Index X with Memory" },
/* 0xBF */ { "*LAX", Addr_AbslY, true, 4, 1, false, "Illegal" },
/* 0xC0 */ { "CPY", Addr_Immediate, false, 2, 0, false, "Compare Memory with Index Y" },
/* 0xC1 */ { "CMP", Addr_IndirX, false, 6, 0, false, "Compare Memory with Accumulator" },
/* 0xC2 */ { "*NOP", Addr_Immediate, true, 2, 0, false, "Illegal" },
/* 0xC3 */ { "*DCP", Addr_IndirX, true, 8, 0, false, "Illegal" },
/* 0xC4 */ { "CPY", Addr_ZeroPage, false, 3, 0, false, "Compare Memory with Index Y" },
/* 0xC5 */ { "CMP", Addr_ZeroPage, false, 3, 0, false, "Compare Memory with Accumulator" },
/* 0xC6 */ { "DEC", Addr_ZeroPage, false, 5, 0, true, "Decrement Memory by One" },
/* 0xC7 */ { "*DCP", Addr_ZeroPage, true, 5, 0, false, "Illegal" },
/* 0xC8 */ { "INY", Addr_Implicit, false, 2, 0, false, "Increment Index Y by One" },
/* 0xC9 */ { "CMP", Addr_Immediate, false, 2, 0, false, "Compare Memory with Accumulator" },
/* 0xCA */ { "DEX", Addr_Implicit, false, 2, 0, false, "Decrement Index X by One" },
/* 0xCB */ { "*NOP", Addr_Immediate, true, 2, 0, false, "Illegal" },
/* 0xCC */ { "CPY", Addr_Absolute, false, 4, 0, false, "Compare Memory with Index Y" },
/* 0xCD */ { "CMP", Addr_Absolute, false, 4, 0, false, "Compare Memory with Accumulator" },
/* 0xCE */ { "DEC", Addr_Absolute, false, 6, 0, false, "Decrement Memory by One" },
/* 0xCF */ { "*DCP", Addr_Absolute, true, 6, 0, false, "Illegal" },
/* 0xD0 */ { "BNE", Addr_Relative, false, 2, 1, false, "Branch if Not Equal" },
/* 0xD1 */ { "CMP", Addr_IndirY, false, 5, 1, false, "Compare Memory with Accumulator" },
/* 0xD2 */ { "*NOP", Addr_Illegal, true, 0, 0, false, "Illegal" },
/* 0xD3 */ { "*DCP", Addr_IndirY, true, 8, 0, false, "Illegal" },
/* 0xD4 */ { "*NOP", Addr_ZeroPageX, true, 4, 0, false, "Illegal" },
/* 0xD5 */ { "CMP", Addr_ZeroPageX, false, 4, 0, false, "Compare Memory with Accumulator" },
/* 0xD6 */ { "DEC", Addr_ZeroPageX, false, 6, 0, false, "Decrement Memory by One" },
/* 0xD7 */ { "*DCP", Addr_ZeroPageX, true, 6, 0, false, "Illegal" },
/* 0xD8 */ { "CLD", Addr_Implicit, false, 2, 0, false, "Clear Decimal Mode" },
/* 0xD9 */ { "CMP", Addr_AbslY, false, 4, 1, false, "Compare Memory with Accumulator" },
/* 0xDA */ { "*NOP", Addr_Illegal, true, 2, 0, false, "Illegal" },
/* 0xDB */ { "*DCP", Addr_AbslY, true, 7, 0, false, "Illegal" },
/* 0xDC */ { "*NOP", Addr_AbslX, true, 4, 1, false, "Illegal" },
/* 0xDD */ { "CMP", Addr_AbslX, false, 4, 1, false, "Compare Memory with Accumulator" },
/* 0xDE */ { "DEC", Addr_AbslX, false, 7, 0, false, "Decrement Memory by One" },
/* 0xDF */ { "*DCP", Addr_AbslX, true, 7, 0, false, "Illegal" },
/* 0xE0 */ { "CPX", Addr_Immediate, false, 2, 0, false, "Compare Memory with Index X" },
/* 0xE1 */ { "SBC", Addr_IndirX, false, 6, 0, false, "Subtract Memory from Accumulator with Borrow" },
/* 0xE2 */ { "*NOP", Addr_Immediate, true, 2, 0, false, "Illegal" },
/* 0xE3 */ { "*ISB", Addr_IndirX, true, 8, 0, false, "Illegal" },
/* 0xE4 */ { "CPX", Addr_ZeroPage, false, 3, 0, false, "Compare Memory with Index X" },
/* 0xE5 */ { "SBC", Addr_ZeroPage, false, 3, 0, false, "Subtract Memory from Accumulator with Borrow" },
/* 0xE6 */ { "INC", Addr_ZeroPage, false, 5, 0, true, "Increment Memory by One" },
/* 0xE7 */ { "*ISB", Addr_ZeroPage, true, 5, 0, false, "Illegal" },
/* 0xE8 */ { "INX", Addr_Implicit, false, 2, 0, false, "Increment Index X by One" },
/* 0xE9 */ { "SBC", Addr_Immediate, false, 2, 0, false, "Subtract Memory from Accumulator with Borrow" },
/* 0xEA */ { "NOP", Addr_Implicit, false, 2, 0, false, "No Operation" },
/* 0xEB */ { "*SBC", Addr_Immediate, true, 2, 0, false, "Illegal" },
/* 0xEC */ { "CPX", Addr_Absolute, false, 4, 0, false, "Compare Memory with Index X" },
/* 0xED */ { "SBC", Addr_Absolute, false, 4, 0, false, "Subtract Memory from Accumulator with Borrow" },
/* 0xEE */ { "INC", Addr_Absolute, false, 6, 0, true, "Increment Memory by One" },
/* 0xEF */ { "*ISB", Addr_Absolute, true, 6, 0, false, "Illegal" },
/* 0xF0 */ { "BEQ", Addr_Relative, false, 2, 1, false, "Branch if Equal" },
/* 0xF1 */ { "SBC", Addr_IndirY, false, 5, 1, false, "Subtract Memory from Accumulator with Borrow" },
/* 0xF2 */ { "*NOP", Addr_Illegal, true, 0, 0, false, "Illegal" },
/* 0xF3 */ { "*ISB", Addr_IndirY, true, 8, 0, false, "Illegal" },
/* 0xF4 */ { "*NOP", Addr_ZeroPageX, true, 4, 0, false, "Illegal" },
/* 0xF5 */ { "SBC", Addr_ZeroPageX, false, 4, 0, false, "Subtract Memory from Accumulator with Borrow" },
/* 0xF6 */ { "INC", Addr_ZeroPageX, false, 6, 0, true, "Increment Memory by One" },
/* 0xF7 */ { "*ISB", Addr_ZeroPageX, true, 6, 0, false, "Illegal" },
/* 0xF8 */ { "SED", Addr_Implicit, false, 2, 0, false, "Set Decimal Mode" },
/* 0xF9 */ { "SBC", Addr_AbslY, false, 4, 1, false, "Subtract Memory from Accumulator with Borrow" },
/* 0xFA */ { "*NOP", Addr_Illegal, true, 2, 0, false, "Illegal" },
/* 0xFB */ { "*ISB", Addr_AbslY, true, 7, 0, false, "Illegal" },
/* 0xFC */ { "*NOP", Addr_AbslX, true, 4, 1, false, "Illegal" },
/* 0xFD */ { "SBC", Addr_AbslX, false, 4, 1, false, "Subtract Memory from Accumulator with Borrow" },
/* 0xFE */ { "INC", Addr_AbslX, false, 7, 0, true, "Increment Memory by One" },
/* 0xFF */ { "*ISB", Addr_AbslX, true, 7, 0, false, "Illegal" }
};
enum Opcodes {
OP_ADC_IMM = 0x69,
OP_ADC_ZP = 0x65,
OP_ADC_ZPX = 0x75,
OP_ADC_ABS = 0x6d,
OP_ADC_ABSX = 0x7d,
OP_ADC_ABSY = 0x79,
OP_ADC_INDX = 0x61,
OP_ADC_INDY = 0x71,
OP_AND_IMM = 0x29,
OP_AND_ZP = 0x25,
OP_AND_ZPX = 0x35,
OP_AND_ABS = 0x2d,
OP_AND_ABSX = 0x3d,
OP_AND_ABSY = 0x39,
OP_AND_INDX = 0x21,
OP_AND_INDY = 0x31,
OP_ASL_ACC = 0x0a,
OP_ASL_ZP = 0x06,
OP_ASL_ZPX = 0x16,
OP_ASL_ABS = 0x0e,
OP_ASL_ABSX = 0x1e,
OP_BCC_REL = 0x90,
OP_BCS_REL = 0xB0,
OP_BEQ_REL = 0xF0,
OP_BMI_REL = 0x30,
OP_BNE_REL = 0xD0,
OP_BPL_REL = 0x10,
OP_BV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