From 85242ba896cde1e6663ee5279413a14e656f84dc Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Fri, 29 Apr 2022 11:10:14 -0400 Subject: [PATCH] Add to Xcode project, template on Model as per CLR being odd. Fill in some obvious answers. --- InstructionSets/M68k/Sequence.cpp | 35 ++++++++++--- InstructionSets/M68k/Sequence.hpp | 49 ++++++++++--------- .../Clock Signal.xcodeproj/project.pbxproj | 4 ++ 3 files changed, 58 insertions(+), 30 deletions(-) diff --git a/InstructionSets/M68k/Sequence.cpp b/InstructionSets/M68k/Sequence.cpp index a476be507..0471759da 100644 --- a/InstructionSets/M68k/Sequence.cpp +++ b/InstructionSets/M68k/Sequence.cpp @@ -10,21 +10,44 @@ using namespace InstructionSet::M68k; -template struct Steps { +template struct Steps { static constexpr uint16_t value = 0; }; -template struct Steps { - static constexpr uint16_t value = uint16_t(F) | uint16_t(Mask::value << 3); +template struct Steps { + static constexpr uint16_t value = uint16_t(F) | uint16_t(Steps::value << 3); }; -uint16_t Sequence::steps_for(Operation operation) { +template uint16_t Sequence::steps_for(Operation operation) { switch(operation) { // This handles a NOP, and not much else. default: return 0; - case Operation::ABCD: return Steps< Step::FetchOp1, Step::Perform, Step::StoreOp1 >::value; + // + // Single operand, read-modify-write. + // + case Operation::NBCD: return Steps< Step::FetchOp1, Step::Perform, Step::StoreOp1 >::value; + + // + // Two operand, read-modify-write. + // + case Operation::ABCD: case Operation::SBCD: + case Operation::ADDb: case Operation::ADDw: case Operation::ADDl: + case Operation::ADDAw: case Operation::ADDAl: + case Operation::ADDXb: case Operation::ADDXw: case Operation::ADDXl: + case Operation::SUBb: case Operation::SUBw: case Operation::SUBl: + case Operation::SUBAw: case Operation::SUBAl: + case Operation::SUBXb: case Operation::SUBXw: case Operation::SUBXl: + case Operation::MOVEb: case Operation::MOVEw: case Operation::MOVEl: + case Operation::MOVEAw: case Operation::MOVEAl: + return Steps< Step::FetchOp1, Step::FetchOp2, Step::Perform, Step::StoreOp2 >::value; } } -Sequence::Sequence(Operation operation) : steps_(steps_for(operation)) {} +template Sequence::Sequence(Operation operation) : steps_(steps_for(operation)) {} + +template class InstructionSet::M68k::Sequence; +template class InstructionSet::M68k::Sequence; +template class InstructionSet::M68k::Sequence; +template class InstructionSet::M68k::Sequence; +template class InstructionSet::M68k::Sequence; diff --git a/InstructionSets/M68k/Sequence.hpp b/InstructionSets/M68k/Sequence.hpp index b33ca0ce7..2e13afc8d 100644 --- a/InstructionSets/M68k/Sequence.hpp +++ b/InstructionSets/M68k/Sequence.hpp @@ -10,38 +10,39 @@ #define InstructionSets_68k_Sequencer_hpp #include "Instruction.hpp" +#include "Model.hpp" namespace InstructionSet { namespace M68k { +enum class Step { + /// No further steps remain. + Done, + /// Fetch the value of operand 1. + FetchOp1, + /// Fetch the value of operand 2. + FetchOp2, + /// Do the logical operation. + Perform, + /// A catch-all for bus activity that doesn't fit the pattern + /// of fetch/stop operand 1/2, e.g. this opaquely covers almost + /// the entirety of MOVEM. + /// + /// TODO: list all operations that contain this step, + /// and to cover what activity. + SpecificBusActivity, + /// Store the value of operand 1. + StoreOp1, + /// Store the value of operand 2. + StoreOp2, +}; + /// Indicates the abstract steps necessary to perform an operation, /// at least as far as that's generic. -class Sequence { +template class Sequence { public: Sequence(Operation); - enum class Step { - /// No further steps remain. - Done, - /// Fetch the value of operand 1. - FetchOp1, - /// Fetch the value of operand 2. - FetchOp2, - /// Do the logical operation. - Perform, - /// A catch-all for bus activity that doesn't fit the pattern - /// of fetch/stop operand 1/2, e.g. this opaquely covers almost - /// the entirety of MOVEM. - /// - /// TODO: list all operations that contain this step, - /// and to cover what activity. - SpecificBusActivity, - /// Store the value of operand 1. - StoreOp1, - /// Store the value of operand 2. - StoreOp2, - }; - /// @returns The next @c Step to perform, or @c Done /// if no further steps remain. This step is removed from the /// list of remaining steps. @@ -63,7 +64,7 @@ class Sequence { uint16_t steps_for(Operation); }; -static_assert(sizeof(Sequence) == sizeof(uint16_t)); +static_assert(sizeof(Sequence) == sizeof(uint16_t)); } } diff --git a/OSBindings/Mac/Clock Signal.xcodeproj/project.pbxproj b/OSBindings/Mac/Clock Signal.xcodeproj/project.pbxproj index 280d5e11f..771e04656 100644 --- a/OSBindings/Mac/Clock Signal.xcodeproj/project.pbxproj +++ b/OSBindings/Mac/Clock Signal.xcodeproj/project.pbxproj @@ -427,6 +427,8 @@ 4B7962A02819681F008130F9 /* Decoder.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4B79629F2819681F008130F9 /* Decoder.cpp */; }; 4B7962A12819681F008130F9 /* Decoder.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4B79629F2819681F008130F9 /* Decoder.cpp */; }; 4B7962A22819681F008130F9 /* Decoder.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4B79629F2819681F008130F9 /* Decoder.cpp */; }; + 4B7962A5281C32D8008130F9 /* Sequence.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4B7962A4281C2EE3008130F9 /* Sequence.cpp */; }; + 4B7962A6281C32D8008130F9 /* Sequence.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4B7962A4281C2EE3008130F9 /* Sequence.cpp */; }; 4B79A5011FC913C900EEDAD5 /* MSX.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4B79A4FF1FC913C900EEDAD5 /* MSX.cpp */; }; 4B79E4441E3AF38600141F11 /* cassette.png in Resources */ = {isa = PBXBuildFile; fileRef = 4B79E4411E3AF38600141F11 /* cassette.png */; }; 4B79E4451E3AF38600141F11 /* floppy35.png in Resources */ = {isa = PBXBuildFile; fileRef = 4B79E4421E3AF38600141F11 /* floppy35.png */; }; @@ -5464,6 +5466,7 @@ 4BC080CB26A238CC00D03FD8 /* AmigaADF.cpp in Sources */, 4B4B1A3D200198CA00A0F866 /* KonamiSCC.cpp in Sources */, 4B055AC31FAE9AE80060FFFF /* AmstradCPC.cpp in Sources */, + 4B7962A5281C32D8008130F9 /* Sequence.cpp in Sources */, 4B055A9E1FAE85DA0060FFFF /* G64.cpp in Sources */, 4B055AB81FAE860F0060FFFF /* ZX80O81P.cpp in Sources */, 4B055AB01FAE86070060FFFF /* PulseQueuedTape.cpp in Sources */, @@ -5700,6 +5703,7 @@ 4B894518201967B4007DE474 /* ConfidenceCounter.cpp in Sources */, 4BCE005A227CFFCA000CA200 /* Macintosh.cpp in Sources */, 4B6AAEA4230E3E1D0078E864 /* MassStorageDevice.cpp in Sources */, + 4B7962A6281C32D8008130F9 /* Sequence.cpp in Sources */, 4B89452E201967B4007DE474 /* StaticAnalyser.cpp in Sources */, 4BC890D3230F86020025A55A /* DirectAccessDevice.cpp in Sources */, 4B7BA03723CEB86000B98D9E /* BD500.cpp in Sources */,