From 1f4a84b803b20bd98d27371be61a757554d17226 Mon Sep 17 00:00:00 2001 From: Adrian Conlon Date: Sun, 7 Oct 2018 09:47:10 +0100 Subject: [PATCH] Add test for ADDA immediate. Seems to be working. Signed-off-by: Adrian Conlon --- MC6809/unittest/mc6809_tests.cpp | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/MC6809/unittest/mc6809_tests.cpp b/MC6809/unittest/mc6809_tests.cpp index 6d2a16d..13f6813 100644 --- a/MC6809/unittest/mc6809_tests.cpp +++ b/MC6809/unittest/mc6809_tests.cpp @@ -43,3 +43,26 @@ TEST_CASE("Add Memory Plus Carry to Accumulator A", "[ADC][ADCA]") { REQUIRE(cpu.cycles() == 2); } } + +TEST_CASE("Add Memory to Accumulator A", "[ADD][ADDA]") { + + Board board; + board.initialise(); + auto& cpu = board.CPU(); + cpu.step(); // Step over the reset + + SECTION("Immediate (byte)") { + board.poke(0, 0x8b); + board.poke(1, 0x8b); + EightBit::Chip::setFlag(cpu.CC(), EightBit::mc6809::CF); + cpu.A() = 0x24; + cpu.step(); + REQUIRE(cpu.A() == 0xaf); + REQUIRE((cpu.CC() & EightBit::mc6809::ZF) == 0); + REQUIRE((cpu.CC() & EightBit::mc6809::HF) == 0); + REQUIRE((cpu.CC() & EightBit::mc6809::VF) == 0); + REQUIRE((cpu.CC() & EightBit::mc6809::NF) != 0); + REQUIRE((cpu.CC() & EightBit::mc6809::CF) == 0); + REQUIRE(cpu.cycles() == 2); + } +}