diff options
| author | 2026-03-18 19:14:19 +0100 | |
|---|---|---|
| committer | 2026-03-18 19:14:19 +0100 | |
| commit | 7a552c92e7175dffee473f84fbb8e4a79263adf0 (patch) | |
| tree | caf0e52f96d3fe07d9caa97bffa8fa49bdb68a44 /src/devices/cpu | |
| parent | 8657b6b0a804e839358d91b4e2cf7d043808229d (diff) | |
m6502: small refactor to do_sbc_d to make it easier to see the difference between nmos/cmos
Diffstat (limited to 'src/devices/cpu')
| -rw-r--r-- | src/devices/cpu/m6502/m6502.cpp | 4 | ||||
| -rw-r--r-- | src/devices/cpu/m6502/w65c02.cpp | 6 |
2 files changed, 7 insertions, 3 deletions
diff --git a/src/devices/cpu/m6502/m6502.cpp b/src/devices/cpu/m6502/m6502.cpp index 8e97fe008c3..c8480540120 100644 --- a/src/devices/cpu/m6502/m6502.cpp +++ b/src/devices/cpu/m6502/m6502.cpp @@ -258,8 +258,6 @@ void m6502_device::do_sbc_d(uint8_t val) m_P &= ~(F_N|F_V|F_Z|F_C); uint16_t diff = m_A - val - c; uint8_t al = (m_A & 15) - (val & 15) - c; - if(int8_t(al) < 0) - al -= 6; uint8_t ah = (m_A >> 4) - (val >> 4) - (int8_t(al) < 0); if(!uint8_t(diff)) m_P |= F_Z; @@ -269,6 +267,8 @@ void m6502_device::do_sbc_d(uint8_t val) m_P |= F_V; if(!(diff & 0xff00)) m_P |= F_C; + if(int8_t(al) < 0) + al -= 6; if(int8_t(ah) < 0) ah -= 6; m_A = (ah << 4) | (al & 15); diff --git a/src/devices/cpu/m6502/w65c02.cpp b/src/devices/cpu/m6502/w65c02.cpp index 145faf79f60..6875a20b72d 100644 --- a/src/devices/cpu/m6502/w65c02.cpp +++ b/src/devices/cpu/m6502/w65c02.cpp @@ -41,7 +41,11 @@ void w65c02_device::do_sbc_d(uint8_t val) m_P |= F_V; if(!(diff & 0xff00)) m_P |= F_C; - m_A = ((ah << 4) | (al & 15)) - ((int8_t(ah) < 0 ? 0x60 : 0) | (int8_t(al) < 0 ? 6 : 0)); + m_A = (ah << 4) | (al & 15); + if(int8_t(al) < 0) + m_A -= 6; + if(int8_t(ah) < 0) + m_A -= 0x60; } std::unique_ptr<util::disasm_interface> w65c02_device::create_disassembler() |
