1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-07-05 10:28:58 +00:00

Generalises CMP to implement CPX and CPY.

This commit is contained in:
Thomas Harte 2020-10-07 18:09:56 -04:00
parent 466ca38dfa
commit 5ca1c0747f

View File

@ -573,20 +573,20 @@ template <typename BusHandler> void Processor<BusHandler>::run_for(const Cycles
// Arithmetic. // Arithmetic.
// //
case CMP: { #define cp(v, shift) {\
if(m_flag()) { const uint32_t temp32 = v.full - data_buffer_.value; \
const uint16_t temp16 = a_.halves.low - data_buffer_.value; flags_.set_nz(uint16_t(temp32), shift); \
flags_.set_nz(uint8_t(temp16)); flags_.carry = ((~temp32) >> (8 + shift))&1; \
flags_.carry = ((~temp16) >> 8)&1; }
} else {
const uint32_t temp32 = a_.full - data_buffer_.value; case CMP: cp(a_, m_shift_); break;
flags_.set_nz(uint16_t(temp32), 8); case CPX: cp(x_, x_shift_); break;
flags_.carry = ((~temp32) >> 16)&1; case CPY: cp(y_, x_shift_); break;
}
} break; #undef cp
// TODO: // TODO:
// ADC, BIT, CPX, CPY, SBC, // ADC, BIT, SBC,
// PLP, // PLP,
// PHP, PHD, PHK, // PHP, PHD, PHK,
// TRB, TSB, // TRB, TSB,