diff --git a/InstructionSets/x86/Implementation/PerformImplementation.hpp b/InstructionSets/x86/Implementation/PerformImplementation.hpp index cf8ed5d01..efeb3cd9a 100644 --- a/InstructionSets/x86/Implementation/PerformImplementation.hpp +++ b/InstructionSets/x86/Implementation/PerformImplementation.hpp @@ -533,7 +533,9 @@ template < template < InstructionType type, typename ContextT -> void perform( +> +requires is_context +void perform( const Instruction &instruction, ContextT &context ) { @@ -597,7 +599,9 @@ template < template < typename ContextT -> void interrupt( +> +requires is_context +void interrupt( const int index, ContextT &context ) { diff --git a/InstructionSets/x86/Perform.hpp b/InstructionSets/x86/Perform.hpp index d04735af9..684b46995 100644 --- a/InstructionSets/x86/Perform.hpp +++ b/InstructionSets/x86/Perform.hpp @@ -12,8 +12,39 @@ #include "Model.hpp" #include "Flags.hpp" +#include + namespace InstructionSet::x86 { +template +concept is_registers = true; + +template +concept is_segments = true; + +template +concept is_linear_memory = true; + +template +concept is_segmented_memory = true; + +template +concept is_flow_controller = true; + +template +concept is_cpu_control = true; + +template +concept is_context = requires(ContextT context) { + { context.flags } -> std::same_as; + { context.registers } -> is_registers; + { context.segments } -> is_segments; + { context.memory } -> is_segmented_memory; + { context.linear_memory } -> is_linear_memory; + { context.flow_controller } -> is_flow_controller; + + // TODO: is < 286 or has is_cpu_control for .cpu_control. +}; /// Performs @c instruction querying @c registers and/or @c memory as required, using @c io for port input/output, /// and providing any flow control effects to @c flow_controller. @@ -22,7 +53,9 @@ namespace InstructionSet::x86 { template < InstructionType type, typename ContextT -> void perform( +> +requires is_context +void perform( const Instruction &instruction, ContextT &context ); @@ -30,7 +63,9 @@ template < /// Performs an x86 INT operation; also often used by other operations to indicate an error. template < typename ContextT -> void interrupt( +> +requires is_context +void interrupt( int index, ContextT &context );