1
0
mirror of https://github.com/rkujawa/rk65c02.git synced 2024-12-22 15:31:12 +00:00

Add test cases for branches.

This commit is contained in:
Radosław Kujawa 2017-01-29 21:18:01 +01:00
parent 3c5162b0b9
commit bf01ceb4cf
10 changed files with 207 additions and 0 deletions

View File

@ -891,10 +891,128 @@ ATF_TC_BODY(emul_jsr_rts, tc)
}
ATF_TC_WITHOUT_HEAD(emul_branch);
ATF_TC_BODY(emul_branch, tc)
{
rk65c02emu_t e;
bus_t b;
b = bus_init();
e = rk65c02_init(&b);
/* BCC */
e.regs.PC = ROM_LOAD_ADDR;
ATF_REQUIRE(bus_load_file(&b, ROM_LOAD_ADDR,
rom_path("test_emulation_bcc.rom", tc)));
e.regs.P &= ~P_CARRY;
rk65c02_step(&e, 2);
ATF_CHECK(e.regs.PC = 0xC005);
rk65c02_step(&e, 2);
ATF_CHECK(e.regs.PC = 0xC003);
rk65c02_start(&e);
/* BCS */
e.regs.PC = ROM_LOAD_ADDR;
ATF_REQUIRE(bus_load_file(&b, ROM_LOAD_ADDR,
rom_path("test_emulation_bcs.rom", tc)));
e.regs.P |= P_CARRY;
rk65c02_step(&e, 2);
ATF_CHECK(e.regs.PC = 0xC005);
rk65c02_step(&e, 2);
ATF_CHECK(e.regs.PC = 0xC003);
rk65c02_start(&e);
/* BRA */
e.regs.PC = ROM_LOAD_ADDR;
ATF_REQUIRE(bus_load_file(&b, ROM_LOAD_ADDR,
rom_path("test_emulation_bra.rom", tc)));
rk65c02_step(&e, 1);
ATF_CHECK(e.regs.PC = 0xC004);
rk65c02_start(&e);
/* BEQ */
e.regs.PC = ROM_LOAD_ADDR;
ATF_REQUIRE(bus_load_file(&b, ROM_LOAD_ADDR,
rom_path("test_emulation_beq.rom", tc)));
e.regs.P |= P_ZERO;
rk65c02_step(&e, 2);
ATF_CHECK(e.regs.PC = 0xC005);
rk65c02_step(&e, 2);
ATF_CHECK(e.regs.PC = 0xC003);
rk65c02_start(&e);
/* BMI */
e.regs.PC = ROM_LOAD_ADDR;
ATF_REQUIRE(bus_load_file(&b, ROM_LOAD_ADDR,
rom_path("test_emulation_bmi.rom", tc)));
e.regs.P |= P_NEGATIVE;
rk65c02_step(&e, 2);
ATF_CHECK(e.regs.PC = 0xC005);
rk65c02_step(&e, 2);
ATF_CHECK(e.regs.PC = 0xC003);
rk65c02_start(&e);
/* BNE */
e.regs.PC = ROM_LOAD_ADDR;
ATF_REQUIRE(bus_load_file(&b, ROM_LOAD_ADDR,
rom_path("test_emulation_bne.rom", tc)));
e.regs.P |= P_NEGATIVE;
rk65c02_step(&e, 2);
ATF_CHECK(e.regs.PC = 0xC005);
rk65c02_step(&e, 2);
ATF_CHECK(e.regs.PC = 0xC003);
rk65c02_start(&e);
/* BPL */
e.regs.PC = ROM_LOAD_ADDR;
ATF_REQUIRE(bus_load_file(&b, ROM_LOAD_ADDR,
rom_path("test_emulation_bpl.rom", tc)));
e.regs.P &= ~P_NEGATIVE;
rk65c02_step(&e, 2);
ATF_CHECK(e.regs.PC = 0xC005);
rk65c02_step(&e, 2);
ATF_CHECK(e.regs.PC = 0xC003);
rk65c02_start(&e);
/* BVC */
e.regs.PC = ROM_LOAD_ADDR;
ATF_REQUIRE(bus_load_file(&b, ROM_LOAD_ADDR,
rom_path("test_emulation_bvc.rom", tc)));
e.regs.P &= ~P_SIGN_OVERFLOW;
rk65c02_step(&e, 2);
ATF_CHECK(e.regs.PC = 0xC005);
rk65c02_step(&e, 2);
ATF_CHECK(e.regs.PC = 0xC003);
rk65c02_start(&e);
/* BVS */
e.regs.PC = ROM_LOAD_ADDR;
ATF_REQUIRE(bus_load_file(&b, ROM_LOAD_ADDR,
rom_path("test_emulation_bvs.rom", tc)));
e.regs.P |= P_SIGN_OVERFLOW;
rk65c02_step(&e, 2);
ATF_CHECK(e.regs.PC = 0xC005);
rk65c02_step(&e, 2);
ATF_CHECK(e.regs.PC = 0xC003);
rk65c02_start(&e);
}
ATF_TP_ADD_TCS(tp)
{
ATF_TP_ADD_TC(tp, emul_and);
ATF_TP_ADD_TC(tp, emul_bit);
ATF_TP_ADD_TC(tp, emul_branch);
ATF_TP_ADD_TC(tp, emul_cmp);
ATF_TP_ADD_TC(tp, emul_cpx);
ATF_TP_ADD_TC(tp, emul_cpy);

10
test/test_emulation_bcc.s Normal file
View File

@ -0,0 +1,10 @@
.org 0xC000
start: nop
bcc foo2
foo: nop
stp
foo2: nop
bcc foo
nop

10
test/test_emulation_bcs.s Normal file
View File

@ -0,0 +1,10 @@
.org 0xC000
start: nop
bcs foo2
foo: nop
stp
foo2: nop
bcs foo
nop

10
test/test_emulation_beq.s Normal file
View File

@ -0,0 +1,10 @@
.org 0xC000
start: nop
beq foo2
foo: nop
stp
foo2: nop
beq foo
nop

10
test/test_emulation_bmi.s Normal file
View File

@ -0,0 +1,10 @@
.org 0xC000
start: nop
bmi foo2
foo: nop
stp
foo2: nop
bmi foo
nop

10
test/test_emulation_bne.s Normal file
View File

@ -0,0 +1,10 @@
.org 0xC000
start: nop
bne foo2
foo: nop
stp
foo2: nop
bne foo
nop

10
test/test_emulation_bpl.s Normal file
View File

@ -0,0 +1,10 @@
.org 0xC000
start: nop
bpl foo2
foo: nop
stp
foo2: nop
bpl foo
nop

View File

@ -0,0 +1,9 @@
.org 0xC000
start: bra foo
nop
nop
foo: nop
stp

10
test/test_emulation_bvc.s Normal file
View File

@ -0,0 +1,10 @@
.org 0xC000
start: nop
bvc foo2
foo: nop
stp
foo2: nop
bvc foo
nop

10
test/test_emulation_bvs.s Normal file
View File

@ -0,0 +1,10 @@
.org 0xC000
start: nop
bvs foo2
foo: nop
stp
foo2: nop
bvs foo
nop