1
0
mirror of https://github.com/cc65/cc65.git synced 2024-06-18 07:29:36 +00:00

Merge pull request #1626 from mdsteele/paravirt

Fix Pop() implementation in src/sim65/paravirt.c (fixes #1625)
This commit is contained in:
Bob Andrews 2022-01-29 22:33:32 +01:00 committed by GitHub
commit ad1ebb697f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -105,7 +105,7 @@ static void SetAX (CPURegs* Regs, unsigned Val)
static unsigned char Pop (CPURegs* Regs)
{
return MemReadByte (0x0100 + ++Regs->SP);
return MemReadByte (0x0100 + (++Regs->SP & 0xFF));
}
@ -317,6 +317,8 @@ void ParaVirtInit (unsigned aArgStart, unsigned char aSPAddr)
void ParaVirtHooks (CPURegs* Regs)
/* Potentially execute paravirtualization hooks */
{
unsigned lo;
/* Check for paravirtualization address range */
if (Regs->PC < PARAVIRT_BASE ||
Regs->PC >= PARAVIRT_BASE + sizeof (Hooks) / sizeof (Hooks[0])) {
@ -327,5 +329,6 @@ void ParaVirtHooks (CPURegs* Regs)
Hooks[Regs->PC - PARAVIRT_BASE] (Regs);
/* Simulate RTS */
Regs->PC = Pop(Regs) + (Pop(Regs) << 8) + 1;
lo = Pop (Regs);
Regs->PC = lo + (Pop (Regs) << 8) + 1;
}