1
0
mirror of https://github.com/rkujawa/rk65c02.git synced 2024-12-04 04:51:27 +00:00

Add CLI and SEI emulation and test case.

This commit is contained in:
Radosław Kujawa 2017-01-28 11:19:34 +01:00
parent ee66f9c78c
commit f3205e7272
5 changed files with 42 additions and 2 deletions

View File

@ -87,7 +87,7 @@ OP_NOPI_55,"nop",ZPX,2,NULL,false
OP_EOR_ZPX,"eor",ZPX,2,emul_eor,false
OP_LSR_ZPX,"lsr",ZPX,2,emul_lsr,false
OP_RMB5_ZP,"rmb5",ZP,2,emul_rmb5,false
OP_CLI,"cli",IMPLIED,1,NULL,false
OP_CLI,"cli",IMPLIED,1,emul_cli,false
OP_EOR_ABSY,"eor",ABSOLUTEY,3,emul_eor,false
OP_PHY,"phy",IMPLIED,1,emul_phy,false
OP_NOPI_5C,"nop",IMPLIED,1,NULL,false
@ -119,7 +119,7 @@ OP_STZ_ZPX,"stz",ZPX,2,emul_stz,false
OP_ADC_ZPX,"adc",ZPX,2,NULL,false
OP_ROR_ZPX,"ror",ZPX,2,emul_ror,false
OP_RMB7_ZP,"rmb7",ZP,2,emul_rmb7,false
OP_SEI,"sei",IMPLIED,1,NULL,false
OP_SEI,"sei",IMPLIED,1,emul_sei,false
OP_ADC_ABSY,"adc",ABSOLUTEY,3,NULL,false
OP_PLY,"ply",IMPLIED,1,emul_ply,false
OP_NOPI_7C,"nop",IMPLIED,1,NULL,false

1 opcode_id mnemonic addressing size emulation modify_pc
87 OP_EOR_ZPX eor ZPX 2 emul_eor false
88 OP_LSR_ZPX lsr ZPX 2 emul_lsr false
89 OP_RMB5_ZP rmb5 ZP 2 emul_rmb5 false
90 OP_CLI cli IMPLIED 1 NULL emul_cli false
91 OP_EOR_ABSY eor ABSOLUTEY 3 emul_eor false
92 OP_PHY phy IMPLIED 1 emul_phy false
93 OP_NOPI_5C nop IMPLIED 1 NULL false
119 OP_ADC_ZPX adc ZPX 2 NULL false
120 OP_ROR_ZPX ror ZPX 2 emul_ror false
121 OP_RMB7_ZP rmb7 ZP 2 emul_rmb7 false
122 OP_SEI sei IMPLIED 1 NULL emul_sei false
123 OP_ADC_ABSY adc ABSOLUTEY 3 NULL false
124 OP_PLY ply IMPLIED 1 emul_ply false
125 OP_NOPI_7C nop IMPLIED 1 NULL false

View File

@ -72,6 +72,13 @@ emul_clc(rk65c02emu_t *e, void *id, instruction_t *i)
e->regs.P &= ~P_CARRY;
}
/* CLI - clear interrupt disable flag */
void
emul_cli(rk65c02emu_t *e, void *id, instruction_t *i)
{
e->regs.P &= ~P_IRQ_DISABLE;
}
/* CLV - clear overflow flag */
void
emul_clv(rk65c02emu_t *e, void *id, instruction_t *i)
@ -446,6 +453,13 @@ emul_sec(rk65c02emu_t *e, void *id, instruction_t *i)
e->regs.P |= P_CARRY;
}
/* SEI - set the interrupt disable flag */
void
emul_sei(rk65c02emu_t *e, void *id, instruction_t *i)
{
e->regs.P |= P_IRQ_DISABLE;
}
/* STP - stop the processor */
void
emul_stp(rk65c02emu_t *e, void *id, instruction_t *i)

View File

@ -324,6 +324,25 @@ ATF_TC_BODY(emul_clc_sec, tc)
bus_finish(&b);
}
ATF_TC_WITHOUT_HEAD(emul_cli_sei);
ATF_TC_BODY(emul_cli_sei, tc)
{
rk65c02emu_t e;
bus_t b;
b = bus_init();
e = rk65c02_init(&b);
/* CLI */
ATF_REQUIRE(rom_start(&e, "test_emulation_cli.rom", tc));
ATF_CHECK(!(e.regs.P & P_IRQ_DISABLE));
/* SEI */
ATF_REQUIRE(rom_start(&e, "test_emulation_sei.rom", tc));
ATF_CHECK(e.regs.P & P_IRQ_DISABLE);
bus_finish(&b);
}
ATF_TC_WITHOUT_HEAD(emul_and);
ATF_TC_BODY(emul_and, tc)
{
@ -682,6 +701,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_cli_sei);
ATF_TP_ADD_TC(tp, emul_clv);
ATF_TP_ADD_TC(tp, emul_inc);
ATF_TP_ADD_TC(tp, emul_inx_iny);

View File

@ -0,0 +1,3 @@
start: cli
stp

View File

@ -0,0 +1,3 @@
start: sei
stp