From ee8a16a5ba0c637f8e4f367084ab3594ef309855 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rados=C5=82aw=20Kujawa?= Date: Mon, 23 Jan 2017 14:53:05 +0100 Subject: [PATCH] Add ORA and EOR emulation. --- src/65c02isa.csv | 34 +++++++++++++++++----------------- src/emulation.c | 20 ++++++++++++++++++++ 2 files changed, 37 insertions(+), 17 deletions(-) diff --git a/src/65c02isa.csv b/src/65c02isa.csv index ad0198f..87cef11 100644 --- a/src/65c02isa.csv +++ b/src/65c02isa.csv @@ -1,14 +1,14 @@ opcode_id,mnemonic,addressing,size,emulation OP_BRK,"brk",IMPLIED,1,NULL -OP_ORA_IZPX,"ora",IZPX,1,NULL +OP_ORA_IZPX,"ora",IZPX,1,emul_ora OP_NOPI_3,"nop",IMMEDIATE,2,NULL OP_NOPI_4,"nop",IMPLIED,1,NULL OP_TSB_ZP,"tsb",ZP,2,NULL -OP_ORA_ZP,"ora",ZP,2,NULL +OP_ORA_ZP,"ora",ZP,2,emul_ora OP_ASL_ZP,"asl",ZP,2,NULL OP_RMB0_ZP,"rmb0",ZP,2,NULL OP_PHP,"php",IMPLIED,1,emul_php -OP_ORA_IMM,"ora",IMMEDIATE,2,NULL +OP_ORA_IMM,"ora",IMMEDIATE,2,emul_ora OP_ASL,"asl",ACCUMULATOR,1,NULL OP_NOPI_C,"nop",IMPLIED,1,NULL OP_TSB_ABS,"tsb",ABSOLUTE,3,NULL @@ -16,19 +16,19 @@ OP_ORA_ABS,"abs",ABSOLUTE,3,NULL OP_ASL_ABS,"asl",ABSOLUTE,3,NULL OP_BBR0_REL,"bbr0",ZPR,2,NULL OP_BPL_REL,"bpl",RELATIVE,2,NULL -OP_ORA_IZPY,"ora",IZPY,2,NULL -OP_ORA_IZP,"ora",IZP,2,NULL +OP_ORA_IZPY,"ora",IZPY,2,emul_ora +OP_ORA_IZP,"ora",IZP,2,emul_ora OP_NOPI_14,"nop",IMPLIED,1,NULL OP_TRB_ZP,"trb",ZP,2,NULL -OP_ORA_ZPX,"ora",ZPX,2,NULL +OP_ORA_ZPX,"ora",ZPX,2,emul_ora OP_ASL_ZPX,"asl",ZPX,2,NULL OP_RMB1_ZP,"rmb1",ZP,1,NULL OP_CLC,"clc",IMPLIED,1,emul_clc -OP_ORA_ABSY,"ora",ABSOLUTEY,3,NULL +OP_ORA_ABSY,"ora",ABSOLUTEY,3,emul_ora OP_INC,"inc",ACCUMULATOR,1,NULL OP_NOPI_1C,"nop",IMPLIED,1,NULL OP_TRB_ABS,"trb",ABSOLUTE,3,NULL -OP_ORA_ABSX,"ora",ABSOLUTEX,3,NULL +OP_ORA_ABSX,"ora",ABSOLUTEX,3,emul_ora OP_ASL_ABSX,"asl",ABSOLUTEX,3,NULL OP_BBR1_REL,"bbr1",ZPR,2,NULL OP_JSR,"jsr",ABSOLUTE,3,NULL @@ -64,35 +64,35 @@ OP_AND_ABSX,"and",ABSOLUTEX,3,NULL OP_ROL_ABSX,"rol",ABSOLUTEX,3,NULL OP_BBR3_REL,"bbr3",ZPR,2,NULL OP_RTI,"rti",IMPLIED,1,NULL -OP_EOR_IZPX,"eor",IZPX,2,NULL +OP_EOR_IZPX,"eor",IZPX,2,emul_eor OP_NOPI_43,"nop",IMMEDIATE,2,NULL OP_NOPI_44,"nop",IMPLIED,1,NULL OP_NOPI_45,"nop",ZP,2,NULL -OP_EOR_ZP,"eor",ZP,2,NULL +OP_EOR_ZP,"eor",ZP,2,emul_eor OP_LSR_ZP,"lsr",ZP,2,NULL OP_RMB4_ZP,"rmb4",ZP,2,NULL OP_PHA,"pha",IMPLIED,1,emul_pha -OP_EOR_IMM,"eor",IMMEDIATE,2,NULL +OP_EOR_IMM,"eor",IMMEDIATE,2,emul_eor OP_LSR,"lsr",ACCUMULATOR,1,NULL OP_NOPI_4C,"nop",IMPLIED,1,NULL OP_JMP_ABS,"jmp",ABSOLUTE,3,NULL -OP_EOR_ABS,"eor",ABSOLUTE,3,NULL +OP_EOR_ABS,"eor",ABSOLUTE,3,emul_eor OP_LSR_ABS,"lsr",ABSOLUTE,3,NULL OP_BBR4_REL,"bbr4",ZPR,2,NULL OP_BVC_REL,"bvc",RELATIVE,2,NULL -OP_EOR_IZPY,"eor",IZPY,2,NULL -OP_EOR_IZP,"eor",IZP,2,NULL +OP_EOR_IZPY,"eor",IZPY,2,emul_eor +OP_EOR_IZP,"eor",IZP,2,emul_eor OP_NOPI_54,"nop",IMPLIED,1,NULL OP_NOPI_55,"nop",ZPX,2,NULL -OP_EOR_ZPX,"eor",ZPX,2,NULL +OP_EOR_ZPX,"eor",ZPX,2,emul_eor OP_LSR_ZPX,"lsr",ZPX,2,NULL OP_RMB5_ZP,"rmb5",ZP,2,NULL OP_CLI,"cli",IMPLIED,1,NULL -OP_EOR_ABSY,"eor",ABSOLUTEY,3,NULL +OP_EOR_ABSY,"eor",ABSOLUTEY,3,emul_eor OP_PHY,"phy",IMPLIED,1,NULL OP_NOPI_5C,"nop",IMPLIED,1,NULL OP_NOPI_5D,"nop",ABSOLUTE,3,NULL -OP_EOR_ABSX,"eor",ABSOLUTEX,3,NULL +OP_EOR_ABSX,"eor",ABSOLUTEX,3,emul_eor OP_LSR_ABSX,"lsr",ABSOLUTEX,3,NULL OP_BBR5_REL,"bbr5",ZPR,2,NULL OP_RTS,"rts",IMPLIED,1,NULL diff --git a/src/emulation.c b/src/emulation.c index 0430cb5..4083b15 100644 --- a/src/emulation.c +++ b/src/emulation.c @@ -39,6 +39,16 @@ emul_dey(rk65c02emu_t *e, void *id, instruction_t *i) instruction_status_adjust_negative(e, e->regs.Y); } +/* EOR - logical exclusive OR */ +void +emul_eor(rk65c02emu_t *e, void *id, instruction_t *i) +{ + e->regs.A ^= instruction_data_read_1(e, (instrdef_t *) id, i); + + instruction_status_adjust_zero(e, e->regs.A); + instruction_status_adjust_negative(e, e->regs.A); +} + /* INX - increment X */ void emul_inx(rk65c02emu_t *e, void *id, instruction_t *i) @@ -95,6 +105,16 @@ emul_nop(rk65c02emu_t *e, void *id, instruction_t *i) { } +/* ORA - logical inclusive OR */ +void +emul_ora(rk65c02emu_t *e, void *id, instruction_t *i) +{ + e->regs.A |= instruction_data_read_1(e, (instrdef_t *) id, i); + + instruction_status_adjust_zero(e, e->regs.A); + instruction_status_adjust_negative(e, e->regs.A); +} + /* PHA - push accumulator to stack */ void emul_pha(rk65c02emu_t *e, void *id, instruction_t *i)