CPU: BIT with immediate addressing should not alter V/N flags
This commit is contained in:
parent
0f64559882
commit
3cf0b0e46d
1 changed files with 20 additions and 9 deletions
|
@ -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()
|
||||
|
|
Loading…
Add table
Reference in a new issue