Who would have thought that in 2023 some idiot would write another Tiny Basic for the 6502…
Well, I was that idiot… Because: Why Not!
It all started as something else… Over the summer just past I wrote a new programming language called APRICOT with the intention of making it a tiny but usable thing on the 6502. That hasn’t happened… yet.
But in looking to make a 6502 version or APRICOT, I had a look at all the variants of Tiny Basic there are out there with the view of using one to act as a platform to help me port APRICOT… What happened instead is that I found one on an old platform I have a touch of fondness for so set about re-writing that for the 6502 instead.
That platform was the INS8060 CPU, commonly known as the SC/MP. The name of the implementation was NIBL Short for National (As in National Semiconductor) Industrial BASIC Language.
Coming in at just under 4KB of SC/MP code it was a slightly longer version of most Tiny Basics which tried to get under 2KB wherever possible… However it did have some nice features that I was interested in – namely FOR/NEXT and DO/UNTIL loops.
And given the name NIBL, I felt I had to call it something similar, so GIBL for Gordons Interactive Basic Language) was coined.
As I was rewriting it, I actually thought that the old SC/MP was going to be much more code dense that the 6502 – turns out they’re about the same, although some operations seems easier on the SC/MP due to it having 16-bit pointer registers with a variety of auto increment/decrement modes. However, the 6502 version is currently at just under 3700 bytes of code and runs much faster than the SC/MP version (for many reasons, not just that the SC/MP has a bit-serial ALU)
So want to get the code? Click here …
But beware – it won’t run on any system other than my own Ruby board, but it might just run as a ROM in a BBC Micro – starting it will require a magic *FX command or unplug BASIC… Or Go into MODE 7, assemble it to run at &4000 load it there and off you go…
… And port
Please read the PORTING.TXT file that’s included with either the TGZ or ZIP file. I’ve made it easier to port now with almost everything in a single file and I’ve also included 2 routines that are part of my RubyOS so you don’t need to write those for yourself.
For other systems… You will need to read and edit the system.s file to work out what to you. Possibly also the data.s file too.
You’ll need to provide your own routines for a number of calls to handle character IO from a terminal. However it should be no worse than porting e.g. EhBASIC for your system, so if you can get that running, then you can get GIBL running.
There are a few demo programs for it including my new Mandelbrot implementation, but be aware – Tiny Basics are not known for their speed. They do not tokenise the input like MS and newer Basics so there is a lot of string compares going on for every line of code executed.
Have a Mandelbrot because we all love Mandelbrots!
And here is the listing:
100 VDU12:PRINT “Mandelbrot – Gordons TinyBasic – Integers”
110 PRINT “Start”
120 !160=0:REM Initialise TIME
130 Z=TOP:$Z=”.,’~=+:;*%&$OXB#@ ”
150 FOR Y = -12 TO 12
160 FOR X = -49 TO 29
230 A=T: P=A/F:Q=B/F
240 IF ((P*P)+(Q*Q))>=5 GOTO 280
250 I=I+1:IF I<16 GOTO 200
260 PRINT” “;
270 GOTO 290
280 VDU ?(Z+I)
290 NEXT X
300 PRINT “”
310 NEXT Y
340 PRINT”Time: “, Q/100, ” secs.”
History, lest we forget…
The history of Tiny Basic is quite fascinating and starts in 1975. At that point the emerging Homebrew computer Club in California was holding meetings and a couple of enterprising individuals decided to write a BASIC for those computers (mostly Intel 8080 systems), so a chap called Bill Gates and a couple of friends got together and wrote a BASIC for these early systems and sold it for $150 a tape… Some folks thought this was too much and copied the tapes, giving them away for free. Mr. Gates was naturally upset and sent out a stern letter… So with their get on and do it attitude, the Californians got on and did iy and and wrote their own… Starting with Dennis Allison who wrote the initial specification and interpreter for an Intermediate Language (IL) designed to make it easy to implement a BASIC. The rest, as they say is history, but the next year, 1976, a couple of chaps at National Semiconductor (Mark Alexander & Steve Leininger) did a slightly larger and more feature-full implementation for the INS8060 and it’s this version I re-wrote to suite the 6502.