Sandboxing BASIC
Jon Abbott (1421) 2651 posts |
I want to run a sandboxed copy of the BASIC Module to avoid having to patch the ROM Module – ADFFS patches USR and CALL to issue an SWI instead of jumping directly to an address so it can trap 26bit code entry. Am I correct in presuming BASIC keeps it’s privates within appspace, so the only thing I need to do is redirect *BASIC to the relevant version of the Module and they’ll then happily coexist? Unlike CLib 2.0+, it doesn’t store anything in Page Zero does it? I’ve already sandboxed APCS-A, APCS-R and APCS-32, which all run a local copy of the relevant CLib Module when one of CLib’s SWI’s is issued. I need to do something similar for BASIC. |
Chris Hall (132) 3554 posts |
I thought that BASIC did store stuff below PAGE (&8F00) but not in page zero? My recollection is that PAGE could be as low as &E00 on earlier machines but no lower than &8000 (start of app space) on RO5. Zero page was more useful on the 6502 so lots of stuff was stored there (memory from &0000 to &0100). Hence lots of BASIC apps could run with application workspace separate for each programme but the BASIC module held in one place (ROM). |
Steve Drain (222) 1620 posts |
I am not sure that I can answer this in depth, but two things might be relevant: the BASIC module does not have its own workspace; when BASIC interprets a program it uses a chunk of memory at the start of the application space for its arguments.1 Is ‘the relevant version of the module’ one with a different name, say BASIC_ADFFS? If so, I can see no reason for it not to co-exist with either the ROM or a single soft-loaded copy of the BASIC module. The problems of replacing the BASIC module have been well rehersed here. ;-) 1 from &8000 to &8F00 for BASIC V; to &9300 for BASIC VI. |
Steve Drain (222) 1620 posts |
I am not sure how you intended to do this, but it just occured to me that you could alias *Basic to *Basic_ADFFS. |
Jon Abbott (1421) 2651 posts |
Yes, as with the CLib Modules, I’ll load a Module with a different name, *commands and/or SWI block.
That’s a good point, I haven’t looked at BASIC VI. It wasn’t in RO3.71 so I’m guessing it was a 32bit addition.
Haven’t thought that far ahead, but aliasing is the obvious method. I’m trying to avoid system wide changes, so possibly Hypervizing OS_CLI and trap *BASIC, which isolates it to code running under the JIT. |
Steve Drain (222) 1620 posts |
BASIC VI has always been a soft-load option until fairly recently. You would need to alias/trap *Basic64, which is the call to invoke it. |