diff --git a/M6502/inc/mos6502.h b/M6502/inc/mos6502.h index 170ee35..44ae15a 100644 --- a/M6502/inc/mos6502.h +++ b/M6502/inc/mos6502.h @@ -162,14 +162,14 @@ namespace EightBit { } uint8_t AM_AbsoluteX() { - if (Address_AbsoluteX()) + if (UNLIKELY(Address_AbsoluteX())) addCycle(); BUS().ADDRESS() = MEMPTR(); return getByte(); } uint8_t AM_AbsoluteY() { - if (Address_AbsoluteY()) + if (UNLIKELY(Address_AbsoluteY())) addCycle(); BUS().ADDRESS() = MEMPTR(); return getByte(); @@ -191,7 +191,7 @@ namespace EightBit { } uint8_t AM_IndirectIndexedY() { - if (Address_IndirectIndexedY()) + if (UNLIKELY(Address_IndirectIndexedY())) addCycle(); BUS().ADDRESS() = MEMPTR(); return getByte(); diff --git a/M6502/src/mos6502.cpp b/M6502/src/mos6502.cpp index c85be38..d404b27 100644 --- a/M6502/src/mos6502.cpp +++ b/M6502/src/mos6502.cpp @@ -336,7 +336,7 @@ int EightBit::MOS6502::execute(uint8_t cell) { __assume(0); } - if (cycles() == 0) + if (UNLIKELY(cycles() == 0)) throw std::logic_error("Unhandled opcode"); return cycles(); @@ -480,7 +480,7 @@ void EightBit::MOS6502::ADC_d(uint8_t data) { void EightBit::MOS6502::Branch(int8_t displacement) { const auto page = PC().high; PC().word += displacement; - if (PC().high != page) + if (UNLIKELY(PC().high != page)) addCycle(); addCycle(); }