summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorIan C <ianc@noddybox.co.uk>2012-03-20 23:45:29 +0000
committerIan C <ianc@noddybox.co.uk>2012-03-20 23:45:29 +0000
commitf69afb0f5c39a6bdb732cc20c4ad3ab5ec7c2c67 (patch)
tree1b2af063b07ab130c0214443ca004aa89a96169b /src
parentad560dc976170701ce54fbbcb99f8dc648ad8ef8 (diff)
Added instruction counter to Z80
Diffstat (limited to 'src')
-rw-r--r--src/Noddybox.Emulation.EightBit.Z80/Z80Cpu.cs24
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