from Hacker News

Building a BASIC Interpreter, '80s style

by new_here on 7/3/20, 11:49 AM with 14 comments

  • by rbanffy on 7/4/20, 10:58 AM

    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...

  • by photokandy on 7/4/20, 4:29 PM

    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... ;-)

  • by new_here on 7/4/20, 7:30 AM

    Online version of the interpreter here: https://blissful-bose-ff8542.netlify.app/
  • by photokandy on 7/8/20, 8:48 PM

    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...

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

  • by rchase on 7/4/20, 3:09 PM

    Very cool article. Having grown up on msoft BASIC and assembly on the C64, I really appreciate the low-level insights.
  • by trec on 7/4/20, 11:28 AM

    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..