diff --git a/InstructionSets/x86/Implementation/PerformImplementation.hpp b/InstructionSets/x86/Implementation/PerformImplementation.hpp index 4ef6cad44..8a1e7a6f7 100644 --- a/InstructionSets/x86/Implementation/PerformImplementation.hpp +++ b/InstructionSets/x86/Implementation/PerformImplementation.hpp @@ -524,7 +524,7 @@ template < const uint16_t ip = context.memory.template access(address); const uint16_t cs = context.memory.template access(address + 2); - auto flags = context.flags.get(); + const auto flags = context.flags.get(); Primitive::push(flags, context); context.flags.template set_from(0); diff --git a/InstructionSets/x86/Implementation/Stack.hpp b/InstructionSets/x86/Implementation/Stack.hpp index 6568d2040..5f538dcd0 100644 --- a/InstructionSets/x86/Implementation/Stack.hpp +++ b/InstructionSets/x86/Implementation/Stack.hpp @@ -18,7 +18,7 @@ namespace InstructionSet::x86::Primitive { // which should place the value of SP after the push onto the stack. template void push( - IntT &value, + const IntT &value, ContextT &context ) { context.registers.sp() -= sizeof(IntT); @@ -45,7 +45,7 @@ IntT pop( template void sahf( - uint8_t &ah, + const uint8_t &ah, ContextT &context ) { /* @@ -86,7 +86,7 @@ template void pushf( ContextT &context ) { - uint16_t value = context.flags.get(); + const uint16_t value = context.flags.get(); push(value, context); } @@ -121,7 +121,7 @@ void pusha( ContextT &context ) { context.memory.preauthorise_stack_read(sizeof(IntT) * 8); - IntT initial_sp = context.registers.sp(); + const IntT initial_sp = context.registers.sp(); if constexpr (std::is_same_v) { push(context.registers.eax(), context); push(context.registers.ecx(), context); diff --git a/InstructionSets/x86/Perform.hpp b/InstructionSets/x86/Perform.hpp index 46821aab7..62110f543 100644 --- a/InstructionSets/x86/Perform.hpp +++ b/InstructionSets/x86/Perform.hpp @@ -41,6 +41,7 @@ template < ContextT &context ); +/// Performs an x86 INT operation; also often used by other operations to indicate an error. template < typename ContextT > void interrupt( diff --git a/Machines/PCCompatible/Memory.hpp b/Machines/PCCompatible/Memory.hpp index ce2c5524f..ccb988f4b 100644 --- a/Machines/PCCompatible/Memory.hpp +++ b/Machines/PCCompatible/Memory.hpp @@ -111,12 +111,12 @@ struct Memory { // // Helper for instruction fetch. // - std::pair next_code() { + std::pair next_code() const { const uint32_t start = segments_.cs_base_ + registers_.ip(); return std::make_pair(&memory[start], 0x10'000 - start); } - std::pair all() { + std::pair all() const { return std::make_pair(memory.data(), 0x10'000); } @@ -136,7 +136,7 @@ struct Memory { Registers ®isters_; const Segments &segments_; - uint32_t segment_base(InstructionSet::x86::Source segment) { + uint32_t segment_base(const InstructionSet::x86::Source segment) const { using Source = InstructionSet::x86::Source; switch(segment) { default: return segments_.ds_base_; @@ -146,13 +146,13 @@ struct Memory { } } - uint32_t address(InstructionSet::x86::Source segment, uint16_t offset) { + uint32_t address(const InstructionSet::x86::Source segment, const uint16_t offset) const { return (segment_base(segment) + offset) & 0xf'ffff; } template typename InstructionSet::x86::Accessor::type - split_word(uint32_t low_address, uint32_t high_address) { + split_word(const uint32_t low_address, const uint32_t high_address) { if constexpr (is_writeable(type)) { write_back_address_[0] = low_address; write_back_address_[1] = high_address;