tests_cpu_simple - Add test for RST op

This commit is contained in:
madmaurice 2023-08-30 10:48:18 +02:00
parent c4e171cb80
commit b434b63b75

View file

@ -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);
}