diff --git a/tests/test_cpu_simple.cpp b/tests/test_cpu_simple.cpp index 41ea4ec..9f63dcb 100644 --- a/tests/test_cpu_simple.cpp +++ b/tests/test_cpu_simple.cpp @@ -217,3 +217,35 @@ TEST_CASE("RST op leads to correct call") 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); +}