From 64d556f60fd6b89acac53e03a2ba41235f8f5998 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Wed, 20 Jan 2021 21:39:13 -0500 Subject: [PATCH] Implements shifts and rotates. --- InstructionSets/M50740/Executor.cpp | 30 ++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/InstructionSets/M50740/Executor.cpp b/InstructionSets/M50740/Executor.cpp index f6cb37b2d..e557067fa 100644 --- a/InstructionSets/M50740/Executor.cpp +++ b/InstructionSets/M50740/Executor.cpp @@ -350,7 +350,35 @@ template void Executor::perform(uint8_t *operand [[maybe_u // TODO: // // BRK, STP, - // ADC, SBC, BIT, ASL, LSR, ROL, ROR, RRF + // ADC, SBC, BIT + + case Operation::ASL: + carry_flag_ = *operand >> 7; + *operand <<= 1; + set_nz(*operand); + break; + + case Operation::LSR: + carry_flag_ = *operand & 1; + *operand >>= 1; + set_nz(*operand); + break; + + case Operation::ROL: { + const uint8_t temp8 = uint8_t((*operand << 1) | carry_flag_); + carry_flag_ = *operand >> 7; + set_nz(*operand = temp8); + } break; + + case Operation::ROR: { + const uint8_t temp8 = uint8_t((*operand >> 1) | (carry_flag_ << 7)); + carry_flag_ = *operand & 1; + set_nz(*operand = temp8); + } break; + + case Operation::RRF: + *operand = uint8_t((*operand >> 4) | (*operand << 4)); + break; /* Operations affected by the index mode flag: ADC, AND, CMP, EOR, LDA, ORA, and SBC.