Subtilis: A new BASIC-like compiler for RiscOS
Re: Subtilis: A new BASIC-like compiler for RiscOS
(Thanks for that! If this info is very hard to come by, I recommend uploading it to the Internet Archive. I can do that if you like - but then only I could update it.)
Re: Subtilis: A new BASIC-like compiler for RiscOS
Thanks for posting this Sophira. I had fun playing around with !sBASIC this evening. For those of you who haven't tried it, !sBASIC compiles your program to BASIC assembler. When you run the generated BASIC file, it assembles your program and then runs it. I tried the primes program which works fine. I ported it to Subtilis and then had a mini battle of the compilers. On my 4MB A3000 (the program ran too quickly on the RiscPC) the !sBASIC compiled primes program took 1.79 seconds and the Subtilis version (see below) took 1.61. Thinking that most of the time was probably spent doing IO I removed the line that prints out the primes, i.e., IF ARRAY(a) THEN PRINT a; from both programs and reran. The !sBASIC version took .5secs and the Subtilis version took .34secs.
I only measured the execution time for the !sBASIC code (and not the assembly time). I disabled escape checking in the Subtilis compiler as !sBASIC doesn't seem to do this.
Here's the Subtilis version of the code. I modified it to use integers explicitly and to use local vars instead of globals.
Code: Select all
t% := TIME
local dim ARRAY%(10000)
a%:=0
WHILE a%<10000
a%=a%+1
ARRAY%(a%)=1
ENDWHILE
a%=1
WHILE a%<100
a%=a%+1
IF ARRAY%(a%) THEN
b%:=a%
WHILE b%<=10000-a%
b%=b%+a%
ARRAY%(b%)=0
ENDWHILE
ENDIF
ENDWHILE
a%=0
WHILE a%<10000
a%=a%+1
IF ARRAY%(a%) THEN PRINT a%; PRINT " "; ENDIF
ENDWHILE
PRINT ""
PRINT TIME-t%