mirror of
https://github.com/cc65/cc65.git
synced 2024-11-19 06:31:31 +00:00
Merge pull request #1626 from mdsteele/paravirt
Fix Pop() implementation in src/sim65/paravirt.c (fixes #1625)
This commit is contained in:
commit
ad1ebb697f
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user