CPU: BIT with immediate addressing should not alter V/N flags

This commit is contained in:
Sour 2019-02-14 00:49:34 -05:00
parent 0f64559882
commit 3cf0b0e46d

View file

@ -801,16 +801,27 @@ Bit test operations
********************/
template<typename T> void Cpu::TestBits(T value)
{
if(_instAddrMode <= AddrMode::ImmM) {
//"Immediate addressing only affects the z flag (with the result of the bitwise And), but does not affect the n and v flags."
if(((T)_state.A & value) == 0) {
SetFlags(ProcFlags::Zero);
} else {
ClearFlags(ProcFlags::Zero);
}
} else {
ClearFlags(ProcFlags::Zero | ProcFlags::Overflow | ProcFlags::Negative);
if(((T)_state.A & value) == 0) {
SetFlags(ProcFlags::Zero);
}
if(value & (1 << (sizeof(T) * 8 - 2))) {
SetFlags(ProcFlags::Overflow);
}
if(value & (1 << (sizeof(T) * 8 - 1))) {
SetFlags(ProcFlags::Negative);
}
}
}
void Cpu::BIT()