diff --git a/EightBit/Register16.cs b/EightBit/Register16.cs index 1104f63..6f88050 100644 --- a/EightBit/Register16.cs +++ b/EightBit/Register16.cs @@ -19,10 +19,7 @@ namespace EightBit private ref ushort Whole { [MethodImpl(MethodImplOptions.AggressiveInlining)] - get - { - return ref Unsafe.As(ref this._low); - } + get => ref Unsafe.As(ref this._low); } public Register16(byte low, byte high) diff --git a/EightBit/TestHarness.cs b/EightBit/TestHarness.cs index c9f8308..0455560 100644 --- a/EightBit/TestHarness.cs +++ b/EightBit/TestHarness.cs @@ -13,12 +13,15 @@ namespace EightBit private readonly TProcessor _cpu = cpu; private readonly int _targetClocksPerSecond = targetClocksPerSecond; private long _totalCycles; + private long _totalInstructions; public long ElapsedMilliseconds => this._timer.ElapsedMilliseconds; public TimeSpan ActualElapsed => TimeSpan.FromMilliseconds(this.ElapsedMilliseconds); - public double CyclesPerSecond => this._totalCycles / this.ActualElapsed.TotalSeconds; + public double CyclesPerSecond => this.TotalCycles / this.ActualElapsed.TotalSeconds; + + public double InstructionsPerSecond => this.TotalInstructions / this.ActualElapsed.TotalSeconds; public double ActualClockSpeed => this.CyclesPerSecond / 1_000_000; @@ -28,6 +31,8 @@ namespace EightBit public long TotalCycles => this._totalCycles; + public long TotalInstructions => this._totalInstructions; + public TimeSpan TargetElapsed => TimeSpan.FromSeconds(this.TotalCycles / (double)this.TargetClocksPerSecond); public void Run() @@ -35,16 +40,21 @@ namespace EightBit this._board.Initialize(); this._board.RaisePOWER(); + this._totalCycles = 0; + this._totalInstructions = 0; + this._timer.Start(); while (this._cpu.Powered) { this._totalCycles += this._cpu.Step(); + ++this._totalInstructions; } this._timer.Stop(); Console.Out.WriteLine(); - Console.Out.WriteLine($"Guest cycles = {this._totalCycles:N0}"); + Console.Out.WriteLine($"Guest cycles = {this.TotalCycles:N0}"); + Console.Out.WriteLine($"Instructions executed = {this.TotalInstructions:N0} ({this.InstructionsPerSecond:N0} instructions per second)"); Console.Out.WriteLine($"Elapsed time (at {this.ActualClockSpeed:g3}MHz actual) = {this.ActualElapsed}"); Console.Out.WriteLine($"Elapsed time (at {this.TargetClockSpeed:g3}MHz target) = {this.TargetElapsed}"); } diff --git a/M6502/Core.cs b/M6502/Core.cs index 2882e90..261488c 100644 --- a/M6502/Core.cs +++ b/M6502/Core.cs @@ -1148,7 +1148,7 @@ namespace M6502 protected void RTS() => this.Return(); - protected override void Return() + public override void Return() { this.SwallowPop(); base.Return(); diff --git a/MC6809/MC6809.Test/Program.cs b/MC6809/MC6809.Test/Program.cs index 2b4312c..666a274 100644 --- a/MC6809/MC6809.Test/Program.cs +++ b/MC6809/MC6809.Test/Program.cs @@ -8,6 +8,13 @@ namespace EightBit internal static class Program { + private static void Run(Configuration configuration) + { + var board = new Board(configuration); + var harness = new EightBit.TestHarness(board, board.CPU); + harness.Run(); + } + public static void Main(string[] args) { var configuration = new Configuration(); @@ -16,9 +23,7 @@ namespace EightBit configuration.Debug = true; #endif - var board = new Board(configuration); - var harness = new EightBit.TestHarness(board, board.CPU); - harness.Run(); + Run(configuration); } } }