In the series about the assemblers Commodore used for developing the ROMs of their 8-bit computers, this article covers the 1976 “MOS Resident Assembler” that ran on a variety of 6502-based computers.
- Part 0: Overview
- Part 1: MOS Cross-Assembler
- Part 2: MOS Resident Assembler ← this article
- Part 3: BSO CY6502
- Part 4: HCD65
- Part 5: Commodore 6502ASM [coming soon]
MOS Technology, Inc. released two assemblers for the newly introduced 6502 architecture: the “Cross-Assembler” (1975), available for various mainframes and minicomputers, and the “Resident Assembler” (1976), running natively on 6502 systems.
The Resident Assembler was written by Michael Corder (of MOS contractor COMPAS Microsystems) by hand-assembling the Cross-Assembler FORTRAN code to native 6502 assembly.
Consequently, both assemblers were compatible in that they understood the same source format, with the same math features1 and the same directives and options. That way, they defined the basic format supported by all future Commodore assemblers.
This means that the Resident Assembler took uppercase ASCII source files and created ASCII-encoded OBJ output files. It could even create the same LST output, but it was sent to the screen or the printer instead of a file.
Versions and Platforms
The Resident Assembler ran on almost all 8-bit computer systems by MOS and Commodore.
MOS built two computers for demonstration of and development for their new 6502 CPU: the MDT650 and the KIM-1.
The very first version of the Resident Assembler targeted the MDT650 (“Microcomputer Development Terminal”; 1976), a development computer by MOS that contained two 6502 CPUs: One to develop software, and one to test it on. Its ROM came with an editor, the Resident Assembler and a disassembler. Source was saved on tape, and later on 8″ disks.
According to the manual, the feature list of this version of the Resident Assembler was the same as that of the Cross-Assembler, except:
- no multiplication or division
- no error files
- no cross references
- no symbol table sorting
- no error messages; but errors numbers instead (1-23)
No ROM dumps are known.
The KIM-1 (1976) was a single-board computer originally intended as a demonstration board for the 6502, but with additional hardware, it could also be used as a full computer. For this, MOS released hardware like the KIM-2/KIM-3 RAM extension and the KIM-4 motherboard.
In 1977, Commodore announced the Resident Assembler for the KIM-1, which was supposed to ship in the form of the KIM-5 ROM board with three 6540 ROM chips (6 KB total) containing the assembler and a simple editor. The same year, they announced that the project was being postponed indefinitely, but it did appear in a price list in 1979.
There is a 1977 manual, which does not mention the
.SKIP directives. These were probably just undocumented, since the smaller AIM-65 version (see below) does support them.
The assembler could read source from cassette tape or paper tape, but it could not write OBJ files; instead, it would write the binary to RAM.
No ROM dumps are known.
(A company named “ARESCO” offered a 6 KB RAM-based assembler for the KIM-1 that may have been based on the MOS Resident Assembler. According to the documentation of the Apple II version, the supported directives and error codes matched the MOS Resident Assembler, and some sources call it the “MOS/ARESCO” assembler. Unfortunately, no dumps are known.)
The AIM-65 (“Advanced Interactive Microcomputer”, 1978) was a single-board computer similar to the KIM-1, sold by the 6502 second source Rockwell. A very stripped down and optimized 4 KB version of the MDT650 version of the Resident Assembler was available for this platform.
The AIM-65 is not a MOS/Commodore device, and it was not used internally at Commodore, but its version of the Resident Assembler is presumably based on the (lost) KIM-1 version.
Chapter 5 of the AIM-65 User’s Guide covers the assembler.
After the release of the CBM 2040 disk drive for the PET in 1978, John Feagans (of KERNAL fame) ported the MDT650 version of the Resident Assembler to the new platform.
The oldest known version is undated:
The next known versions are the only ones publicly released:
- PET Resident Assembler V112779 (1979-11-27, 7426 bytes); for BASIC 2
- PET Resident Assembler V121579 BASIC4 (1979-12-15, 7546 bytes); for BASIC 4
These two binaries were published as part of the Commodore PET Assembler Development System in 1980.
They add multiplication and division support, as well as textual error messages. So except for the missing cross-reference support, this version basically has feature parity with the MOS Cross-Assembler. The manual is based on the KIM-1 Assembler Manual, and adds descriptions of the OBJ format as well as the added features. Conditional compilation (
.IFE) is undocumented, but supported by the BASIC 4 version of the assembler.
There are more versions, all of which have only been used only internally:
- PET Resident Assembler V121579 BASIC2 (1979-12-15, 7546 bytes, from RB 6502ASM/MASTER.D80, UTIL001.D80, UTIL003.D80, UTIL004.D80, UTIL008.D80, UTIL009.D80); for BASIC 2: only direct calls into the PET ROM differ
- PET Resident Assembler V090580 A (1980-09-05, 7858 bytes, from cbmhardware.de); adds cross-reference support
- PET Resident Assembler V090580 B1 (1980-09-05, 7938 bytes, from DJ b128-editor-1of1.d64); later (!) version with optimizations
- PET Resident Assembler V090580 B2 (1980-09-05, 7822 bytes, from RB UNKN003.D80, UTIL008.D80, UTIL009.D80); identical to B1, but for 72 lines per page instead of 66
- PET Resident Assembler V102780 (1980-10-27, 8049 bytes, from DJ c64kernal.d64); detects BASIC 2/4 at runtime
These two versions are non-mainline:
- PET Resident Assembler V050482 (1982-05-04, 7624 bytes, from RB UTIL008.D80); binary-patched version of V121579 BASIC4, asks “PAPER LENGTH (CR/66 OR 72)?”
- CBM 6502 Copyright Assembler V26MAR82RR (1982-03-26, 7982 bytes, from DJ b128-kernal-2of2.d64); based on V090580 B, calls itself “CBM 6502 COPYRIGHT ASSEMBLER”; changes to LST format
There is one known version of the Resident Assembler for the C64:
- CBM Resident Assembler V080282 (C64) (1982-08-02, 9714 bytes)
It was released on disk as part of the Commodore 64 Macro Assembler Development System. The manual is based on the PET version, and adds documentation of the macro (see below) and cross-reference features, but does not document conditional compilation. An earlier version of the manual, which is part of the Commodore 64 Development Kit internal document, does document conditional compilation, but not macros.
TED Series (C16, C116, Plus/4)
Commodore also ported the assembler to the TED series, but never released it publicly:
This binary was built from the original source code. Unlike all earlier and later versions, this one does not interactively ask for its arguments, but relies on a BASIC program to place the arguments in memory before calling the machine code.
And finally, there is a C128 version:
It was based on the TED version, but went back to being standalone and asking for the arguments itself.
This version, too, was not released publicly.
While the MDT650 version of the Resident Assembler had no additional features compared to the Cross-Assembler, new features were added to later versions.
The AIM-65 version (and presumably the KIM-1 version) of the Resident Assembler added one new directive:
.FILE: switch to different source file, do not return
The size of the source of a more complex program could easily exceed the amount of RAM installed in a KIM-1/AIM-65. For instance, the 4 KB version of the Resident Assembler itself was, without comments, 24 KB in size, much larger than the typical amount of RAM in a KIM-1 or AIM-65.
While the powerful computers that the Cross-Assembler ran on had text editors that could handle files larger than the available RAM, the KIM-1/AIM-65 editors could not do this.
Therefore, the assembler allowed splitting the source into multiple files, which were then concatenated during the build.
PET V112779 (1979-11-27)
Version V112779 of the PET Resident Assembler had the following additional features:
.LIB: switch to a different source file (and unlike
.FILE, return to the original source file after the end of the included file)
NOSYMBOL: add symbol table to the end of the LST
PET V121579 (1979-12-15)
Version V121579 added conditional assembly:
.IFE: conditionally assemble if expression == 0
.IFN: conditionally assemble if expression != 0
The code guarded by the condition has to be between
.IFN GDEBUG < JSR GRBPRI ;GARBAGE DEBUG >
C64 V080282 (1982-08-02)
The C64 version adds support for macros. The manual contains the following example:
.MAC DPINC ;DOUBLE PRECISION INCREMENT INC ?1 BNE ?2 INC ?1+1 ?2 .MND
The argument of
.MAC is the name of the macro. The macro contents are defined between
.MND. Arguments are named
?1 etc., and local variables can be declared from the same namespace.
No known Commodore source code used this feature.
The TED version adds the following
NLONG: allow long labels
NMLI: enable expanding macros in LST
Also, expressions can contain
& (bitwise and),
. (bitwise or) and
! (bitwise exclusive or).
C128 V022086 (1986-02-20)
The C128 version removes support for mnemo statistics (
The sources of the AIM-65 version, all PET versions as well as the C64 version have been reconstructed from the TED source and are also available in this repository:
Bugs and Quirks
The C64 version has at least two known bugs:
- Commodore Disk User 1990-08 contains an article that fixes some problems with macros.
- A thread in comp.sys.cbm discusses and fixes a problem with multiplication.
It remains to be researched whether the TED source and the C128 binary contain these bugs.
Also, there is a confusing error message:
**RAN OFF END OF CARD
This means that the assembler was expecting more input, but encountered the end of the line. Back in the mainframe days, lines were also called “cards”, since one punch card stored a single input line.
The Cross-Assembler used to call lines “cards”, as can be seen in the LST headings:
CARD # LOC CODE CARD 10 0009 B1 0E NEXT LDA (SAVIL)Y
The Resident Assembler had dropped the “card” nomenclature on the PET though:
LINE# LOC CODE LINE 10 0009 B1 0E NEXT LDA (SAVIL)Y
…except for the single remaining case of the error message.
Use at Commodore
Commodore used the Resident Assembler on the MDT650 (with an 8″ disk drive) to develop the ROM of the original PET and the CBM 2040 (dual 5.25″) disk drive. At the time, the two MDT650 systems at Commodore were a scarce resource, so as soon as the CBM 2040 drive was available, the Resident Assembler was ported to the PET, and thus 6502 software development was switched to PETs.
The software Commodore built on the PET was:
- KERNAL/EDITOR and BASIC of later PETs, the CBM2, VIC-20 and C64
- the DOS ROMs of the 4040, 8061/8062, D9060/D9090, 8050/8250/1001, 2031, 1540 and the original 1541
- the ROMs of the 6502-based printers
- Commodore-developed applications and games, like Gorf and Omega Race
A large amount of Commodore source since 1980 (VIC-20, 1540, CBM 4040, …) has been preserved, and all source until 1984 (just before the TED series) is in a format that can be built with the Resident Assembler (V121579 or above).
The next article will discuss the BSO cross-assembler on VAX that Commodore switched to in 1984.
Multiplication and division were missing from the original version.↩