removed bus::is_psw special case from add/sub
This commit is contained in:
parent
f1bcefe433
commit
5c9a46aec7
4 changed files with 9 additions and 36 deletions
13
bus.cpp
13
bus.cpp
|
@ -531,19 +531,6 @@ uint16_t bus::read(const uint16_t addr_in, const word_mode_t word_mode, const rm
|
|||
return temp;
|
||||
}
|
||||
|
||||
bool bus::is_psw(const uint16_t addr, const int run_mode, const d_i_space_t space) const
|
||||
{
|
||||
auto meta = mmu_->calculate_physical_address(run_mode, addr);
|
||||
|
||||
if (space == d_space && meta.physical_data_is_psw)
|
||||
return true;
|
||||
|
||||
if (space == i_space && meta.physical_instruction_is_psw)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool bus::write(const uint16_t addr_in, const word_mode_t word_mode, uint16_t value, const rm_selection_t mode_selection, const d_i_space_t space)
|
||||
{
|
||||
int run_mode = mode_selection == rm_cur ? c->getPSW_runmode() : c->getPSW_prev_runmode();
|
||||
|
|
2
bus.h
2
bus.h
|
@ -136,6 +136,4 @@ public:
|
|||
void write_word(const uint16_t a, const uint16_t value, const d_i_space_t s);
|
||||
void write_word(const uint16_t a, const uint16_t value) override { write_word(a, value, i_space); }
|
||||
void write_physical(const uint32_t a, const uint16_t value);
|
||||
|
||||
bool is_psw(const uint16_t addr, const int run_mode, const d_i_space_t space) const;
|
||||
};
|
||||
|
|
29
cpu.cpp
29
cpu.cpp
|
@ -547,7 +547,6 @@ bool cpu::putGAM(const gam_rc_t & g, const uint16_t value)
|
|||
|
||||
if (g.addr.has_value()) {
|
||||
auto rc = b->write(g.addr.value(), g.word_mode, value, g.mode_selection, g.space);
|
||||
|
||||
return rc == false;
|
||||
}
|
||||
|
||||
|
@ -709,37 +708,27 @@ bool cpu::double_operand_instructions(const uint16_t instr)
|
|||
|
||||
int16_t result = 0;
|
||||
|
||||
bool set_flags = true;
|
||||
if (instr & 0x8000) // SUB
|
||||
result = g_dst.value.value() - g_ssrc.value.value();
|
||||
else // ADD
|
||||
result = g_dst.value.value() + g_ssrc.value.value();
|
||||
|
||||
if (g_dst.addr.has_value())
|
||||
set_flags = !b->is_psw(g_dst.addr.value(), g_dst.mode_selection, g_dst.space);
|
||||
bool set_flags = putGAM(g_dst, result);
|
||||
|
||||
if (instr & 0x8000) { // SUB
|
||||
result = (g_dst.value.value() - g_ssrc.value.value()) & 0xffff;
|
||||
|
||||
if (set_flags) {
|
||||
if (set_flags) {
|
||||
if (instr & 0x8000) { // SUB
|
||||
setPSW_v(SIGN((g_dst.value.value() ^ g_ssrc.value.value()) & (~g_ssrc.value.value() ^ result), wm_word));
|
||||
setPSW_c(uint16_t(g_dst.value.value()) < uint16_t(g_ssrc.value.value()));
|
||||
}
|
||||
}
|
||||
else { // ADD
|
||||
uint32_t temp = g_dst.value.value() + g_ssrc.value.value();
|
||||
|
||||
result = temp;
|
||||
|
||||
if (set_flags) {
|
||||
setPSW_v(SIGN((~g_ssrc.value.value() ^ g_dst.value.value()) & (g_ssrc.value.value() ^ (temp & 0xffff)), wm_word));
|
||||
else {
|
||||
setPSW_v(SIGN((~g_ssrc.value.value() ^ g_dst.value.value()) & (g_ssrc.value.value() ^ (result & 0xffff)), wm_word));
|
||||
setPSW_c(uint16_t(result) < uint16_t(g_ssrc.value.value()));
|
||||
}
|
||||
}
|
||||
|
||||
if (set_flags) {
|
||||
setPSW_n(result < 0);
|
||||
setPSW_z(result == 0);
|
||||
}
|
||||
|
||||
(void)putGAM(g_dst, result);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
1
main.cpp
1
main.cpp
|
@ -710,7 +710,6 @@ int main(int argc, char *argv[])
|
|||
*running = false;
|
||||
|
||||
uint32_t stop_event = event.exchange(EVENT_NONE);
|
||||
|
||||
if (stop_event == EVENT_HALT || stop_event == EVENT_INTERRUPT || stop_event == EVENT_TERMINATE)
|
||||
break;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue