Run a SuperBasic program from Assembler?

Anything QL Software or Programming Related.
User avatar
t0nyt
Gold Card
Posts: 390
Joined: Wed Nov 22, 2023 6:46 pm
Location: UK

Re: Run a SuperBasic program from Assembler?

Post by t0nyt »

Hi Per, the extra byte was an attempt to try and work out why my code was failing (the actual reason being me!) and I forgot to remove it when posting the code. The code I've been using had that removed and still worked.

I don't have (S)GC so SMSQ/E isn't an option for me

Many thanks


User avatar
pjw
QL Wafer Drive
Posts: 1316
Joined: Fri Jul 11, 2014 8:44 am
Location: Norway
Contact:

Re: Run a SuperBasic program from Assembler?

Post by pjw »

Anyone with a PC can have SMSQ/E for free if they want.

If one started out with Qdos nomenclature and at some later date wanted to develop programs for SMSQ/E one would have to relearn the entire nomenclature. Not so the other way round; SMSQ/E nomenclature works perfectly for Qdos too. And the most comprehensive, up to date, debugged documentation is written using the SMSQ/E nomenclature. Therefore it makes sense to learn to use that from the start.

Here is your program re-written with SMSQ/E nomenclature. I have taken the liberty of correcting my previous mistakes and unravelling the loop so it now only contains three instructions (plus whatever goes on in the ioq.pbyt routine) instead of 16++.

Code: Select all

;        Type a command into current keyboard queue

         section code

         filetype 0

         include  dev8_keys_sys
         include  dev8_keys_qdos_sms
         include  dev8_keys_qlv
         include  dev8_mac_proc2

         lea.l   define,a1
         move.w  sb.inipr,a2
         jmp     (a2)
*
define
         proc_stt
         proc_def MENU
         proc_end
         proc_stt
         proc_end
*
MENU     moveq    #sms.info,d0          get sys vars pointer into a0
         trap     #do.smsq
         move.l   sys_ckyq(a0),a2       a2 -> current keyboard queue
         move.w   ioq.pbyt,a4           a4 -> queue byte utility

         lea.l    runcmd,a5             a5 -> text/cmd
         move.w   (a5)+,d4              d4 = length word of text
         bra.s    lend                  - 1 for dbra
*
nextchar move.b   (a5)+,d1              get next character
         jsr      (a4)                  send it to queue
lend     dbra     d4,nextchar

done     moveq    #0,d0                 no errors
         rts                            back to BASIC
*
runcmd   dc.w     rcend-runcmd          set string length
         dc.b    'print "Hello world!"',$0A
rcend
         ds.w     0                     align

         end
The includes can be had by downloading the SMSQ/E sources (which also happens to contain lots of brilliant coding examples!) By convention they are accessed via dev8_


Per
dont be happy. worry
- ?
User avatar
t0nyt
Gold Card
Posts: 390
Joined: Wed Nov 22, 2023 6:46 pm
Location: UK

Re: Run a SuperBasic program from Assembler?

Post by t0nyt »

Sorry Per, but SMSQ/E (like Minerva) isn’t something that’s of interest to me however good they are (I only use TK2 for folders and overwrite y/n otherwise I wouldn’t use that either)

And I’m not really interested in doing things on a PC that I can’t do on my actual QL (as with all my retro systems)

Many thanks


Derek_Stewart
Font of All Knowledge
Posts: 3978
Joined: Mon Dec 20, 2010 11:40 am
Location: Sunny Runcorn, Cheshire, UK

Re: Run a SuperBasic program from Assembler?

Post by Derek_Stewart »

Hi

With regards to QL Assembler reference material, in addition to Norman's excellent Assembly Language Magazine, I use for:

QDOS: QL Technical Guide, Minerva ROM source code. SMSQ/E: SMSQ/E Reference Guide, SMSQ/E source code.

The operating system source code for Minerva and SMSQ/E give very good reference material on how assembly language on the QL should be written.

And it is all free...


Regards,

Derek
User avatar
pjw
QL Wafer Drive
Posts: 1316
Joined: Fri Jul 11, 2014 8:44 am
Location: Norway
Contact:

Re: Run a SuperBasic program from Assembler?

Post by pjw »

Derek_Stewart wrote: Sun Mar 31, 2024 8:57 am <>
The operating system source code for Minerva and SMSQ/E give very good reference material on how assembly language on the QL should be written.
<>
Hi Derek,
I agree. Its very well annotated too. Reads like a novel ;)


