8 struct cpu_65c02 *self,
9 int (*read_byte)(void *context, int addr),
10 void *read_byte_context,
11 void (*write_byte)(void *context, int addr, int data),
12 void *write_byte_context
14 memset(self, 0, sizeof(struct cpu_65c02));
15 self->regs.byte.p = 0x30; // unused bits are hard coded to 1
16 self->read_byte = read_byte;
17 self->read_byte_context = read_byte_context;
18 self->write_byte = write_byte;
19 self->write_byte_context = write_byte_context;
22 void cpu_65c02_reset(struct cpu_65c02 *self) {
23 self->regs.word.pc = cpu_65c02_read_word(self, CPU_65C02_RESET_VECTOR);
24 self->regs.byte.iflags = 0;
25 self->regs.bit._if = true;
26 self->regs.bit.df = false;
30 void cpu_65c02_execute(struct cpu_65c02 *self) {
31 if (self->regs.bit.stp_flag) {
36 if (self->regs.bit.nmi_pending) {
37 self->regs.bit.nmi_pending = false;
38 self->regs.bit.wai_flag = false;
39 cpu_65c02_irq(self, false, CPU_65C02_NMI_VECTOR);
43 if (self->regs.bit.irq_pending) {
44 if (self->regs.bit._if == 0) {
45 self->regs.bit.irq_pending = false;
46 self->regs.bit.wai_flag = false;
47 cpu_65c02_irq(self, false, CPU_65C02_IRQ_VECTOR);
50 if (self->regs.bit.wai_flag) {
51 self->regs.bit.irq_pending = false;
52 self->regs.bit.wai_flag = false;
55 else if (self->regs.bit.wai_flag) {
60 switch (cpu_65c02_fetch_byte(self)) {
63 cpu_65c02_irq(self, true, CPU_65C02_IRQ_VECTOR);
66 cpu_65c02_ora(self, cpu_65c02_read_byte(self, cpu_65c02_ea_zero_page_indexed_indirect(self, self->regs.byte.x)));
69 cpu_65c02_illegal_opcode22(self);
72 cpu_65c02_illegal_opcode11(self);
75 cpu_65c02_tsb(self, cpu_65c02_ea_zero_page(self));
78 cpu_65c02_ora(self, cpu_65c02_read_byte(self, cpu_65c02_ea_zero_page(self)));
81 cpu_65c02_asl(self, cpu_65c02_ea_zero_page(self));
84 cpu_65c02_rmb(self, 0, cpu_65c02_ea_zero_page(self));
87 cpu_65c02_ph(self, self->regs.byte.p);
90 cpu_65c02_ora(self, cpu_65c02_fetch_byte(self));
93 cpu_65c02_asl(self, CPU_65C02_EA_A);
96 cpu_65c02_illegal_opcode11(self);
99 cpu_65c02_tsb(self, cpu_65c02_ea_absolute(self));
102 cpu_65c02_ora(self, cpu_65c02_read_byte(self, cpu_65c02_ea_absolute(self)));
105 cpu_65c02_asl(self, cpu_65c02_ea_absolute(self));
109 int rvalue = cpu_65c02_read_byte(self, cpu_65c02_ea_zero_page(self));
110 cpu_65c02_bra(self, !(rvalue & 1), cpu_65c02_ea_relative(self));
114 cpu_65c02_bra(self, !self->regs.bit.nf, cpu_65c02_ea_relative(self));
117 cpu_65c02_ora(self, cpu_65c02_read_byte(self, cpu_65c02_ea_zero_page_indirect_indexed(self, self->regs.byte.y)));
120 cpu_65c02_ora(self, cpu_65c02_read_byte(self, cpu_65c02_ea_zero_page_indirect(self)));
123 cpu_65c02_illegal_opcode11(self);
126 cpu_65c02_trb(self, cpu_65c02_ea_zero_page(self));
129 cpu_65c02_ora(self, cpu_65c02_read_byte(self, cpu_65c02_ea_zero_page_indexed(self, self->regs.byte.x)));
132 cpu_65c02_asl(self, cpu_65c02_ea_zero_page_indexed(self, self->regs.byte.x));
135 cpu_65c02_rmb(self, 1, cpu_65c02_ea_zero_page(self));
138 cpu_65c02_cl(self, CPU_65C02_REG_P_BIT_C);
141 cpu_65c02_ora(self, cpu_65c02_read_byte(self, cpu_65c02_ea_absolute_indexed(self, self->regs.byte.y)));
144 cpu_65c02_inc(self, CPU_65C02_EA_A);
147 cpu_65c02_illegal_opcode11(self);
150 cpu_65c02_trb(self, cpu_65c02_ea_absolute(self));
153 cpu_65c02_ora(self, cpu_65c02_read_byte(self, cpu_65c02_ea_absolute_indexed(self, self->regs.byte.x)));
156 cpu_65c02_asl(self, cpu_65c02_ea_absolute_indexed(self, self->regs.byte.x));
160 int rvalue = cpu_65c02_read_byte(self, cpu_65c02_ea_zero_page(self));
161 cpu_65c02_bra(self, !((rvalue >> 1) & 1), cpu_65c02_ea_relative(self));
165 cpu_65c02_jsr(self, cpu_65c02_ea_absolute(self));
168 cpu_65c02_and(self, cpu_65c02_read_byte(self, cpu_65c02_ea_zero_page_indexed_indirect(self, self->regs.byte.x)));
171 cpu_65c02_illegal_opcode22(self);
174 cpu_65c02_illegal_opcode11(self);
177 cpu_65c02_bit(self, cpu_65c02_read_byte(self, cpu_65c02_ea_zero_page(self)));
180 cpu_65c02_and(self, cpu_65c02_read_byte(self, cpu_65c02_ea_zero_page(self)));
183 cpu_65c02_rol(self, cpu_65c02_ea_zero_page(self));
186 cpu_65c02_rmb(self, 2, cpu_65c02_ea_zero_page(self));
192 cpu_65c02_and(self, cpu_65c02_fetch_byte(self));
195 cpu_65c02_rol(self, CPU_65C02_EA_A);
198 cpu_65c02_illegal_opcode11(self);
201 cpu_65c02_bit(self, cpu_65c02_read_byte(self, cpu_65c02_ea_absolute(self)));
204 cpu_65c02_and(self, cpu_65c02_read_byte(self, cpu_65c02_ea_absolute(self)));
207 cpu_65c02_rol(self, cpu_65c02_ea_absolute(self));
211 int rvalue = cpu_65c02_read_byte(self, cpu_65c02_ea_zero_page(self));
212 cpu_65c02_bra(self, !((rvalue >> 2) & 1), cpu_65c02_ea_relative(self));
216 cpu_65c02_bra(self, self->regs.bit.nf, cpu_65c02_ea_relative(self));
219 cpu_65c02_and(self, cpu_65c02_read_byte(self, cpu_65c02_ea_zero_page_indirect_indexed(self, self->regs.byte.y)));
222 cpu_65c02_and(self, cpu_65c02_read_byte(self, cpu_65c02_ea_zero_page_indirect(self)));
225 cpu_65c02_illegal_opcode11(self);
228 cpu_65c02_bit(self, cpu_65c02_read_byte(self, cpu_65c02_ea_zero_page_indexed(self, self->regs.byte.x)));
231 cpu_65c02_and(self, cpu_65c02_read_byte(self, cpu_65c02_ea_zero_page_indexed(self, self->regs.byte.x)));
234 cpu_65c02_rol(self, cpu_65c02_ea_zero_page_indexed(self, self->regs.byte.x));
237 cpu_65c02_rmb(self, 3, cpu_65c02_ea_zero_page(self));
240 cpu_65c02_se(self, CPU_65C02_REG_P_BIT_C);
243 cpu_65c02_and(self, cpu_65c02_read_byte(self, cpu_65c02_ea_absolute_indexed(self, self->regs.byte.y)));
246 cpu_65c02_dec(self, CPU_65C02_EA_A);
249 cpu_65c02_illegal_opcode11(self);
252 cpu_65c02_bit(self, cpu_65c02_read_byte(self, cpu_65c02_ea_absolute_indexed(self, self->regs.byte.x)));
255 cpu_65c02_and(self, cpu_65c02_read_byte(self, cpu_65c02_ea_absolute_indexed(self, self->regs.byte.x)));
258 cpu_65c02_rol(self, cpu_65c02_ea_absolute_indexed(self, self->regs.byte.x));
262 int rvalue = cpu_65c02_read_byte(self, cpu_65c02_ea_zero_page(self));
263 cpu_65c02_bra(self, !((rvalue >> 3) & 1), cpu_65c02_ea_relative(self));
270 cpu_65c02_eor(self, cpu_65c02_read_byte(self, cpu_65c02_ea_zero_page_indexed_indirect(self, self->regs.byte.x)));
273 cpu_65c02_illegal_opcode22(self);
276 cpu_65c02_illegal_opcode11(self);
279 cpu_65c02_illegal_opcode23(self);
282 cpu_65c02_eor(self, cpu_65c02_read_byte(self, cpu_65c02_ea_zero_page(self)));
285 cpu_65c02_lsr(self, cpu_65c02_ea_zero_page(self));
288 cpu_65c02_rmb(self, 4, cpu_65c02_ea_zero_page(self));
291 cpu_65c02_ph(self, self->regs.byte.a);
294 cpu_65c02_eor(self, cpu_65c02_fetch_byte(self));
297 cpu_65c02_lsr(self, CPU_65C02_EA_A);
300 cpu_65c02_illegal_opcode11(self);
303 cpu_65c02_jmp(self, cpu_65c02_ea_absolute(self));
306 cpu_65c02_eor(self, cpu_65c02_read_byte(self, cpu_65c02_ea_absolute(self)));
309 cpu_65c02_lsr(self, cpu_65c02_ea_absolute(self));
313 int rvalue = cpu_65c02_read_byte(self, cpu_65c02_ea_zero_page(self));
314 cpu_65c02_bra(self, !((rvalue >> 4) & 1), cpu_65c02_ea_relative(self));
318 cpu_65c02_bra(self, !self->regs.bit.vf, cpu_65c02_ea_relative(self));
321 cpu_65c02_eor(self, cpu_65c02_read_byte(self, cpu_65c02_ea_zero_page_indirect_indexed(self, self->regs.byte.y)));
324 cpu_65c02_eor(self, cpu_65c02_read_byte(self, cpu_65c02_ea_zero_page_indirect(self)));
327 cpu_65c02_illegal_opcode11(self);
330 cpu_65c02_illegal_opcode24(self);
333 cpu_65c02_eor(self, cpu_65c02_read_byte(self, cpu_65c02_ea_zero_page_indexed(self, self->regs.byte.x)));
336 cpu_65c02_lsr(self, cpu_65c02_ea_zero_page_indexed(self, self->regs.byte.x));
339 cpu_65c02_rmb(self, 5, cpu_65c02_ea_zero_page(self));
342 cpu_65c02_cl(self, CPU_65C02_REG_P_BIT_I);
345 cpu_65c02_eor(self, cpu_65c02_read_byte(self, cpu_65c02_ea_absolute_indexed(self, self->regs.byte.y)));
348 cpu_65c02_ph(self, self->regs.byte.y);
351 cpu_65c02_illegal_opcode11(self);
354 cpu_65c02_illegal_opcode38(self);
357 cpu_65c02_eor(self, cpu_65c02_read_byte(self, cpu_65c02_ea_absolute_indexed(self, self->regs.byte.x)));
360 cpu_65c02_lsr(self, cpu_65c02_ea_absolute_indexed(self, self->regs.byte.x));
364 int rvalue = cpu_65c02_read_byte(self, cpu_65c02_ea_zero_page(self));
365 cpu_65c02_bra(self, !((rvalue >> 5) & 1), cpu_65c02_ea_relative(self));
372 cpu_65c02_adc(self, cpu_65c02_read_byte(self, cpu_65c02_ea_zero_page_indexed_indirect(self, self->regs.byte.x)));
375 cpu_65c02_illegal_opcode22(self);
378 cpu_65c02_illegal_opcode11(self);
381 cpu_65c02_st(self, 0, cpu_65c02_ea_zero_page(self));
384 cpu_65c02_adc(self, cpu_65c02_read_byte(self, cpu_65c02_ea_zero_page(self)));
387 cpu_65c02_ror(self, cpu_65c02_ea_zero_page(self));
390 cpu_65c02_rmb(self, 6, cpu_65c02_ea_zero_page(self));
393 cpu_65c02_pl(self, CPU_65C02_EA_A);
396 cpu_65c02_adc(self, cpu_65c02_fetch_byte(self));
399 cpu_65c02_ror(self, CPU_65C02_EA_A);
402 cpu_65c02_illegal_opcode11(self);
405 cpu_65c02_jmp(self, cpu_65c02_ea_absolute_indirect(self));
408 cpu_65c02_adc(self, cpu_65c02_read_byte(self, cpu_65c02_ea_absolute(self)));
411 cpu_65c02_ror(self, cpu_65c02_ea_absolute(self));
415 int rvalue = cpu_65c02_read_byte(self, cpu_65c02_ea_zero_page(self));
416 cpu_65c02_bra(self, !((rvalue >> 6) & 1), cpu_65c02_ea_relative(self));
420 cpu_65c02_bra(self, self->regs.bit.vf, cpu_65c02_ea_relative(self));
423 cpu_65c02_adc(self, cpu_65c02_read_byte(self, cpu_65c02_ea_zero_page_indirect_indexed(self, self->regs.byte.y)));
426 cpu_65c02_adc(self, cpu_65c02_read_byte(self, cpu_65c02_ea_zero_page_indirect(self)));
429 cpu_65c02_illegal_opcode11(self);
432 cpu_65c02_st(self, 0, cpu_65c02_ea_zero_page_indexed(self, self->regs.byte.x));
435 cpu_65c02_adc(self, cpu_65c02_read_byte(self, cpu_65c02_ea_zero_page_indexed(self, self->regs.byte.x)));
438 cpu_65c02_ror(self, cpu_65c02_ea_zero_page_indexed(self, self->regs.byte.x));
441 cpu_65c02_rmb(self, 7, cpu_65c02_ea_zero_page(self));
444 cpu_65c02_se(self, CPU_65C02_REG_P_BIT_I);
447 cpu_65c02_adc(self, cpu_65c02_read_byte(self, cpu_65c02_ea_absolute_indexed(self, self->regs.byte.y)));
450 cpu_65c02_pl(self, CPU_65C02_EA_Y);
453 cpu_65c02_illegal_opcode11(self);
456 cpu_65c02_jmp(self, cpu_65c02_ea_absolute_indexed_indirect(self, self->regs.byte.x));
459 cpu_65c02_adc(self, cpu_65c02_read_byte(self, cpu_65c02_ea_absolute_indexed(self, self->regs.byte.x)));
462 cpu_65c02_ror(self, cpu_65c02_ea_absolute_indexed(self, self->regs.byte.x));
466 int rvalue = cpu_65c02_read_byte(self, cpu_65c02_ea_zero_page(self));
467 cpu_65c02_bra(self, !((rvalue >> 7) & 1), cpu_65c02_ea_relative(self));
471 cpu_65c02_bra(self, true, cpu_65c02_ea_relative(self));
474 cpu_65c02_st(self, self->regs.byte.a, cpu_65c02_ea_zero_page_indexed_indirect(self, self->regs.byte.x));
477 cpu_65c02_illegal_opcode22(self);
480 cpu_65c02_illegal_opcode11(self);
483 cpu_65c02_st(self, self->regs.byte.y, cpu_65c02_ea_zero_page(self));
486 cpu_65c02_st(self, self->regs.byte.a, cpu_65c02_ea_zero_page(self));
489 cpu_65c02_st(self, self->regs.byte.x, cpu_65c02_ea_zero_page(self));
492 cpu_65c02_smb(self, 0, cpu_65c02_ea_zero_page(self));
495 cpu_65c02_dec(self, CPU_65C02_EA_Y);
498 cpu_65c02_bit_imm(self, cpu_65c02_fetch_byte(self));
501 cpu_65c02_ld(self, CPU_65C02_EA_A, self->regs.byte.x);
504 cpu_65c02_illegal_opcode11(self);
507 cpu_65c02_st(self, self->regs.byte.y, cpu_65c02_ea_absolute(self));
510 cpu_65c02_st(self, self->regs.byte.a, cpu_65c02_ea_absolute(self));
513 cpu_65c02_st(self, self->regs.byte.x, cpu_65c02_ea_absolute(self));
517 int rvalue = cpu_65c02_read_byte(self, cpu_65c02_ea_zero_page(self));
518 cpu_65c02_bra(self, rvalue & 1, cpu_65c02_ea_relative(self));
522 cpu_65c02_bra(self, !self->regs.bit.cf, cpu_65c02_ea_relative(self));
525 cpu_65c02_st(self, self->regs.byte.a, cpu_65c02_ea_zero_page_indirect_indexed(self, self->regs.byte.y));
528 cpu_65c02_st(self, self->regs.byte.a, cpu_65c02_ea_zero_page_indirect(self));
531 cpu_65c02_illegal_opcode11(self);
534 cpu_65c02_st(self, self->regs.byte.y, cpu_65c02_ea_zero_page_indexed(self, self->regs.byte.x));
537 cpu_65c02_st(self, self->regs.byte.a, cpu_65c02_ea_zero_page_indexed(self, self->regs.byte.x));
540 cpu_65c02_st(self, self->regs.byte.x, cpu_65c02_ea_zero_page_indexed(self, self->regs.byte.y));
543 cpu_65c02_smb(self, 1, cpu_65c02_ea_zero_page(self));
546 cpu_65c02_ld(self, CPU_65C02_EA_A, self->regs.byte.y);
549 cpu_65c02_st(self, self->regs.byte.a, cpu_65c02_ea_absolute_indexed(self, self->regs.byte.y));
552 cpu_65c02_st(self, self->regs.byte.x, CPU_65C02_EA_S);
555 cpu_65c02_illegal_opcode11(self);
558 cpu_65c02_st(self, 0, cpu_65c02_ea_absolute(self));
561 cpu_65c02_st(self, self->regs.byte.a, cpu_65c02_ea_absolute_indexed(self, self->regs.byte.x));
564 cpu_65c02_st(self, 0, cpu_65c02_ea_absolute_indexed(self, self->regs.byte.x));
568 int rvalue = cpu_65c02_read_byte(self, cpu_65c02_ea_zero_page(self));
569 cpu_65c02_bra(self, (rvalue >> 1) & 1, cpu_65c02_ea_relative(self));
573 cpu_65c02_ld(self, CPU_65C02_EA_Y, cpu_65c02_fetch_byte(self));
576 cpu_65c02_ld(self, CPU_65C02_EA_A, cpu_65c02_read_byte(self, cpu_65c02_ea_zero_page_indexed_indirect(self, self->regs.byte.x)));
579 cpu_65c02_ld(self, CPU_65C02_EA_X, cpu_65c02_fetch_byte(self));
582 cpu_65c02_illegal_opcode11(self);
585 cpu_65c02_ld(self, CPU_65C02_EA_Y, cpu_65c02_read_byte(self, cpu_65c02_ea_zero_page(self)));
588 cpu_65c02_ld(self, CPU_65C02_EA_A, cpu_65c02_read_byte(self, cpu_65c02_ea_zero_page(self)));
591 cpu_65c02_ld(self, CPU_65C02_EA_X, cpu_65c02_read_byte(self, cpu_65c02_ea_zero_page(self)));
594 cpu_65c02_smb(self, 2, cpu_65c02_ea_zero_page(self));
597 cpu_65c02_ld(self, CPU_65C02_EA_Y, self->regs.byte.a);
600 cpu_65c02_ld(self, CPU_65C02_EA_A, cpu_65c02_fetch_byte(self));
603 cpu_65c02_ld(self, CPU_65C02_EA_X, self->regs.byte.a);
606 cpu_65c02_illegal_opcode11(self);
609 cpu_65c02_ld(self, CPU_65C02_EA_Y, cpu_65c02_read_byte(self, cpu_65c02_ea_absolute(self)));
612 cpu_65c02_ld(self, CPU_65C02_EA_A, cpu_65c02_read_byte(self, cpu_65c02_ea_absolute(self)));
615 cpu_65c02_ld(self, CPU_65C02_EA_X, cpu_65c02_read_byte(self, cpu_65c02_ea_absolute(self)));
619 int rvalue = cpu_65c02_read_byte(self, cpu_65c02_ea_zero_page(self));
620 cpu_65c02_bra(self, (rvalue >> 2) & 1, cpu_65c02_ea_relative(self));
624 cpu_65c02_bra(self, self->regs.bit.cf, cpu_65c02_ea_relative(self));
627 cpu_65c02_ld(self, CPU_65C02_EA_A, cpu_65c02_read_byte(self, cpu_65c02_ea_zero_page_indirect_indexed(self, self->regs.byte.y)));
630 cpu_65c02_ld(self, CPU_65C02_EA_A, cpu_65c02_read_byte(self, cpu_65c02_ea_zero_page_indirect(self)));
633 cpu_65c02_illegal_opcode11(self);
636 cpu_65c02_ld(self, CPU_65C02_EA_Y, cpu_65c02_read_byte(self, cpu_65c02_ea_zero_page_indexed(self, self->regs.byte.x)));
639 cpu_65c02_ld(self, CPU_65C02_EA_A, cpu_65c02_read_byte(self, cpu_65c02_ea_zero_page_indexed(self, self->regs.byte.x)));
642 cpu_65c02_ld(self, CPU_65C02_EA_X, cpu_65c02_read_byte(self, cpu_65c02_ea_zero_page_indexed(self, self->regs.byte.y)));
645 cpu_65c02_smb(self, 3, cpu_65c02_ea_zero_page(self));
648 cpu_65c02_cl(self, CPU_65C02_REG_P_BIT_V);
651 cpu_65c02_ld(self, CPU_65C02_EA_A, cpu_65c02_read_byte(self, cpu_65c02_ea_absolute_indexed(self, self->regs.byte.y)));
654 cpu_65c02_ld(self, CPU_65C02_EA_X, self->regs.byte.s);
657 cpu_65c02_illegal_opcode11(self);
660 cpu_65c02_ld(self, CPU_65C02_EA_Y, cpu_65c02_read_byte(self, cpu_65c02_ea_absolute_indexed(self, self->regs.byte.x)));
663 cpu_65c02_ld(self, CPU_65C02_EA_A, cpu_65c02_read_byte(self, cpu_65c02_ea_absolute_indexed(self, self->regs.byte.x)));
666 cpu_65c02_ld(self, CPU_65C02_EA_X, cpu_65c02_read_byte(self, cpu_65c02_ea_absolute_indexed(self, self->regs.byte.y)));
670 int rvalue = cpu_65c02_read_byte(self, cpu_65c02_ea_zero_page(self));
671 cpu_65c02_bra(self, (rvalue >> 3) & 1, cpu_65c02_ea_relative(self));
675 cpu_65c02_cmp(self, self->regs.byte.y, cpu_65c02_fetch_byte(self));
678 cpu_65c02_cmp(self, self->regs.byte.a, cpu_65c02_read_byte(self, cpu_65c02_ea_zero_page_indexed_indirect(self, self->regs.byte.x)));
681 cpu_65c02_illegal_opcode22(self);
684 cpu_65c02_illegal_opcode11(self);
687 cpu_65c02_cmp(self, self->regs.byte.y, cpu_65c02_read_byte(self, cpu_65c02_ea_zero_page(self)));
690 cpu_65c02_cmp(self, self->regs.byte.a, cpu_65c02_read_byte(self, cpu_65c02_ea_zero_page(self)));
693 cpu_65c02_dec(self, cpu_65c02_ea_zero_page(self));
696 cpu_65c02_smb(self, 4, cpu_65c02_ea_zero_page(self));
699 cpu_65c02_inc(self, CPU_65C02_EA_Y);
702 cpu_65c02_cmp(self, self->regs.byte.a, cpu_65c02_fetch_byte(self));
705 cpu_65c02_dec(self, CPU_65C02_EA_X);
711 cpu_65c02_cmp(self, self->regs.byte.y, cpu_65c02_read_byte(self, cpu_65c02_ea_absolute(self)));
714 cpu_65c02_cmp(self, self->regs.byte.a, cpu_65c02_read_byte(self, cpu_65c02_ea_absolute(self)));
717 cpu_65c02_dec(self, cpu_65c02_ea_absolute(self));
721 int rvalue = cpu_65c02_read_byte(self, cpu_65c02_ea_zero_page(self));
722 cpu_65c02_bra(self, (rvalue >> 4) & 1, cpu_65c02_ea_relative(self));
726 cpu_65c02_bra(self, !self->regs.bit.zf, cpu_65c02_ea_relative(self));
729 cpu_65c02_cmp(self, self->regs.byte.a, cpu_65c02_read_byte(self, cpu_65c02_ea_zero_page_indirect_indexed(self, self->regs.byte.y)));
732 cpu_65c02_cmp(self, self->regs.byte.a, cpu_65c02_read_byte(self, cpu_65c02_ea_zero_page_indirect(self)));
735 cpu_65c02_illegal_opcode11(self);
738 cpu_65c02_illegal_opcode24(self);
741 cpu_65c02_cmp(self, self->regs.byte.a, cpu_65c02_read_byte(self, cpu_65c02_ea_zero_page_indexed(self, self->regs.byte.x)));
744 cpu_65c02_dec(self, cpu_65c02_ea_zero_page_indexed(self, self->regs.byte.x));
747 cpu_65c02_smb(self, 5, cpu_65c02_ea_zero_page(self));
750 cpu_65c02_cl(self, CPU_65C02_REG_P_BIT_D);
753 cpu_65c02_cmp(self, self->regs.byte.a, cpu_65c02_read_byte(self, cpu_65c02_ea_absolute_indexed(self, self->regs.byte.y)));
756 cpu_65c02_ph(self, self->regs.byte.x);
759 cpu_65c02_illegal_opcode11(self);
762 cpu_65c02_illegal_opcode34(self);
765 cpu_65c02_cmp(self, self->regs.byte.a, cpu_65c02_read_byte(self, cpu_65c02_ea_absolute_indexed(self, self->regs.byte.x)));
768 cpu_65c02_dec(self, cpu_65c02_ea_absolute_indexed(self, self->regs.byte.x));
772 int rvalue = cpu_65c02_read_byte(self, cpu_65c02_ea_zero_page(self));
773 cpu_65c02_bra(self, (rvalue >> 5) & 1, cpu_65c02_ea_relative(self));
777 cpu_65c02_cmp(self, self->regs.byte.x, cpu_65c02_fetch_byte(self));
780 cpu_65c02_sbc(self, cpu_65c02_read_byte(self, cpu_65c02_ea_zero_page_indexed_indirect(self, self->regs.byte.x)));
783 cpu_65c02_illegal_opcode22(self);
786 cpu_65c02_illegal_opcode11(self);
789 cpu_65c02_cmp(self, self->regs.byte.x, cpu_65c02_read_byte(self, cpu_65c02_ea_zero_page(self)));
792 cpu_65c02_sbc(self, cpu_65c02_read_byte(self, cpu_65c02_ea_zero_page(self)));
795 cpu_65c02_inc(self, cpu_65c02_ea_zero_page(self));
798 cpu_65c02_smb(self, 6, cpu_65c02_ea_zero_page(self));
801 cpu_65c02_inc(self, CPU_65C02_EA_X);
804 cpu_65c02_sbc(self, cpu_65c02_fetch_byte(self));
810 cpu_65c02_illegal_opcode11(self);
813 cpu_65c02_cmp(self, self->regs.byte.x, cpu_65c02_read_byte(self, cpu_65c02_ea_absolute(self)));
816 cpu_65c02_sbc(self, cpu_65c02_read_byte(self, cpu_65c02_ea_absolute(self)));
819 cpu_65c02_inc(self, cpu_65c02_ea_absolute(self));
823 int rvalue = cpu_65c02_read_byte(self, cpu_65c02_ea_zero_page(self));
824 cpu_65c02_bra(self, (rvalue >> 6) & 1, cpu_65c02_ea_relative(self));
828 cpu_65c02_bra(self, self->regs.bit.zf, cpu_65c02_ea_relative(self));
831 cpu_65c02_sbc(self, cpu_65c02_read_byte(self, cpu_65c02_ea_zero_page_indirect_indexed(self, self->regs.byte.y)));
834 cpu_65c02_sbc(self, cpu_65c02_read_byte(self, cpu_65c02_ea_zero_page_indirect(self)));
837 cpu_65c02_illegal_opcode11(self);
840 cpu_65c02_illegal_opcode24(self);
843 cpu_65c02_sbc(self, cpu_65c02_read_byte(self, cpu_65c02_ea_zero_page_indexed(self, self->regs.byte.x)));
846 cpu_65c02_inc(self, cpu_65c02_ea_zero_page_indexed(self, self->regs.byte.x));
849 cpu_65c02_smb(self, 7, cpu_65c02_ea_zero_page(self));
852 cpu_65c02_se(self, CPU_65C02_REG_P_BIT_D);
855 cpu_65c02_sbc(self, cpu_65c02_read_byte(self, cpu_65c02_ea_absolute_indexed(self, self->regs.byte.y)));
858 cpu_65c02_pl(self, CPU_65C02_EA_X);
861 cpu_65c02_illegal_opcode11(self);
864 cpu_65c02_illegal_opcode34(self);
867 cpu_65c02_sbc(self, cpu_65c02_read_byte(self, cpu_65c02_ea_absolute_indexed(self, self->regs.byte.x)));
870 cpu_65c02_inc(self, cpu_65c02_ea_absolute_indexed(self, self->regs.byte.x));
874 int rvalue = cpu_65c02_read_byte(self, cpu_65c02_ea_zero_page(self));
875 cpu_65c02_bra(self, (rvalue >> 7) & 1, cpu_65c02_ea_relative(self));