1
0
mirror of https://github.com/cc65/cc65.git synced 2025-01-12 17:30:50 +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) 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) void ParaVirtHooks (CPURegs* Regs)
/* Potentially execute paravirtualization hooks */ /* Potentially execute paravirtualization hooks */
{ {
unsigned lo;
/* Check for paravirtualization address range */ /* Check for paravirtualization address range */
if (Regs->PC < PARAVIRT_BASE || if (Regs->PC < PARAVIRT_BASE ||
Regs->PC >= PARAVIRT_BASE + sizeof (Hooks) / sizeof (Hooks[0])) { Regs->PC >= PARAVIRT_BASE + sizeof (Hooks) / sizeof (Hooks[0])) {
@ -327,5 +329,6 @@ 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; lo = Pop (Regs);
Regs->PC = lo + (Pop (Regs) << 8) + 1;
} }