diff --git a/Processors/68000Mk2/Implementation/68000Mk2Implementation.hpp b/Processors/68000Mk2/Implementation/68000Mk2Implementation.hpp index d6405ced6..300810710 100644 --- a/Processors/68000Mk2/Implementation/68000Mk2Implementation.hpp +++ b/Processors/68000Mk2/Implementation/68000Mk2Implementation.hpp @@ -32,7 +32,7 @@ void Processor. + // + // TODO: add MOVE special case, somewhere. case State::FetchOperand: switch(instruction_.mode(next_operand_)) { case Mode::None: @@ -206,16 +219,39 @@ void Processor( + instruction_, operand_[0], operand_[1], status_, *static_cast(this)); + Prefetch(); // np + + next_operand_ = 0; + MoveToState(operand_flags_ & 0x0c ? State::StoreOperand : State::Decode); + break; + + case State::Perform_np_n: + InstructionSet::M68k::perform( + instruction_, operand_[0], operand_[1], status_, *static_cast(this)); + Prefetch(); // np + IdleBus(1); // n + + next_operand_ = 0; + MoveToState(operand_flags_ & 0x0c ? State::StoreOperand : State::Decode); + break; + - [[fallthrough]]; default: - printf("Unhandled or unterminated state: %d\n", state_); + printf("Unhandled state: %d\n", state_); assert(false); }} @@ -240,11 +276,13 @@ void Processor(); \ - perform_state_ = State::p; \ + perform_state_ = p; \ break; + using Mode = InstructionSet::M68k::AddressingMode; + switch(instruction_.operation) { - BIND(NBCD, Perform_np); + BIND(NBCD, instruction_.mode(0) == Mode::DataRegisterDirect ? State::Perform_np_n : State::Perform_np); default: assert(false); @@ -253,6 +291,17 @@ void Processor CPU::MC68000Mk2::State Processor::get_state() { return CPU::MC68000Mk2::State(); @@ -262,6 +311,7 @@ template ::set_state(const CPU::MC68000Mk2::State &) { } + } } diff --git a/Processors/68000Mk2/Implementation/68000Mk2Storage.hpp b/Processors/68000Mk2/Implementation/68000Mk2Storage.hpp index 78583eec2..8ddf365de 100644 --- a/Processors/68000Mk2/Implementation/68000Mk2Storage.hpp +++ b/Processors/68000Mk2/Implementation/68000Mk2Storage.hpp @@ -9,13 +9,14 @@ #ifndef _8000Mk2Storage_h #define _8000Mk2Storage_h -#include "../../../InstructionSets/M68k/Status.hpp" #include "../../../InstructionSets/M68k/Decoder.hpp" +#include "../../../InstructionSets/M68k/Perform.hpp" +#include "../../../InstructionSets/M68k/Status.hpp" namespace CPU { namespace MC68000Mk2 { -struct ProcessorBase { +struct ProcessorBase: public InstructionSet::M68k::NullFlowController { /// States for the state machine which are named by /// me for their purpose rather than automatically by file position. /// These are negative to avoid ambiguity with the other group. @@ -24,6 +25,7 @@ struct ProcessorBase { Decode = -2, WaitForDTACK = -3, FetchOperand = -4, + StoreOperand = -5, // Various different effective address calculations. @@ -34,6 +36,7 @@ struct ProcessorBase { // indicated bus cycle. Perform_np = -6, + Perform_np_n = -7, }; int state_ = State::Reset; @@ -86,6 +89,38 @@ struct ProcessorBase { /// When fetching or storing operands, this is the next one to fetch /// or store. int next_operand_ = 0; + + // Flow controller... all TODO. + using Preinstruction = InstructionSet::M68k::Preinstruction; + + template void did_mulu(IntT) {} + template void did_muls(IntT) {} + void did_chk([[maybe_unused]] bool was_under, [[maybe_unused]] bool was_over) {} + void did_shift([[maybe_unused]] int bit_count) {} + template void did_divu([[maybe_unused]] uint32_t dividend, [[maybe_unused]] uint32_t divisor) {} + template void did_divs([[maybe_unused]] int32_t dividend, [[maybe_unused]] int32_t divisor) {} + void did_bit_op([[maybe_unused]] int bit_position) {} + inline void did_update_status(); + template void complete_bcc(bool matched_condition, IntT offset) {} + void complete_dbcc(bool matched_condition, bool overflowed, int16_t offset) {} + void bsr(uint32_t offset) {} + void jsr(uint32_t address) {} + void jmp(uint32_t address) {} + void rtr() {} + void rte() {} + void rts() {} + void stop() {} + void reset() {} + void link(Preinstruction instruction, uint32_t offset) {} + void unlink(uint32_t &address) {} + void pea(uint32_t address) {} + void move_to_usp(uint32_t address) {} + void move_from_usp(uint32_t &address) {} + void tas(Preinstruction instruction, uint32_t address) {} + template void movep(Preinstruction instruction, uint32_t source, uint32_t dest) {} + template void movem_toM(Preinstruction instruction, uint32_t mask, uint32_t address) {} + template void movem_toR(Preinstruction instruction, uint32_t mask, uint32_t address) {} + template void raise_exception([[maybe_unused]] int vector) {} }; }