From 5a4d448cc1a3857502a783f3640c2c66d6f80890 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Sun, 28 May 2017 15:09:58 -0400 Subject: [PATCH] Corrected logical flags; now down to 68 failures, all of them on the ED page. --- .../Mac/Clock SignalTests/FUSETests.swift | 2 +- Processors/Z80/Z80.hpp | 24 +++++++++---------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/OSBindings/Mac/Clock SignalTests/FUSETests.swift b/OSBindings/Mac/Clock SignalTests/FUSETests.swift index ca0f16fd8..2258f1720 100644 --- a/OSBindings/Mac/Clock SignalTests/FUSETests.swift +++ b/OSBindings/Mac/Clock SignalTests/FUSETests.swift @@ -167,7 +167,7 @@ class FUSETests: XCTestCase { let name = itemDictionary["name"] as! String -// if name != "ed40" { +// if name != "a0" { // continue; // } diff --git a/Processors/Z80/Z80.hpp b/Processors/Z80/Z80.hpp index e70f27113..c1750f44b 100644 --- a/Processors/Z80/Z80.hpp +++ b/Processors/Z80/Z80.hpp @@ -703,30 +703,30 @@ template class Processor: public MicroOpScheduler { #pragma mark - Logical +#define set_logical_flags(hf) \ + sign_result_ = zero_result_ = bit5_result_ = bit3_result_ = a_; \ + set_parity(a_); \ + half_carry_flag_ = hf; \ + subtract_flag_ = 0; \ + carry_flag_ = 0; + case MicroOp::And: a_ &= *(uint8_t *)operation->source; - half_carry_flag_ = Flag::HalfCarry; - sign_result_ = zero_result_ = bit5_result_ = bit3_result_ = a_; - parity_overflow_flag_ = 0; - set_parity(a_); + set_logical_flags(Flag::HalfCarry); break; case MicroOp::Or: a_ |= *(uint8_t *)operation->source; - half_carry_flag_ = 0; - sign_result_ = zero_result_ = bit5_result_ = bit3_result_ = a_; - parity_overflow_flag_ = 0; - set_parity(a_); + set_logical_flags(0); break; case MicroOp::Xor: a_ ^= *(uint8_t *)operation->source; - half_carry_flag_ = 0; - sign_result_ = zero_result_ = bit5_result_ = bit3_result_ = a_; - parity_overflow_flag_ = 0; - set_parity(a_); + set_logical_flags(0); break; +#undef set_logical_flags + case MicroOp::CPL: a_ ^= 0xff; subtract_flag_ = Flag::Subtract;