1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-11-23 03:32:32 +00:00

Hit a realisation: write-back isn't going to work with MOVEP as formulated.

This commit is contained in:
Thomas Harte 2022-05-05 09:26:26 -04:00
parent 665f2d4c00
commit 4a4e786060
2 changed files with 38 additions and 0 deletions

View File

@ -50,6 +50,8 @@ template <Model model, typename BusHandler> class Executor {
void jsr(uint32_t offset);
void link(uint32_t &address, uint32_t offset);
void unlink(uint32_t &address);
template <typename IntT> void movep_fromR(uint32_t reg, uint32_t address);
template <typename IntT> void movep_toR(uint32_t &reg, uint32_t address);
// TODO: ownership of this shouldn't be here.
struct Registers {

View File

@ -393,6 +393,42 @@ void Executor<model, BusHandler>::unlink(uint32_t &address) {
address_[7].l += 4;
}
template <Model model, typename BusHandler>
template <typename IntT>
void Executor<model, BusHandler>::movep_fromR(uint32_t reg, uint32_t address) {
if constexpr (sizeof(IntT) == 4) {
bus_handler_.template write<uint8_t>(address, uint8_t(reg >> 24));
address += 2;
bus_handler_.template write<uint8_t>(address, uint8_t(reg >> 16));
address += 2;
}
bus_handler_.template write<uint8_t>(address, uint8_t(reg >> 8));
address += 2;
bus_handler_.template write<uint8_t>(address, uint8_t(reg));
}
template <Model model, typename BusHandler>
template <typename IntT>
void Executor<model, BusHandler>::movep_toR(uint32_t &reg, uint32_t address) {
if constexpr (sizeof(IntT) == 4) {
reg = bus_handler_.template read<uint8_t>(address) << 24;
address += 2;
reg |= bus_handler_.template read<uint8_t>(address) << 26;
address += 2;
} else {
reg &= 0xffff0000;
}
reg |= bus_handler_.template read<uint8_t>(address) << 8;
address += 2;
reg |= bus_handler_.template read<uint8_t>(address);
}
}
}