mirror of
https://github.com/cc65/cc65.git
synced 2024-12-25 02:29:52 +00:00
Fix Pop() implementation in src/sim65/paravirt.c (fixes #1625)
The Pop() function was not handling stack pointer wrap around correctly. Also, change the simulated RTS implementation in ParaVirtHooks() to explicitly sequence the two Pop() calls in the correct order.
This commit is contained in:
parent
c2608599aa
commit
623e951e33
@ -105,7 +105,7 @@ static void SetAX (CPURegs* Regs, unsigned Val)
|
|||||||
|
|
||||||
static unsigned char Pop (CPURegs* Regs)
|
static unsigned char Pop (CPURegs* Regs)
|
||||||
{
|
{
|
||||||
return MemReadByte (0x0100 + ++Regs->SP);
|
return MemReadByte (0x0100 + (++Regs->SP & 0xFF));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -327,5 +327,7 @@ void ParaVirtHooks (CPURegs* Regs)
|
|||||||
Hooks[Regs->PC - PARAVIRT_BASE] (Regs);
|
Hooks[Regs->PC - PARAVIRT_BASE] (Regs);
|
||||||
|
|
||||||
/* Simulate RTS */
|
/* Simulate RTS */
|
||||||
Regs->PC = Pop(Regs) + (Pop(Regs) << 8) + 1;
|
unsigned lo = Pop(Regs);
|
||||||
|
unsigned hi = Pop(Regs);
|
||||||
|
Regs->PC = lo + (hi << 8) + 1;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user