From 730f5bc97091dbc23842e614e9f615aeb9136cc0 Mon Sep 17 00:00:00 2001 From: KallDrexx Date: Tue, 30 Dec 2025 15:32:34 -0500 Subject: [PATCH] Csproj cleanup and always pass unused processor status bit as 1, per 6502 spec --- src/Dotnet6502.Common/Hardware/Base6502Hal.cs | 2 +- .../Dotnet6502.ComprehensiveTestRunner.csproj | 7 +------ src/Dotnet6502.ComprehensiveTestRunner/Program.cs | 10 +++++++--- src/Dotnet6502.ComprehensiveTestRunner/TestRunner.cs | 2 +- .../Common/InstructionToMsilTests/BrkTests.cs | 4 ++-- .../Common/InstructionToMsilTests/RtiTests.cs | 2 +- .../Common/MsilGeneration/BinaryInstructionTests.cs | 2 +- .../Common/MsilGeneration/CopyInstructionTests.cs | 8 ++++---- .../Common/MsilGeneration/PollForInterruptsTests.cs | 2 +- .../MsilGeneration/PopStackValueInstructionTests.cs | 2 +- .../MsilGeneration/PushStackValueInstructionTests.cs | 2 +- 11 files changed, 21 insertions(+), 22 deletions(-) diff --git a/src/Dotnet6502.Common/Hardware/Base6502Hal.cs b/src/Dotnet6502.Common/Hardware/Base6502Hal.cs index 4a07414..21ced47 100644 --- a/src/Dotnet6502.Common/Hardware/Base6502Hal.cs +++ b/src/Dotnet6502.Common/Hardware/Base6502Hal.cs @@ -7,7 +7,7 @@ public class Base6502Hal private readonly MemoryBus _memoryBus; private readonly Dictionary _flags = new() { - { CpuStatusFlags.Unused, false }, + { CpuStatusFlags.Unused, true }, { CpuStatusFlags.BFlag, false }, { CpuStatusFlags.Carry, false }, { CpuStatusFlags.Decimal, false }, diff --git a/src/Dotnet6502.ComprehensiveTestRunner/Dotnet6502.ComprehensiveTestRunner.csproj b/src/Dotnet6502.ComprehensiveTestRunner/Dotnet6502.ComprehensiveTestRunner.csproj index 33ccc00..4ed3d9b 100644 --- a/src/Dotnet6502.ComprehensiveTestRunner/Dotnet6502.ComprehensiveTestRunner.csproj +++ b/src/Dotnet6502.ComprehensiveTestRunner/Dotnet6502.ComprehensiveTestRunner.csproj @@ -12,12 +12,7 @@ - - - - - - + diff --git a/src/Dotnet6502.ComprehensiveTestRunner/Program.cs b/src/Dotnet6502.ComprehensiveTestRunner/Program.cs index 0f0d90c..47aa2b5 100644 --- a/src/Dotnet6502.ComprehensiveTestRunner/Program.cs +++ b/src/Dotnet6502.ComprehensiveTestRunner/Program.cs @@ -36,11 +36,15 @@ try Console.WriteLine($"Failures written to: {absoluteOutputPath}"); return 1; } - else + + if (totalTests == 0) { - Console.WriteLine("All tests passed!"); - return 0; + Console.WriteLine("No test cases found!"); + return 1; } + + Console.WriteLine("All tests passed!"); + return 0; } catch (Exception ex) { diff --git a/src/Dotnet6502.ComprehensiveTestRunner/TestRunner.cs b/src/Dotnet6502.ComprehensiveTestRunner/TestRunner.cs index bb9c96d..45409d2 100644 --- a/src/Dotnet6502.ComprehensiveTestRunner/TestRunner.cs +++ b/src/Dotnet6502.ComprehensiveTestRunner/TestRunner.cs @@ -15,7 +15,7 @@ public static class TestRunner // Find all opcodes that match this mnemonic var matchingOpcodes = new List(); - for (byte opcode = 0; opcode <= 0xFF; opcode++) + for (byte opcode = 0;; opcode++) { var instructionInfo = InstructionSet.GetInstruction(opcode); if (instructionInfo.Mnemonic.Equals(mnemonic, StringComparison.OrdinalIgnoreCase)) diff --git a/src/Dotnet6502.Tests/Common/InstructionToMsilTests/BrkTests.cs b/src/Dotnet6502.Tests/Common/InstructionToMsilTests/BrkTests.cs index ea88bf4..3451d35 100644 --- a/src/Dotnet6502.Tests/Common/InstructionToMsilTests/BrkTests.cs +++ b/src/Dotnet6502.Tests/Common/InstructionToMsilTests/BrkTests.cs @@ -65,7 +65,7 @@ public class BrkTests jit.AddMethod(0x3456, [callableInstruction]); // IRQ address jit.RunMethod(0x1234); - jit.TestHal.PopFromStack().ShouldBe((byte)0b11011111); + jit.TestHal.PopFromStack().ShouldBe((byte)0b11111111); jit.TestHal.PopFromStack().ShouldBe((byte)0x47); // low address byte jit.TestHal.PopFromStack().ShouldBe((byte)0x23); // high address byte } @@ -127,6 +127,6 @@ public class BrkTests jit.AddMethod(0x3456, [callableInstruction]); // IRQ address jit.RunMethod(0x1234); - jit.TestHal.PopFromStack().ShouldBe((byte)0b00010000); + jit.TestHal.PopFromStack().ShouldBe((byte)0b00110000); } } \ No newline at end of file diff --git a/src/Dotnet6502.Tests/Common/InstructionToMsilTests/RtiTests.cs b/src/Dotnet6502.Tests/Common/InstructionToMsilTests/RtiTests.cs index ea4f64a..9cbe85b 100644 --- a/src/Dotnet6502.Tests/Common/InstructionToMsilTests/RtiTests.cs +++ b/src/Dotnet6502.Tests/Common/InstructionToMsilTests/RtiTests.cs @@ -35,7 +35,7 @@ public class RtiTests jit.AddMethod(0x2345, [callableInstruction]); jit.RunMethod(0x1234); - jit.TestHal.ProcessorStatus.ShouldBe((byte)0b11001111); + jit.TestHal.ProcessorStatus.ShouldBe((byte)0b11101111); jit.TestHal.ReadMemory(0x4000).ShouldBe((byte)99); // Verify return address was called } } \ No newline at end of file diff --git a/src/Dotnet6502.Tests/Common/MsilGeneration/BinaryInstructionTests.cs b/src/Dotnet6502.Tests/Common/MsilGeneration/BinaryInstructionTests.cs index 0a10a50..559f052 100644 --- a/src/Dotnet6502.Tests/Common/MsilGeneration/BinaryInstructionTests.cs +++ b/src/Dotnet6502.Tests/Common/MsilGeneration/BinaryInstructionTests.cs @@ -469,7 +469,7 @@ public class BinaryInstructionTests jit.AddMethod(0x1234, [instruction]); jit.RunMethod(0x1234); - jit.TestHal.YRegister.ShouldBe((byte)0x85); + jit.TestHal.YRegister.ShouldBe((byte)0xA5); } [Fact] diff --git a/src/Dotnet6502.Tests/Common/MsilGeneration/CopyInstructionTests.cs b/src/Dotnet6502.Tests/Common/MsilGeneration/CopyInstructionTests.cs index 82b977b..1873814 100644 --- a/src/Dotnet6502.Tests/Common/MsilGeneration/CopyInstructionTests.cs +++ b/src/Dotnet6502.Tests/Common/MsilGeneration/CopyInstructionTests.cs @@ -533,7 +533,7 @@ public class CopyInstructionTests jit.AddMethod(0x1234, [instruction]); jit.RunMethod(0x1234); - jit.TestHal.ARegister.ShouldBe((byte)0x85); + jit.TestHal.ARegister.ShouldBe((byte)0xA5); } [Fact] @@ -548,7 +548,7 @@ public class CopyInstructionTests jit.AddMethod(0x1234, [instruction]); jit.RunMethod(0x1234); - jit.TestHal.ProcessorStatus.ShouldBe((byte)0x85); + jit.TestHal.ProcessorStatus.ShouldBe((byte)0xA5); } [Fact] @@ -563,7 +563,7 @@ public class CopyInstructionTests jit.AddMethod(0x1234, [instruction]); jit.RunMethod(0x1234); - jit.TestHal.ReadMemory(0xB000).ShouldBe((byte)0x85); + jit.TestHal.ReadMemory(0xB000).ShouldBe((byte)0xA5); } [Fact] @@ -578,7 +578,7 @@ public class CopyInstructionTests jit.TestHal.WriteMemory(0xC000, 0x85); jit.RunMethod(0x1234); - jit.TestHal.ProcessorStatus.ShouldBe((byte)0x85); + jit.TestHal.ProcessorStatus.ShouldBe((byte)0xA5); } [Fact] diff --git a/src/Dotnet6502.Tests/Common/MsilGeneration/PollForInterruptsTests.cs b/src/Dotnet6502.Tests/Common/MsilGeneration/PollForInterruptsTests.cs index 3bf3385..001fcb8 100644 --- a/src/Dotnet6502.Tests/Common/MsilGeneration/PollForInterruptsTests.cs +++ b/src/Dotnet6502.Tests/Common/MsilGeneration/PollForInterruptsTests.cs @@ -54,7 +54,7 @@ public class PollForInterruptsTests jit.AddMethod(0x9078, []); jit.RunMethod(0x1234); - jit.TestHal.PopFromStack().ShouldBe((byte)0b11001111); + jit.TestHal.PopFromStack().ShouldBe((byte)0b11101111); jit.TestHal.PopFromStack().ShouldBe((byte)0x56); jit.TestHal.PopFromStack().ShouldBe((byte)0x34); } diff --git a/src/Dotnet6502.Tests/Common/MsilGeneration/PopStackValueInstructionTests.cs b/src/Dotnet6502.Tests/Common/MsilGeneration/PopStackValueInstructionTests.cs index 51ccbb7..7003213 100644 --- a/src/Dotnet6502.Tests/Common/MsilGeneration/PopStackValueInstructionTests.cs +++ b/src/Dotnet6502.Tests/Common/MsilGeneration/PopStackValueInstructionTests.cs @@ -189,7 +189,7 @@ public class PopStackValueInstructionTests jit.TestHal.PushToStack(0x85); jit.RunMethod(0x1234); - jit.TestHal.ProcessorStatus.ShouldBe((byte)0x85); + jit.TestHal.ProcessorStatus.ShouldBe((byte)0xA5); } [Fact] diff --git a/src/Dotnet6502.Tests/Common/MsilGeneration/PushStackValueInstructionTests.cs b/src/Dotnet6502.Tests/Common/MsilGeneration/PushStackValueInstructionTests.cs index fc552e6..ba8c32a 100644 --- a/src/Dotnet6502.Tests/Common/MsilGeneration/PushStackValueInstructionTests.cs +++ b/src/Dotnet6502.Tests/Common/MsilGeneration/PushStackValueInstructionTests.cs @@ -174,7 +174,7 @@ public class PushStackValueInstructionTests jit.AddMethod(0x1234, [instruction]); jit.RunMethod(0x1234); - jit.TestHal.PopFromStack().ShouldBe((byte)0x85); + jit.TestHal.PopFromStack().ShouldBe((byte)0xA5); } [Fact]