I’ve been meaning to really seriously start learning assembly on real hardware for, well, since I was 15 really, but if I am honest I really struggle – not enough time to dedicate to it I think (that’s my excuse), and I always fall back to the CBM Basic I learned as a kid.
So I’ve been looking for a halfway house to tide me over until such time as I am proficient enough in assembly (that day will come – never say never!)
My main project at the moment is a C64 text adventure to accompany a book I am writing. I am in the parser phase, creating an effiicent way to parse instructions and return meaningful actions, and I think I can get a decent parser done in Basic. It’s just sloooow.
Enter Blitz! – Blitz promises to compile basic to run faster. And it does. There are a number of compilers out there, all with their own limitations and quirks it seems, and I am not going to try all of them today – but the other one in the mix which is considered one of the best is Basic Boss. Great name 🙂
First of all a quick benchmark program to test the compilers. I wrote a small routine to calculate prime numbers between 1 and 1000 – probably a more efficient way to do it but that isn’t the point. As long as we’re comparing eggs with eggs.
In CBM BASIC, as it comes, the sequence of 1 – 1000 completed in 8 minutes 56 seconds.
Blitz! loads up from disk and asks a question around setup – dual or single floppy.
At this stage make sure your disk containing a copy of your program is mounted. Blitz asks for a file name immediately after selecting 1 (single floppy) and you simply type the name of your PRG file (minus extension). The compiler then makes a couple of passes of the code and compiles to two file. IN my case PRIME compiled to C/PRIME and Z/PRIME – C/PRIME being the one you load and run.
So the moment of truth, loading and running C/PRIME shaved 3 minutes 12 seconds off the time, repeatable on each run.
Coming in at 5 minutes 44 seconds – I was reasonably impressed with that, but obviously need to do some more testing on more complex BASIC code with my text parser to get a really good idea of speed gained.
Basic Boss is lauded as the best compiler out there, but it came in at 6 minutes 03 seconds, so behind Blitz by 19 seconds – again, more testing required and I suspect results may differ on larger programs.
Basic Boss too is very easy to use and is basically the same operation as Blitz. Mount your disk, pass it the filename and compile. It compiles to +PRIME (adding a plus sign to the front) and is a single file. It reportedly compiles to pure ML which is why I suspect it may perform better on larger, complex programs than Blitz but we will see.
I’ll update with some parser benchmarks once I am ready to do some testing but for now, I am optimistic that at least one on these compilers will speed up BASIC text adventures to a point where they are playable. If I have time I’ll maybe repeat this excercise over the weekend on BASIC 64, Diablo and Laser, another three compilers worth trying out.
As an aside, I’m also looking at using the Infocom library for 8-bits, PunyInform, but I don’t want to come out of the C64 bubble and work on modern hardware. I’m odd.
By the way, all software and info can be found here.