1
0
mirror of https://github.com/pevans/erc-c.git synced 2024-08-19 17:29:34 +00:00

Overflow should simply be bit 6's value

This commit is contained in:
Peter Evans 2018-01-20 23:47:02 -06:00
parent fcd25f6385
commit 809e6ca7c6

View File

@ -51,7 +51,19 @@ DEFINE_INST(asl)
*/
DEFINE_INST(bit)
{
mos6502_modify_status(cpu, MOS_NVZ, oper, oper);
// We're just relying on the modify_status function to do negative
// and zero; we also need to do overflow, but overflow is checked in
// a slightly different way with BIT...
mos6502_modify_status(cpu, MOS_NZ, oper, oper);
// Normally, overflow is handled by checking if bit 7 flipped from 0
// to 1 or vice versa, and that's done by comparing the result to
// the operand. But in the case of BIT, all we want to know is if
// bit 6 is high.
cpu->P &= ~MOS_OVERFLOW;
if (oper & 0x40) {
cpu->P |= MOS_OVERFLOW;
}
}
/*