Modify rotate and shift instructions to be a little more understandable (6502/6809)

Signed-off-by: Adrian Conlon <Adrian.conlon@gmail.com>
This commit is contained in:
Adrian Conlon 2018-11-01 19:47:21 +00:00
parent 4dc0becb74
commit 7af81018c9
2 changed files with 17 additions and 22 deletions

View File

@ -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() {

View File

@ -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() {