Rearranged paravirt function vector.

- exit right below 6502 vectors.
- keep exit addr stable as it may be called from asm.
This commit is contained in:
Oliver Schmidt
2019-05-30 00:10:17 +02:00
parent c6bbea0bb0
commit 6efb71bea7
3 changed files with 25 additions and 30 deletions

View File

@@ -120,6 +120,18 @@ static unsigned PopParam (unsigned char Incr)
static void PVExit (CPURegs* Regs)
{
Print (stderr, 1, "PVExit ($%02X)\n", Regs->AC);
if (PrintCycles) {
Print (stdout, 0, "%lu cycles\n", GetCycles ());
}
exit (Regs->AC);
}
static void PVArgs (CPURegs* Regs)
{
unsigned ArgC = ArgCount - ArgStart;
@@ -152,18 +164,6 @@ static void PVArgs (CPURegs* Regs)
static void PVExit (CPURegs* Regs)
{
Print (stderr, 1, "PVExit ($%02X)\n", Regs->AC);
if (PrintCycles) {
Print (stdout, 0, "%lu cycles\n", GetCycles ());
}
exit (Regs->AC);
}
static void PVOpen (CPURegs* Regs)
{
char Path[1024];
@@ -295,12 +295,12 @@ static void PVWrite (CPURegs* Regs)
static const PVFunc Hooks[] = {
PVArgs,
PVExit,
PVOpen,
PVClose,
PVRead,
PVWrite,
PVArgs,
PVExit,
};
@@ -318,13 +318,13 @@ void ParaVirtHooks (CPURegs* Regs)
/* Potentially execute paravirtualization hooks */
{
/* Check for paravirtualization address range */
if (Regs->PC < 0xFFF0 ||
Regs->PC >= 0xFFF0 + sizeof (Hooks) / sizeof (Hooks[0])) {
if (Regs->PC < 0xFFF4 ||
Regs->PC >= 0xFFF4 + sizeof (Hooks) / sizeof (Hooks[0])) {
return;
}
/* Call paravirtualization hook */
Hooks[Regs->PC - 0xFFF0] (Regs);
Hooks[Regs->PC - 0xFFF4] (Regs);
/* Simulate RTS */
Regs->PC = Pop(Regs) + (Pop(Regs) << 8) + 1;