From 0fc247d27e9e705adb61552a98d2b6bd74b05e8a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Martin=20H=C3=B6gstedt?= <marin.hogstedt@hotmail.com>
Date: Mon, 10 Jun 2024 16:00:53 +0200
Subject: [PATCH] saving clock cycles for each new asm instruction

---
 src/simudator/processor/mia/mia.py | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/src/simudator/processor/mia/mia.py b/src/simudator/processor/mia/mia.py
index 77262a4..a3b0b46 100644
--- a/src/simudator/processor/mia/mia.py
+++ b/src/simudator/processor/mia/mia.py
@@ -280,17 +280,22 @@ class MIA_CPU(Processor):
 
         self.micro_memory = uM
 
+        # List containing all clock cycles where a new asm instruction started
+        self.assembly_cycles = []
+
         self.lambdas = {}
 
     def do_tick(self) -> None:
-        """After each tick Mia checks for a new instruction.
+        """Mia has special assembly related behaviour.
 
-        This is done by checking if the value of the micro PC is equal to zero."""
+        This includes fetching the curret asm instruction, and saving the current clock
+        cycle in a list to enable stepping back over assembly instructions.
+        """
         super().do_tick()
         if self.get_module("uPC").value == 0:
             self.new_instruction = True
             self.current_instruction = self.get_current_instrution()
-            print(self.current_instruction)
+            self.assembly_cycles.append(self.get_clock())
         else:
             self.new_instruction = False
 
-- 
GitLab