1
0
mirror of https://github.com/TomHarte/CLK.git synced 2025-02-23 03:29:04 +00:00

Adds RESET, fixes branches and attempts to fix CMPI.

This commit is contained in:
Thomas Harte 2019-03-29 23:40:54 -04:00
parent a93a1ae40f
commit bc6349f823
4 changed files with 29 additions and 1 deletions

View File

@ -64,6 +64,9 @@ struct Microcycle {
/// of the data strobes are. /// of the data strobes are.
static const int SameAddress = 2; static const int SameAddress = 2;
/// A Reset cycle is one in which the RESET output is asserted.
static const int Reset = 3;
/// Indicates that the address and both data select strobes are active. /// Indicates that the address and both data select strobes are active.
static const int SelectWord = 1 << 2; static const int SelectWord = 1 << 2;

View File

@ -254,6 +254,12 @@ template <class T, bool dtack_is_implicit> void Processor<T, dtack_is_implicit>:
active_program_->source->halves.low.full = get_status(); active_program_->source->halves.low.full = get_status();
break; break;
/*
The no-op.
*/
case Operation::None:
break;
/* /*
SBCD subtracts the lowest byte of the source from that of the destination using SBCD subtracts the lowest byte of the source from that of the destination using
BCD arithmetic, obeying the extend flag. BCD arithmetic, obeying the extend flag.

View File

@ -191,6 +191,13 @@ struct ProcessorStorageConstructor {
} }
break; break;
case '_': // Indicates the reset cycle.
step.microcycle.length = HalfCycles(248);
step.microcycle.operation = Microcycle::Reset;
steps.push_back(step);
++access_pattern;
break;
default: default:
std::cerr << "MC68000 program builder; Unknown access type " << *access_pattern << std::endl; std::cerr << "MC68000 program builder; Unknown access type " << *access_pattern << std::endl;
assert(false); assert(false);
@ -244,6 +251,7 @@ struct ProcessorStorageConstructor {
Bcc, // twelve lowest bits are ignored, only a PerformAction is scheduled Bcc, // twelve lowest bits are ignored, only a PerformAction is scheduled
LEA, // decodes register, mode, register LEA, // decodes register, mode, register
MOVEq, // decodes just a destination register MOVEq, // decodes just a destination register
RESET, // no further decoding applied
}; };
using Operation = ProcessorStorage::Operation; using Operation = ProcessorStorage::Operation;
@ -294,6 +302,8 @@ struct ProcessorStorageConstructor {
{0xf000, 0x6000, Operation::Bcc, Decoder::Bcc}, // 4-25 (p129) {0xf000, 0x6000, Operation::Bcc, Decoder::Bcc}, // 4-25 (p129)
{0xf1c0, 0x41c0, Operation::MOVEAl, Decoder::LEA}, // 4-110 (p214) {0xf1c0, 0x41c0, Operation::MOVEAl, Decoder::LEA}, // 4-110 (p214)
{0xf100, 0x7000, Operation::MOVEq, Decoder::MOVEq}, // 4-134 (p238) {0xf100, 0x7000, Operation::MOVEq, Decoder::MOVEq}, // 4-134 (p238)
{0xffff, 0x4e70, Operation::None, Decoder::RESET}, // 6-83 (p537)
}; };
std::vector<size_t> micro_op_pointers(65536, std::numeric_limits<size_t>::max()); std::vector<size_t> micro_op_pointers(65536, std::numeric_limits<size_t>::max());
@ -321,6 +331,7 @@ struct ProcessorStorageConstructor {
// This decoder actually decodes nothing; it just schedules a PerformOperation followed by an empty step. // This decoder actually decodes nothing; it just schedules a PerformOperation followed by an empty step.
case Decoder::Bcc: { case Decoder::Bcc: {
op(Action::PerformOperation); op(Action::PerformOperation);
op(); // The above looks terminal, but will be dynamically reprogrammed.
} break; } break;
// A little artificial, there's nothing really to decode for BRA. // A little artificial, there's nothing really to decode for BRA.
@ -354,7 +365,7 @@ struct ProcessorStorageConstructor {
const auto destination_mode = source_mode; const auto destination_mode = source_mode;
const auto destination_register = source_register; const auto destination_register = source_register;
storage_.instructions[instruction].source = &storage_.prefetch_queue_; storage_.instructions[instruction].source = &storage_.bus_data_[0];
storage_.instructions[instruction].set_destination(storage_, destination_mode, destination_register); storage_.instructions[instruction].set_destination(storage_, destination_mode, destination_register);
const bool is_byte_access = mapping.operation == Operation::CMPb; const bool is_byte_access = mapping.operation == Operation::CMPb;
@ -362,10 +373,12 @@ struct ProcessorStorageConstructor {
const int mode = (is_long_word_access ? 0x100 : 0) | combined_mode(destination_mode, destination_register); const int mode = (is_long_word_access ? 0x100 : 0) | combined_mode(destination_mode, destination_register);
switch(mode) { switch(mode) {
case 0x000: // CMPI.bw #, Dn case 0x000: // CMPI.bw #, Dn
storage_.instructions[instruction].source = &storage_.prefetch_queue_;
op(Action::PerformOperation, seq("np np")); op(Action::PerformOperation, seq("np np"));
break; break;
case 0x100: // CMPI.l #, Dn case 0x100: // CMPI.l #, Dn
storage_.instructions[instruction].source = &storage_.prefetch_queue_;
op(Action::None, seq("np")); op(Action::None, seq("np"));
op(Action::PerformOperation, seq("np np n")); op(Action::PerformOperation, seq("np np n"));
break; break;
@ -503,6 +516,7 @@ struct ProcessorStorageConstructor {
case Decoder::MOVEtoSR: { case Decoder::MOVEtoSR: {
if(source_mode == 1) continue; if(source_mode == 1) continue;
storage_.instructions[instruction].set_source(storage_, source_mode, source_register); storage_.instructions[instruction].set_source(storage_, source_mode, source_register);
storage_.instructions[instruction].requires_supervisor = true;
/* DEVIATION FROM YACHT.TXT: it has all of these reading an extra word from the PC; /* DEVIATION FROM YACHT.TXT: it has all of these reading an extra word from the PC;
this looks like a mistake so I've padded with nil cycles in the middle. */ this looks like a mistake so I've padded with nil cycles in the middle. */
@ -1121,6 +1135,10 @@ struct ProcessorStorageConstructor {
} }
} break; } break;
case Decoder::RESET:
op(Action::None, seq("nn _ np"));
break;
default: default:
std::cerr << "Unhandled decoder " << int(mapping.decoder) << std::endl; std::cerr << "Unhandled decoder " << int(mapping.decoder) << std::endl;
continue; continue;

View File

@ -42,6 +42,7 @@ class ProcessorStorage {
HalfCycles half_cycles_left_to_run_; HalfCycles half_cycles_left_to_run_;
enum class Operation { enum class Operation {
None,
ABCD, SBCD, ABCD, SBCD,
ADD, AND, EOR, OR, SUB, ADD, AND, EOR, OR, SUB,