Page 1 of 1

QLiberator v3.44

Posted: Mon Sep 20, 2021 7:42 pm
by EmmBee
Here is the latest QLiberator.

This is a much tidied-up version, with
ON..GOTO's converted to SELect On's
Multiple line IFs converted into single line IF's
All to aid readability - and thus, understandability.
Per Witte's latest version of QLIB_run, V3.42 is now included.
Enjoy!
Qlib_344.zip
(95.33 KiB) Downloaded 131 times

Re: QLiberator v3.44

Posted: Mon Sep 20, 2021 8:29 pm
by RalfR
Thanks, Michael.

Would like to hear from the boys, if that match their source. ;)

Re: QLiberator v3.44

Posted: Mon Sep 20, 2021 8:58 pm
by dilwyn
Thank you, EmmBee.

Re: QLiberator v3.44

Posted: Wed Sep 22, 2021 9:58 pm
by RalfR
Puh, I have spent a few hours to read the actual QLib source. Not quit really easy to understand, my respects to EmmBee. I have seen, that you use FPOS and GET from TK2 but that is not mentioned in the update text. What was formerly used?

It would be good to know, what the different extension keywords mean and what they do (I just know the PE keywords). That would make the source better understandable.

Re: QLiberator v3.44

Posted: Thu Sep 23, 2021 9:24 pm
by EmmBee
RalfR wrote:Puh, I have spent a few hours to read the actual QLib source. Not quit really easy to understand, my respects to EmmBee. I have seen, that you use FPOS and GET from TK2 but that is not mentioned in the update text. What was formerly used?
The program uses POS for FPOS, and NEXT_TOKEN for reading from the work file. This has 6 parameters … NEXT_TOKEN sym1%, sym2%, sym3, sym4$, End_of_Stmt%, End_of_Line% Their usage is detailed from line 21140 onwards.
RalfR wrote: It would be good to know, what the different extension keywords mean and what they do (I just know the PE keywords). That would make the source better understandable.
Agreed. I’m wondering whether Per Witte can be of help, here.

Here is one keyword that I do know the meaning of: NEXTLINE. The meaning is: EOF(#wrk). This appears at line number 1100. It has to be so because this is what is always checked for before input is taken. NEXTLINE is written in C style manner, returning with a zero exit status if all is well, indicating that another line can be read from the file. If something goes wrong, such as EOF(#wrk) then it returns with an error code. This is the direct opposite of what SBASIC does, which returns zero for failure and non-zero for success. This difference also adds to the difficulty in reading the code.

Having read through the code, and having gained some more understanding, here are two suggestions for renaming two procedures at the end of the each_line loop

start_of_line …………….rename to … initialise_trace
remainder_of_line ….. rename to … process_line

start_of_line is defined at line 4220 which restarts the numbering of the statements from 1. The machine code procedure, “ GENop 4” does this.

Remainder_of_line is defined at line 2980 and processes every statement on the line.

Re: QLiberator v3.44

Posted: Mon Sep 27, 2021 7:41 pm
by pjw
Yesterday I did a little more work on one of Qlib's system toolkits,
Qlib1_bin. Not much, but thats three hours Ill never get back..

So, I dissembled it and made some half-hearted attempt to document
parameter usage (see QLib1_BIN.txt). Assembling the dissembly with
Qmac produces an identical binary to the original.

I didnt try very hard to figure out what the various commands do but
I and others can fill in what we know or discover and add to the
documentation over time.

The dissembly can be optimised slightly (Qlib1_list), but it also
contains some commands that dont appear to be used in Qlib itself, so
they could be removed. Some commands replicate commands found in TK2.
To my mind these too could be removed (or at least one could try and
see what happens), and commands with different names that do the same
as commands in TK2 could be removed also, and the commands renamed in
the Qlib_bas code. That would imply that the Qlib compiler would only
run on Qdos/Minerva with TK2 or on SMSQ/E. The object code produced by
it would not be affected.

When youve stopped screaming, consider: The retro brigade already have
their Qlib compiler. Its called Q_Liberator V3.36. It works and will
continue working in the retro environment for eternity or until just
before the North Pole comes to a boil.

Those who wish to progress should be interested in a leaner, meaner
Qlib V4x. My suggested modifications would only be a first step to
knocking Qlib into shape. Re-working the code helps to understand it
better for each iteration, and once it is understood it can be
improved as, indeed, we already see happening (heres looking at you,
EmmBee).

Just my penny's worth.
qlib1_344.zip
(4.93 KiB) Downloaded 69 times

Re: QLiberator v3.44

Posted: Tue Sep 28, 2021 10:48 am
by Derek_Stewart
Hi Per,

Really excellent work.

I must admit to not using most or all the command in QLIB_BIN, but the command commands should be documented correctly.

I would not worry about compatibility, if something does not work on older QDOS system, then it is not loaded, unlike other OS systems, where they have to patch the system to bodge the operation of out of date software.

Personally, I would not use anything other SMSQ/E or Minerva, mainly due to the use of multi tasking basic, once used it is a total miss.

Re: QLiberator v3.44

Posted: Tue Sep 28, 2021 12:41 pm
by mk79
Before you sink anymore time into this, these are my diassemblies of the QLib_obj utilities that I did two years ago.

Re: QLiberator v3.44

Posted: Tue Sep 28, 2021 4:20 pm
by pjw
Derek_Stewart wrote:Hi Per,

Really excellent work.
No, really sloppy - compared to mk79's, at least..
Derek_Stewart wrote:I must admit to not using most or all the
command in QLIB_BIN, but the command commands should be documented
correctly.
These are not Qlib user toolkits. They are part of the compiler itself.
Most commands are pretty specialised and dont have much use outside
of Qlib itself. But yes, for the sake of understanding how Qlib works,
we need to document them.
Derek_Stewart wrote:I would not worry about compatibility, if
something does not work on older QDOS system, then it is not loaded,
unlike other OS systems, where they have to patch the system to bodge
the operation of out of date software.

Personally, I would not use anything other SMSQ/E or Minerva, mainly
due to the use of multi tasking basic, once used it is a total
miss.
I basically agree with you, but its not up to me; its
a "community effort".

I dont believe in backward compatibility at all costs, but nor do I
believe in riding roughshod over it. Its a balancing act.
mk79 wrote:Before you sink anymore time into this, these are my
diassemblies of the QLib_obj utilities that I did two years
ago.
My time wasnt wasted if it poked you into sharing your efforts ;)
Very nice and useful analysis! Any more?

