Page 1 of 1

Call SuperBASIC from M/C

Posted: Thu Sep 21, 2017 5:27 pm
by tcat
Hi,

I have done some basic assembly coding for the QL, suited for the CALL command from within SBASIC program. Now I may face writing a SBASIC extension, something I have not done before, though there are some nice examples to draw on here in the forum, also QL Technical Guide gives essential info.

I will probably need to make use of COPY command from within the extension. Question is, how I can chain a call to SBASIC, and return back to assembly code?

Many thanks in advance.
Tomas

Re: Call SuperBASIC from M/C

Posted: Thu Sep 21, 2017 7:10 pm
by RWAP
I don't believe that you can under QDOS other than stuffing a string into the SuperBASIC command line (see EDLINE$ from DIY Toolkit).

You could potentially use the multiple BASICs code in SMSQ/e and Mnerva (and even possibly the MultiBASIC code in DIY Toolkit) to generate a new instance of SuperBASIC and execute a command.

However, you are probably best looking at some of the TRAP calls to open a channel to an existing file and then buffer the contents and write it out to a channel opened to the new file (remembering to handle the posittion if the new file already exists).

Re: Call SuperBASIC from M/C

Posted: Thu Sep 21, 2017 7:12 pm
by NormanDunbar
Hi Tomas,

I don't think that what you want to do is possible. Sorry.

However, I'm willing to be corrected!


Cheers,
Norm.

Re: Call SuperBASIC from M/C

Posted: Thu Sep 21, 2017 8:29 pm
by tofro
That could probably work - At least on a QL with TK2, COPY is a machine code extension. Such extension's addresses are collectable from the name table. I would assume the same in SBASIC on SMSQ/E. I am not sure what's the situation with plain QDOS.

You should, in theory, be able to pull that start address from the name table, push two strings and a separator onto a simulated math stack and probably be able to call the BASIC extension.

I am, however, even if it might possibly work [quite some "probably", "possibly" and "in theory"s in my sentences, aren't they?], pretty sure it wouldn't be any simpler than IO.OPEN, IO.FSTRG and IO.SSTRG in a loop and IO.CLOSE, which is actually pretty straightforward... In case the file to copy fits into available memory, you could even use FS.LOAD and FS.SAVE to load and save it in one go.

Tobias

Re: Call SuperBASIC from M/C

Posted: Sat Sep 23, 2017 12:55 am
by janbredenbeek
tofro wrote:That could probably work - At least on a QL with TK2, COPY is a machine code extension. Such extension's addresses are collectable from the name table. I would assume the same in SBASIC on SMSQ/E. I am not sure what's the situation with plain QDOS.

You should, in theory, be able to pull that start address from the name table, push two strings and a separator onto a simulated math stack and probably be able to call the BASIC extension.
Tobias
It's not really the math stack but the parameters at the end of the name table which the original command routine expects. These are pointed to by (A6,A3.L) (first one) to -8(A6,A5.L) (last one). You could fiddle around with extra parameters and adjust A3 and/or A5 before calling the COPY command routine, but it expects at least one parameter to be evaluated as a string (or name). You cannot just put something on the math stack since all S*BASIC command routines have nothing on the stack when they are called. They need to evaluate the parameters first (using CA.GTINT/GTFP/GTSTR/GTLIN).

Jan.

Re: Call SuperBASIC from M/C

Posted: Sat Sep 23, 2017 9:25 am
by tofro
Jan,

You're absolutely right, forgot that. Long time since I tried to write my last Basic extension.

Doesn't make it any easier, though. I'd still go for programming my own COPY...

Tobias