Member-only story

Writing a Utility Program for the ZX81 Was Such Fun

Here’s a quick program I wrote to turn Sinclair BASIC into assembly code.

Steven Reid
7 min readAug 9, 2024

Sometimes, you do things out of necessity. I spent an inordinate amount of time working on adding automatic scrolling to a PRINT command. In fact, I haver another version of my print scroll routine I'll talk about later. But this is about a utility program. A way to print out BASIC code in hex. And this article is about what I did and why.

# Let’s start with the problem.

While working on print scroll, I wrote the assembly program like I always did. What that means is I use the z80asm linker to build a working ZX81 program. The program usually has two lines. The first is a REM with all the machine code. The second is a BASIC routine that runs that code. This is the first version of print scroll I wrote to give you an idea of what it looks like.

1 REM /-**PRTSCRL**SLR/2024**
2 RAND USR VAL "16514"

Note that the first line actually has a bunch more code in it but I add a newline (hex $76) at the end of the first line to hide it. The /- at the start is actually a jump into the code. The 2 ndline just runs it-and you don't usually see it unless you list it because of the aforementioned newline.

Now this works great for most of my programs because this is exactly what I want them to do: load and run. This is also nice for my visitors because they don’t need to…

--

--

Steven Reid
Steven Reid

Written by Steven Reid

Computer dude, amateur photographer, artist, author. Read my blog at https://www.reids4fun.com.

No responses yet