1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-09-29 16:55:59 +00:00

Implement RTS, RTR, RTE.

This commit is contained in:
Thomas Harte 2022-05-06 12:30:49 -04:00
parent ac6a9ab631
commit 1defeca1ad
5 changed files with 37 additions and 15 deletions

View File

@ -55,6 +55,9 @@ template <Model model, typename BusHandler> class Executor {
template <typename IntT> void movem_toR(Preinstruction instruction, uint32_t source, uint32_t dest);
void pea(uint32_t address);
void tas(Preinstruction instruction, uint32_t address);
void rtr();
void rts();
void rte();
// TODO: ownership of this shouldn't be here.
struct Registers {

View File

@ -401,6 +401,26 @@ void Executor<model, BusHandler>::pea(uint32_t address) {
bus_handler_.template write<uint32_t>(sp().l, address);
}
template <Model model, typename BusHandler>
void Executor<model, BusHandler>::rtr() {
status_.set_ccr(bus_handler_.template read<uint16_t>(sp().l));
sp().l += 2;
rts();
}
template <Model model, typename BusHandler>
void Executor<model, BusHandler>::rte() {
status_.set_status(bus_handler_.template read<uint16_t>(sp().l));
sp().l += 2;
rts();
}
template <Model model, typename BusHandler>
void Executor<model, BusHandler>::rts() {
program_counter_.l = bus_handler_.template read<uint32_t>(sp().l);
sp().l += 4;
}
template <Model model, typename BusHandler>
void Executor<model, BusHandler>::tas(Preinstruction instruction, uint32_t address) {
uint8_t original_value;

View File

@ -1204,21 +1204,17 @@ template <
/*
RTE and RTR share an implementation.
*/
// case Operation::RTE_RTR:
// // If this is RTR, patch out the supervisor half of the status register.
// if(decoded_instruction_.l == 0x4e77) {
// const auto current_status = status();
// source_bus_data_.halves.low.halves.high =
// uint8_t(current_status >> 8);
// }
// apply_status(source_bus_data_.l);
// break;
case Operation::RTR:
flow_controller.rtr();
break;
// case Operation::RTE:
// break;
//
// case Operation::RTR:
// break;
case Operation::RTE:
flow_controller.rte();
break;
case Operation::RTS:
flow_controller.rts();
break;
/*
TSTs: compare to zero.

View File

@ -276,6 +276,7 @@ template <Model model, Operation t_operation = Operation::Undefined> uint8_t ope
case Operation::MOVEMtoMw: case Operation::MOVEMtoMl:
case Operation::MOVEMtoRw: case Operation::MOVEMtoRl:
case Operation::TAS:
case Operation::RTR: case Operation::RTS: case Operation::RTE:
return 0;
//

View File

@ -52,6 +52,8 @@
// swap
// tas
// tst
// rts
// rtr
// Issues to fix:
//
@ -81,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:@[@"rts.json", @"rtr.json"]];
// _fileSet = [NSSet setWithArray:@[@"rts.json", @"rtr.json"]];
// _testSet = [NSSet setWithArray:@[@"NEGX 00c0"]];
// _fileSet = [NSSet setWithArray:@[@"jmp_jsr.json"]];
// _testSet = [NSSet setWithArray:@[@"CHK 41a8"]];