From 49e77cfdcb48d3ef5d3a92443cbef4eec7affa93 Mon Sep 17 00:00:00 2001 From: folkert van heusden Date: Thu, 4 Apr 2024 21:55:54 +0200 Subject: [PATCH] SBCB v-flag fix --- cpu.cpp | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/cpu.cpp b/cpu.cpp index 37f4c0e..d2a591a 100644 --- a/cpu.cpp +++ b/cpu.cpp @@ -916,7 +916,7 @@ bool cpu::single_operand_instructions(const uint16_t instr) else { auto a = getGAM(dst_mode, dst_reg, word_mode, rm_cur); int32_t vl = (a.value.value() + 1) & (word_mode == wm_byte ? 0xff : 0xffff); - bool set_flags = a.addr.value() != ADDR_PSW; + bool set_flags = a.addr.value() != ADDR_PSW; // FIXME if (set_flags) { setPSW_n(SIGN(vl, word_mode)); @@ -1047,7 +1047,7 @@ bool cpu::single_operand_instructions(const uint16_t instr) setPSW_n(SIGN(v, word_mode)); setPSW_z(IS_0(v, word_mode)); - setPSW_v(word_mode == wm_byte ? (vo & 0xff) == 0x80 : vo == 0x8000); + setPSW_v((word_mode == wm_byte ? (vo & 0xff) == 0x80 : vo == 0x8000) && org_c); if (IS_0(vo, word_mode) && org_c) setPSW_c(true); @@ -1071,10 +1071,7 @@ bool cpu::single_operand_instructions(const uint16_t instr) setPSW_z(IS_0(v, word_mode)); setPSW_v(word_mode == wm_byte ? (vo & 0xff) == 0x80 : vo == 0x8000); - if (IS_0(vo, word_mode) && org_c) - setPSW_c(true); - else - setPSW_c(false); + setPSW_c(IS_0(vo, word_mode) && org_c); } } break;