From d44718ed226d4f186ac27e0f20d878621c0b52f3 Mon Sep 17 00:00:00 2001 From: Adrian Conlon Date: Tue, 21 Aug 2018 17:01:20 +0100 Subject: [PATCH] Add INC instruction to the 6809 processor. Signed-off-by: Adrian Conlon --- MC6809/inc/mc6809.h | 1 + MC6809/src/mc6809.cpp | 14 ++++++++++++++ 2 files changed, 15 insertions(+) diff --git a/MC6809/inc/mc6809.h b/MC6809/inc/mc6809.h index bd69f8a..efc33c8 100644 --- a/MC6809/inc/mc6809.h +++ b/MC6809/inc/mc6809.h @@ -195,6 +195,7 @@ namespace EightBit { uint8_t dec(uint8_t operand); uint8_t eor(uint8_t operand, uint8_t data); void exg(uint8_t data); + uint8_t inc(uint8_t operand); uint8_t neg(uint8_t operand); register16_t m_d; diff --git a/MC6809/src/mc6809.cpp b/MC6809/src/mc6809.cpp index 5f06316..f56a8f4 100644 --- a/MC6809/src/mc6809.cpp +++ b/MC6809/src/mc6809.cpp @@ -187,6 +187,13 @@ int EightBit::mc6809::executeUnprefixed(uint8_t opcode) { // EXG case 0x1e: addCycles(8); exg(AM_immediate_byte()); break; // EXG (EXG R1,R2 immediate) + // INC + case 0x0c: addCycles(6); BUS().write(inc(AM_direct_byte())); break; // INC (INC direct) + case 0x4c: addCycles(2); A() = inc(A()); break; // INC (INCA inherent) + case 0x5c: addCycles(2); B() = inc(B()); break; // INC (INCB inherent) + case 0x6c: addCycles(6); BUS().write(inc(AM_indexed_byte())); break; // INC (INC indexed) + case 0x7c: addCycles(7); BUS().write(inc(AM_extended_byte())); break; // INC (INC extended) + default: UNREACHABLE; } @@ -572,3 +579,10 @@ void EightBit::mc6809::exg(uint8_t data) { else std::swap(referenceTransfer8(reg1), referenceTransfer8(reg2)); } + +uint8_t EightBit::mc6809::inc(uint8_t operand) { + const uint8_t result = operand + 1; + adjustNZ(result); + adjustOverflow(operand, 1, result); + return result; +}