Making ALPA (Assembly Language Programming Aid) work on C64

From the book C64 Machine Language for the Absolute Beginner by Danny Davis (Published by Melbourne House 1984, reissued in 2002)

Book [image]

If you picked up this book you'll quickly realize that it assumes working on the original hardware. Which is great if that's what you're after. The issue is however, that it gives most of its code examples in ALPA format.

What is ALPA?

ALPA is a BASIC program intended to help with being able to type the machine code program in in text, before executing it. It supports line numbers, which works like like in BASIC. It can watch memory adresses, disassemble and dump, so it's a simple assembler really. You can of course also save or load your programs to tape or disk.

How to get it?

Well, you see, that's the problem. I wasn't able to find the program anywhere. Luckily the book comes with the source code of it in Appendix 13. You just have to type it in! I was determined enough to do it. Because I wanted to experience how was it before the Internet and easy access to software. When for a brief period in time the most common way of getting new software was typing them in from magazines and books. As ALPA is pretty significant in size (8 pages), I wouldn't have considered it if it wouldn't have a checksum utility built in. Luckily it has, which can help you to find the lines you made mistakes in.

Typing in ALPA

It's still a challenge. The printing of the book is not perfect, it can be hard to read at some places and it struggles with PETSCII characters. It's also confusing with the spaces being all over the place.

Here are my tips:

String literals. The book shows space symbols within the quotes. Type in spaces equal to the number of the space symbols. Ignore the spaces before and after the symbols themselves. Same for the other special symbols within strings.

The inverted signs are special control signs within a string. They can be typed in only after opening a quote with "

The inverted circle (like in line 2042) is the "Move cursor 1 position up" command sign. To type it, press Shift + Crsr⇅.

The inverted heart (like in line 2759) is the "Clear text on screen and place cursor in top left corner" command sign. To type it, press Shift + Clr/Home.

The inverted triangle (line 9060) is the "Set text color to cyan" command sign. To type it, press Ctrl + 4.

Here are all the PETSCII characters and their key combinations, very useful:

These lines can be hard to read, but they have equal signs:

5110 JJ$=C$(J,1):GOSUB 20000:CJ=JJ
6070 V(I)=PEEK(G):H=INT(V(I)/16):L=V(I)-16*H

In the DATA lines, where there are space signs, type only that number of spaces, but where there are no space signs (outside of the strings), type the not explicit spaces as well. So for example (I marked spaces with _):

9323 DATA2,"LDA_($__,X)",2,LDX_#$,1,???,2,LDY_$,2,LDA_$,2,LDX_$,1,???

Line 40005 and 10 has a ^ sign used for power. The C64 doesn't have this sign, so this must be a mistake. You can use the up arrow ↑ instead:

40005 RT=INT(ET/(16↑RR))

Do one page at a time (or less) as you'll get tired and make more mistakes. I did 1-2 pages a day, managed to finish it in a few days.

Save your progress often to tape or disk. Do backup saves. I have only a 1531 Datasette, so I saved my progress to cassette. Worked well.

Proof read the part after line 60000 carefully, as this is the checksum calculation code, it must work correctly.

After you typed the whole thing in, type:

run 62000

You'll be asked if you want the output to a printer or not. If you don't have a printer (I didn't) you need a way to record the output as it will scroll out of the screen pretty quickly. I used a phone on a stand to record a video and watch back the output. Then check the total value. If it's different from what's in the book, go line-by-line and mark those lines that have a different checksum than what's in the book. Then you can do:

LIST line#

Go through that line again to fix any typing errors and press enter on the line to commit it. Repeat this, until you have a a checksom value that matches the book.

ALPA checksum [image]

Oh, and of course save your program after everything matches, before running the program itself as it ends up in an infinite loop, you might not be able to run-stop it and you might lose your progress.

ALPA running [image]

Download

If you are for some strange reason not keen typing in the whole thing, I managed to transfer the result from my datasette to my PC and convert it to a d64 image. Here it is:

alpa.d64
Back to the main page