One more basic diversion

I found and loaded a copy of BBCBasic on the AltairDuino. This is a basic I never used when I was really running CP/M but it looked interesting. In the veins of the previous MBASIC post, I ran the sieve on it to see how well it ran:

[2019-12-25 10:45:15] >LIST
[2019-12-25 10:45:17]     5 PRINT "Start"
[2019-12-25 10:45:17]    10 DIM flag%(8191)
[2019-12-25 10:45:17]    20 count = 0
[2019-12-25 10:45:17]    30 FOR i = 1 TO 8191
[2019-12-25 10:45:17]    40   flag%(i)=1
[2019-12-25 10:45:17]    50 NEXT i
[2019-12-25 10:45:17]    60 FOR i = 0 TO 8190
[2019-12-25 10:45:17]    70   IF flag%(i+1)=0 THEN GOTO 150
[2019-12-25 10:45:17]    80   prime = i+i+3
[2019-12-25 10:45:17]    90   k=i+prime
[2019-12-25 10:45:17]   100   IF k > 8190 THEN GOTO 140
[2019-12-25 10:45:17]   110   flag%(k+1)=0
[2019-12-25 10:45:17]   120   k=k+prime
[2019-12-25 10:45:17]   130   GOTO 100
[2019-12-25 10:45:17]   140   count = count + 1
[2019-12-25 10:45:17]   150 NEXT i
[2019-12-25 10:45:17]   160 PRINT "End, Primes =", count
[2019-12-25 10:45:17] >RUN
[2019-12-25 10:45:19] Start
[2019-12-25 10:50:49] End, Primes =             1899
[2019-12-25 10:50:49] >

As you can see, the code is slightly different. The indentations are provided natively by BBCBasic. Interesting note is that I couldn’t LOAD(yes, it all has to be caps) the code. This Basic is expecting a tokenized form. However, I did some sleuthing and found out you can *EXEC "FILENAME.TXT" and it will import an ASCII file in.

Anyways, the result above is pretty clear. This basic runs the sieve in 5 minutes 30 seconds or roughly 21% faster. Cool. Wish I’d know about this back in the day.

You must be logged in to post a comment.