From dac58b121a8d9cc43511e2e1c74d92150cd18d16 Mon Sep 17 00:00:00 2001 From: Adrian Conlon Date: Mon, 12 Mar 2018 01:22:28 +0000 Subject: [PATCH] More small tidyups in the core emulator set. Signed-off-by: Adrian Conlon --- Intel8080/inc/Intel8080.h | 5 ++++- Intel8080/src/Intel8080.cpp | 8 ++++---- M6502/src/mos6502.cpp | 12 ++++++------ Z80/src/Z80.cpp | 9 ++++----- 4 files changed, 18 insertions(+), 16 deletions(-) diff --git a/Intel8080/inc/Intel8080.h b/Intel8080/inc/Intel8080.h index 4f497a4..fda563b 100644 --- a/Intel8080/inc/Intel8080.h +++ b/Intel8080/inc/Intel8080.h @@ -68,7 +68,7 @@ namespace EightBit { default: UNREACHABLE; } - throw std::logic_error("Unhandled registry mechanism"); + UNREACHABLE; } void R(int r, uint8_t& a, uint8_t value) { @@ -100,6 +100,7 @@ namespace EightBit { default: UNREACHABLE; } + UNREACHABLE; } register16_t& RP(int rp) { @@ -115,6 +116,7 @@ namespace EightBit { default: UNREACHABLE; } + UNREACHABLE; } register16_t& RP2(int rp) { @@ -130,6 +132,7 @@ namespace EightBit { default: UNREACHABLE; } + UNREACHABLE; } static void adjustAuxiliaryCarryAdd(uint8_t& f, uint8_t before, uint8_t value, int calculation) { diff --git a/Intel8080/src/Intel8080.cpp b/Intel8080/src/Intel8080.cpp index 19f34e6..6a6e290 100644 --- a/Intel8080/src/Intel8080.cpp +++ b/Intel8080/src/Intel8080.cpp @@ -68,7 +68,7 @@ bool EightBit::Intel8080::jumpConditionalFlag(uint8_t& f, int flag) { default: UNREACHABLE; } - throw std::logic_error("Unhandled JP conditional"); + UNREACHABLE; } bool EightBit::Intel8080::returnConditionalFlag(uint8_t& f, int flag) { @@ -92,7 +92,7 @@ bool EightBit::Intel8080::returnConditionalFlag(uint8_t& f, int flag) { default: UNREACHABLE; } - throw std::logic_error("Unhandled RET conditional"); + UNREACHABLE; } bool EightBit::Intel8080::callConditionalFlag(uint8_t& f, int flag) { @@ -116,7 +116,7 @@ bool EightBit::Intel8080::callConditionalFlag(uint8_t& f, int flag) { default: UNREACHABLE; } - throw std::logic_error("Unhandled CALL conditional"); + UNREACHABLE; } void EightBit::Intel8080::add(uint8_t& f, register16_t& operand, register16_t value) { @@ -234,7 +234,7 @@ void EightBit::Intel8080::xhtl(register16_t& operand) { MEMPTR().low = BUS().read(SP()); BUS().write(operand.low); operand.low = MEMPTR().low; - BUS().ADDRESS().word++; + ++BUS().ADDRESS().word; MEMPTR().high = BUS().read(); BUS().write(operand.high); operand.high = MEMPTR().high; diff --git a/M6502/src/mos6502.cpp b/M6502/src/mos6502.cpp index b5a7f62..924b2e6 100644 --- a/M6502/src/mos6502.cpp +++ b/M6502/src/mos6502.cpp @@ -53,7 +53,7 @@ void EightBit::MOS6502::reset() { EightBit::register16_t EightBit::MOS6502::getWordPaged(uint8_t page, uint8_t offset) { EightBit::register16_t returned; returned.low = getBytePaged(page, offset); - BUS().ADDRESS().low++; + ++BUS().ADDRESS().low; returned.high = BUS().read(); return returned; } @@ -78,7 +78,7 @@ void EightBit::MOS6502::interrupt(uint8_t vector) { PC() = getWordPaged(0xff, vector); } -int EightBit::MOS6502::execute(uint8_t cell) { +int EightBit::MOS6502::execute(uint8_t cell) { switch (cell) { @@ -498,7 +498,7 @@ void EightBit::MOS6502::Branch(int8_t displacement) { void EightBit::MOS6502::Branch(bool flag) { const int8_t displacement = AM_Immediate(); - if (flag) + if (UNLIKELY(flag)) Branch(displacement); } @@ -516,7 +516,7 @@ void EightBit::MOS6502::PLP() { void EightBit::MOS6502::JSR_abs() { Address_Absolute(); - PC().word--; + --PC().word; call(); } @@ -527,7 +527,7 @@ void EightBit::MOS6502::RTI() { void EightBit::MOS6502::RTS() { ret(); - PC().word++; + ++PC().word; } void EightBit::MOS6502::JMP_abs() { @@ -541,7 +541,7 @@ void EightBit::MOS6502::JMP_ind() { } void EightBit::MOS6502::BRK() { - PC().word++; + ++PC().word; pushWord(PC()); PHP(); setFlag(P(), IF); diff --git a/Z80/src/Z80.cpp b/Z80/src/Z80.cpp index 9e17393..ba8aab5 100644 --- a/Z80/src/Z80.cpp +++ b/Z80/src/Z80.cpp @@ -434,9 +434,8 @@ void EightBit::Z80::daa(uint8_t& a, uint8_t& f) { } f = (f & (CF | NF)) | (a > 0x99 ? CF : 0) | ((a ^ updated) & HC); - a = updated; - adjustSZPXY(f, a); + adjustSZPXY(f, a = updated); } void EightBit::Z80::cpl(uint8_t& a, uint8_t& f) { @@ -1123,7 +1122,7 @@ void EightBit::Z80::executeOther(uint8_t& a, uint8_t& f, const int x, const int case 5: case 6: case 7: - if (jrConditionalFlag(f, y - 4)) + if (UNLIKELY(jrConditionalFlag(f, y - 4))) addCycles(5); addCycles(5); break; @@ -1364,7 +1363,7 @@ void EightBit::Z80::executeOther(uint8_t& a, uint8_t& f, const int x, const int case 3: switch (z) { case 0: // Conditional return - if (returnConditionalFlag(f, y)) + if (UNLIKELY(returnConditionalFlag(f, y))) addCycles(6); addCycles(5); break; @@ -1447,7 +1446,7 @@ void EightBit::Z80::executeOther(uint8_t& a, uint8_t& f, const int x, const int } break; case 4: // Conditional call: CALL cc[y], nn - if (callConditionalFlag(f, y)) + if (UNLIKELY(callConditionalFlag(f, y))) addCycles(7); addCycles(10); break;