From 21ac9363e918e2af9a84d213f0f44803588292ce Mon Sep 17 00:00:00 2001
From: Thomas Harte <thomas.harte@gmail.com>
Date: Mon, 11 Apr 2022 16:32:57 -0400
Subject: [PATCH] Add page 8.

---
 InstructionSets/68k/Decoder.cpp | 25 ++++++++++++++++++++++++-
 InstructionSets/68k/Decoder.hpp |  1 +
 2 files changed, 25 insertions(+), 1 deletion(-)

diff --git a/InstructionSets/68k/Decoder.cpp b/InstructionSets/68k/Decoder.cpp
index bd10e0626..b4c201c23 100644
--- a/InstructionSets/68k/Decoder.cpp
+++ b/InstructionSets/68k/Decoder.cpp
@@ -113,8 +113,9 @@ template <Operation operation> Preinstruction Predecoder::decode(uint16_t instru
 			}
 
 		//
-		// MARK: MULU, MULS.
+		// MARK: MULU, MULS, DIVU, DIVS.
 		//
+		case Operation::DIVU:	case Operation::DIVS:
 		case Operation::MULU:	case Operation::MULS:
 			return Preinstruction(operation,
 				ea_combined_mode, ea_register,
@@ -125,6 +126,27 @@ template <Operation operation> Preinstruction Predecoder::decode(uint16_t instru
 
 // MARK: - Page decoders.
 
+Preinstruction Predecoder::decode8(uint16_t instruction) {
+	// 4-171 (p275)
+	if((instruction & 0x1f0) == 0x100) return decode<Operation::SBCD>(instruction);
+
+	// 4-150 (p254)
+	switch(instruction & 0x0c0) {
+		case 0x00:	return decode<Operation::ORb>(instruction);
+		case 0x40:	return decode<Operation::ORw>(instruction);
+		case 0x80:	return decode<Operation::ORl>(instruction);
+		default: break;
+	}
+
+	switch(instruction & 0x1c0) {
+		case 0x0c0:	return decode<Operation::DIVU>(instruction);	// 4-97 (p201)
+		case 0x1c0:	return decode<Operation::DIVS>(instruction);	// 4-93 (p197)
+		default: break;
+	}
+
+	return Preinstruction();
+}
+
 Preinstruction Predecoder::decodeC(uint16_t instruction) {
 	// 4-3 (p107)
 	if((instruction & 0x1f0) == 0x100) return decode<Operation::ABCD>(instruction);
@@ -157,6 +179,7 @@ Preinstruction Predecoder::decodeC(uint16_t instruction) {
 Preinstruction Predecoder::decode(uint16_t instruction) {
 	// Divide first based on line.
 	switch(instruction & 0xf000) {
+		case 0x8000:	return decode8(instruction);
 		case 0xc000:	return decodeC(instruction);
 
 		default: break;
diff --git a/InstructionSets/68k/Decoder.hpp b/InstructionSets/68k/Decoder.hpp
index 06f450e32..d9bd2e86c 100644
--- a/InstructionSets/68k/Decoder.hpp
+++ b/InstructionSets/68k/Decoder.hpp
@@ -26,6 +26,7 @@ class Predecoder {
 	private:
 		// Page by page decoders; each gets a bit ad hoc so
 		// it is neater to separate them.
+		Preinstruction decode8(uint16_t instruction);
 		Preinstruction decodeC(uint16_t instruction);
 
 		// Specific instruction decoders.