I "fixed" one of them up to make it Qmac compatible (movea.l
(sb.gtlin).w,a2 ! Wassat?! bsr.w ? Which assembler were you using?

I also removed some redundant commands and their code (BINPUT, BWRITE,
SINPUT, SWRITE, READSETUP). (It turns out ALCHP and RECHP are too
different from the TK2 versions to be removed without fiddling the
BASIC source as well.)

The two assembler source files you posted are now named Qlib1_asm and
Qlib2_asm to fit in with the current nomenclature. Theyre included
with the attachment, below.

I also added a few lines of code to the BASIC to save me (or anyone)
from having to load all those toolkits into memory before compiling
the compiler, not least of all because Qlib1_bin smashes ALCHP/RECHP:

Code: Select all

126 REMark                           Version 3.44a
127 :
128 EXT_PROC "CURDIS", "CURSEN", "Dnr", "FCOPY", "GENB", "GENfloat"
129 EXT_PROC "GENint", "GENL", "GENntd", "GENop", "GENsfloat", "GENstring"
130 EXT_PROC "GENtext", "GENW", "INITgen", "input_edit$", "LINT", "LSET_POS", "LWRITE"
131 EXT_PROC "NEXT_TOKEN", "PACK_N", "Q_ERR_LIST", "Q_ERR_OFF", "Q_ERR_ON", "READ_name"
132 EXT_PROC "RECHP", "RNAME", "SETPOS", "SETUP", "SMEM", "TSORT"
133 EXT_PROC "UNPACK_N", "WINPUT", "WM_Outln", "WM_Rptr", "WM_Sptr", "WM_wrsp"
134 EXT_PROC "WNAME", "WWRITE"
135 :
136 EXT_FN "_BPCOL", "_BUFFER", "_CUCOL", "_DICOL", "_HEAP", "_HELPF"
137 EXT_FN "_NRCHAN", "_SICOL", "_STACK", "_TICOL", "ALCHP", "b1"
138 EXT_FN "FINDNEXT", "FINDSYMBOL", "FREE", "Fwind", "GENSYMBOL"
139 EXT_FN "LPOS", "NEXTLINE", "ODD", "POS", "Q_ERR", "RA6"
140 EXT_FN "RMODE", "RP_ADDR", "SCRXLIM", "SCRYLIM", "SHORTF", "Tqueue"
141 EXT_FN "UNdef"
142 :
143 main
144 STOP
145 :
This is included in the attachment as Header_bas and could be dropped
right into the BASIC source file.

I used Qlib 3.44 to compile the resulting file (without loading any toolkits!),
using the new Qlib1_bin and Qlib2_bin. I used the resulting object code to
compile itself again (and again). While this is not proof that it is bug free,
it is a pretty good stress test. I wont muddy the waters by including the
result here. Interested parties have all they need to try it out for
themselves. I leave it to EmmBee to publish the "official versions".
Qlib344a.zip
(9.77 KiB) Downloaded 56 times

Re: QLiberator v3.44

Posted: Tue Sep 28, 2021 9:07 pm
by mk79
pjw wrote:My time wasnt wasted if it poked you into sharing your efforts ;)
Very nice and useful analysis! Any more?
Yeah, almost all of it, I really spent far too much time on this thing...
I "fixed" one of them up to make it Qmac compatible (movea.l (sb.gtlin).w,a2 ! Wassat?! bsr.w ? Which assembler were you using?
No assembler, but my disassembler is IDA Pro, which at some 500€ per year is fortunately paid for by my employer... I even created some Python extensions for it that can decode SuperBasic function tables and stuff, it really is quite powerful.

IDA Pro produces the official syntax as described in the Motorola manual (e.g. in the address mode tables it is specified as "(xxx).W", therefore "(sb.gtlin).w"). I have created a post-process in Perl that normally fixes this and more stuff, but for some reason qutil2 was not processed by the latest script (I just took what's there and that is dated 2019 while gen_util2 is 2020).

Cheers, Marcel