1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-11-25 16:31:42 +00:00

Add did_set_pc.

This commit is contained in:
Thomas Harte 2024-04-18 19:30:07 -04:00
parent 018f0e097f
commit d464ce831a
2 changed files with 9 additions and 0 deletions

View File

@ -31,6 +31,7 @@ DestinationT read_bus(SourceT value) {
struct NullStatusHandler { struct NullStatusHandler {
void did_set_status() {} void did_set_status() {}
void did_set_pc() {}
}; };
/// A class compatible with the @c OperationMapper definition of a scheduler which applies all actions /// A class compatible with the @c OperationMapper definition of a scheduler which applies all actions
@ -195,6 +196,7 @@ struct Executor {
if(!is_comparison(flags.operation()) && fields.destination() == 15) { if(!is_comparison(flags.operation()) && fields.destination() == 15) {
registers_.set_pc(pc_proxy); registers_.set_pc(pc_proxy);
status_observer_.did_set_pc();
} }
if constexpr (flags.set_condition_codes()) { if constexpr (flags.set_condition_codes()) {
// "When Rd is R15 and the S flag in the instruction is set, the PSR is overwritten by the // "When Rd is R15 and the S flag in the instruction is set, the PSR is overwritten by the
@ -250,6 +252,7 @@ struct Executor {
registers_[14] = registers_.pc_status(0); registers_[14] = registers_.pc_status(0);
} }
registers_.set_pc(registers_.pc(4) + branch.offset()); registers_.set_pc(registers_.pc(4) + branch.offset());
status_observer_.did_set_pc();
} }
template <Flags f> void perform(SingleDataTransfer transfer) { template <Flags f> void perform(SingleDataTransfer transfer) {
@ -358,6 +361,7 @@ struct Executor {
if(transfer.destination() == 15) { if(transfer.destination() == 15) {
registers_.set_pc(value); registers_.set_pc(value);
status_observer_.did_set_pc();
} else { } else {
registers_[transfer.destination()] = value; registers_[transfer.destination()] = value;
} }
@ -369,6 +373,7 @@ struct Executor {
if(flags.operation() == SingleDataTransferFlags::Operation::STR || transfer.base() != transfer.destination()) { if(flags.operation() == SingleDataTransferFlags::Operation::STR || transfer.base() != transfer.destination()) {
if(transfer.base() == 15) { if(transfer.base() == 15) {
registers_.set_pc(offsetted_address); registers_.set_pc(offsetted_address);
status_observer_.did_set_pc();
} else { } else {
registers_[transfer.base()] = offsetted_address; registers_[transfer.base()] = offsetted_address;
} }
@ -555,6 +560,7 @@ struct Executor {
// If this was an LDM to R15 then apply it appropriately. // If this was an LDM to R15 then apply it appropriately.
if(is_ldm && list & (1 << 15)) { if(is_ldm && list & (1 << 15)) {
registers_.set_pc(pc_proxy); registers_.set_pc(pc_proxy);
status_observer_.did_set_pc();
if constexpr (flags.load_psr()) { if constexpr (flags.load_psr()) {
registers_.set_status(pc_proxy); registers_.set_status(pc_proxy);
status_observer_.did_set_status(); status_observer_.did_set_status();

View File

@ -420,6 +420,9 @@ class ConcreteMachine:
update_interrupts(); update_interrupts();
} }
void did_set_pc() {
}
void update_clock_rates() { void update_clock_rates() {
video_divider_ = executor_.bus.video().clock_divider(); video_divider_ = executor_.bus.video().clock_divider();
} }