FAQ  •  Register  •  Login

Using ZX Basic to create ESXDOS dot commands

<<

Uto

Posts: 10

Joined: Sat Jul 16, 2016 12:02 pm

Post Sat Jul 16, 2016 12:18 pm

Using ZX Basic to create ESXDOS dot commands

Hello all,

I'm new to ZXBasic, but despite of that I've managed to properly build and application using it (https://github.com/Utodev/ZXCU). 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?
<<

Uto

Posts: 10

Joined: Sat Jul 16, 2016 12:02 pm

Post Sun Oct 09, 2016 11:24 am

Re: Using ZX Basic to create ESXDOS dot commands

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>
<<

emook

Posts: 27

Joined: Tue Dec 06, 2016 1:23 am

Post Sun Mar 12, 2017 5:04 pm

Re: Using ZX Basic to create ESXDOS dot commands

Have you got an example of the ESXDOS assembler part?
<<

britlion

Posts: 766

Joined: Mon Apr 27, 2009 7:26 pm

Location: Slough, Berkshire, UK

Post Wed Mar 15, 2017 3:58 pm

Re: Using ZX Basic to create ESXDOS dot commands

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....
<<

Uto

Posts: 10

Joined: Sat Jul 16, 2016 12:02 pm

Post Fri Mar 17, 2017 9:10 am

Re: Using ZX Basic to create ESXDOS dot commands

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.
<<

Uto

Posts: 10

Joined: Sat Jul 16, 2016 12:02 pm

Post Fri Mar 17, 2017 9:11 am

Re: Using ZX Basic to create ESXDOS dot commands

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.

Return to Help & Support

Who is online

Users browsing this forum: Yahoo [Bot] and 3 guests

cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by Vjacheslav Trushkin for Free Forums/DivisionCore.

phpBB SEO