Skip to content
Merged

Dev #16

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions CPU_emu/CPU/CPU_CMD_Methods.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public void Cmd_BD() // Load Accumulator absolute X BD

// LDA $nnnn,Y
[Opcode(4)]
public void Cmd_B9()
public void Cmd_B9() // Load Accumulator absolute Y B9
{
ushort addr = AddrAbsoluteY();
byte value = ReadByteFromMemory(addr);
Expand All @@ -76,7 +76,7 @@ public void Cmd_B9()

// LDA ($zz,X) – Indirect,X
[Opcode(6)]
public void Cmd_A1()
public void Cmd_A1() // Load Accumulator indirect X A1
{
ushort addr = AddrIndirectX();
byte value = ReadByteFromMemory(addr);
Expand All @@ -86,7 +86,7 @@ public void Cmd_A1()

// LDA ($zz),Y – Indirect,Y
[Opcode(5)]
public void Cmd_B1()
public void Cmd_B1() // Load Accumulator indirect y B1
{
ushort addr = AddrIndirectY();
byte value = ReadByteFromMemory(addr);
Expand Down
73 changes: 72 additions & 1 deletion CPU_emuTests/CPU_Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,78 @@ public void Cmd_AD_Test(byte value, bool expectedZ, bool expectedN, byte expecte

}

#endregion
// Load Accumulator absolute X BD
[TestCase(0xff, false, true, 0xff, 6)]
[TestCase(0x00, true, false, 0x00, 6)]
public void Cmd_BD_Test(byte value, bool expectedZ, bool expectedN, byte expectedA, int expectedCycles)
{
cpu.Reset();
cpu.WriteByteToMemory(value, 0xFFEF);
cpu.WriteByteToMemory(0xEE, 0x200);
cpu.WriteByteToMemory(0xFF, 0x201);
cpu.SetRegister("X", 0x01);
cpu.SetPC(0x200);

TestHelper.GetPrivateMethod("CallInstruction", cpu).Invoke(cpu, new object[] { cpu.GetType(), (byte)0xBD });

Assert.Multiple(() =>
{
Assert.That(cpu.flags["Z"], Is.EqualTo(expectedZ), "Zero Flag");
Assert.That(cpu.flags["N"], Is.EqualTo(expectedN), "Negative Flag");
Assert.That(cpu.A, Is.EqualTo(expectedA), "Register A");
Assert.That(cpu.CpuCycle, Is.EqualTo(expectedCycles), "CPU Cycles");
});

}

// Load Accumulator absolute Y B9
[TestCase(0xff, false, true, 0xff, 6)]
[TestCase(0x00, true, false, 0x00, 6)]
public void Cmd_B9_Test(byte value, bool expectedZ, bool expectedN, byte expectedA, int expectedCycles)
{
cpu.Reset();
cpu.WriteByteToMemory(value, 0xFFEF);
cpu.WriteByteToMemory(0xEE, 0x200);
cpu.WriteByteToMemory(0xFF, 0x201);
cpu.SetRegister("Y", 0x01);
cpu.SetPC(0x200);

TestHelper.GetPrivateMethod("CallInstruction", cpu).Invoke(cpu, new object[] { cpu.GetType(), (byte)0xB9 });

Assert.Multiple(() =>
{
Assert.That(cpu.flags["Z"], Is.EqualTo(expectedZ), "Zero Flag");
Assert.That(cpu.flags["N"], Is.EqualTo(expectedN), "Negative Flag");
Assert.That(cpu.A, Is.EqualTo(expectedA), "Register A");
Assert.That(cpu.CpuCycle, Is.EqualTo(expectedCycles), "CPU Cycles");
});

}

// Load Accumulator indirect X A1
[TestCase(0xff, false, true, 0xff, 7)]
[TestCase(0x00, true, false, 0x00, 7)]
public void Cmd_A1_Test(byte value, bool expectedZ, bool expectedN, byte expectedA, int expectedCycles)
{
cpu.Reset();
cpu.WriteByteToMemory(value, 0xFFEF);
cpu.WriteByteToMemory(0xEF, 0x01);
cpu.WriteByteToMemory(0xFF, 0x02);
cpu.SetRegister("X", 0x01);
cpu.SetPC(0x200);

TestHelper.GetPrivateMethod("CallInstruction", cpu).Invoke(cpu, new object[] { cpu.GetType(), (byte)0xA1 });

Assert.Multiple(() =>
{
Assert.That(cpu.flags["Z"], Is.EqualTo(expectedZ), "Zero Flag");
Assert.That(cpu.flags["N"], Is.EqualTo(expectedN), "Negative Flag");
Assert.That(cpu.A, Is.EqualTo(expectedA), "Register A");
Assert.That(cpu.CpuCycle, Is.EqualTo(expectedCycles), "CPU Cycles");
});

}
#endregion

#region LDX

Expand Down