• Published on | Jun 12, 2016 | by Chris Osborn

Linux plus CP/M plus assembly equals LASM

With the TRS-80 Model II working one of the first things I did with it was to send the world’s first tweet from a TRS-80 Model II. To do that I used Kermit for CP/M.

The TRS-80 Model II support in Kermit is missing hardware flow control support however which means that it’s very prone to dropping characters. I started to look into what it might take to add hardware flow control and this sent me down a rabbit hole of trying to figure out how the TRS-80 hardware works, how the Z80 SIO works, learning Z80 assembly, and of course, how the heck you even build CP/M Kermit 4.11 from source.

The instructions for building Kermit are buried somewhere around the middle in the documentation file that describes how to use Kermit. The source is in 8080 assembler and targets Microsoft’s M80 or LASM, originally made by Ward Christensen. He reverse engineered the assembler that came with CP/M and made improvements to it. There seems to be some confusion over the copyright on LASM, and I’m not certain Ward’s original assembly source was ever released. About all I found about the source was a message from 1989 where a Kermit distributor was trying to hunt it down.

I was able to build the TRS-80 overlay for Kermit on CP/M. At first I tried doing it on the TRS-80 itself, but I was having too many issues with bad sectors and seek errors. Not sure if it’s bad media or bad drives. Since trying to build on retro hardware was becoming too difficult I got z80pack and was able to use the CP/M simulator to do the build.

While building inside of a CP/M environment works, it’s inconvenient. It’s a hassle moving files in and out of disk images. Editing files under CP/M would also be torture, I’d much rather use emacs which can take advantage of my screen real estate. Even back when CP/M was still king development was often done on faster more powerful computers with more resources available whenever possible. Cross assembling under Linux would also allow me to setup a nice Makefile. I tried out half a dozen different cross assemblers under Linux, but not one of them accepted the LASM syntax.

I thought if I could find the source for LASM it would make it easier to write a new program in C or Python to make a Linux cross assembler. I did find source for LASM-TDL but it is a different animal and even though it claims to be a derivative of LASM it is not compatible. Yesterday I realized there was probably an easier way. Instead of writing an assembler from scratch I decided to massage the 8080 LASM-style source into something that one of the other assemblers that runs on Linux would accept. Of all the different assemblers I had tried under Linux I found that the AS Macroassembler was the best fit. The others were too simple to understand conditional directives or insisted that ORG had to be set before you could even define any macros!

It took most of the day but before I went to bed I had something that would pre-process all the Kermit ASM files, rewrite mnemonics, fix up string constants, and in the end spit out a hex file that was identical to what I was getting from LASM running on CP/M. This morning I had to make a few more tweaks to it and then I was able to assemble the 8080 CP/M 2.2 source too.

I’ve put my lasm cross assembler up on github if by chance you actually happen to have some 8080 code that was written in LASM syntax that you want to work on again.

†Links to all the different Z80 assemblers I tried:

I wonder if I should have named it “kasm” for “Kermit assembler” since that’s probably the only thing it will ever be used for.

Join The Discussion

+1  Posted by ignusfast • Jun.12.2016 at 17.20 • Reply

I used EDTASM back in the late '70s early '80s...

+1  Posted by Sampsa • Jun.18.2016 at 17.05 • Reply

You know the SIMH Altair Z80 emulator comes with some CP/M utilities for moving files back and forth between the emulated CP/M box and the host OS?

+1  Posted by Chris Osborn • Jun.18.2016 at 17.59 • Reply

You can also use cpmtools to move files back and forth between a huge variety of CP/M formats, not just a single emulator. However as I said above, moving files back and forth between an emulator is much more of a hassle than simply assembling the source directly on Linux. With my version of LASM that runs on Linux I don't need to jump through hoops to build the project, I can do it with a single button in my preferred IDE.

+1  Posted by Myles • Jun.18.2016 at 22.01 • Reply

Dude, you da bomb! Nice work.