test_cpu_simple - Add DAA example as a test

This commit is contained in:
madmaurice 2023-08-30 12:56:40 +02:00
parent 3d244d1ec0
commit 66c98f53fb

View file

@ -217,3 +217,35 @@ TEST_CASE("RST op leads to correct call")
CHECK(cpu.state.PC == expected_pc); CHECK(cpu.state.PC == expected_pc);
} }
TEST_CASE("DAA")
{
u8 test_ram[] = {
0x80, // ADD A,B
0x27, // DAA
0x90, // SUB A,B
0x27, // DAA
};
RAM r(test_ram, 0x4, true);
Cpu cpu(&r);
cpu.state.A = 0x45;
cpu.state.B = 0x38;
cpu.step();
CHECK(cpu.state.A == 0x7D);
cpu.step();
CHECK(cpu.state.A == 0x83);
cpu.step();
CHECK(cpu.state.A == 0x4B);
cpu.step();
CHECK(cpu.state.A == 0x45);
}