From e4426dc952c4845adeb47756a53fc5ca60e17441 Mon Sep 17 00:00:00 2001
From: Thomas Harte <thomas.harte@gmail.com>
Date: Fri, 29 Apr 2022 20:30:48 -0400
Subject: [PATCH 1/2] Introduce calculate EA steps.

---
 .../Implementation/PerformImplementation.hpp    |  4 ++--
 InstructionSets/M68k/Sequence.cpp               |  7 ++++---
 InstructionSets/M68k/Sequence.hpp               | 17 ++++++++++++-----
 3 files changed, 18 insertions(+), 10 deletions(-)

diff --git a/InstructionSets/M68k/Implementation/PerformImplementation.hpp b/InstructionSets/M68k/Implementation/PerformImplementation.hpp
index 2dad77da5..c4f450c85 100644
--- a/InstructionSets/M68k/Implementation/PerformImplementation.hpp
+++ b/InstructionSets/M68k/Implementation/PerformImplementation.hpp
@@ -399,7 +399,7 @@ template <
 
 		// JMP: copies EA(0) to the program counter.
 		case Operation::JMP:
-			flow_controller.set_pc(flow_controller.effective_address(0));
+			flow_controller.set_pc(src.l);
 		break;
 
 		/*
@@ -438,7 +438,7 @@ template <
 		break;
 
 		case Operation::LEA:
-			dest.l = flow_controller.effective_address(0);
+			dest.l = src.l;
 		break;
 
 //		case Operation::PEA:
diff --git a/InstructionSets/M68k/Sequence.cpp b/InstructionSets/M68k/Sequence.cpp
index dc45925bd..07ec25bb4 100644
--- a/InstructionSets/M68k/Sequence.cpp
+++ b/InstructionSets/M68k/Sequence.cpp
@@ -11,14 +11,14 @@
 using namespace InstructionSet::M68k;
 
 template <Step... T> struct Steps {
-	static constexpr uint16_t value = 0;
+	static constexpr uint32_t value = 0;
 };
 
 template <Step F, Step... T> struct Steps<F, T...> {
-	static constexpr uint16_t value = uint16_t(F) | uint16_t(Steps<T...>::value << 3);
+	static constexpr uint32_t value = uint16_t(F) | uint16_t(Steps<T...>::value << 4);
 };
 
-template<Model model> uint16_t Sequence<model>::steps_for(Operation operation) {
+template<Model model> uint32_t Sequence<model>::steps_for(Operation operation) {
 	switch(operation) {
 		// This handles a NOP, and not much else.
 		default: return 0;
@@ -28,6 +28,7 @@ template<Model model> uint16_t Sequence<model>::steps_for(Operation operation) {
 		//
 		case Operation::LEA:
 		return Steps<
+			Step::CalcEA1,
 			Step::Perform
 		>::value;
 
diff --git a/InstructionSets/M68k/Sequence.hpp b/InstructionSets/M68k/Sequence.hpp
index 2e13afc8d..7c1c4a328 100644
--- a/InstructionSets/M68k/Sequence.hpp
+++ b/InstructionSets/M68k/Sequence.hpp
@@ -35,6 +35,12 @@ enum class Step {
 	StoreOp1,
 	/// Store the value of operand 2.
 	StoreOp2,
+	/// Calculate effective address of operand 1.
+	CalcEA1,
+	/// Calculate effective address of operand 2.
+	CalcEA2,
+
+	Max = CalcEA2
 };
 
 /// Indicates the abstract steps necessary to perform an operation,
@@ -47,8 +53,9 @@ template<Model model> class Sequence {
 		/// if no further steps remain. This step is removed from the
 		/// list of remaining steps.
 		Step pop_front() {
-			const auto step = Step(steps_ & 7);
-			steps_ >>= 3;
+			static_assert(int(Step::Max) < 16);
+			const auto step = Step(steps_ & 15);
+			steps_ >>= 4;
 			return step;
 		}
 
@@ -59,12 +66,12 @@ template<Model model> class Sequence {
 		}
 
 	private:
-		uint16_t steps_ = 0;
+		uint32_t steps_ = 0;
 
-		uint16_t steps_for(Operation);
+		uint32_t steps_for(Operation);
 };
 
-static_assert(sizeof(Sequence<Model::M68000>) == sizeof(uint16_t));
+static_assert(sizeof(Sequence<Model::M68000>) == sizeof(uint32_t));
 
 }
 }

From f4074e0bba899c9b8151efa81b4363f26e2536c3 Mon Sep 17 00:00:00 2001
From: Thomas Harte <thomas.harte@gmail.com>
Date: Sat, 30 Apr 2022 08:38:28 -0400
Subject: [PATCH 2/2] Add basic status.

---
 InstructionSets/M68k/Executor.hpp | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/InstructionSets/M68k/Executor.hpp b/InstructionSets/M68k/Executor.hpp
index a51af6fce..b9a28ebec 100644
--- a/InstructionSets/M68k/Executor.hpp
+++ b/InstructionSets/M68k/Executor.hpp
@@ -46,6 +46,8 @@ template <Model model, typename BusHandler> class Executor {
 		// Processor state.
 		Status status_;
 		CPU::SlicedInt32 program_counter_;
+		CPU::SlicedInt32 data_[8], address_[8];
+		CPU::SlicedInt32 stack_pointers_[2];
 };
 
 }