Add test for ASRA inherent. And fix resulting bugs exposed!

Signed-off-by: Adrian Conlon <Adrian.conlon@gmail.com>
This commit is contained in:
Adrian Conlon 2018-10-07 10:48:27 +01:00
parent f2b9ab0814
commit cf32f37fc3
2 changed files with 23 additions and 2 deletions

View File

@ -783,8 +783,10 @@ uint8_t EightBit::mc6809::asl(uint8_t operand) {
}
uint8_t EightBit::mc6809::asr(uint8_t operand) {
setFlag(CC(), CF, operand & Bit7);
adjustNZ(operand >>= 1);
setFlag(CC(), CF, operand & Bit0);
operand >>= 1;
operand |= Bit7;
adjustNZ(operand);
return operand;
}

View File

@ -104,3 +104,22 @@ TEST_CASE("Shift Accumulator or Memory Byte Left", "[ASL][ASLA]") {
REQUIRE(cpu.cycles() == 2);
}
}
TEST_CASE("Shift Accumulator or Memory Byte Right", "[ASR][ASRA]") {
Board board;
board.initialise();
auto& cpu = board.CPU();
cpu.step(); // Step over the reset
SECTION("Inherent") {
board.poke(0, 0x47);
cpu.A() = 0xcb;
cpu.step();
REQUIRE(cpu.A() == 0xe5);
REQUIRE((cpu.CC() & EightBit::mc6809::CF) != 0);
REQUIRE((cpu.CC() & EightBit::mc6809::ZF) == 0);
REQUIRE((cpu.CC() & EightBit::mc6809::NF) != 0);
REQUIRE(cpu.cycles() == 2);
}
}