1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-11-22 12:33:29 +00:00

Increases likelihood of 68000 Program offset-size assumptions being met.

This commit is contained in:
Thomas Harte 2020-07-02 22:24:04 -04:00
parent 8bf5ed52ea
commit 402f2ddbd9

View File

@ -23,6 +23,16 @@ class ProcessorStorage {
RegisterPair32 prefetch_queue_; // Each word will go into the low part of the word, then proceed upward. RegisterPair32 prefetch_queue_; // Each word will go into the low part of the word, then proceed upward.
// Generic sources and targets for memory operations;
// by convention: effective_address_[0] = source, [1] = destination.
//
// These, and the various register contents above, should be kept
// close to the top of this class so that small-integer offsets can be
// used in instances of Program (see below).
RegisterPair32 effective_address_[2];
RegisterPair32 source_bus_data_;
RegisterPair32 destination_bus_data_;
enum class ExecutionState { enum class ExecutionState {
/// The normal mode, this means the 68000 is expending processing effort. /// The normal mode, this means the 68000 is expending processing effort.
Executing, Executing,
@ -72,12 +82,6 @@ class ProcessorStorage {
int accepted_interrupt_level_ = 0; int accepted_interrupt_level_ = 0;
bool is_starting_interrupt_ = false; bool is_starting_interrupt_ = false;
// Generic sources and targets for memory operations;
// by convention: [0] = source, [1] = destination.
RegisterPair32 effective_address_[2];
RegisterPair32 source_bus_data_;
RegisterPair32 destination_bus_data_;
HalfCycles half_cycles_left_to_run_; HalfCycles half_cycles_left_to_run_;
HalfCycles e_clock_phase_; HalfCycles e_clock_phase_;
@ -383,11 +387,13 @@ class ProcessorStorage {
void set_source(ProcessorStorage &storage, RegisterPair32 *target) { void set_source(ProcessorStorage &storage, RegisterPair32 *target) {
source_offset = decltype(source_offset)(reinterpret_cast<uint8_t *>(target) - reinterpret_cast<uint8_t *>(&storage)); source_offset = decltype(source_offset)(reinterpret_cast<uint8_t *>(target) - reinterpret_cast<uint8_t *>(&storage));
// Test that destination_offset could be stored fully within the integer size provided for source_offset.
assert(source_offset == (reinterpret_cast<uint8_t *>(target) - reinterpret_cast<uint8_t *>(&storage))); assert(source_offset == (reinterpret_cast<uint8_t *>(target) - reinterpret_cast<uint8_t *>(&storage)));
} }
void set_destination(ProcessorStorage &storage, RegisterPair32 *target) { void set_destination(ProcessorStorage &storage, RegisterPair32 *target) {
destination_offset = decltype(destination_offset)(reinterpret_cast<uint8_t *>(target) - reinterpret_cast<uint8_t *>(&storage)); destination_offset = decltype(destination_offset)(reinterpret_cast<uint8_t *>(target) - reinterpret_cast<uint8_t *>(&storage));
// Test that destination_offset could be stored fully within the integer size provided for destination_offset.
assert(destination_offset == (reinterpret_cast<uint8_t *>(target) - reinterpret_cast<uint8_t *>(&storage))); assert(destination_offset == (reinterpret_cast<uint8_t *>(target) - reinterpret_cast<uint8_t *>(&storage)));
} }