diff --git a/InstructionSets/x86/Implementation/LoadStore.hpp b/InstructionSets/x86/Implementation/LoadStore.hpp index 4e8132856..398d5fa6e 100644 --- a/InstructionSets/x86/Implementation/LoadStore.hpp +++ b/InstructionSets/x86/Implementation/LoadStore.hpp @@ -96,8 +96,6 @@ void lmsw( context.registers.set_msw(source); if(source & MachineStatus::ProtectedModeEnable) { context.cpu_control.set_mode(Mode::Protected286); -// context.memory.set_mode(Mode::Protected286); -// context.segments.set_mode(Mode::Protected286); } } diff --git a/InstructionSets/x86/Model.hpp b/InstructionSets/x86/Model.hpp index c1b67e69a..faec3c524 100644 --- a/InstructionSets/x86/Model.hpp +++ b/InstructionSets/x86/Model.hpp @@ -47,8 +47,16 @@ static constexpr bool has_mode(const Model model, const Mode mode) { } return false; } + static constexpr bool uses_8086_exceptions(const Model model) { return model <= Model::i80186; } + +template +concept has_descriptor_tables = model >= Model::i80286; + +template +concept has_32bit_instructions = model >= Model::i80386; + } diff --git a/InstructionSets/x86/Perform.hpp b/InstructionSets/x86/Perform.hpp index 684b46995..c14f8bc21 100644 --- a/InstructionSets/x86/Perform.hpp +++ b/InstructionSets/x86/Perform.hpp @@ -16,12 +16,33 @@ namespace InstructionSet::x86 { +// +// Register interface requirements. +// template concept is_registers = true; +// +// Segment/descriptor interface requirements. +// template -concept is_segments = true; +concept has_segment_update = requires(SegmentsT segments) { + segments.did_update(Source{}); +}; +template +concept has_descriptor_table_update = requires(SegmentsT segments) { + segments.did_update(DescriptorTable{}); +}; + +template +concept is_segments = + has_segment_update && + (!has_descriptor_tables || has_descriptor_table_update); + +// +// +// template concept is_linear_memory = true; @@ -29,10 +50,19 @@ template concept is_segmented_memory = true; template -concept is_flow_controller = true; +concept is_flow_controller = requires(FlowControllerT controller) { + controller.template jump(uint16_t{}); + controller.template jump(uint16_t{}, uint16_t{}); + controller.halt(); + controller.wait(); + controller.repeat_last(); + + // TODO: if 32-bit, check for jump, Somehow? +}; template concept is_cpu_control = true; +// TODO: if 286 or better, cpu_control.set_mode(Mode{}); template concept is_context = requires(ContextT context) {