From 7f8da55931d400df6a92ec1d366b33268e018e02 Mon Sep 17 00:00:00 2001 From: Bobbi Webber-Manners Date: Mon, 25 May 2020 21:18:18 -0400 Subject: [PATCH] Added basic infrastructure for using aux memory --- sortdir.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/sortdir.c b/sortdir.c index f85f4a9..baddb0b 100644 --- a/sortdir.c +++ b/sortdir.c @@ -37,6 +37,7 @@ #define CHECK /* Perform additional integrity checking */ #define SORT /* Enable sorting code */ #undef FREELIST /* Checking of free list */ +#undef AUXMEM /* Auxiliary memory support on //e and up */ #define NLEVELS 4 /* Number of nested sorts permitted */ @@ -178,6 +179,10 @@ static char *buf; /* General purpose scratch buffer */ static char *buf2; /* General purpose scratch buffer */ /* Prototypes */ +#ifdef AUXMEM +void copyaux(char *src, char *dst, uint len, uchar dir); +char *auxalloc(uint bytes); +#endif void hline(void); void confirm(void); void err(enum errtype severity, char *fmt, ...); @@ -239,6 +244,37 @@ void zeroblock(uchar device, uint blocknum); void zerofreeblocks(uchar device, uint freeblks); void parseargs(void); +#ifdef AUXMEM + +/* Aux memory copy routine */ +#define FROMAUX 0 +#define TOAUX 1 +void copyaux(char *src, char *dst, uint len, uchar dir) { + char **a1 = (char**)0x3c; + char **a2 = (char**)0x3e; + char **a4 = (char**)0x42; + *a1 = src; + *a2 = src + len; + *a4 = dst; + if (dir == TOAUX) { + __asm__("sec"); // Copy main->aux + __asm__("jsr $c311"); // AUXMOVE + } else { + __asm__("clc"); // Copy aux->main + __asm__("jsr $c311"); // AUXMOVE + } +} + +/* Extremely simple aux memory allocator */ +#define STARTAUX 0x200 +char *auxalloc(uint bytes) { + static char *highwater = (char*)STARTAUX; + highwater += bytes; + return highwater; +} + +#endif + /* Horizontal line */ void hline(void) { uint i;