diff --git a/test/Makefile b/test/Makefile index 6bc4530..83638ac 100644 --- a/test/Makefile +++ b/test/Makefile @@ -5,11 +5,14 @@ VASM=vasm6502_std VASMFLAGS=-Fbin -c02 UTILS=utils.o -TESTS=test_bus test_emulation +TESTS=test_bus test_emulation test_stepping TESTROMS:=$(addsuffix .rom,$(basename $(wildcard *.s))) all : $(TESTS) $(TESTROMS) +test_stepping : test_step.o $(UTILS) $(RK6502LIB) + $(CC) -o $@ $(LDFLAGS) $< $(RK6502LIB) + test_bus : test_bus.o $(UTILS) $(RK6502LIB) $(CC) -o $@ $(LDFLAGS) $< $(RK6502LIB) diff --git a/test/test_stepping.c b/test/test_stepping.c new file mode 100644 index 0000000..5d917e1 --- /dev/null +++ b/test/test_stepping.c @@ -0,0 +1,36 @@ +#include + +#include + +#include "bus.h" +#include "rk65c02.h" +#include "utils.h" + +ATF_TC_WITHOUT_HEAD(step1); +ATF_TC_BODY(step1, tc) +{ + rk65c02emu_t e; + bus_t b; + + b = bus_init(); + e = rk65c02_init(&b); + + e->regs.PC = ROM_LOAD_ADDR; + + ATF_REQUIRE(bus_load_file(e->bus, ROM_LOAD_ADDR, + "test_stepping_step1.rom")); + + rk65c02_step(e, 1); + ATF_CHECK(e->regs.PC == ROM_LOAD_ADDR+1); + rk65c02_step(e, 1); + ATF_CHECK(e->regs.PC == ROM_LOAD_ADDR+2); +} + +ATF_TP_ADD_TCS(tp) +{ + ATF_TP_ADD_TC(tp, step1); + + return (atf_no_error()); + +} + diff --git a/test/test_stepping_step1.s b/test/test_stepping_step1.s new file mode 100644 index 0000000..e7e1143 --- /dev/null +++ b/test/test_stepping_step1.s @@ -0,0 +1,5 @@ +start: nop + nop + nop + stp +