Structured SuperBASIC

Anything QL Software or Programming Related.
User avatar
NormanDunbar
Forum Moderator
Posts: 2456
Joined: Tue Dec 14, 2010 9:04 am
Location: Buckie, Scotland
Contact:

Re: Structured SuperBASIC

Post by NormanDunbar »

Morning all,

Pause is a bugger, I have removed it from the code. Thanks for the reminders of the problems.

I also have the cause of the "overflow" problem when dealing with GOTO/GOSUB/RESTORE on Minerva. Minerva stores numbers in as few bytes as possible in the program file. QDOS/SMSQ store the line numbers for those commands as floats, Minerva uses integers. However, I'm rather at a loss as to the exact format of the integers!

On SMSQ I have this code:

Code: Select all

10 GOTO 20
It dumps out as

Code: Select all

0010 8D00 000A 810A 810B F805 50000000 840A
On Minerva it is this:

Code: Select all

000C 8D00 000A 810A 810B 8914 840A
In case you are wondering the various words are:

Anyway, the float under QDOS/SMSQ is representing the value 20. But how the hell do I extract 20 from $8914 I wonder?

$8914 is:

35,092 (unsigned), OR
-30,444 (signed), OR
1000 1001 0001 0100 (Binary!)

Which is fine, the lower 8 bits are indeed 20 in binary, but what are the upper 8 bits denoting?

It appears that there is a poke that we can do on Minerva to get the code to turn off integer tokenisation:

Code: Select all

POKE \\212,128
And it works! If that pokse is executed before loading or typing a SuperBASIC program, the Basic2ssb_obj utility will work on Minerva.

HOORAY!

Cheers,
Norm.





Line length,
Line number coming,
Actual line number as a word,
Code for GO,
Code for TO,
Actual Line number for 20
End of line word.


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
tofro
Font of All Knowledge
Posts: 3057
Joined: Sun Feb 13, 2011 10:53 pm
Location: SW Germany

Re: Structured SuperBASIC

Post by tofro »

NormanDunbar wrote: Sat Apr 26, 2025 12:12 pm ...
On Minerva it is this:

Code: Select all

000C 8D00 000A 810A 810B 8914 840A
In case you are wondering the various words are:

Anyway, the float under QDOS/SMSQ is representing the value 20. But how the hell do I extract 20 from $8914 I wonder?

$8914 is:

35,092 (unsigned), OR
-30,444 (signed), OR
1000 1001 0001 0100 (Binary!)

Which is fine, the lower 8 bits are indeed 20 in binary, but what are the upper 8 bits denoting?
Congrats you got it to work. To answer your questions above:
Minerva stores integers tokenized to save space and performance (in QDOS, storing a line number as a float and handling it as a word doesn't really make an awful lot of sense and leads to a large amount of basically unnecessary format conversions....) and distinguingishes between short (byte (!!)) and long (word(!!)) types. $89 is the token marker for "short" integers (1 byte with signed value follows), $8a marks "long" words (signed word), 2 bytes to follow. I guess a line number >255 is initiated with $8a.

This whole shebang has the other interesting side effect that on Minerva, RENUM is not able to renumber line references <127 in GOTO, GOSUB and RESTORE (which is documented like that in the Minerva manual as "This should rarely be a hardship" ;) )
Last edited by tofro on Sat Apr 26, 2025 12:48 pm, edited 1 time in total.


ʎɐqǝ ɯoɹɟ ǝq oʇ ƃuᴉoƃ ʇou sᴉ pɹɐoqʎǝʞ ʇxǝu ʎɯ 'ɹɐǝp ɥO
User avatar
NormanDunbar
Forum Moderator
Posts: 2456
Joined: Tue Dec 14, 2010 9:04 am
Location: Buckie, Scotland
Contact:

Re: Structured SuperBASIC

Post by NormanDunbar »

Hi ToFro,

that was very helpful indeed. I can adjust the code to look for those (new) tokens when I expect a float at present, and to process accordingly.

Much appreciated, thanks.


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
tofro
Font of All Knowledge
Posts: 3057
Joined: Sun Feb 13, 2011 10:53 pm
Location: SW Germany

Re: Structured SuperBASIC

Post by tofro »

NormanDunbar wrote: Sat Apr 26, 2025 12:47 pm That was very helpful indeed. I can adjust the code to look for those (new) tokens when I expect a float at present, and to process accordingly.
If you have a look at the token table, you'll find that $89 and $8a have always been defined and reserved for integers, but never been used in original SuperBasic. So, "new" is relative, as always....


ʎɐqǝ ɯoɹɟ ǝq oʇ ƃuᴉoƃ ʇou sᴉ pɹɐoqʎǝʞ ʇxǝu ʎɯ 'ɹɐǝp ɥO
Derek_Stewart
Font of All Knowledge
Posts: 4652
Joined: Mon Dec 20, 2010 11:40 am
Location: Sunny Runcorn, Cheshire, UK

Re: Structured SuperBASIC

Post by Derek_Stewart »

Hi,

According to the Online Superbasic Manual


https://superbasic-manual.readthedocs.i ... pause.html

The command PAUSE halts execution of a program temporarily for the specified timeout number of frames (there are 50 frames per second in the UK and Europe, 60 frames per second in the US). If no timeout or a negative timeout is specified, the command will wait indefinitely. If a timeout of zero is specified, no actual PAUSE will take place. Execution will continue at the end of the timeout, or if a key is pressed. The key is read from channel #0 and therefore the command will report the error ‘channel not open’ if #0 is not open.


Regards,

Derek
Post Reply