diff --git a/src/65c02isa.csv b/src/65c02isa.csv index 93fa44a..6bca62f 100644 --- a/src/65c02isa.csv +++ b/src/65c02isa.csv @@ -183,7 +183,7 @@ OP_LDY_ZPX,"ldy",ZPX,2,emul_ldy,false OP_LDA_ZPX,"lda",ZPX,2,emul_lda,false OP_LDX_ZPY,"ldx",ZPY,1,emul_ldx,false OP_SMB3_ZP,"smb3",ZP,2,NULL,false -OP_CLV,"clv",IMPLIED,1,NULL,false +OP_CLV,"clv",IMPLIED,1,emul_clv,false OP_LDA_ABSY,"lda",ABSOLUTEY,3,emul_lda,false OP_TSX,"tsx",IMPLIED,1,emul_tsx,false OP_NOPI_BC,"nop",IMPLIED,1,NULL,false diff --git a/src/emulation.c b/src/emulation.c index 3eb4253..e0bb186 100644 --- a/src/emulation.c +++ b/src/emulation.c @@ -72,6 +72,13 @@ emul_clc(rk65c02emu_t *e, void *id, instruction_t *i) e->regs.P &= ~P_CARRY; } +/* CLV - clear overflow flag */ +void +emul_clv(rk65c02emu_t *e, void *id, instruction_t *i) +{ + e->regs.P &= ~P_SIGN_OVERFLOW; +} + /* DEC - decrement memory location/acumulator */ void emul_dec(rk65c02emu_t *e, void *id, instruction_t *i) diff --git a/test/test_emulation.c b/test/test_emulation.c index c1d4f48..202eeda 100644 --- a/test/test_emulation.c +++ b/test/test_emulation.c @@ -287,6 +287,23 @@ ATF_TC_BODY(emul_stz, tc) bus_finish(&b); } +ATF_TC_WITHOUT_HEAD(emul_clv); +ATF_TC_BODY(emul_clv, tc) +{ + rk65c02emu_t e; + bus_t b; + + b = bus_init(); + e = rk65c02_init(&b); + + e.regs.P |= P_SIGN_OVERFLOW; + /* CLV */ + ATF_REQUIRE(rom_start(&e, "test_emulation_clv.rom", tc)); + ATF_CHECK(e.regs.P ^ P_SIGN_OVERFLOW); + + bus_finish(&b); +} + ATF_TC_WITHOUT_HEAD(emul_clc_sec); ATF_TC_BODY(emul_clc_sec, tc) { @@ -665,6 +682,7 @@ ATF_TP_ADD_TCS(tp) ATF_TP_ADD_TC(tp, emul_dec); ATF_TP_ADD_TC(tp, emul_dex_dey); ATF_TP_ADD_TC(tp, emul_clc_sec); + ATF_TP_ADD_TC(tp, emul_clv); ATF_TP_ADD_TC(tp, emul_inc); ATF_TP_ADD_TC(tp, emul_inx_iny); ATF_TP_ADD_TC(tp, emul_jmp); diff --git a/test/test_emulation_clv.s b/test/test_emulation_clv.s new file mode 100644 index 0000000..f0c298a --- /dev/null +++ b/test/test_emulation_clv.s @@ -0,0 +1,3 @@ +start: clv + stp +