EightBitNet/MC6809/MC6809.UnitTest/RtsTests.cs
Adrian Conlon 0c69c5d8bb Whoops: missed additional MC6809 unit tests.
Signed-off-by: Adrian Conlon <Adrian.conlon@gmail.com>
2019-05-05 10:14:29 +01:00

47 lines
1.1 KiB
C#

namespace EightBit
{
using Microsoft.VisualStudio.TestTools.UnitTesting;
// https://github.com/sorenroug/osnine-java/blob/master/core/src/test/java/org/roug/osnine/BranchAndJumpTest.java
[TestClass]
public class RtsTests
{
private readonly Board board = new Board();
private readonly MC6809 cpu;
public RtsTests()
{
this.cpu = this.board.CPU;
this.board.Poke(0, 0x3a);
}
[TestInitialize]
public void Initialise()
{
this.board.RaisePOWER();
this.cpu.Step(); // Step over the reset
}
[TestCleanup]
public void Cleanup() => this.board.LowerPOWER();
[TestMethod]
public void TestRts()
{
this.cpu.S.Word = 0x300;
this.cpu.PokeWord(0x300, 0x102C); // Write return address
this.board.Poke(0xB00, 0x39); // RTS
this.cpu.PC.Word = 0xB00;
this.cpu.Step();
Assert.AreEqual(0x102C, this.cpu.PC.Word);
Assert.AreEqual(0x302, this.cpu.S.Word);
Assert.AreEqual(5, this.cpu.Cycles);
}
}
}