diff --git a/MC6809/inc/mc6809.h b/MC6809/inc/mc6809.h index 36c977d..5e51375 100644 --- a/MC6809/inc/mc6809.h +++ b/MC6809/inc/mc6809.h @@ -132,17 +132,6 @@ namespace EightBit { // Read/Modify/Write - // Macro version: easy to use - // RMW(AM_direct_byte, asl) - #define RMW(ACCESSOR, OPERATION) \ - { \ - const auto data = ACCESSOR(); \ - const auto address = BUS().ADDRESS(); \ - const auto result = OPERATION(data); \ - eat(); \ - memoryWrite(address, result); \ - } - typedef std::function accessor_t; typedef std::function operation_t; @@ -156,6 +145,10 @@ namespace EightBit { memoryWrite(address, result); } + // So define a helper macro + #define RMW(ACCESSOR, OPERATION) \ + rmw([this]() { return ACCESSOR(); }, [this](uint8_t data) { return OPERATION(data); }); + // Stack manipulation void push(register16_t& stack, uint8_t value); @@ -326,17 +319,17 @@ namespace EightBit { // Branching - auto branch(const register16_t destination, const int condition) { + auto branch(const register16_t destination, const bool condition) { if (condition) jump(destination); - return !!condition; + return condition; } - void branchShort(const int condition) { + void branchShort(const bool condition) { branch(Address_relative_byte(), condition); } - void branchLong(const int condition) { + void branchLong(const bool condition) { if (branch(Address_relative_word(), condition)) eat(); }