diff --git a/MC6809/inc/mc6809.h b/MC6809/inc/mc6809.h index a0ab371..a241d57 100644 --- a/MC6809/inc/mc6809.h +++ b/MC6809/inc/mc6809.h @@ -121,6 +121,7 @@ namespace EightBit { uint8_t andr(uint8_t operand, uint8_t data); uint8_t asl(uint8_t operand); uint8_t asr(uint8_t operand); + uint8_t clr(); uint8_t neg(uint8_t operand); register16_t m_d; diff --git a/MC6809/src/mc6809.cpp b/MC6809/src/mc6809.cpp index 322b660..561f8e1 100644 --- a/MC6809/src/mc6809.cpp +++ b/MC6809/src/mc6809.cpp @@ -98,6 +98,13 @@ int EightBit::mc6809::execute(uint8_t cell) { case 0xe5: addCycles(4); andr(B(), AM_indexed_byte()); break; // BIT (BITB, indexed) case 0xf5: addCycles(5); andr(B(), AM_extended_byte()); break; // BIT (BITB, extended) + // CLR + case 0x0f: addCycles(6); Address_direct(); BUS().write(clr()); break; // CLR (CLR, direct) + case 0x4f: addCycles(2); A() = clr(); break; // CLR (CLRA, implied) + case 0x5f: addCycles(2); B() = clr(); break; // CLR (CLRB, implied) + case 0x6f: addCycles(6); Address_indexed(); BUS().write(clr()); break; // CLR (CLR, indexed) + case 0x7f: addCycles(7); Address_extended(); BUS().write(clr()); break; // CLR (CLR, extended) + // NEG case 0x00: addCycles(6); BUS().write(neg(AM_direct_byte())); break; // NEG (direct) case 0x40: addCycles(2); A() = neg(A()); break; // NEG (NEGA, inherent) @@ -311,3 +318,9 @@ uint8_t EightBit::mc6809::asr(uint8_t operand) { adjustNZ(operand); return operand; } + +uint8_t EightBit::mc6809::clr() { + clearFlag(CC(), HF | ZF | VF | CF); + setFlag(CC(), ZF); + return 0; +}