Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Using ZX Basic to create ESXDOS dot commands
#1
Hello all,

I'm new to ZXBasic, but despite of that I've managed to properly build and application using it (<!-- m --><a class="postlink" href="https://github.com/Utodev/ZXCU">https://github.com/Utodev/ZXCU</a><!-- m -->). I've found ZXBasic and its extension a great help to build that application, so first of all, thank you for building this tool.

The application is a menu driven setup application for Zx-Uno spectrum clone, built for latest core avaliable so far. While providing this application as .tap file may be OK, I wanted to try to compile it so it is a ESXDOS dot command, that may be invoked just by .zxuc.

I have built small ESXDOS dot commands before (just proofs of concept), made in assembler, and all that I know, considering they are undocummented, is:

- They are raw machine code binary files, that is, if first instruction is RET the dot command does nothing but returning to prompt. There is no header.
- They start at 0x4000 (ORG 8192)
- They apparently have 8K maximum size (largest one included with ESXDOS, .snaload, takes almost thos 8K)

I have compiled my code using -S 8192 option, but when y run .zxuc ZXUno freezes. I have also tried to compile a very simple code, and do the same, and in that case it doesn't freeze, but it does nothing.

Code:
PRINT "Hello World"

Compiling that code into a .hello command just returns with OK, without printing "Hello World"

I have decompiled what ZXBasic compiles and first instructions are what is expected, but it's way too complicated to debug furthermore.

I have also tried to reduce heap size with -H parameter, but nothing changes.

Any idea what may be wrong?
Reply
#2
After some investigation, I wil reply myself here for others that may read this later:

It's not easy to build an ESXDOS command using ZX Basic, cause of two reasons:

1) Max length for an ESXDOS command is about 8K. Unless you have a very simple program, it's easy that once the compiler libraries are added you don't have too much room for your own code.
2) When an ESXDOS command is executing, the ESXDOS ROM is active, not the Spectrum ROM. Thus, most calls from Boriel basic to ROM would lead to some kind of issue (freezing, reseting, etc.), including RST calls.

There is a way to call to ROM from ESXDOS commands, that forces standard ROM mapping on call and again ESXDOS mapping on return, but of course no ZX Basic call is doing that, and I guess changing it it's quite complicated.

I've found a walkaround though, not the bes solution but it works:

1) Compile ZX-Basic program to BIN (raw) code, with ORG somewhere in the RAM
2) Make your ESXDOS command be an assembler prorgama (not ZX Basic, pure assembler) that loads the bin file into upper RAM, and then calls the code using the EXDOS ROM unmap funcion:

Code:
RST $18
DW <ORG address>
Reply
#3
Have you got an example of the ESXDOS assembler part?
Reply
#4
I suspect the issue is that you're writing these to fit into 8K of RAM starting at address 8192. There's nothing wrong with that, per-se, but when these are running, the ZX Spectrum ROM is not available - it normally lives in that 0-16383 address space. ZX Basic often uses bits of the Spectrum ROM, and if you use any code that hops into the ROM when the ROM isn't actually there, you're going to get into trouble quite quickly....
Reply
#5
britlion Wrote:I suspect the issue is that you're writing these to fit into 8K of RAM starting at address 8192. There's nothing wrong with that, per-se, but when these are running, the ZX Spectrum ROM is not available - it normally lives in that 0-16383 address space. ZX Basic often uses bits of the Spectrum ROM, and if you use any code that hops into the ROM when the ROM isn't actually there, you're going to get into trouble quite quickly....

Yes, you are right, after some testing I came to the same conclusion.
Reply
#6
emook Wrote:Have you got an example of the ESXDOS assembler part?

You just have to dissasemble any of the dot commands, they are raw code that is loaded at 8192.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)