From 551c26bb3c75ab53435539db775f840fb7473e94 Mon Sep 17 00:00:00 2001 From: Adrian Conlon Date: Tue, 21 Aug 2018 23:07:22 +0100 Subject: [PATCH] Add OR instruction to the 6809 processor Signed-off-by: Adrian Conlon --- MC6809/inc/mc6809.h | 1 + MC6809/src/mc6809.cpp | 25 ++++++++++++++++++++++++- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/MC6809/inc/mc6809.h b/MC6809/inc/mc6809.h index 31daeff..7f4e2ff 100644 --- a/MC6809/inc/mc6809.h +++ b/MC6809/inc/mc6809.h @@ -215,6 +215,7 @@ namespace EightBit { uint8_t lsr(uint8_t operand); register16_t mul(uint8_t first, uint8_t second); uint8_t neg(uint8_t operand); + uint8_t orr(uint8_t operand, uint8_t data); register16_t m_d; register16_t m_x; diff --git a/MC6809/src/mc6809.cpp b/MC6809/src/mc6809.cpp index cca4300..ae55604 100644 --- a/MC6809/src/mc6809.cpp +++ b/MC6809/src/mc6809.cpp @@ -89,7 +89,7 @@ int EightBit::mc6809::executeUnprefixed(uint8_t opcode) { case 0xe4: addCycles(4); B() = andr(B(), AM_indexed_byte()); break; // AND (ANDB indexed) case 0xf4: addCycles(5); B() = andr(B(), AM_extended_byte()); break; // AND (ANDB extended) - case 0x1c: addCycles(3); CC() = andr(CC(), AM_immediate_byte()); break; // AND (ANDCC immediate) + case 0x1c: addCycles(3); CC() &= AM_immediate_byte(); break; // AND (ANDCC immediate) // ASL/LSL case 0x08: addCycles(6); BUS().write(asl(AM_direct_byte())); break; // ASL (direct) @@ -255,6 +255,23 @@ int EightBit::mc6809::executeUnprefixed(uint8_t opcode) { // NOP case 0x12: addCycles(2); break; // NOP (inherent) + // OR + + // ORA + case 0x8a: addCycles(3); A() = orr(A(), AM_immediate_byte()); break; // OR (ORA immediate) + case 0x9a: addCycles(3); A() = orr(A(), AM_direct_byte()); break; // OR (ORA direct) + case 0xaa: addCycles(3); A() = orr(A(), AM_indexed_byte()); break; // OR (ORA indexed) + case 0xba: addCycles(3); A() = orr(A(), AM_extended_byte()); break; // OR (ORA extended) + + // ORB + case 0xca: addCycles(3); A() = orr(A(), AM_immediate_byte()); break; // OR (ORB immediate) + case 0xda: addCycles(3); A() = orr(A(), AM_direct_byte()); break; // OR (ORB direct) + case 0xea: addCycles(3); A() = orr(A(), AM_indexed_byte()); break; // OR (ORB indexed) + case 0xfa: addCycles(3); A() = orr(A(), AM_extended_byte()); break; // OR (ORB extended) + + // ORCC + case 0x1a: addCycles(3); CC() |= AM_immediate_byte(); break; // OR (ORCC immediate) + default: UNREACHABLE; } @@ -675,3 +692,9 @@ uint8_t EightBit::mc6809::neg(uint8_t operand) { adjustCarry(result); return operand; } + +uint8_t EightBit::mc6809::orr(uint8_t operand, uint8_t data) { + clearFlag(CC(), VF); + adjustNZ(operand |= data); + return operand; +}