1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-09-28 09:54:49 +00:00

Switched to following the current program via address.

This commit is contained in:
Thomas Harte 2017-05-30 18:49:40 -04:00
parent 244b5ba3c2
commit a0189a6fe1
3 changed files with 14 additions and 14 deletions

View File

@ -558,15 +558,14 @@ template <class T> class Processor: public MicroOpScheduler<MicroOp> {
// without touching the class storage (i.e. it explicitly says they need be completely up
// to date in this stack frame only); which saves some complicated addressing
unsigned int scheduleProgramsReadPointer = schedule_programs_read_pointer_;
unsigned int scheduleProgramProgramCounter = schedule_program_program_counter_;
RegisterPair nextAddress = next_address_;
BusOperation nextBusOperation = next_bus_operation_;
uint16_t busAddress = bus_address_;
uint8_t *busValue = bus_value_;
#define checkSchedule(op) \
if(!scheduled_programs_[scheduleProgramsReadPointer]) {\
scheduleProgramsReadPointer = schedule_programs_write_pointer_ = scheduleProgramProgramCounter = 0;\
if(!scheduled_program_counter_) {\
scheduleProgramsReadPointer = schedule_programs_write_pointer_ = 0;\
if(interrupt_requests_) {\
if(interrupt_requests_ & (InterruptRequestFlags::Reset | InterruptRequestFlags::PowerOn)) {\
interrupt_requests_ &= ~InterruptRequestFlags::PowerOn;\
@ -607,8 +606,8 @@ template <class T> class Processor: public MicroOpScheduler<MicroOp> {
while(1) {
const MicroOp cycle = program[scheduleProgramProgramCounter];
scheduleProgramProgramCounter++;
const MicroOp cycle = *scheduled_program_counter_;
scheduled_program_counter_++;
#define read_op(val, addr) nextBusOperation = BusOperation::ReadOpcode; busAddress = addr; busValue = &val; val = 0xff
#define read_mem(val, addr) nextBusOperation = BusOperation::Read; busAddress = addr; busValue = &val; val = 0xff
@ -649,7 +648,7 @@ template <class T> class Processor: public MicroOpScheduler<MicroOp> {
case OperationMoveToNextProgram:
scheduled_programs_[scheduleProgramsReadPointer] = NULL;
scheduleProgramsReadPointer = (scheduleProgramsReadPointer+1)&3;
scheduleProgramProgramCounter = 0;
scheduled_program_counter_ = scheduled_programs_[scheduleProgramsReadPointer];
checkSchedule();
program = scheduled_programs_[scheduleProgramsReadPointer];
continue;
@ -1083,7 +1082,6 @@ template <class T> class Processor: public MicroOpScheduler<MicroOp> {
cycles_left_to_run_ = number_of_cycles;
schedule_programs_read_pointer_ = scheduleProgramsReadPointer;
schedule_program_program_counter_ = scheduleProgramProgramCounter;
next_address_ = nextAddress;
next_bus_operation_ = nextBusOperation;
bus_address_ = busAddress;

View File

@ -17,7 +17,7 @@ template <class T> class MicroOpScheduler {
scheduled_programs_{nullptr, nullptr, nullptr, nullptr},
schedule_programs_write_pointer_(0),
schedule_programs_read_pointer_(0),
schedule_program_program_counter_(0) {}
scheduled_program_counter_(nullptr) {}
protected:
/*
@ -28,7 +28,8 @@ template <class T> class MicroOpScheduler {
queue to take that step.
*/
const T *scheduled_programs_[4];
unsigned int schedule_programs_write_pointer_, schedule_programs_read_pointer_, schedule_program_program_counter_;
const T *scheduled_program_counter_;
unsigned int schedule_programs_write_pointer_, schedule_programs_read_pointer_;
/*!
Schedules a new program, adding it to the end of the queue. Programs should be
@ -39,13 +40,14 @@ template <class T> class MicroOpScheduler {
*/
inline void schedule_program(const T *program) {
scheduled_programs_[schedule_programs_write_pointer_] = program;
if(schedule_programs_write_pointer_ == schedule_programs_read_pointer_) scheduled_program_counter_ = program;
schedule_programs_write_pointer_ = (schedule_programs_write_pointer_+1)&3;
}
inline void move_to_next_program() {
scheduled_programs_[schedule_programs_read_pointer_] = NULL;
scheduled_programs_[schedule_programs_read_pointer_] = nullptr;
schedule_programs_read_pointer_ = (schedule_programs_read_pointer_+1)&3;
schedule_program_program_counter_ = 0;
scheduled_program_counter_ = scheduled_programs_[schedule_programs_read_pointer_];
}
};

View File

@ -686,8 +686,8 @@ template <class T> class Processor: public MicroOpScheduler<MicroOp> {
checkSchedule();
while(1) {
const MicroOp *operation = &scheduled_programs_[schedule_programs_read_pointer_][schedule_program_program_counter_];
schedule_program_program_counter_++;
const MicroOp *operation = scheduled_program_counter_;
scheduled_program_counter_++;
#define set_parity(v) \
parity_overflow_result_ = v^1;\
@ -697,7 +697,7 @@ template <class T> class Processor: public MicroOpScheduler<MicroOp> {
switch(operation->type) {
case MicroOp::BusOperation:
if(number_of_cycles_ < operation->machine_cycle.length) { schedule_program_program_counter_--; return; }
if(number_of_cycles_ < operation->machine_cycle.length) { scheduled_program_counter_--; return; }
number_of_cycles_ -= operation->machine_cycle.length;
number_of_cycles_ -= static_cast<T *>(this)->perform_machine_cycle(&operation->machine_cycle);
break;