Merge pull request #2547 from sidneycadot/fix-jmp-ind

Fixed the behavior of JMP (ind) in sim65 when it runs with the 6502X CPU type.
This commit is contained in:
Bob Andrews
2024-12-02 00:21:31 +01:00
committed by GitHub

View File

@@ -1964,25 +1964,17 @@ static void OPC_6502_6C (void)
PC = Regs.PC; PC = Regs.PC;
Lo = MemReadWord (PC+1); Lo = MemReadWord (PC+1);
if (CPU == CPU_6502) /* Emulate the buggy 6502 behavior */
{ Cycles = 5;
/* Emulate the 6502 bug */ Regs.PC = MemReadByte (Lo);
Cycles = 5; Hi = (Lo & 0xFF00) | ((Lo + 1) & 0xFF);
Regs.PC = MemReadByte (Lo); Regs.PC |= (MemReadByte (Hi) << 8);
Hi = (Lo & 0xFF00) | ((Lo + 1) & 0xFF);
Regs.PC |= (MemReadByte (Hi) << 8);
/* Output a warning if the bug is triggered */ /* Output a warning if the bug is triggered */
if (Hi != Lo + 1) if (Hi != Lo + 1)
{
Warning ("6502 indirect jump bug triggered at $%04X, ind addr = $%04X",
PC, Lo);
}
}
else
{ {
Cycles = 6; Warning ("6502 indirect jump bug triggered at $%04X, ind addr = $%04X",
Regs.PC = MemReadWord(Lo); PC, Lo);
} }
ParaVirtHooks (&Regs); ParaVirtHooks (&Regs);