Wednesday, October 28, 2026

Giving plm09 a spin!

There is a decent chance that you have never really heard of PL/M. Even if you are as old as I am, this one might have slipped by you. The truth is, it really is a bit before my time. I first heard of PL/M about the time that the CP/M sources started to become publicly available, and even then the complaint was that there would be no way to compile much of the source anymore. PL/M had been nearly forgotten by the mid-90's, even by those of us who were already interested in retrocomputing. But do not worry! This post will (or may?) get you started!


 Everyone has this on their bookshelf, right? ;-)

Hello, world!

 Or, at least something similar? An example program or two that output some text. Unlike many/most languages, PL/M lacks any form of standard I/O. Instead, that exercise is mostly left "for the reader". That is to say that rather than simply including a language feature for writing a string of text for output, the programmer must format any such string internally, and output each character sequentially. Fortunately the plm09 runtime provides PUTCH and PUTDEC procedures to simplify the actual output tasks, so let's look at an example that makes use of those:

 /* hello.plm */
HELLO: DO;
PUTCH: PROCEDURE (C) EXTERNAL; DECLARE C BYTE; END PUTCH;
PUTDEC: PROCEDURE (N) EXTERNAL; DECLARE N ADDRESS; END PUTDEC;
DECLARE I BYTE;
I = 1;
DO WHILE I <= 5;
    CALL PUTDEC(I * I);
    I = I + 1;
END;
CALL PUTCH('!');
END HELLO;

Here we see a DO WHILE loop which counts to 5 while calling PUTDEC to print each value to the output. PUTCH is used at the end to pring a final '!' character.

I used the following Makefile to execute the build procedures and to run the result:

 PLM09_SHARE = /usr/share/plm09

PLMC = plmc
LWASM = lwasm -9
SIM6809 = sim6809

%.asm: %.plm
    $(PLMC) -o $@ $<

%.s19: %.asm
    $(LWASM) -f srec -I $(PLM09_SHARE)/runtime -I $(PLM09_SHARE)/runtime/sim -o $@ $<

%: %.s19
    $(SIM6809) $<

With the program save in "hello.plm", a simple 'make hello' is sufficient to run the binary to see the result below:

 sim6809 hello.s19
1
4
9
16
25
!

Let's try one more example!

 /* sum.plm */
SUM: DO;
PUTDEC: PROCEDURE (N) EXTERNAL; DECLARE N ADDRESS; END PUTDEC;
DECLARE I BYTE, TOTAL ADDRESS;
TOTAL = 0;
I = 1;
DO WHILE I <= 10;
    TOTAL = TOTAL + I;
    I = I + 1;
END;
CALL PUTDEC (TOTAL);
END SUM;

This program similarly uses a DO WHILE loop to count to 10, this time keeping the sum of each iterated value in TOTAL. Finally PUTDEC is used to output TOTAL at the end. Typing 'make sum' will yield the following output:

 sim6809 sum.s19
55

Simple enough... What can you do with plm09?

Tuesday, October 27, 2026

An old dog learns a new-ish trick?

For those that aren't aware, I retired from Red Hat earlier this year. I was there for almost 22 years, most of which were both pleasant and rewarding for me. The exceptions were the final 2 or 3 years, during which I was constantly a bit annoyed by the dogged pressures from upper management to integrate AI into my workflow even when I saw no place for it or I judged that there was little or no value in doing so for my particular tasks or duties. Since regaining full mastery of how my skills are utilized and how my time is spent, I have continued to be aware of the growing use and influence of AI tools in my areas of interest both professionally and in the retrocomputing hobby.

Over time I  developed a nagging feeling that my overall lack of interest in AI tools was leaving me with an experiential gap which was separating me from my peers. I began to consult various friends from my professional life and collecting their advice and opinions on how best to make use of AI tools, particularly the well-known Claude Code. Since hands-on learning tends to yield the best results, I decided that I should pick a hobby-related project to use for my learning experience. All that and a reasonable token allowance allowed me to produce1 a Linux-based compiler for the PL/M programming language which targets the Motorola 6809 processor.

Why A PL/M Compiler?

For some time I have had an interest in programming tools for retro computing targets, but there is really no community need for yet another assembler or even another C compiler. Programming Language for Microcomputers (PL/M) is a high(-ish) level systems programming language originally conceived to support early microprocessors from Intel. This role yielded a language which reminds me quite a bit of C, but without the decades of accumulated baggage and expectations. IMHO, the language maps reasonably well to the capabilities of my favorite vintage CPU, the 6809. Hopefully the availability of this language will be welcomed by the existing communities of 6809 users, particularly that surrounding  the Tandy Color Computer.

Working With Claude

The collected advice from everyone came down to two points: a) be specific about the desired outcome without specifying how to achieve it;  and b) treat the AI like one would treat an intern (i.e. someone skilled and competent, but distracted and inexperienced). With that advice in mind, I gave Claude the following prompt:

Project goal is a Linux-based compiler for a minimal version of the PL/M language which outputs 6809 assembly language compatible with the lwasm  assembler toolchain.

After that, Claude asked a handful of clarifying questions. This included some specifics to help define what a "minimal verion of the PL/M language" meant, and some other minor clarifications. After a little time burning tokens, Claude showed me what it had for a plan and asked me to approve it. Initially I asked Claude to allow me to approve each change, but soon I was comfortable enough to let it proceed in automatic mode. I asked Claude to generate PDF documentation for the main binaries and to keep both the docs and the Claude.md file up-to-date with each subsequent change to the project.

How Did Claude Do?

I admit to having been extremely skeptical about what Claude would produce. Early experiences with various AI tools had been embarassingly disappointing, so I anticipated something that would at best mimic the assigned task. But instead, I was pleasantly surprised. Claude produced both a tool that compiles PL/M source code down to 6809 assembly language and a command-line 6809 simulator capable of running 6809 binaries which is used to run all of the compiler tests which Claude produced as part of its development process. Claude also built a system to provide runtime support for different machine targets, including the Tandy Color Computer and an example target for a user to customize for other targets. At my prompting, Claude provided targets for OS-9 and FLEX as well as the simon6809, the kswitchit 6809 kit, and Grant Searle's 6809 design. I have had limited opportunity to toy with the results so far, but so far I am quite pleased. Claude was even able to produce an RPM file suitable for Fedora!

Where Are The Results?

The git tree for the resulting PL/M compiler for 6809 is here:

https://github.com/retrotinker/plm09
 The PDF documenting the compiler is available here:

https://github.com/retrotinker/plm09/blob/master/docs/plmc.pdf 

And the PDF documenting the simulator is here:

https://github.com/retrotinker/plm09/blob/master/docs/sim6809.pdf 

Finally, Fedora users can use the RPM here:

plm09-0.3.3-1.fc44.x86_64.rpm 

Conclusion 

So, there you have it! I believe this tool is suitable for play/testing by retro computing enthusiasts with an interest in PL/M and/or the Motorola 6809, particularly if that enthusiast has a Tandy Color Computer, or one of the other supported targets. Someone suitably skilled and motivated could even extend the example runtime support for their own custom target. Finally, Fedora users can use my pre-built RPM for their own testing.

Please do give the tool a try and let me know what you think, or if you find any problems! I look forward to hearing from you in the comments!


1 I think "produce" is the correct term. I wrote essentially none of the actual code, but merely specified what I wanted from Claude and any additional changes which I wanted along the way. ↩