Call SuperBASIC from M/C

Anything QL Software or Programming Related.
tcat
Gold Card
Posts: 399
Joined: Fri Jan 18, 2013 5:27 pm
Location: Prague, Czech Republic

Call SuperBASIC from M/C

Postby tcat » Thu Sep 21, 2017 5:27 pm

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


RWAP
RWAP Master
Posts: 2229
Joined: Sun Nov 28, 2010 4:51 pm
Location: Stone, United Kingdom
Contact:

Re: Call SuperBASIC from M/C

Postby RWAP » Thu Sep 21, 2017 7:10 pm

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


User avatar
NormanDunbar
Gold Card
Posts: 279
Joined: Tue Dec 14, 2010 9:04 am
Location: Leeds, West Yorkshire, UK
Contact:

Re: Call SuperBASIC from M/C

Postby NormanDunbar » Thu Sep 21, 2017 7:12 pm

Hi Tomas,

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

However, I'm willing to be corrected!


Cheers,
Norm.


Why do they put lightning conductors on churches?
How come Tarzan never grew a beard?
User avatar
tofro
QL Wafer Drive
Posts: 1121
Joined: Sun Feb 13, 2011 10:53 pm
Location: SW Germany

Re: Call SuperBASIC from M/C

Postby tofro » Thu Sep 21, 2017 8:29 pm

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


User avatar
janbredenbeek
Trump Card
Posts: 159
Joined: Wed Jan 21, 2015 4:54 pm
Location: Hilversum, The Netherlands

Re: Call SuperBASIC from M/C

Postby janbredenbeek » Sat Sep 23, 2017 12:55 am

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.


User avatar
tofro
QL Wafer Drive
Posts: 1121
Joined: Sun Feb 13, 2011 10:53 pm
Location: SW Germany

Re: Call SuperBASIC from M/C

Postby tofro » Sat Sep 23, 2017 9:25 am

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



Return to “Software & Programming”

Who is online

Users browsing this forum: No registered users and 4 guests