odd trap handling method

This commit is contained in:
folkert van heusden 2023-03-23 14:19:35 +01:00
parent cd4322ac4a
commit f9eb348572
Signed by untrusted user who does not match committer: folkert
GPG key ID: 6B6455EDFEED3BD1
2 changed files with 14 additions and 5 deletions

18
bus.cpp
View file

@ -106,6 +106,14 @@ uint16_t bus::read_par(const uint32_t a, const int run_mode, const bool word_mod
return word_mode ? (a & 1 ? t >> 8 : t & 255) : t;
}
void bus::trap_odd(const uint16_t a)
{
MMR0 &= ~(7 << 1);
MMR0 |= (a >> 13) << 1;
c->trap(004); // invalid access
}
uint16_t bus::read(const uint16_t a, const bool word_mode, const bool use_prev, const bool peek_only, const d_i_space_t space)
{
uint16_t temp = 0;
@ -148,7 +156,7 @@ uint16_t bus::read(const uint16_t a, const bool word_mode, const bool use_prev,
if (!peek_only) {
if ((a & 1) && word_mode == false) {
DOLOG(debug, true, "bus::readWord: odd address UNHANDLED %06o in i/o area", a);
c->trap(004); // invalid access
trap_odd(a);
return 0;
}
}
@ -340,7 +348,7 @@ uint16_t bus::read(const uint16_t a, const bool word_mode, const bool use_prev,
if (peek_only == false && word_mode == false && (a & 1)) {
if (!peek_only) DOLOG(debug, true, "READ from %06o - odd address!", a);
c->trap(004); // invalid access
trap_odd(a);
throw 2;
return 0;
}
@ -411,7 +419,7 @@ void bus::check_odd_addressing(const uint16_t a, const int run_mode, const d_i_s
if (is_write)
pages[run_mode][space == d_space][a >> 13].pdr |= 1 << 7;
c->trap(004); // invalid access
trap_odd(a);
throw 4;
}
@ -855,7 +863,7 @@ void bus::write(const uint16_t a, const bool word_mode, uint16_t value, const bo
if (word_mode == false && (a & 1)) {
DOLOG(debug, true, "WRITE to %06o (value: %06o) - odd address!", a, value);
c->trap(004); // invalid access
trap_odd(a);
throw 8;
}
@ -868,7 +876,7 @@ void bus::write(const uint16_t a, const bool word_mode, uint16_t value, const bo
if (word_mode == false && (a & 1)) {
DOLOG(debug, true, "WRITE to %06o (value: %06o) - odd address!", a, value);
c->trap(004); // invalid access
trap_odd(a);
throw 10;
}

1
bus.h
View file

@ -153,6 +153,7 @@ public:
void setMMR2(const uint16_t value);
void check_odd_addressing(const uint16_t a, const int run_mode, const d_i_space_t space, const bool is_write);
void trap_odd(const uint16_t a);
uint32_t calculate_physical_address(const int run_mode, const uint16_t a, const bool trap_on_failure, const bool is_write, const bool peek_only, const bool is_data);