Per
dont be happy. worry
- ?
User avatar
t0nyt
Gold Card
Posts: 390
Joined: Wed Nov 22, 2023 6:46 pm
Location: UK

Re: Run a SuperBasic program from Assembler?

Post by t0nyt »

pjw wrote: Sun Mar 31, 2024 3:41 pm
Derek_Stewart wrote: Sun Mar 31, 2024 8:57 am <>
The operating system source code for Minerva and SMSQ/E give very good reference material on how assembly language on the QL should be written.
<>
Hi Derek,
I agree. Its very well annotated too. Reads like a novel ;)
Thank you all for the heads up, I’ll download the code to have a look thru. Hopefully I can pick up some good QL programming practices from them

Many thanks


User avatar
NormanDunbar
Forum Moderator
Posts: 2281
Joined: Tue Dec 14, 2010 9:04 am
Location: Leeds, West Yorkshire, UK
Contact:

Re: Run a SuperBasic program from Assembler?

Post by NormanDunbar »

Hi T0nyt,

you asked about using config as a QL best practice. You don't have to!

My suggestion was simply a feeble attempt at humour. Sorry. However, as relates to your "menu" system, you will always be LRUNning the same S*BASIC program, so no need for a config block.

However, if this was a "commercial" or freely distributable utility, then other people might not have the same file as you; or may not have an assembler to make changes to suit their system. In that case, a config block would be a good idea. It would alow them to adapt the program to be LRUN to suit their own environment without the need to ever reassemble the utility. Maybe, they are using floppies or microdrives, so "win1" isn't any use, but with config, they could change that to their own device names.

As I said, it was a feeble attempt at humour.


Cheers,
Norm.


Why do they put lightning conductors on churches?
Author of Arduino Software Internals
Author of Arduino Interrupts

No longer on Twitter, find me on https://mastodon.scot/@NormanDunbar.
User avatar
t0nyt
Gold Card
Posts: 390
Joined: Wed Nov 22, 2023 6:46 pm
Location: UK

Re: Run a SuperBasic program from Assembler?

Post by t0nyt »

Hi Norm,

I did take it as a light hearted comment

But genuinely interested in what a config might look like in the “ QL world” though

Maybe, for something like this, pass the string to the code as a parameter at initialisation time in the boot file maybe? (If that’s possible)

Many thanks
Tony


User avatar
tofro
Font of All Knowledge
Posts: 2702
Joined: Sun Feb 13, 2011 10:53 pm
Location: SW Germany

Re: Run a SuperBasic program from Assembler?

Post by tofro »

t0nyt wrote: Sun Mar 31, 2024 6:16 pm Hi Norm,

I did take it as a light hearted comment

But genuinely interested in what a config might look like in the “ QL world” though

Maybe, for something like this, pass the string to the code as a parameter at initialisation time in the boot file maybe? (If that’s possible)

Many thanks
Tony
Have a look into this assembly file for an example on how to create a config block (roughly starting at "configBlk"). It uses the Tony Tebby Macro file "config_mac" (same repository). Doing it that way allows you to configure binary files using "menuconfig" or "config", which is the "standard way" of configuring something in the QDOS/SMSQ/E world.


ʎɐqǝ ɯoɹɟ ǝq oʇ ƃuᴉoƃ ʇou sᴉ pɹɐoqʎǝʞ ʇxǝu ʎɯ 'ɹɐǝp ɥO
User avatar
t0nyt
Gold Card
Posts: 390
Joined: Wed Nov 22, 2023 6:46 pm
Location: UK

Re: Run a SuperBasic program from Assembler?

Post by t0nyt »

tofro wrote: Sun Mar 31, 2024 8:19 pm
t0nyt wrote: Sun Mar 31, 2024 6:16 pm Hi Norm,

I did take it as a light hearted comment

But genuinely interested in what a config might look like in the “ QL world” though

Maybe, for something like this, pass the string to the code as a parameter at initialisation time in the boot file maybe? (If that’s possible)

Many thanks
Tony
Have a look into this assembly file for an example on how to create a config block (roughly starting at "configBlk"). It uses the Tony Tebby Macro file "config_mac" (same repository). Doing it that way allows you to configure binary files using "menuconfig" or "config", which is the "standard way" of configuring something in the QDOS/SMSQ/E world.
Many thanks Tofro, will give it a go


Post Reply