DAA tests added to MC6809 core

Signed-off-by: Adrian Conlon <Adrian.conlon@gmail.com>
This commit is contained in:
Adrian Conlon
2019-06-10 08:50:24 +01:00
parent 1eb5caed3c
commit 6697974711
2 changed files with 51 additions and 0 deletions
+50
View File
@@ -0,0 +1,50 @@
// <copyright file="DaaTests.cs" company="Adrian Conlon">
// Copyright (c) Adrian Conlon. All rights reserved.
// </copyright>
namespace EightBit
{
using Microsoft.VisualStudio.TestTools.UnitTesting;
[TestClass]
public class DaaTests
{
private readonly Board board = new Board();
private readonly MC6809 cpu;
public DaaTests() => 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();
// Decimal Addition Adjust.
// The Half-Carry flag is not affected by this instruction.
// The Negative flag is set equal to the new value of bit 7 in Accumulator A.
// The Zero flag is set if the new value of Accumulator A is zero; cleared otherwise.
// The affect this instruction has on the Overflow flag is undefined.
// The Carry flag is set if the BCD addition produced a carry; cleared otherwise.
[TestMethod]
public void TestDAA()
{
this.board.Poke(0xb00, 0x19);
this.cpu.CC = 0;
this.cpu.A = 0x7f;
this.cpu.PC.Word = 0xb00;
this.cpu.Step();
Assert.AreEqual(0x85, this.cpu.A);
Assert.AreNotEqual(0, this.cpu.Negative);
Assert.AreEqual(0, this.cpu.Zero);
Assert.AreEqual(0, this.cpu.Overflow);
Assert.AreEqual(0, this.cpu.Carry);
}
}
}
@@ -86,6 +86,7 @@
<Compile Include="ComTests.cs" />
<Compile Include="LeaTests.cs" />
<Compile Include="MulTests.cs" />
<Compile Include="DaaTests.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\EightBit\EightBit.csproj">