diff --git a/tests/test_cpu_simple.cpp b/tests/test_cpu_simple.cpp index 83d2e30..41ea4ec 100644 --- a/tests/test_cpu_simple.cpp +++ b/tests/test_cpu_simple.cpp @@ -194,3 +194,26 @@ TEST_CASE("JR e") CHECK(cpu.state.PC == 0x0); } + +TEST_CASE("RST op leads to correct call") +{ + u8 test_ram[] = { 0x00 }; + RAM r(test_ram, 0x1, true); + + Cpu cpu(&r); + + u16 expected_pc; + + SUBCASE("RST $00") { test_ram[0] = 0xC7; expected_pc = 0x00; } + SUBCASE("RST $08") { test_ram[0] = 0xCF; expected_pc = 0x08; } + SUBCASE("RST $10") { test_ram[0] = 0xD7; expected_pc = 0x10; } + SUBCASE("RST $18") { test_ram[0] = 0xDF; expected_pc = 0x18; } + SUBCASE("RST $20") { test_ram[0] = 0xE7; expected_pc = 0x20; } + SUBCASE("RST $28") { test_ram[0] = 0xEF; expected_pc = 0x28; } + SUBCASE("RST $30") { test_ram[0] = 0xF7; expected_pc = 0x30; } + SUBCASE("RST $38") { test_ram[0] = 0xFF; expected_pc = 0x38; } + + cpu.step(); + + CHECK(cpu.state.PC == expected_pc); +}