From f51f8de303728aacab275a5d3bd45778df1b1b08 Mon Sep 17 00:00:00 2001 From: folkert van heusden Date: Thu, 31 Mar 2022 17:19:20 +0200 Subject: [PATCH] NEG fix --- cpu.cpp | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/cpu.cpp b/cpu.cpp index c556163..bb4e796 100644 --- a/cpu.cpp +++ b/cpu.cpp @@ -786,21 +786,22 @@ bool cpu::single_operand_instructions(const uint16_t instr) setPSW_n(SIGN(v, word_mode)); setPSW_z(v == 0); setPSW_v(word_mode ? (v & 0xff) == 0x80 : v == 0x8000); + setPSW_c(v); setRegister(dst_reg, false, v); } else { - uint16_t a = getGAMAddress(dst_mode, dst_reg, word_mode, false); - uint16_t v = b -> read(a, word_mode); - int32_t vl = word_mode ? uint8_t(-v) : -v; + uint16_t a = getGAMAddress(dst_mode, dst_reg, word_mode, false); + uint16_t v = -b -> read(a, word_mode); - b->write(a, word_mode, vl); + b->write(a, word_mode, v); - setPSW_n(SIGN(vl, word_mode)); - setPSW_z(vl == 0); - setPSW_v(word_mode ? vl == 0x80 : vl == 0x8000); - setPSW_c(vl); + setPSW_n(SIGN(v, word_mode)); + setPSW_z(v == 0); + setPSW_v(word_mode ? (v & 0xff) == 0x80 : v == 0x8000); + setPSW_c(v); } + break; }