fix for BKTCB0.BIC

This commit is contained in:
folkert van heusden 2024-04-07 22:26:35 +02:00
parent d020492384
commit e123d6d55f
Signed by untrusted user who does not match committer: folkert
GPG key ID: 6B6455EDFEED3BD1
2 changed files with 11 additions and 17 deletions

27
cpu.cpp
View file

@ -378,7 +378,7 @@ void cpu::addToMMR1(const uint8_t mode, const uint8_t reg, const word_mode_t wor
// GAM = general addressing modes // GAM = general addressing modes
gam_rc_t cpu::getGAM(const uint8_t mode, const uint8_t reg, const word_mode_t word_mode, const rm_selection_t mode_selection, const bool read_value) gam_rc_t cpu::getGAM(const uint8_t mode, const uint8_t reg, const word_mode_t word_mode, const rm_selection_t mode_selection, const bool read_value)
{ {
gam_rc_t g { word_mode, mode_selection, i_space, { }, { }, { } }; gam_rc_t g { word_mode, mode_selection, i_space, mode, { }, { }, { } };
d_i_space_t isR7_space = reg == 7 ? i_space : (b->get_use_data_space(getPSW_runmode()) ? d_space : i_space); d_i_space_t isR7_space = reg == 7 ? i_space : (b->get_use_data_space(getPSW_runmode()) ? d_space : i_space);
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ always d_space here? TODO // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ always d_space here? TODO
@ -452,6 +452,11 @@ gam_rc_t cpu::getGAM(const uint8_t mode, const uint8_t reg, const word_mode_t wo
bool cpu::putGAM(const gam_rc_t & g, const uint16_t value) bool cpu::putGAM(const gam_rc_t & g, const uint16_t value)
{ {
if (g.reg == 7) {
trap(0250);
throw 100;
}
if (g.addr.has_value()) { if (g.addr.has_value()) {
b->write(g.addr.value(), g.word_mode, value, g.mode_selection, g.space); b->write(g.addr.value(), g.word_mode, value, g.mode_selection, g.space);
@ -1311,7 +1316,9 @@ bool cpu::single_operand_instructions(const uint16_t instr)
uint16_t v = popStack(); uint16_t v = popStack();
bool set_flags = true; bool set_flags = true;
mtpi_count++; mtpi_count++;
if (dst_mode == 0) if (dst_mode == 0)
setRegister(dst_reg, v, rm_prev); setRegister(dst_reg, v, rm_prev);
else { else {
@ -1320,22 +1327,8 @@ bool cpu::single_operand_instructions(const uint16_t instr)
b->mmudebug(a.addr.value()); b->mmudebug(a.addr.value());
bool is_d = word_mode == wm_byte; a.mode_selection = rm_prev;
auto phys = b->calculate_physical_address(prev_run_mode, a.addr.value()); set_flags = putGAM(a, v);
uint32_t phys_a = is_d ? phys.physical_data : phys.physical_instruction;
bool phys_psw = is_d ? phys.physical_data_is_psw : phys.physical_instruction_is_psw;
if (phys_a >= b->get_io_base()) {
DOLOG(debug, true, "%lu %06o MTP%c %06o: %06o (I/O: %o/%d)", mtpi_count, pc-2, is_d ? 'D' : 'I', a.addr.value(), v, phys_a, prev_run_mode);
b->write(a.addr.value(), wm_word, v, rm_prev); // put in '13/12' address space
set_flags = phys_psw;
}
else {
DOLOG(debug, true, "%lu %06o MTP%c %06o: %06o (physical: %o/%d)", mtpi_count, pc-2, is_d ? 'D' : 'I', a.addr.value(), v, phys_a, prev_run_mode);
b->check_odd_addressing(phys_a, prev_run_mode, is_d ? d_space : i_space, true); // TODO d/i space must depend on the check done in calculate_physical_address
b->writePhysical(phys_a, v);
}
} }
if (set_flags) if (set_flags)

1
cpu.h
View file

@ -19,6 +19,7 @@ typedef struct {
word_mode_t word_mode; word_mode_t word_mode;
rm_selection_t mode_selection; rm_selection_t mode_selection;
d_i_space_t space; d_i_space_t space;
int access_mode;
std::optional<uint16_t> addr; std::optional<uint16_t> addr;
std::optional<int> reg; std::optional<int> reg;