mirror of
https://github.com/MoleskiCoder/EightBitNet.git
synced 2025-01-06 18:31:05 +00:00
More analysis fixes
This commit is contained in:
parent
4190943998
commit
3cbc7f32d2
@ -8,10 +8,10 @@ namespace EightBit
|
||||
|
||||
public class Disassembler(Bus bus)
|
||||
{
|
||||
private bool _prefixCB = false;
|
||||
private bool _prefixDD = false;
|
||||
private bool _prefixED = false;
|
||||
private bool _prefixFD = false;
|
||||
private bool _prefixCB;
|
||||
private bool _prefixDD;
|
||||
private bool _prefixED;
|
||||
private bool _prefixFD;
|
||||
|
||||
public Bus Bus { get; } = bus;
|
||||
|
||||
@ -155,7 +155,7 @@ namespace EightBit
|
||||
if (outputFormatSpecification)
|
||||
{
|
||||
output += '\t';
|
||||
output += string.Format(specification, (int)immediate, (int)absolute, relative, (int)displacement, indexedImmediate);
|
||||
output += string.Format(CultureInfo.InvariantCulture, specification, (int)immediate, (int)absolute, relative, (int)displacement, indexedImmediate);
|
||||
}
|
||||
|
||||
return output;
|
||||
|
@ -5,6 +5,7 @@
|
||||
namespace Z80.Test
|
||||
{
|
||||
using EightBit;
|
||||
using System.Globalization;
|
||||
|
||||
internal class Board : Bus
|
||||
{
|
||||
@ -14,7 +15,7 @@ namespace Z80.Test
|
||||
private readonly Disassembler disassembler;
|
||||
private readonly MemoryMapping mapping;
|
||||
|
||||
private int warmstartCount = 0;
|
||||
private int warmstartCount;
|
||||
|
||||
public Board(Configuration configuration)
|
||||
{
|
||||
@ -69,7 +70,7 @@ namespace Z80.Test
|
||||
switch (this.CPU.C)
|
||||
{
|
||||
case 0x2:
|
||||
System.Console.Out.Write(this.CPU.E.ToString());
|
||||
System.Console.Out.Write(this.CPU.E.ToString(CultureInfo.InvariantCulture));
|
||||
break;
|
||||
case 0x9:
|
||||
for (var i = this.CPU.DE.Word; this.Peek(i) != '$'; ++i)
|
||||
|
@ -6,13 +6,13 @@ namespace Z80.Test
|
||||
{
|
||||
using EightBit;
|
||||
|
||||
internal class Configuration
|
||||
internal sealed class Configuration
|
||||
{
|
||||
public Configuration()
|
||||
{
|
||||
}
|
||||
|
||||
public bool DebugMode { get; set; } = false;
|
||||
public bool DebugMode { get; set; }
|
||||
|
||||
public Register16 LoadAddress { get; } = new(0x100);
|
||||
|
||||
|
@ -9,60 +9,62 @@ namespace Z80.Test
|
||||
|
||||
internal class TestHarness(Configuration configuration) : IDisposable
|
||||
{
|
||||
private readonly Process process = Process.GetCurrentProcess();
|
||||
private readonly Stopwatch timer = new();
|
||||
private readonly Board board = new(configuration);
|
||||
private long totalCycles = 0;
|
||||
private long totalCycles;
|
||||
private TimeSpan totalUserProcessorTime;
|
||||
|
||||
private bool disposed = false;
|
||||
private bool disposed;
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
this.Dispose(true);
|
||||
Dispose(true);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
public long ElapsedMilliseconds => this.timer.ElapsedMilliseconds;
|
||||
public long ElapsedMilliseconds => timer.ElapsedMilliseconds;
|
||||
|
||||
public float ElapsedSeconds => this.ElapsedMilliseconds / 1000.0f;
|
||||
public float ElapsedSeconds => ElapsedMilliseconds / 1000.0f;
|
||||
|
||||
public float CyclesPerSecond => this.totalCycles / this.ElapsedSeconds;
|
||||
public float CyclesPerSecond => totalCycles / ElapsedSeconds;
|
||||
|
||||
public void Run()
|
||||
{
|
||||
this.timer.Start();
|
||||
var startingUsage = this.process.UserProcessorTime;
|
||||
|
||||
this.board.Initialize();
|
||||
this.board.RaisePOWER();
|
||||
|
||||
var cpu = this.board.CPU;
|
||||
while (cpu.Powered)
|
||||
using var process = Process.GetCurrentProcess();
|
||||
{
|
||||
this.totalCycles += cpu.Step();
|
||||
}
|
||||
timer.Start();
|
||||
var startingUsage = process.UserProcessorTime;
|
||||
|
||||
var finishingUsage = this.process.UserProcessorTime;
|
||||
this.timer.Stop();
|
||||
this.totalUserProcessorTime = finishingUsage - startingUsage;
|
||||
board.Initialize();
|
||||
board.RaisePOWER();
|
||||
|
||||
var cpu = board.CPU;
|
||||
while (cpu.Powered)
|
||||
{
|
||||
totalCycles += cpu.Step();
|
||||
}
|
||||
|
||||
var finishingUsage = process.UserProcessorTime;
|
||||
timer.Stop();
|
||||
totalUserProcessorTime = finishingUsage - startingUsage;
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void Dispose(bool disposing)
|
||||
{
|
||||
if (!this.disposed)
|
||||
if (!disposed)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
System.Console.Out.WriteLine();
|
||||
|
||||
System.Console.Out.WriteLine($"Guest cycles = {this.totalCycles:N0}");
|
||||
System.Console.Out.WriteLine($"Seconds = {this.ElapsedSeconds}");
|
||||
System.Console.Out.WriteLine($"Guest cycles = {totalCycles:N0}");
|
||||
System.Console.Out.WriteLine($"Seconds = {ElapsedSeconds}");
|
||||
|
||||
System.Console.Out.WriteLine($"{this.CyclesPerSecond / 1000000} MHz");
|
||||
System.Console.Out.WriteLine($"Processor time = {this.totalUserProcessorTime.TotalSeconds:g}");
|
||||
System.Console.Out.WriteLine($"{CyclesPerSecond / 1000000} MHz");
|
||||
System.Console.Out.WriteLine($"Processor time = {totalUserProcessorTime.TotalSeconds:g}");
|
||||
}
|
||||
|
||||
this.disposed = true;
|
||||
disposed = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -7,7 +7,7 @@
|
||||
<GenerateDocumentationFile>False</GenerateDocumentationFile>
|
||||
<SignAssembly>False</SignAssembly>
|
||||
<EnforceCodeStyleInBuild>True</EnforceCodeStyleInBuild>
|
||||
<AnalysisLevel>latest</AnalysisLevel>
|
||||
<AnalysisLevel>latest-all</AnalysisLevel>
|
||||
<OutputType>Exe</OutputType>
|
||||
</PropertyGroup>
|
||||
|
||||
|
22
Z80/Z80.cs
22
Z80/Z80.cs
@ -23,10 +23,10 @@ namespace EightBit
|
||||
|
||||
private RefreshRegister _refresh = new(0x7f);
|
||||
|
||||
private bool _prefixCB = false;
|
||||
private bool _prefixDD = false;
|
||||
private bool _prefixED = false;
|
||||
private bool _prefixFD = false;
|
||||
private bool _prefixCB;
|
||||
private bool _prefixDD;
|
||||
private bool _prefixED;
|
||||
private bool _prefixFD;
|
||||
|
||||
private PinLevel _nmiLine = PinLevel.Low;
|
||||
private PinLevel _m1Line = PinLevel.Low;
|
||||
@ -36,11 +36,11 @@ namespace EightBit
|
||||
private PinLevel _rdLine = PinLevel.Low;
|
||||
private PinLevel _wrLine = PinLevel.Low;
|
||||
|
||||
private int _accumulatorFlagsSet = 0;
|
||||
private int _accumulatorFlagsSet;
|
||||
|
||||
private int _registerSet = 0;
|
||||
private sbyte _displacement = 0;
|
||||
private bool _displaced = false;
|
||||
private int _registerSet;
|
||||
private sbyte _displacement;
|
||||
private bool _displaced;
|
||||
|
||||
public event EventHandler<EventArgs>? RaisingNMI;
|
||||
|
||||
@ -100,11 +100,11 @@ namespace EightBit
|
||||
|
||||
public byte IV { get; set; } = 0xff;
|
||||
|
||||
public int IM { get; set; } = 0;
|
||||
public int IM { get; set; }
|
||||
|
||||
public bool IFF1 { get; set; } = false;
|
||||
public bool IFF1 { get; set; }
|
||||
|
||||
public bool IFF2 { get; set; } = false;
|
||||
public bool IFF2 { get; set; }
|
||||
|
||||
public override Register16 AF => _accumulatorFlags[_accumulatorFlagsSet];
|
||||
|
||||
|
@ -7,7 +7,7 @@
|
||||
<GenerateDocumentationFile>False</GenerateDocumentationFile>
|
||||
<SignAssembly>False</SignAssembly>
|
||||
<EnforceCodeStyleInBuild>True</EnforceCodeStyleInBuild>
|
||||
<AnalysisLevel>latest</AnalysisLevel>
|
||||
<AnalysisLevel>latest-all</AnalysisLevel>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||
|
Loading…
Reference in New Issue
Block a user