
Building a BASIC Interpreter, '80s style - new_here
https://able.bio/kerrishotts/building-a-basic-interpreter-80s-style--79a9d703
======
rbanffy
In most 8-bit BASIC interpreters, the LIST command is, actually, a pretty
printer: it reads and parses the tokenized source from memory and outputs it
to the "terminal". On the Apple II, for instance, we see upper-case versions
with added spaces for clarity (and some annoyance for editing the on-screen
code on very long lines).

It just occurred to me we missed an opportunity there, with computers that
could display some form of screen attributes (Atari, VIC-20, C-64 and
countless text terminals), to make use of color and typography to enhance
screen presentation with a negligible cost in ROM.

It'd have been really cool to have color syntax highlighting on 8-bit
computers in the late 70's...

~~~
pmiller2
That's true, but it's typically not a very _nice_ pretty printer. For example,
I don't know of any old school version of BASIC where the LIST command shows
any sort of indentation.

~~~
photokandy
A quick search indicates that BBC Basic had a LISTO command that could add
indents. I should see if I can add something similar.

------
photokandy
Author here & wow! Didn't expect to see this get posted anywhere, but happy to
see that there are people as interested in this stuff as I am.

If you do play with Retroputer at all, it is still very much WIP -- so lots of
things aren't implemented (or don't work). It's proven a fun project to
reacquaint myself with lower-level concepts after having been in very high
level languages for several years.

One thing I really loved about the computers like the C64 I grew up on: it was
possible to hold the entire workings of the machine in your head. While things
often appeared magical at first glance, it wasn't that hard to figure out how
and why they worked, and then to use that to your advantage. I don't _know_ if
that's a benefit when writing high level code today, but I like to think that
having that low-level understanding is useful.

It's also proven useful as a project to learn _new_ things. I'm figuring out
some back-end coding, Twitter bots, and at some point would love to make this
thing in hardware with an fpga. One of these days... ;-)

~~~
wizzwizz4
I think you could make your lowercase loop shorter – and definitely faster –
by jumping into a second loop when inside a string, instead of setting a flag.

~~~
photokandy
You’re right! I’ll do that. :-)

I haven’t done a lot of optimization yet-probably lots of things like this.
:-)

------
new_here
Online version of the interpreter here: [https://blissful-bose-
ff8542.netlify.app/](https://blissful-bose-ff8542.netlify.app/)

~~~
Jaruzel
Nice! - looking forward to the follow up articles.

------
photokandy
I finally had time to revisit the suggestions in the comments -- what great
ideas. :-)

I wrote them up in a post here: [https://able.bio/kerrishotts/building-a-
basic-interpreter-80...](https://able.bio/kerrishotts/building-a-basic-
interpreter-80s-style-redux--4323d1db)

I also included some links to resources that may prove useful to others trying
to do similar things.

------
rchase
Very cool article. Having grown up on msoft BASIC and assembly on the C64, I
really appreciate the low-level insights.

------
trec
Nice work.

I have been following similar series from various sources and hope that this
will reach end. Sadly all similar material is always abandoned when arriving
interesting parts..

