From a43b1109bcf0972029ad707ae8af48daccff7a7f Mon Sep 17 00:00:00 2001 From: Adrian Conlon Date: Fri, 24 Aug 2018 00:33:18 +0100 Subject: [PATCH] Add TST instruction to the 6809 processor Signed-off-by: Adrian Conlon --- MC6809/inc/mc6809.h | 1 + MC6809/src/mc6809.cpp | 14 +++++++++----- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/MC6809/inc/mc6809.h b/MC6809/inc/mc6809.h index 3837dc0..6c3763a 100644 --- a/MC6809/inc/mc6809.h +++ b/MC6809/inc/mc6809.h @@ -300,6 +300,7 @@ namespace EightBit { uint8_t st(uint8_t data); register16_t st(register16_t data); void tfr(uint8_t data); + void tst(uint8_t data); register16_t m_d; register16_t m_x; diff --git a/MC6809/src/mc6809.cpp b/MC6809/src/mc6809.cpp index ad6298f..0bc6181 100644 --- a/MC6809/src/mc6809.cpp +++ b/MC6809/src/mc6809.cpp @@ -374,11 +374,11 @@ int EightBit::mc6809::executeUnprefixed(uint8_t opcode) { case 0x1f: addCycles(6); tfr(AM_immediate_byte()); break; // TFR (immediate) // TST - case 0x0d: addCycles(6); break; // TST (direct) - case 0x4d: addCycles(2); break; // TST (TSTA inherent) - case 0x5d: addCycles(2); break; // TST (TSTB inherent) - case 0x6d: addCycles(6); break; // TST (indexed) - case 0x7d: addCycles(7); break; // TST (extended) + case 0x0d: addCycles(6); tst(AM_direct_byte()); break; // TST (direct) + case 0x4d: addCycles(2); tst(A()); break; // TST (TSTA inherent) + case 0x5d: addCycles(2); tst(B()); break; // TST (TSTB inherent) + case 0x6d: addCycles(6); tst(AM_indexed_byte()); break; // TST (indexed) + case 0x7d: addCycles(7); tst(AM_extended_byte()); break; // TST (extended) // Branching @@ -1127,3 +1127,7 @@ EightBit::register16_t EightBit::mc6809::sub(register16_t operand, register16_t adjustSubtraction(operand, data, subtraction); return subtraction & Mask16; } + +void EightBit::mc6809::tst(uint8_t data) { + cmp(data, 0); +}