Run a SuperBasic program from Assembler?
Run a SuperBasic program from Assembler?
I'm trying to find a way to run a SuperBasic program from within assembler code
The only 2 things I can think of, but I don't know how to do either, is to be able to do an equivalent to LRUN from within the assembler or send keystrokes to the console
I'm pretty sure both of these should be possible (especially the latter as it's like the F-Key utility)
Could anyone point me in the direction of some sample assembler code at all please?
Many thanks
The only 2 things I can think of, but I don't know how to do either, is to be able to do an equivalent to LRUN from within the assembler or send keystrokes to the console
I'm pretty sure both of these should be possible (especially the latter as it's like the F-Key utility)
Could anyone point me in the direction of some sample assembler code at all please?
Many thanks
- janbredenbeek
- Super Gold Card
- Posts: 637
- Joined: Wed Jan 21, 2015 4:54 pm
- Location: Hilversum, The Netherlands
- Contact:
Re: Run a SuperBasic program from Assembler?
It's different depending on which system you're running.
QDOS: No easy way, you could try stuffing an LRUN command into channel 0's keyboard queue (this of course only works when SB is idle since it cannot multitask).
Minerva: Start an instance of MultiBASIC. The details are in the Minerva manual.
SMSQ/E: Start an instance of the SBASIC Thing, like the EXEP 'SBASIC' command. I haven't yet figured out how to do this from a job running machine code.
QDOS: No easy way, you could try stuffing an LRUN command into channel 0's keyboard queue (this of course only works when SB is idle since it cannot multitask).
Minerva: Start an instance of MultiBASIC. The details are in the Minerva manual.
SMSQ/E: Start an instance of the SBASIC Thing, like the EXEP 'SBASIC' command. I haven't yet figured out how to do this from a job running machine code.
Re: Run a SuperBasic program from Assembler?
Thanks. It's for QDOS and would only need to work when idle.janbredenbeek wrote: ↑Fri Mar 29, 2024 12:48 am It's different depending on which system you're running.
QDOS: No easy way, you could try stuffing an LRUN command into channel 0's keyboard queue (this of course only works when SB is idle since it cannot multitask).
Minerva: Start an instance of MultiBASIC. The details are in the Minerva manual.
SMSQ/E: Start an instance of the SBASIC Thing, like the EXEP 'SBASIC' command. I haven't yet figured out how to do this from a job running machine code.
So stuffing channel 0's keyboard buffer would do, will see if I can find some sample "stuffing" code
Many thanks
Re: Run a SuperBasic program from Assembler?
Just found IO.QIN and tk3 qin sourcet0nyt wrote: ↑Fri Mar 29, 2024 7:20 amThanks. It's for QDOS and would only need to work when idle.janbredenbeek wrote: ↑Fri Mar 29, 2024 12:48 am It's different depending on which system you're running.
QDOS: No easy way, you could try stuffing an LRUN command into channel 0's keyboard queue (this of course only works when SB is idle since it cannot multitask).
Minerva: Start an instance of MultiBASIC. The details are in the Minerva manual.
SMSQ/E: Start an instance of the SBASIC Thing, like the EXEP 'SBASIC' command. I haven't yet figured out how to do this from a job running machine code.
So stuffing channel 0's keyboard buffer would do, will see if I can find some sample "stuffing" code
Many thanks
Re: Run a SuperBasic program from Assembler?
Programmatically injecting an LRUN into the interpreter from an external program is basically impossible - SBASIC doesn't have an external interface that would allow you to execute BASIC keywords. SBASIC to your assembly program is an independantly running external job that doesn't have any accessible API.t0nyt wrote: ↑Thu Mar 28, 2024 8:29 pm I'm trying to find a way to run a SuperBasic program from within assembler code
The only 2 things I can think of, but I don't know how to do either, is to be able to do an equivalent to LRUN from within the assembler or send keystrokes to the console
I'm pretty sure both of these should be possible (especially the latter as it's like the F-Key utility)
Could anyone point me in the direction of some sample assembler code at all please?
Many thanks
Using the keyboard queue to inject text commands into the interpreter is a bit tricky. You need to find the #0 BASIC channel (that would mean running through the BASIC channel table, then find #0, then connect the keyboard queue to #0, then push bytes into the keyboard queue (which can be found by the system variable SV_KEYQ and would invole messing with that queue from the outside). This needs to have the interpreter at idle, otherwise it won't succeed.
The most simple method I can imagine to connect SBASIC and assembly is indeed having a BASIC program running before you start the assembly program, listening on a pipe for messages from there and run BASIC subroutines based on these commands. An assembly program would then get the pipe channel on the command line and simply write commands to that pipe. I would follow this part, because it creates the least mess in the system.
Obviously, the very best is use SMSQ/E and the SBASIC thing. But that wouldn't be possible on bare QDOS.
ʎɐqǝ ɯoɹɟ ǝq oʇ ƃuᴉoƃ ʇou sᴉ pɹɐoqʎǝʞ ʇxǝu ʎɯ 'ɹɐǝp ɥO
Re: Run a SuperBasic program from Assembler?
Thanks Tofro
Basically I have a menu (in assembler) and as that can’t do LRUN I wrap it in a basic routine that deletes a temporary file, runs the menu, and then runs the temporary file created by the assembly
That all works good and is launched at the end of my boot file
But to relaunch I have to type “lrun win1_menu_bat” (or whatever) but I want to just be able to type “menu” which is where the resident assembly procedure idea comes in
Not having much luck so far though
Basically I have a menu (in assembler) and as that can’t do LRUN I wrap it in a basic routine that deletes a temporary file, runs the menu, and then runs the temporary file created by the assembly
That all works good and is launched at the end of my boot file
But to relaunch I have to type “lrun win1_menu_bat” (or whatever) but I want to just be able to type “menu” which is where the resident assembly procedure idea comes in
Not having much luck so far though
Re: Run a SuperBasic program from Assembler?
Turbo Tookit's TYPE_IN, COMMAND_LINE, END_CMD do just that. You could try disassembling them to see how its done. Job#0's channel #0 always has the channel ID $00000000 (unless someone's really messed around!) so no need hunting through S*BASIC's channels tables etc.
The main difficulty may be to ensure job#0 is listening out for commands. If a BASIC program is running it wont hear you, and in some scenarios the job will be buried and therefore be unresponsive. In some scenarios this implies your command will go astray and end up in some other job's queue with unknown consequences.
Been there; done that, albeit a long time ago..
The main difficulty may be to ensure job#0 is listening out for commands. If a BASIC program is running it wont hear you, and in some scenarios the job will be buried and therefore be unresponsive. In some scenarios this implies your command will go astray and end up in some other job's queue with unknown consequences.
Been there; done that, albeit a long time ago..
Per
dont be happy. worry
- ?
dont be happy. worry
- ?
Re: Run a SuperBasic program from Assembler?
I was wondering if anyone could spot why, when I assemble & exec this code, it returns to qdos for a very short while and then q-emulator reports an exception please? I mean it's not as if it's doing anything other than returning
I can't get my head around this
Many thanks
I can't get my head around this
Code: Select all
TITLE Show Menu
; INCLUDE 'win2_dev_quanta_QDOS1_IN'
; INCLUDE 'win2_dev_quanta_MACRO_LIB'
BP_INIT equ $110
IO_QIN equ $E0
SECTION CODE
start lea define,a1
move.w BP_INIT,a2
jsr (a2) ; have also tried jmp as per first part of Normans example
rts
define dc.w 1
dc.w siri-*
dc.b 4,'SIRI'
dc.w 0
dc.w 0
dc.w 0
SIRI moveq #0,d0
rts
END
Re: Run a SuperBasic program from Assembler?
Simple answer: You can't just return from an executing job - The system doesn't know where to return to. (Or did you "CALL" that code from BASIC?)
The proper way to end a job is to call MT.FRJB with -1 as job id (Which basically tells QDOS "kill me"). Although that code doesn't look at all like an executable job.
The proper way to end a job is to call MT.FRJB with -1 as job id (Which basically tells QDOS "kill me"). Although that code doesn't look at all like an executable job.
ʎɐqǝ ɯoɹɟ ǝq oʇ ƃuᴉoƃ ʇou sᴉ pɹɐoqʎǝʞ ʇxǝu ʎɯ 'ɹɐǝp ɥO
Re: Run a SuperBasic program from Assembler?
Hi Tofrotofro wrote: ↑Fri Mar 29, 2024 3:20 pm Simple answer: You can't just return from an executing job - The system doesn't know where to return to. (Or did you "CALL" that code from BASIC?)
The proper way to end a job is to call MT.FRJB with -1 as job id (Which basically tells QDOS "kill me"). Although that code doesn't look at all like an executable job.
It’s example code from Norman’s book to extend basic, but I’ve taken out all the stuff that does anything (maybe I’ve taken out too much)
But I think you’ve just solved the problem I had with a test program I gave up on!
Many thanks