diff --git a/MC6809/MC6809.UnitTest/LdTests.cs b/MC6809/MC6809.UnitTest/LdTests.cs new file mode 100644 index 0000000..fb8269b --- /dev/null +++ b/MC6809/MC6809.UnitTest/LdTests.cs @@ -0,0 +1,67 @@ +// +// Copyright (c) Adrian Conlon. All rights reserved. +// + +namespace EightBit +{ + using Microsoft.VisualStudio.TestTools.UnitTesting; + + [TestClass] + public class LdTests + { + private readonly Board board = new Board(); + private readonly MC6809 cpu; + + public LdTests() => this.cpu = this.board.CPU; + + [TestInitialize] + public void Initialise() + { + this.board.RaisePOWER(); + this.cpu.Step(); // Step over the reset + } + + [TestCleanup] + public void Cleanup() => this.board.LowerPOWER(); + + [TestMethod] + public void TestIndexedAccumulatorOffset_A() + { + this.board.Poke(0, 0xe6); + this.board.Poke(1, 0x86); + this.cpu.A = 0x2b; + this.cpu.B = 0x00; + this.cpu.X.Word = 0xc300; + this.board.Poke(0xc32b, 0x4e); + this.cpu.Step(); + Assert.AreEqual(0x4e, this.cpu.B); + } + + [TestMethod] + public void TestIndexedAccumulatorOffset_B() + { + this.board.Poke(0, 0xa6); + this.board.Poke(1, 0x85); + this.cpu.A = 0x00; + this.cpu.B = 0x2b; + this.cpu.X.Word = 0xc300; + this.board.Poke(0xc32b, 0x4e); + this.cpu.Step(); + Assert.AreEqual(0x4e, this.cpu.A); + } + + [TestMethod] + public void TestIndirectIndexedAccumulatorOffset() + { + this.board.Poke(0, 0xa6); + this.board.Poke(1, 0x95); + this.cpu.A = 0x00; + this.cpu.B = 0x2b; + this.cpu.X.Word = 0xc300; + this.cpu.PokeWord(0xc32b, 0x1234); + this.board.Poke(0x1234, 0x56); + this.cpu.Step(); + Assert.AreEqual(0x56, this.cpu.A); + } + } +} diff --git a/MC6809/MC6809.UnitTest/MC6809.UnitTest.csproj b/MC6809/MC6809.UnitTest/MC6809.UnitTest.csproj index 8b7c6fe..c796af4 100644 --- a/MC6809/MC6809.UnitTest/MC6809.UnitTest.csproj +++ b/MC6809/MC6809.UnitTest/MC6809.UnitTest.csproj @@ -87,6 +87,7 @@ +