Page 3 of 3

Re: Structured SuperBASIC

Posted: Sat Apr 26, 2025 12:12 pm
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.

Re: Structured SuperBASIC

Posted: Sat Apr 26, 2025 12:40 pm
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" ;) )

Re: Structured SuperBASIC

Posted: Sat Apr 26, 2025 12:47 pm
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.

Re: Structured SuperBASIC

Posted: Sat Apr 26, 2025 12:58 pm
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....

Re: Structured SuperBASIC

Posted: Sun Apr 27, 2025 6:57 am
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.