15 comments

[ 3.1 ms ] story [ 38.4 ms ] thread
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...

OMG--that would have been SO nice to have. I don't think I got my first taste of syntax highlighting until I got access to Turbo Pascal.

Adding it to Retroputer BASIC should be trivial. I think I'll have a go at it tonight, since it has support to use control codes to change the text color.

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.
A quick search indicates that BBC Basic had a LISTO command that could add indents. I should see if I can add something similar.
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..

(comment deleted)
Very cool article. Having grown up on msoft BASIC and assembly on the C64, I really appreciate the low-level insights.
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... ;-)

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.
You’re right! I’ll do that. :-)

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

This is a neat project, thanks for writing it up.

Does the Retroputer instruction set have an equivalent to the x86 ja instruction?

If so, here is a trick[0] that can be used for optimizing character class checks.

low <= x <= high is equivalent to x - low u<= high - low

[0] Chapter 4 - Arithmetic Bounds of Hacker's Delight by Henry Warren

Oooh -- good idea. I don't think I have an instruction that quite matches. Retroputer's branch instructions are directly tied to the flags, so you can do `br !c(arry)`, but that doesn't rule out zero like `ja` does. At a quick glance I don't think that should rule something like this out, though. :-)

That looks like a really interesting book -- I think I shall add it to my reading list!