If I remember my Turbo correctly, Def Integer means that those variables will be treated as integers and not floating point. Handy for pre SMS* QLs that can't do integer FOR loops, for example.
Thats what I thought at first, but I couldnt find it in the Turbo manual. I hoped it might have been a way to define long (32 bit) integers viz the code snippet from the relevant program below:
..
100 DEF_INTEGER i,j
110 MANIFEST: n = 200000
120 crossed = ALCHP (n)
140 FOR i = 1 TO n
..
There is a QLib directive of the same name, but only for 16 bit integers, iirc. Compiled with QLib, this program would crash at i = 32k.
My conclusion in the end was that the DEF_INTEGER was a remnant left over from an earlier version of the program, which was originally compiled with QLib, using standard arrays. Later, more precision was wanted, so 15 bit integer indexing and standard arrays had to be abandoned. To compensate for loss of speed due to these changes, a switch was made to Turbo, thus MANIFEST:n = 200000.
Hows that for detective work
Per
DEF_INTEGER is indeed a QLiberator directive telling it to treat variables with floating point names (e.g. 'value') as a 16-bit integer (as though 'value' was really 'value%'). Its purpose was mainly to allow integers to be used where integers are not normally allowed in interpreted SuperBASIC on Sinclair ROMs - in FOR loops and SELect ON structures.
The closest equivalent in Turbo/Turbo Toolkit is the IMPLICIT% command in Turbo Toolkit.
These only work in compiled BASIC programs - they are ignored by interpreted BASIC programs. So some care is needed as the programs may run a little different when compiled. Example: in SuperBASIC something like
IMPLICIT% value
LET value = 3/2
would assign a value of 1.5, whereas compiled it would be 1. In simple examples like this we can write the second line as LET value=3 DIV 2 to ensure programs run as similarly as possible when interpreted and compiled.
Hi,
I have written a superbasic extension program that allows you to rename variables throughout a program as it is loaded and run. It copies itself into Data lines which it then works on. But this ends up making the name table unstable, so I have not used it for some time.
The solution would appear be to use a text editor. If anyone has done this could they please recommend a good program, and where to obtain it?
This is needed as I wish to rewrite the 'Travelling Salesman' program which is at present in shorthand, ready for publication in Quanta.
Steve.
If the same program were to be written in Assembly Language, how much faster would you estimate this to be compared to C code?
Michael
Would "a lot" be an acceptable answer?
Cheers,
Norm.
Suprisingly, this is wrong for most practical cases. The code generation/optimization techniques in C-Compilers like GCC 2.95 (QDOS-GCC) or better are usually equal or even superior to manual human efforts, except for very specific tasks.
When I was still relatively deep into assembler programming, I sometimes compared my own code to optimized C compiler output. And while my own assembler code was shorteror looked more elegant, it almost never was actually faster when measured.
stevepoole wrote:Hi,
I have written a superbasic extension program that allows you to rename variables throughout a program as it is loaded and run. It copies itself into Data lines which it then works on. But this ends up making the name table unstable, so I have not used it for some time.
The solution would appear be to use a text editor. If anyone has done this could they please recommend a good program, and where to obtain it?
This is needed as I wish to rewrite the 'Travelling Salesman' program which is at present in shorthand, ready for publication in Quanta.
Steve.
Yes a text editor is the way to go - use either SPY or Editor 2000 from Dilwyn's site:
stevepoole wrote:Hi,
I have written a superbasic extension program that allows you to rename variables throughout a program as it is loaded and run. It copies itself into Data lines which it then works on. But this ends up making the name table unstable, so I have not used it for some time.
The solution would appear be to use a text editor. If anyone has done this could they please recommend a good program, and where to obtain it?
This is needed as I wish to rewrite the 'Travelling Salesman' program which is at present in shorthand, ready for publication in Quanta.
Steve.
Hi Steve,
You could try using the REPLACE keyword from DIY Toolit - it's in Volume R.
Michael
Hi Embee,
The travelling Salesman Program is currently being rewritten in Assembly language, so we will soon know how much faster it runs than in superbasic. It will subsequently be rewritten in C++, which will also be compared for speed, but will of course only run on PCs. Of course the assembly version will only run on motorola processor hardware, ie various QL-like machines. If anyone would care to write a version for Intel Assembly language, they could contact me via the forum.
Quanta will publish the superbasic program later this year, when the motorola assembly code demonstration will have been fully developed. There remains plenty of scope for further implementations of the program, so anyone interested will be able to get involved.
After a long interruption, I am now reformatting the superbasic from shorthand to readily comprehensible style, which, together with the graphics should make the program's method evident to all, especially Quanta members.
There is a TSP program called 'Concord' which has recently received a lot of interest. But it is restricted to academic circles, whereas the QL 'Shrink_bas' TSP will definitely be available to the QL community.
Happy QLing...
Steve.