fixes for problems found by EQKCE1

This commit is contained in:
folkert van heusden 2023-03-18 21:53:37 +01:00
parent eff5a799e5
commit 488bb55cec
Signed by untrusted user who does not match committer: folkert
GPG key ID: 6B6455EDFEED3BD1
2 changed files with 7 additions and 4 deletions

View file

@ -17,7 +17,7 @@
// see also https://github.com/espressif/esp-idf/issues/1934 // see also https://github.com/espressif/esp-idf/issues/1934
constexpr int n_pages = 12; constexpr int n_pages = 12;
#else #else
constexpr int n_pages = 32; constexpr int n_pages = 128; // 1MB
#endif #endif
constexpr uint16_t di_ena_mask[4] = { 4, 2, 0, 1 }; constexpr uint16_t di_ena_mask[4] = { 4, 2, 0, 1 };

View file

@ -778,6 +778,9 @@ bool cpu::single_operand_instructions(const uint16_t instr)
if (word_mode) if (word_mode)
r = g_dst.value.value() & 0xff00; r = g_dst.value.value() & 0xff00;
// both in byte and word mode the full register must be updated
g_dst.word_mode = false;
bool set_flags = putGAM(g_dst, r); bool set_flags = putGAM(g_dst, r);
if (set_flags) { if (set_flags) {
@ -812,9 +815,9 @@ bool cpu::single_operand_instructions(const uint16_t instr)
case 0b000101010: { // INC/INCB case 0b000101010: { // INC/INCB
auto a = getGAM(dst_mode, dst_reg, word_mode, false); auto a = getGAM(dst_mode, dst_reg, word_mode, false);
uint16_t v = a.value.value();
if (dst_mode == 0) { if (dst_mode == 0) {
uint16_t v = a.value.value();
uint16_t add = word_mode ? v & 0xff00 : 0; uint16_t add = word_mode ? v & 0xff00 : 0;
v = (v + 1) & (word_mode ? 0xff : 0xffff); v = (v + 1) & (word_mode ? 0xff : 0xffff);
@ -834,7 +837,7 @@ bool cpu::single_operand_instructions(const uint16_t instr)
if (set_flags) { if (set_flags) {
setPSW_n(SIGN(vl, word_mode)); setPSW_n(SIGN(vl, word_mode));
setPSW_z(IS_0(vl, word_mode)); setPSW_z(IS_0(vl, word_mode));
setPSW_v(word_mode ? vl == 0x80 : v == 0x8000); setPSW_v(word_mode ? vl == 0x80 : vl == 0x8000);
} }
b->write(a.addr.value(), word_mode, vl, false); b->write(a.addr.value(), word_mode, vl, false);
@ -983,7 +986,7 @@ bool cpu::single_operand_instructions(const uint16_t instr)
if (set_flags) { if (set_flags) {
setPSW_n(SIGN(v, word_mode)); setPSW_n(SIGN(v, word_mode));
setPSW_z(IS_0(v, word_mode)); setPSW_z(IS_0(v, word_mode));
setPSW_v(word_mode? (vo & 0xff) == 0x80 : v == 0x8000); setPSW_v(word_mode? (vo & 0xff) == 0x80 : vo == 0x8000);
if (IS_0(vo, word_mode) && org_c) if (IS_0(vo, word_mode) && org_c)
setPSW_c(true); setPSW_c(true);