diff --git a/Processors/6502/Implementation/6502Base.cpp b/Processors/6502/Implementation/6502Base.cpp index 54fe21138..f82294b72 100644 --- a/Processors/6502/Implementation/6502Base.cpp +++ b/Processors/6502/Implementation/6502Base.cpp @@ -8,6 +8,8 @@ #include "../6502.hpp" +#include + using namespace CPU::MOS6502; const uint8_t CPU::MOS6502::JamOpcode = 0xf2; @@ -80,6 +82,7 @@ ProcessorBase::State ProcessorBase::get_state() { state.execution_state.micro_program = int(micro_offset / list_length); state.execution_state.micro_program_offset = int(micro_offset % list_length); + assert(&operations_[state.execution_state.micro_program][state.execution_state.micro_program_offset] == scheduled_program_counter_); return state; } diff --git a/Reflection/Struct.hpp b/Reflection/Struct.hpp index f60ce06c1..8b1860e3c 100644 --- a/Reflection/Struct.hpp +++ b/Reflection/Struct.hpp @@ -9,6 +9,7 @@ #ifndef Struct_hpp #define Struct_hpp +#include #include #include #include @@ -113,6 +114,15 @@ struct Serialisable { template class StructImpl: public Struct { public: +#ifndef NDEBUG + StructImpl() { + // Protect against declarations that nominate the wrong Owner; this isn't + // a static assert because that wouldn't catch all invalid cases. + const auto owner = static_cast(this); + assert(owner != nullptr); + } +#endif + /*! @returns the value of type @c Type that is loaded from the offset registered for the field @c name. It is the caller's responsibility to provide an appropriate type of data.