asm21 is an assember for the HP-21xx family of 16-bit minicomputers. It is written in Perl.

I developed asm21 to assemble the HP 2000C' Time-Shared BASIC system source code.

asm21 is distributed under the terms of the Free Software Foundation's General Public License, Version 2. If you agree to the terms of the license, you may download it.


asm21 development uses the Subversion revision control system. Instructions for access to the Subversion repository for asm21 are found at, and there is a web interface to browse the repository at



I originally wrote asm21 in May to June of 2000, as part of a project to produce machine-readable source files for HP 2000 C' Time Shared BASIC. I had a printed listing, but no machine-readable source code has been located.

I scanned the listing, but OCR proved useless, so I typed it in most of the system processor listing (including line numbers, addresses, and object code). I have not yet typed in all of the overlays, nor the IOP code, and I don't have a listing of the loader.

Once a listing was typed in, I ran it through an awk script that stripped it down to a source file. At this point I wanted to run it through an assembler that would produce a listing file in an identical format to the listing I'd typed in. asm21 was written for this purpose, and since at that time I did not need it to generate an object file, it produced a listing file only. (Object file generation has been recently added.)

A diff of the listing file output by the assembler with the listing file I typed in revealed many errors which I then corrected. It is likely that there are no significant typos remaining (other than perhaps in comments), because for an error in a mnemonic or operand to go undetected, a corresponding error would have to have been made in the object code as well.

Perl considered harmful

I originally started writing asm21 in awk, but found that a few things are difficult to do in awk, so I switched to Perl. This was my first non-trivial Perl program, and I had to learn how to deal with complex data structures such as a hash of lists of lists that include function references.

A few months later another problem came up for which Perl seemed suited, so I sat down at the keyboard, and... discovered that everything I'd learned about Perl had vanished. I had to get out the books and learn it all over again.

The problem is the Perl is exceptionally cryptic, and the syntax is very baroque. The distinction between scalar and array contexts is particuarly obtuse. In any reasonable language, you'd think that if an array variable was named "@foo", that you could index it using something like "@foo[3]". Not in Perl! You have to use "$foo[3]", where the dollar sign indicates scalar context.

I've been learning Python lately, and it seems much easier to learn and understand. Code written in Python should be much more maintainable. I've started rewriting asm21 in Python, but it's nowhere near ready yet, and I'm not sure that I'll actually have time to finish it in the near future.

Last updated April 20, 2005

Copyright 2003, 2004, 2005 Eric Smith

hacker emblem
Best Viewed With Any Browser Valid HTML 4.01! Valid CSS!

check now

check now