diff options
author | Ian C <ianc@noddybox.co.uk> | 2012-03-20 23:45:29 +0000 |
---|---|---|
committer | Ian C <ianc@noddybox.co.uk> | 2012-03-20 23:45:29 +0000 |
commit | f69afb0f5c39a6bdb732cc20c4ad3ab5ec7c2c67 (patch) | |
tree | 1b2af063b07ab130c0214443ca004aa89a96169b | |
parent | ad560dc976170701ce54fbbcb99f8dc648ad8ef8 (diff) |
Added instruction counter to Z80
-rw-r--r-- | src/Noddybox.Emulation.EightBit.Z80/Z80Cpu.cs | 24 |
1 files changed, 24 insertions, 0 deletions
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++));
}
@@ -330,6 +335,25 @@ namespace Noddybox.Emulation.EightBit.Z80 #region Public members
/// <summary>
+ /// Get/reset the number of executed instructions. If the reset is not zero, and expception is thrown.
+ /// </summary>
+ public uint ExecutedInstructions
+ {
+ get {return executedInstructions;}
+ set
+ {
+ if (value == 0)
+ {
+ executedInstructions = 0;
+ }
+ else
+ {
+ throw new ArgumentOutOfRangeException("Can only reset opcode count to zero");
+ }
+ }
+ }
+
+ /// <summary>
/// Set/get the current state of the accumulator.
/// </summary>
public byte Acummulator
|