SBASIC & C++
Re: SBASIC & C++
> I would rather say that QPC is indeed fully optimised for all the software that has been written
> for the QL so far.
There is a fair bit of software written in the early days of the QL that will not run on QPC or other emulators. Heck, some won't run on anything but a QL with 128K ram. Add a Gold Card and the software will fail. This software was written assuming that the screen will be at a certain location, or that memory will not change, etc. That was all the point I was making.
> for the QL so far.
There is a fair bit of software written in the early days of the QL that will not run on QPC or other emulators. Heck, some won't run on anything but a QL with 128K ram. Add a Gold Card and the software will fail. This software was written assuming that the screen will be at a certain location, or that memory will not change, etc. That was all the point I was making.
Re: SBASIC & C++
Just a short one in case anyone is still interested in speed comparisons:
An (optimized) "Sieve of Erastothenes" program that calculates primes up to 200000 runs in
pure S*Basic on QPC2: 15s
Turbo compiled: 6s
translated to C and C68-compiled: 2s
And just for comparison Q-Liberated: 13s
The tests were run on my pretty fast MacBook. It would be interesting to know how long it takes on original SuperBASIC - I would guess well over several minutes. I simply don't have a working QL handy just now.
Quite a bit of the time spent is lost in screen output (so I guess C would even be faster....), and overall the test is not very fair for various reasons, but you can see the difference.
Sources attached - They should also give a bit of an idea how the same program (I tried to keep them as close as possible) looks in Basic and C.
Tobias
An (optimized) "Sieve of Erastothenes" program that calculates primes up to 200000 runs in
pure S*Basic on QPC2: 15s
Turbo compiled: 6s
translated to C and C68-compiled: 2s
And just for comparison Q-Liberated: 13s
The tests were run on my pretty fast MacBook. It would be interesting to know how long it takes on original SuperBASIC - I would guess well over several minutes. I simply don't have a working QL handy just now.
Quite a bit of the time spent is lost in screen output (so I guess C would even be faster....), and overall the test is not very fair for various reasons, but you can see the difference.
Sources attached - They should also give a bit of an idea how the same program (I tried to keep them as close as possible) looks in Basic and C.
Tobias
Code: Select all
#define N 200000
#include <stdio_h>
#include <math_h>
#include <stdlib_h>
#include <time_h>
char *crossed;
long i, j, k;
void main () {
time_t t;
t = time (NULL);
crossed = calloc (N, 1);
for (i = 2; i < sqrt(N); i++) {
if (!*(crossed + i)) {
printf ("%d, ", i);
for (j = i*i; j < N; j+=i) {
*(crossed + j) = 1;
}
}
}
for (i = sqrt(N) + 1; i < N; i++) {
if (!*(crossed + i)) {
printf("%d, ", i);
}
}
printf("Primes to %d calculated in %d seconds", N, time (NULL) - t);
}
Code: Select all
10 a = DATE
100 DEF_INTEGER i,j
110 MANIFEST: n = 200000
120 crossed = ALCHP (n)
140 FOR i = 1 TO n
150 POKE crossed+i, 0
160 END FOR i
180 REMark sieve
190 FOR i = 2 TO SQRT(n)
200 IF PEEK(crossed+i) = 0 THEN
210 PRINT i; ", ";
220 FOR j = i * i TO n STEP i
230 POKE crossed+j, 1
240 END FOR j
250 END IF
260 END FOR i
280 FOR i = INT(SQRT(n)) + 1 TO n
290 IF PEEK(crossed +i) = 0
300 PRINT i; ", ";
310 END IF
320 END FOR i
330 PRINT :PRINT "Primes to ";n;" calculated in "; DATE - a; " seconds"
335 PAUSE -1
337 RECHP crossed
340 STOP
ʎɐqǝ ɯoɹɟ ǝq oʇ ƃuᴉoƃ ʇou sᴉ pɹɐoqʎǝʞ ʇxǝu ʎɯ 'ɹɐǝp ɥO
-
- Aurora
- Posts: 889
- Joined: Mon Nov 24, 2014 2:03 pm
Re: SBASIC & C++
Thanks everyone. Now I can clearly see what needs doing. So work on the TSP will definitely proceed, as it looks like it already has quite good performance, running on a 2.8+ Ghz PC under QPC2. But that will have to wait until mid-january, as I am in the meantime fully occupied with other things.
Some people have already received a copy of versions of the program. It is at present 6Ko long and will be submitted to Quanta for publication towards the end of january, after further optimisation.
I have the offer of by a C professional programmer to transcode it into C++ thereafter.
Good luck with your projects...
Steve.
Some people have already received a copy of versions of the program. It is at present 6Ko long and will be submitted to Quanta for publication towards the end of january, after further optimisation.
I have the offer of by a C professional programmer to transcode it into C++ thereafter.
Good luck with your projects...
Steve.
Re: SBASIC & C++
Tobias,
What is the DEF_INTEGER on line 100 for?
Per
What is the DEF_INTEGER on line 100 for?
Per
Per
I love long walks, especially when they are taken by people who annoy me.
- Fred Allen
I love long walks, especially when they are taken by people who annoy me.
- Fred Allen
- NormanDunbar
- Forum Moderator
- Posts: 2470
- Joined: Tue Dec 14, 2010 9:04 am
- Location: Buckie, Scotland
- Contact:
Re: SBASIC & C++
Hi Per,
Should run quicker, I think. But that depends on the code obviously.
Cheers,
Norm.
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.pjw wrote:Tobias,
What is the DEF_INTEGER on line 100 for?
Per
Should run quicker, I think. But that depends on the code obviously.
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.
Author of Arduino Software Internals
Author of Arduino Interrupts
No longer on Twitter, find me on https://mastodon.scot/@NormanDunbar.
- NormanDunbar
- Forum Moderator
- Posts: 2470
- Joined: Tue Dec 14, 2010 9:04 am
- Location: Buckie, Scotland
- Contact:
Re: SBASIC & C++
Regarding CPORT, I bought that years ago, and after running it on a couple of fairly simple programs, never used it again. The code output was pretty dire and I'm not sure it would be all that much more efficient.
Maybe I'll dig it out sometime, if my floppies still revolve that is, and have another play, but anything else I ever converted, such as my Archive Syntax Evaluator (or ArSE as i think Dilwyn called it!), was done by hand.
HTH.
Cheers,
Norm.
Maybe I'll dig it out sometime, if my floppies still revolve that is, and have another play, but anything else I ever converted, such as my Archive Syntax Evaluator (or ArSE as i think Dilwyn called it!), was done by hand.
HTH.
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.
Author of Arduino Software Internals
Author of Arduino Interrupts
No longer on Twitter, find me on https://mastodon.scot/@NormanDunbar.
Re: SBASIC & C++
Hi Norman,
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
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: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.
Code: Select all
..
100 DEF_INTEGER i,j
110 MANIFEST: n = 200000
120 crossed = ALCHP (n)
140 FOR i = 1 TO n
..
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
Per
I love long walks, especially when they are taken by people who annoy me.
- Fred Allen
I love long walks, especially when they are taken by people who annoy me.
- Fred Allen
- vanpeebles
- Commissario Pebbli
- Posts: 2852
- Joined: Sat Nov 20, 2010 7:13 pm
- Location: North East UK
Re: SBASIC & C++
Hi Norman,
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
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
Re: SBASIC & C++
Excuse me! That name and the abbreviation were not down to DJC, but to a certain Mr N Dunbar not a million miles away from this page...NormanDunbar wrote:Regarding CPORT, I bought that years ago, and after running it on a couple of fairly simple programs, never used it again. The code output was pretty dire and I'm not sure it would be all that much more efficient.
Maybe I'll dig it out sometime, if my floppies still revolve that is, and have another play, but anything else I ever converted, such as my Archive Syntax Evaluator (or ArSE as i think Dilwyn called it!), was done by hand.
Norm.

--
All things QL - https://dilwyn.theqlforum.com
All things QL - https://dilwyn.theqlforum.com