As you can see – it works! I don’t admitting I was very smug when I got this working. Even worse than usual!
The computer starts in my minimal monitor. By entering “X 8000” I’m telling the computer to start executing code from that address – that’s where the BASIC code lives. So from that point on, we’re in BASIC.
Then I PRINT “Hello world!” because … well, of course I must.
Then I try a simple loop, to prove that variable allocation is working.
Finally here, I write a simple program. Remember that part of my motivation for implementing BASIC is because it would make it easier for me to write code that interrogates hardware. It’ll make future experimentation easier (controlling screens, storage devices, communication, and so on). By writing to the correct location in RAM, this program sets port B on my 6522 as outputs, and then puts a binary count on it. I can then see this on the little display I made.
Running this also highlights a problem to solve later – pressing the Escape key would normally exit a running BASIC program, but because I’ve only implemented OSWORD 0 (“get a line of text”) and not any other keyboard scanning, it means I can’t escape a running BASIC program!
For now, the solution is to hit the “reset” button (which puts me back into my monitor). Fortunately, it seems that running the BASIC ROM again (“X 8000”) and then typing “OLD” will get me my old program back!
Of course, as soon as someone makes their own computer, they always want to do the same things with it: calculate prime numbers, or generate a fractal.
I found a BASIC program on the RC2014 Google Group (have a look here) and tarted it up a bit for BBC BASIC (here, if you’re interested). I send it to my computer by using RealTerm’s “Send” function (which sends a text file as if I typed it myself). When it runs, it looks like this:
It’s hardly a processing powerhouse (I’m not going to be mining bitcoins anytime soon) but I’m still pretty pleased with that!