mirror of
https://github.com/TomHarte/CLK.git
synced 2024-11-23 03:32:32 +00:00
Permit TRAP, TRAPV and CHK to push the next PC rather than the current.
This commit is contained in:
parent
ad6cf5e401
commit
bf8c97abbb
@ -39,13 +39,14 @@ template <Model model, typename BusHandler> class Executor {
|
||||
|
||||
// Flow control.
|
||||
void consume_cycles(int) {}
|
||||
void raise_exception(int);
|
||||
void stop();
|
||||
void set_pc(uint32_t);
|
||||
void add_pc(uint32_t);
|
||||
void decline_branch() {}
|
||||
|
||||
void raise_exception(int, bool use_current_instruction_pc = true);
|
||||
void did_update_status();
|
||||
|
||||
void stop();
|
||||
void bsr(uint32_t offset);
|
||||
void jsr(uint32_t offset);
|
||||
void link(Preinstruction instruction, uint32_t offset);
|
||||
|
@ -330,7 +330,7 @@ void Executor<model, BusHandler>::set_state(const Registers &state) {
|
||||
// TODO: flow control, all below here.
|
||||
|
||||
template <Model model, typename BusHandler>
|
||||
void Executor<model, BusHandler>::raise_exception(int index) {
|
||||
void Executor<model, BusHandler>::raise_exception(int index, bool use_current_instruction_pc) {
|
||||
const uint32_t address = index << 2;
|
||||
|
||||
// Grab the status to store, then switch into supervisor mode.
|
||||
@ -339,7 +339,7 @@ void Executor<model, BusHandler>::raise_exception(int index) {
|
||||
did_update_status();
|
||||
|
||||
// Push status and the program counter at instruction start.
|
||||
bus_handler_.template write<uint32_t>(sp.l - 4, instruction_address_);
|
||||
bus_handler_.template write<uint32_t>(sp.l - 4, use_current_instruction_pc ? instruction_address_ : program_counter_.l);
|
||||
bus_handler_.template write<uint16_t>(sp.l - 6, status);
|
||||
sp.l -= 6;
|
||||
|
||||
|
@ -652,12 +652,12 @@ template <
|
||||
|
||||
// TRAP, which is a nicer form of ILLEGAL.
|
||||
case Operation::TRAP:
|
||||
flow_controller.raise_exception(src.l + 32);
|
||||
flow_controller.raise_exception(src.l + 32, false);
|
||||
break;
|
||||
|
||||
case Operation::TRAPV: {
|
||||
if(status.overflow_flag_) {
|
||||
flow_controller.raise_exception(7);
|
||||
flow_controller.raise_exception(7, false);
|
||||
}
|
||||
} break;
|
||||
|
||||
@ -683,7 +683,7 @@ template <
|
||||
} else {
|
||||
flow_controller.consume_cycles(12);
|
||||
}
|
||||
flow_controller.raise_exception(6);
|
||||
flow_controller.raise_exception(6, false);
|
||||
}
|
||||
} break;
|
||||
|
||||
|
@ -83,7 +83,7 @@
|
||||
|
||||
- (void)setUp {
|
||||
// To limit tests run to a subset of files and/or of tests, uncomment and fill in below.
|
||||
// _fileSet = [NSSet setWithArray:@[@"link_unlk.json"]];
|
||||
_fileSet = [NSSet setWithArray:@[@"ext.json"]];
|
||||
// _testSet = [NSSet setWithArray:@[@"NEGX 00c0"]];
|
||||
// _fileSet = [NSSet setWithArray:@[@"jmp_jsr.json"]];
|
||||
// _testSet = [NSSet setWithArray:@[@"CHK 41a8"]];
|
||||
|
Loading…
Reference in New Issue
Block a user