zx_goto in newlib...

ZX80, ZX 81, ZX Spectrum, TS2068 and other clones
Post Reply
Xalior
New member
Posts: 6
Joined: Tue Mar 06, 2018 10:38 am

zx_goto in newlib...

Post by Xalior »

Is this "working as expected"? I can't find any references to it obviously in the new codebase on github, only old references out spectrum.h, etc.

Am I coding faster than newlib is progressing, again? ;-)

-Dx
alvin
Well known member
Posts: 1872
Joined: Mon Jul 16, 2007 7:39 pm

Post by alvin »

Yes there is no basic interface code in the newlib.

A zx_goto sounds like your program is ending so an idea might be to use c's return value as a line number. If the program is compiled to be compatible with basic (this is the default where the crt will save iy.hl' and basic's stack location for return) then the return value is placed in BC for basic.

You could call the program with:

GOTO USR 32768

and the return value would be the line number used.

Or if you want to interpret the return value:

LET a=usr 32768
...


NextOS has an api to interact with basic but if this is to also work on regular zx spectrum or esxdos then that api can't be used.
Xalior
New member
Posts: 6
Joined: Tue Mar 06, 2018 10:38 am

Post by Xalior »

That enabled me just enough of a back-channel to be able to write a simple bridge to ESXDOS via .dotcommands, thanks! Still getting some crashes depending upon what BASIC commands I run at this point, but it's a lot further than I was 24hrs ago, so THANK YOU!

Not a nag, but more of an expectation and ability management thing for myself -- but are there plans to reintroduce these into the newlib? And, if so, are those on more the "infinite timescale" kind of thing? :D

I'm just trying to judge if I am going to have to bite the bullet and actually wrap my head around how to implement the advice you gave me on that previously as a "native function" available to the rest of my C...

So far I've managed to avoid writing any actual "raw assembler" on this project and that would be the first, so far it's going to be easy for me to document and support and explain to others for future contributions and extensions while it's all in C and BASIC ;)

-Dx
alvin
Well known member
Posts: 1872
Joined: Mon Jul 16, 2007 7:39 pm

Post by alvin »

Xalior wrote:That enabled me just enough of a back-channel to be able to write a simple bridge to ESXDOS via .dotcommands, thanks! Still getting some crashes depending upon what BASIC commands I run at this point, but it's a lot further than I was 24hrs ago, so THANK YOU!
Nice. I wouldn't expect crashes to happen as long as the CLEAR address is low enough so that basic moves out of the way before the program starts. Maybe on exit from the program you need to restore RAMTOP with another CLEAR before loading the next program.
Not a nag, but more of an expectation and ability management thing for myself -- but are there plans to reintroduce these into the newlib? And, if so, are those on more the "infinite timescale" kind of thing? :D
Honestly they are pretty far down the list atm. Since NextOS has a ready api that will always work, that part will come when the nextos functions are integrated.
Which functions are you missing specifically? It might be possible to just copy them out of the classic lib with few changes.
Post Reply