From 6efb71bea773837c6fc4aae0c8270b2d70e3e69f Mon Sep 17 00:00:00 2001
From: Oliver Schmidt
Date: Thu, 30 May 2019 00:10:17 +0200
Subject: [PATCH] Rearranged paravirt function vector.
- exit right below 6502 vectors.
- keep exit addr stable as it may be called from asm.
---
doc/sim65.sgml | 7 +------
libsrc/sim6502/paravirt.s | 14 +++++++-------
src/sim65/paravirt.c | 34 +++++++++++++++++-----------------
3 files changed, 25 insertions(+), 30 deletions(-)
diff --git a/doc/sim65.sgml b/doc/sim65.sgml
index 075f6cbe2..8a7329b0b 100644
--- a/doc/sim65.sgml
+++ b/doc/sim65.sgml
@@ -166,14 +166,9 @@ Other internal details:
Aside from the loaded binary, the reset vector at The The The built-in functions are provided by 6 paravirtualization hooks present at
-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;