diff --git a/M6502/src/mos6502.cpp b/M6502/src/mos6502.cpp index f6778ab..ebe66ff 100644 --- a/M6502/src/mos6502.cpp +++ b/M6502/src/mos6502.cpp @@ -613,20 +613,18 @@ void EightBit::MOS6502::plp() { P() = (pop() | RF) & ~BF; } -uint8_t EightBit::MOS6502::rol(uint8_t operand) { +uint8_t EightBit::MOS6502::rol(const uint8_t operand) { const auto carryIn = carry(); setFlag(P(), CF, operand & Bit7); - operand <<= 1; - operand |= carryIn; - return through(operand); + const uint8_t result = (operand << 1) | carryIn; + return through(result); } -uint8_t EightBit::MOS6502::ror(uint8_t operand) { +uint8_t EightBit::MOS6502::ror(const uint8_t operand) { const auto carryIn = carry(); setFlag(P(), CF, operand & Bit0); - operand >>= 1; - operand |= (carryIn << 7); - return through(operand); + const uint8_t result = (operand >> 1) | (carryIn << 7); + return through(result); } void EightBit::MOS6502::rti() { diff --git a/MC6809/src/mc6809.cpp b/MC6809/src/mc6809.cpp index baf48ef..610d5c5 100644 --- a/MC6809/src/mc6809.cpp +++ b/MC6809/src/mc6809.cpp @@ -787,10 +787,9 @@ uint8_t EightBit::mc6809::asl(uint8_t operand) { uint8_t EightBit::mc6809::asr(uint8_t operand) { setFlag(CC(), CF, operand & Bit0); - operand >>= 1; - operand |= Bit7; - adjustNZ(operand); - return operand; + const uint8_t result = (operand >> 1) | Bit7; + adjustNZ(result); + return result; } void EightBit::mc6809::bit(const uint8_t operand, const uint8_t data) { @@ -1007,23 +1006,21 @@ void EightBit::mc6809::pul(register16_t& stack, const uint8_t data) { } } -uint8_t EightBit::mc6809::rol(uint8_t operand) { +uint8_t EightBit::mc6809::rol(const uint8_t operand) { const auto carryIn = carry(); setFlag(CC(), CF, operand & Bit7); setFlag(CC(), VF, ((operand & Bit7) >> 7) ^ ((operand & Bit6) >> 6)); - operand <<= 1; - operand |= carryIn; - adjustNZ(operand); - return operand; + const uint8_t result = (operand << 1) | carryIn; + adjustNZ(result); + return result; } -uint8_t EightBit::mc6809::ror(uint8_t operand) { +uint8_t EightBit::mc6809::ror(const uint8_t operand) { const auto carryIn = carry(); setFlag(CC(), CF, operand & Bit0); - operand >>= 1; - operand |= (carryIn << 7); - adjustNZ(operand); - return operand; + const uint8_t result = (operand >> 1) | (carryIn << 7); + adjustNZ(result); + return result; } void EightBit::mc6809::rti() {