Hi,
BIT command is somewhat irregular and surprising, when comes to flag setting. According to manuals there is a difference in modes (immediate and others) and only Z flag is set from result - N and V are set from argument (but not in Immediate case). See: http://www.6502.org/tutorials/65c816opcodes.html#6.1.2.2
Following code should works for me:
public void ExecuteBIT(byte instruction, AddressModes addressMode, int signature)
{
int data = GetValue(addressMode, signature, cpu.A.Width);
int result = cpu.A.Value & data;
cpu.Flags.SetZ(cpu.A.Value & data);
if (addressMode != AddressModes.Immediate)
{
if (cpu.A.Width == 2)
{
cpu.Flags.oVerflow = (data & 0x4000) == 0x4000;
cpu.Flags.Negative = (data & 0x8000) == 0x8000;
}
else
{
cpu.Flags.oVerflow = (data & 0x40) == 0x40;
cpu.Flags.Negative = (data & 0x80) == 0x80;
}
}
}
Hi, BIT command is somewhat irregular and surprising, when comes to flag setting. According to manuals there is a difference in modes (immediate and others) and only Z flag is set from result - N and V are set from argument (but not in Immediate case). See: http://www.6502.org/tutorials/65c816opcodes.html#6.1.2.2
Following code should works for me: