From 52695523465cb8bc72a0728b1f5b46ffc3eb2eef Mon Sep 17 00:00:00 2001 From: bbbradsmith Date: Thu, 30 May 2019 15:34:05 -0400 Subject: [PATCH 001/170] sim65 common define for paravirt hooks base location allows the loaded binary to take up as much space as possible restored some documentation of the hooks but without reference to specific location --- doc/sim65.sgml | 25 ++++++++++--------------- src/sim65/main.c | 4 ++-- src/sim65/paravirt.c | 6 +++--- src/sim65/paravirt.h | 11 +++++++++++ 4 files changed, 26 insertions(+), 20 deletions(-) diff --git a/doc/sim65.sgml b/doc/sim65.sgml index 8a7329b0..075d9584 100644 --- a/doc/sim65.sgml +++ b/doc/sim65.sgml @@ -115,22 +115,12 @@ The - int open (const char* name, int flags, ...); - int __fastcall__ close (int fd); - int __fastcall__ read (int fd, void* buf, unsigned count); - int __fastcall__ write (int fd, const void* buf, unsigned count); - - -These built-in functions can be used with -). Creating a Test in Assembly

@@ -169,6 +159,11 @@ pre-loaded with the given The +Several bytes immediately below the vector table are reserved for paravirtualization functions. +Except for = PARAVIRT_BASE) { + Error ("'%s': To large to fit into $%04X-$%04X", ProgramFile, Addr, PARAVIRT_BASE); } MemWriteByte (Addr++, (unsigned char) Val); } diff --git a/src/sim65/paravirt.c b/src/sim65/paravirt.c index c9f6e61b..603a07e9 100644 --- a/src/sim65/paravirt.c +++ b/src/sim65/paravirt.c @@ -318,13 +318,13 @@ void ParaVirtHooks (CPURegs* Regs) /* Potentially execute paravirtualization hooks */ { /* Check for paravirtualization address range */ - if (Regs->PC < 0xFFF4 || - Regs->PC >= 0xFFF4 + sizeof (Hooks) / sizeof (Hooks[0])) { + if (Regs->PC < PARAVIRT_BASE || + Regs->PC >= PARAVIRT_BASE + sizeof (Hooks) / sizeof (Hooks[0])) { return; } /* Call paravirtualization hook */ - Hooks[Regs->PC - 0xFFF4] (Regs); + Hooks[Regs->PC - PARAVIRT_BASE] (Regs); /* Simulate RTS */ Regs->PC = Pop(Regs) + (Pop(Regs) << 8) + 1; diff --git a/src/sim65/paravirt.h b/src/sim65/paravirt.h index cd491539..99c28fa0 100644 --- a/src/sim65/paravirt.h +++ b/src/sim65/paravirt.h @@ -38,6 +38,17 @@ +/*****************************************************************************/ +/* Data */ +/*****************************************************************************/ + + + +#define PARAVIRT_BASE 0xFFF4 +/* Lowest address used by a paravirtualization hook */ + + + /*****************************************************************************/ /* Code */ /*****************************************************************************/ -- 2.26.0