First stab at cycle accurate 6809

Signed-off-by: Adrian Conlon <adrian.conlon@gmail.com>
This commit is contained in:
Adrian Conlon 2020-04-03 10:13:42 +01:00
parent dcb809d8f9
commit d4e6e13fde
3 changed files with 430 additions and 352 deletions

View File

@ -111,6 +111,8 @@ namespace EightBit {
virtual void busWrite() final;
virtual uint8_t busRead() final;
virtual void call(register16_t destination) final;
private:
const uint8_t RESETvector = 0xfe; // RESET vector
const uint8_t NMIvector = 0xfc; // NMI vector
@ -303,7 +305,7 @@ namespace EightBit {
void branchLong(const int condition) {
if (branch(Address_relative_word(), condition))
tick();
memoryRead(0xffff);
}
// Miscellaneous
@ -336,7 +338,7 @@ namespace EightBit {
uint8_t asl(uint8_t operand);
uint8_t asr(uint8_t operand);
void bit(uint8_t operand, uint8_t data);
uint8_t clr();
uint8_t clr(uint8_t data = 0); // In this form for Read/Modify/Write operations
void cmp(uint8_t operand, uint8_t data);
void cmp(register16_t operand, register16_t data);
uint8_t com(uint8_t operand);

File diff suppressed because it is too large Load Diff

View File

@ -655,7 +655,7 @@ TEST_CASE("Subtract Memory from Accumulator with Borrow (8-bit)", "[SBC][SBCA][S
REQUIRE((cpu.CC() & EightBit::mc6809::VF) == 0);
REQUIRE((cpu.CC() & EightBit::mc6809::NF) != 0);
REQUIRE((cpu.CC() & EightBit::mc6809::CF) != 0);
REQUIRE(cpu.cycles() == 4);
REQUIRE(cpu.cycles() == 2);
}
// Test the subtraction with carry instruction.
@ -691,7 +691,7 @@ TEST_CASE("Subtract Memory from Accumulator with Borrow (8-bit)", "[SBC][SBCA][S
REQUIRE((cpu.CC() & EightBit::mc6809::VF) == 0);
REQUIRE((cpu.CC() & EightBit::mc6809::ZF) != 0);
REQUIRE((cpu.CC() & EightBit::mc6809::NF) == 0);
REQUIRE(cpu.cycles() == 4);
REQUIRE(cpu.cycles() == 2);
}
// Test the SBCA instruction.
@ -707,7 +707,7 @@ TEST_CASE("Subtract Memory from Accumulator with Borrow (8-bit)", "[SBC][SBCA][S
REQUIRE((cpu.CC() & EightBit::mc6809::VF) == 0);
REQUIRE((cpu.CC() & EightBit::mc6809::ZF) == 0);
REQUIRE((cpu.CC() & EightBit::mc6809::NF) == 0);
REQUIRE(cpu.cycles() == 4);
REQUIRE(cpu.cycles() == 2);
}
// Test the SBCA instruction.
@ -722,7 +722,7 @@ TEST_CASE("Subtract Memory from Accumulator with Borrow (8-bit)", "[SBC][SBCA][S
REQUIRE((cpu.CC() & EightBit::mc6809::VF) == 0);
REQUIRE((cpu.CC() & EightBit::mc6809::ZF) == 0);
REQUIRE((cpu.CC() & EightBit::mc6809::NF) != 0);
REQUIRE(cpu.cycles() == 4);
REQUIRE(cpu.cycles() == 2);
}
}
@ -935,7 +935,7 @@ TEST_CASE("Branch on Less than or Equal to Zero", "[BLE]") {
SECTION("BLE1") {
cpu.A() = 0;
cpu.CC() = EightBit::mc6809::ZF;
cpu.CC() = EightBit::mc6809::ZF;
cpu.step();
cpu.step();
REQUIRE(cpu.A() == 2);
@ -984,9 +984,14 @@ TEST_CASE("Branch on Less than or Equal to Zero", "[BLE]") {
cpu.step();
REQUIRE(cpu.A() == 2);
}
}
cpu.lowerRESET();
cpu.step();
TEST_CASE("Subroutines", "[JSR][RTS]") {
Board board;
board.raisePOWER();
auto& cpu = board.CPU();
cpu.step(); // Step over the reset
// Test the JSR - Jump to Subroutine - instruction.
// INDEXED mode: JSR D,Y
@ -1029,7 +1034,7 @@ TEST_CASE("Branch on Less than or Equal to Zero", "[BLE]") {
REQUIRE(board.peek(0x914) == 2);
REQUIRE(board.peek(0x913) == 0xb);
REQUIRE(cpu.cycles() == 10);
REQUIRE(cpu.cycles() == 11);
}
cpu.lowerRESET();