|
|
11ec6e9 |
From 52695523465cb8bc72a0728b1f5b46ffc3eb2eef Mon Sep 17 00:00:00 2001
|
|
|
11ec6e9 |
From: bbbradsmith <bbbradsmith@users.noreply.github.com>
|
|
|
11ec6e9 |
Date: Thu, 30 May 2019 15:34:05 -0400
|
|
|
a4f04fe |
Subject: [PATCH 001/170] sim65 common define for paravirt hooks base location
|
|
|
f26de63 |
allows the loaded binary to take up as much space as possible restored some
|
|
|
11ec6e9 |
documentation of the hooks but without reference to specific location
|
|
|
11ec6e9 |
|
|
|
11ec6e9 |
---
|
|
|
11ec6e9 |
doc/sim65.sgml | 25 ++++++++++---------------
|
|
|
11ec6e9 |
src/sim65/main.c | 4 ++--
|
|
|
11ec6e9 |
src/sim65/paravirt.c | 6 +++---
|
|
|
11ec6e9 |
src/sim65/paravirt.h | 11 +++++++++++
|
|
|
11ec6e9 |
4 files changed, 26 insertions(+), 20 deletions(-)
|
|
|
11ec6e9 |
|
|
|
11ec6e9 |
diff --git a/doc/sim65.sgml b/doc/sim65.sgml
|
|
|
f26de63 |
index 8a7329b0..075d9584 100644
|
|
|
11ec6e9 |
--- a/doc/sim65.sgml
|
|
|
11ec6e9 |
+++ b/doc/sim65.sgml
|
|
|
11ec6e9 |
@@ -115,22 +115,12 @@ The
|
|
|
11ec6e9 |
|
|
|
11ec6e9 |
Exit codes are limited to 8 bits.
|
|
|
11ec6e9 |
|
|
|
11ec6e9 |
-The standard C library high level file input and output is functional,
|
|
|
11ec6e9 |
-and can be used like a command line application in sim65.
|
|
|
11ec6e9 |
+The standard C library high level file input and output is functional.
|
|
|
11ec6e9 |
+A sim65 application can be written like a command line application,
|
|
|
11ec6e9 |
+providing arguments to
|
|
|
11ec6e9 |
|
|
|
11ec6e9 |
-Lower level file input and output is provided by
|
|
|
11ec6e9 |
-a set of built-in paravirtualization functions:
|
|
|
11ec6e9 |
-
|
|
|
11ec6e9 |
-<tscreen><verb>
|
|
|
11ec6e9 |
- int open (const char* name, int flags, ...);
|
|
|
11ec6e9 |
- int __fastcall__ close (int fd);
|
|
|
11ec6e9 |
- int __fastcall__ read (int fd, void* buf, unsigned count);
|
|
|
11ec6e9 |
- int __fastcall__ write (int fd, const void* buf, unsigned count);
|
|
|
11ec6e9 |
-</verb></tscreen>
|
|
|
11ec6e9 |
-
|
|
|
11ec6e9 |
-These built-in functions can be used with
|
|
|
11ec6e9 |
-
|
|
|
11ec6e9 |
-which are mapped to sim65's corresponding file descriptors.
|
|
|
11ec6e9 |
+Internally, file input and output is provided at a lower level by
|
|
|
11ec6e9 |
+a set of built-in paravirtualization functions (<ref id="paravirt-internal" name="see below">).
|
|
|
11ec6e9 |
|
|
|
11ec6e9 |
|
|
|
11ec6e9 |
<sect>Creating a Test in Assembly
|
|
|
11ec6e9 |
@@ -169,6 +159,11 @@ pre-loaded with the given
|
|
|
11ec6e9 |
<item>The
|
|
|
11ec6e9 |
Jumping to this address will terminate execution with the A register value as an exit code.
|
|
|
11ec6e9 |
|
|
|
11ec6e9 |
+<label id="paravirt-internal">
|
|
|
11ec6e9 |
+<item>Several bytes immediately below the vector table are reserved for paravirtualization functions.
|
|
|
11ec6e9 |
+Except for
|
|
|
11ec6e9 |
+These use cc65 calling conventions, and are intended for use with the sim65 target C library.
|
|
|
11ec6e9 |
+
|
|
|
11ec6e9 |
<item>
|
|
|
11ec6e9 |
can be used if the IRQ vector at
|
|
|
11ec6e9 |
|
|
|
11ec6e9 |
diff --git a/src/sim65/main.c b/src/sim65/main.c
|
|
|
f26de63 |
index bcd436a1..f2daf929 100644
|
|
|
11ec6e9 |
--- a/src/sim65/main.c
|
|
|
11ec6e9 |
+++ b/src/sim65/main.c
|
|
|
11ec6e9 |
@@ -200,8 +200,8 @@ static unsigned char ReadProgramFile (void)
|
|
|
11ec6e9 |
/* Read the file body into memory */
|
|
|
11ec6e9 |
Addr = Load;
|
|
|
11ec6e9 |
while ((Val = fgetc(F)) != EOF) {
|
|
|
11ec6e9 |
- if (Addr == 0xFF00) {
|
|
|
11ec6e9 |
- Error ("'%s': To large to fit into $%04X-$FFF0", ProgramFile, Addr);
|
|
|
11ec6e9 |
+ if (Addr >= PARAVIRT_BASE) {
|
|
|
11ec6e9 |
+ Error ("'%s': To large to fit into $%04X-$%04X", ProgramFile, Addr, PARAVIRT_BASE);
|
|
|
11ec6e9 |
}
|
|
|
11ec6e9 |
MemWriteByte (Addr++, (unsigned char) Val);
|
|
|
11ec6e9 |
}
|
|
|
11ec6e9 |
diff --git a/src/sim65/paravirt.c b/src/sim65/paravirt.c
|
|
|
f26de63 |
index c9f6e61b..603a07e9 100644
|
|
|
11ec6e9 |
--- a/src/sim65/paravirt.c
|
|
|
11ec6e9 |
+++ b/src/sim65/paravirt.c
|
|
|
11ec6e9 |
@@ -318,13 +318,13 @@ void ParaVirtHooks (CPURegs* Regs)
|
|
|
11ec6e9 |
/* Potentially execute paravirtualization hooks */
|
|
|
11ec6e9 |
{
|
|
|
11ec6e9 |
/* Check for paravirtualization address range */
|
|
|
11ec6e9 |
- if (Regs->PC < 0xFFF4 ||
|
|
|
11ec6e9 |
- Regs->PC >= 0xFFF4 + sizeof (Hooks) / sizeof (Hooks[0])) {
|
|
|
11ec6e9 |
+ if (Regs->PC < PARAVIRT_BASE ||
|
|
|
11ec6e9 |
+ Regs->PC >= PARAVIRT_BASE + sizeof (Hooks) / sizeof (Hooks[0])) {
|
|
|
11ec6e9 |
return;
|
|
|
11ec6e9 |
}
|
|
|
11ec6e9 |
|
|
|
11ec6e9 |
/* Call paravirtualization hook */
|
|
|
11ec6e9 |
- Hooks[Regs->PC - 0xFFF4] (Regs);
|
|
|
11ec6e9 |
+ Hooks[Regs->PC - PARAVIRT_BASE] (Regs);
|
|
|
11ec6e9 |
|
|
|
11ec6e9 |
/* Simulate RTS */
|
|
|
11ec6e9 |
Regs->PC = Pop(Regs) + (Pop(Regs) << 8) + 1;
|
|
|
11ec6e9 |
diff --git a/src/sim65/paravirt.h b/src/sim65/paravirt.h
|
|
|
f26de63 |
index cd491539..99c28fa0 100644
|
|
|
11ec6e9 |
--- a/src/sim65/paravirt.h
|
|
|
11ec6e9 |
+++ b/src/sim65/paravirt.h
|
|
|
11ec6e9 |
@@ -38,6 +38,17 @@
|
|
|
11ec6e9 |
|
|
|
11ec6e9 |
|
|
|
11ec6e9 |
|
|
|
11ec6e9 |
+/*****************************************************************************/
|
|
|
11ec6e9 |
+/* Data */
|
|
|
11ec6e9 |
+/*****************************************************************************/
|
|
|
11ec6e9 |
+
|
|
|
11ec6e9 |
+
|
|
|
11ec6e9 |
+
|
|
|
11ec6e9 |
+#define PARAVIRT_BASE 0xFFF4
|
|
|
11ec6e9 |
+/* Lowest address used by a paravirtualization hook */
|
|
|
11ec6e9 |
+
|
|
|
11ec6e9 |
+
|
|
|
11ec6e9 |
+
|
|
|
11ec6e9 |
/*****************************************************************************/
|
|
|
11ec6e9 |
/* Code */
|
|
|
11ec6e9 |
/*****************************************************************************/
|
|
|
f26de63 |
--
|
|
|
a4f04fe |
2.26.0
|
|
|
f26de63 |
|