From a47b33966893c243e604f096e8dcb7b16c11013b Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Mon, 29 May 2017 10:28:04 -0400 Subject: [PATCH] Made an attempt at OUT[I/D]R. 10 failures remaining. None of which, I guess, are due to unimplemented operations. --- Processors/Z80/Z80.hpp | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/Processors/Z80/Z80.hpp b/Processors/Z80/Z80.hpp index b644c371a..770300532 100644 --- a/Processors/Z80/Z80.hpp +++ b/Processors/Z80/Z80.hpp @@ -1166,6 +1166,37 @@ template class Processor: public MicroOpScheduler { #undef INxR_STEP +#define OUTxR_STEP(incr) \ + bc_.bytes.high--; \ + hl_.full += (operation->type == incr) ? 1 : -1; \ + \ + sign_result_ = zero_result_ = bit5_result_ = bit3_result_ = bc_.bytes.high; \ + subtract_flag_ = (temp8_ >> 6) & Flag::Subtract; \ + \ + int summation = temp8_ + hl_.bytes.low; \ + if(summation > 0xff) { \ + carry_flag_ = Flag::Carry; \ + half_carry_flag_ = Flag::HalfCarry; \ + } else { \ + carry_flag_ = half_carry_flag_ = 0; \ + } \ + \ + summation = (summation&7) ^ bc_.bytes.high; \ + set_parity(summation); + + case MicroOp::OUTDR: + case MicroOp::OUTIR: { + OUTxR_STEP(MicroOp::OUTIR); + REPEAT(bc_.bytes.high); + } break; + + case MicroOp::OUTD: + case MicroOp::OUTI: { + OUTxR_STEP(MicroOp::OUTI); + } break; + +#undef OUTxR_STEP + #pragma mark - Bit Manipulation case MicroOp::BIT: {