From f69afb0f5c39a6bdb732cc20c4ad3ab5ec7c2c67 Mon Sep 17 00:00:00 2001 From: Ian C Date: Tue, 20 Mar 2012 23:45:29 +0000 Subject: Added instruction counter to Z80 --- src/Noddybox.Emulation.EightBit.Z80/Z80Cpu.cs | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'src/Noddybox.Emulation.EightBit.Z80') diff --git a/src/Noddybox.Emulation.EightBit.Z80/Z80Cpu.cs b/src/Noddybox.Emulation.EightBit.Z80/Z80Cpu.cs index 74a8df1..06433dc 100644 --- a/src/Noddybox.Emulation.EightBit.Z80/Z80Cpu.cs +++ b/src/Noddybox.Emulation.EightBit.Z80/Z80Cpu.cs @@ -123,6 +123,10 @@ namespace Noddybox.Emulation.EightBit.Z80 private bool HALT; private int shift; + // Counters + // + private uint executedInstructions; + #endregion #region Private members @@ -228,6 +232,7 @@ namespace Noddybox.Emulation.EightBit.Z80 CheckInterrupts(); AddR(1); shift = 0; + executedInstructions++; DecodeByte(memory.Read(PC++)); } @@ -329,6 +334,25 @@ namespace Noddybox.Emulation.EightBit.Z80 #region Public members + /// + /// Get/reset the number of executed instructions. If the reset is not zero, and expception is thrown. + /// + public uint ExecutedInstructions + { + get {return executedInstructions;} + set + { + if (value == 0) + { + executedInstructions = 0; + } + else + { + throw new ArgumentOutOfRangeException("Can only reset opcode count to zero"); + } + } + } + /// /// Set/get the current state of the accumulator. /// -- cgit v1.2.3