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,15 +801,26 @@ Bit test operations
|
||||||
********************/
|
********************/
|
||||||
template<typename T> void Cpu::TestBits(T value)
|
template<typename T> void Cpu::TestBits(T value)
|
||||||
{
|
{
|
||||||
ClearFlags(ProcFlags::Zero | ProcFlags::Overflow | ProcFlags::Negative);
|
if(_instAddrMode <= AddrMode::ImmM) {
|
||||||
if(((T)_state.A & value) == 0) {
|
//"Immediate addressing only affects the z flag (with the result of the bitwise And), but does not affect the n and v flags."
|
||||||
SetFlags(ProcFlags::Zero);
|
if(((T)_state.A & value) == 0) {
|
||||||
}
|
SetFlags(ProcFlags::Zero);
|
||||||
if(value & (1 << (sizeof(T) * 8 - 2))) {
|
} else {
|
||||||
SetFlags(ProcFlags::Overflow);
|
ClearFlags(ProcFlags::Zero);
|
||||||
}
|
}
|
||||||
if(value & (1 << (sizeof(T) * 8 - 1))) {
|
} else {
|
||||||
SetFlags(ProcFlags::Negative);
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue