diff --git a/bus.cpp b/bus.cpp index b8cc57a..d582a40 100644 --- a/bus.cpp +++ b/bus.cpp @@ -17,7 +17,7 @@ // see also https://github.com/espressif/esp-idf/issues/1934 constexpr int n_pages = 12; #else -constexpr int n_pages = 32; +constexpr int n_pages = 128; // 1MB #endif constexpr uint16_t di_ena_mask[4] = { 4, 2, 0, 1 }; diff --git a/cpu.cpp b/cpu.cpp index b957c87..9da6e65 100644 --- a/cpu.cpp +++ b/cpu.cpp @@ -778,6 +778,9 @@ bool cpu::single_operand_instructions(const uint16_t instr) if (word_mode) 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); if (set_flags) { @@ -812,9 +815,9 @@ bool cpu::single_operand_instructions(const uint16_t instr) case 0b000101010: { // INC/INCB auto a = getGAM(dst_mode, dst_reg, word_mode, false); - uint16_t v = a.value.value(); if (dst_mode == 0) { + uint16_t v = a.value.value(); uint16_t add = word_mode ? v & 0xff00 : 0; v = (v + 1) & (word_mode ? 0xff : 0xffff); @@ -834,7 +837,7 @@ bool cpu::single_operand_instructions(const uint16_t instr) if (set_flags) { setPSW_n(SIGN(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); @@ -983,7 +986,7 @@ bool cpu::single_operand_instructions(const uint16_t instr) if (set_flags) { setPSW_n(SIGN(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) setPSW_c(true);