Commodore’s Assemblers: Part 5: 6502ASM

In the series about the assemblers Commodore used for developing the ROMs of their 8-bit computers, this article covers the 1989 “Commodore 6502 Assembler” (6502ASM), a cross-assembler written in C that ran on VAX and PC.

Series Overview


To build the ROMs for their 8-bit computers, Commodore originally used an assembler that ran on their own 6502-based machines (part 2 of the series). From 1984 on, they used the “Boston Systems Office” (BSO) cross-assembler running on VAX/VMS (part 3).

In 1989, Commodore started working on the C65 project, a much enhanced successor to the C64. The C65 had a 4510 CPU, which supported the extended 65CE02 instruction set.

In order to be able to use the new 65CE02 instructions, they had several options:

  • Write a set of macros that wrapped the new instructions: This worked well for some instructions, but required non-standard syntax for other cases. Dennis Jarvis, who developed the C65 DOS, started out with this approach while developing using the Merlin 128 assembler. Here is an example for the INW instruction:
    INW MAC  
     DFB $E3 ;INW BP  
     DFB ]1  
  • Add 65CE02 support to an existing assembler: Three years earlier, Commodore had written the HCD65 assembler for C128 (part 4), and they did in fact add 65CE02 support to it. Unfortunately, developing with HCD65 was slow and cumbersome.

  • Write a new assembler from scratch: Using modern tools on a modern platform, writing a new assembler would not be too much work.

The “Commodore 6502 Assembler” (6502ASM") is a 6502/65CE02 cross-assembler written in C, written by Bob Norby of Commodore Semiconductor Group (CSG, formerly MOS). It aimed at full compatibility with the “BSO” cross-assembler on VAX (part 3), which Commodore had been using for all their projects before. It was developed on VAX (using VAX C V2.4-026) to allow for easy comparisons of its outputs with BSO’s.

In June 1989, Fred Bowen ported the source to MS-DOS. An Amiga version was mentioned in the 1991 C65 specification, but it is unclear whether the source was ever actually ported to an Amiga C compiler.


The 6502ASM was closely modeled after the BSO assembler, so it used the same command line interface. The user could pass the arguments either as command line options, or type it into a prompt, if no command line arguments were specified:


C65> is the prompt printed by the assembler. It matches the prompt of the BSO assembler, and symbolizes “Cross assembler for 6502” – it has nothing to do with the Commodore C65 project.

This is the help text that is printed if /H is passed:

the assembler command line consists of the file names and switches

C65> [object],[listing]=source[,source]...[,source][/switch]...[/switch]

Items enclosed in brackets [...] are optional.

The default file extentions are .obj , .lst and .src

Switches  (either upper or lower case)  
/A absolute assembly (default)  
/Cn cpu instruction set /C0 for NMOS 6502   /C1 for CMOS 6502  
     /C2 for CMOS 6502 w/bit instructions   /C3 for Commodore 4502 (default)  
/Dpath specify path for intermediate file ( usually RAM disk on PCs).  
/H help - prints this message  
/L assume long branches on pass1. (default= assume short branches)  
/Mnnn maximum macro nesting depth (default=50, limits=2-999).  
/Pnn maximum number of passes to try (default=15, limits=2-99).  
/N don't print errors to console during assembly  
/R relocatable assembly - illegal since this is an absolute assembler only  
/S narrow list format  
/T don't print symbol table  
/V don't print cross reference  
/X print cross reference (default)

Details on the usage as well as the supported syntax are described in the unofficial manual.


6502ASM is very similar to the BSO assembler. It supports the same directives, and uses the same syntax for local symbols, conditional assembly and macros.

The only real difference seems to be the lack of the .IF directive, just like with HCD65. .IF seems to have been undocumented on the BSO assembler, which would explain its omission from both HCD65 and 6502ASM. That BSO supported it and treated it as a synonym for .IFN can be seen from its use in the TED KERNAL source.


6502ASM B0.0 (1989)

This is the MS-DOS binary of version B0.0, built with Microsoft C 5.00 for MS-DOS (1987):

  • 6502ASM B0.0 (1989-06-14, 67233 bytes, from DJ 4502-asm-for-pc-7-89.img)

This version has a few bugs:

  • A ; character in a string terminates it.
  • If an operand is 8 bits wide and the instruction does not support the zero-page addressing mode (i.e. LDZ on the 65CE02), the assembler does not support falling back to absolute addressing. The following code would fail:

    ldz $80

    This issue prevents some C65 source code from building.

  • If a macro is used within an .INCLUDEd file, assembly is stopped after the current file. on contains an LST file generated by 6502ASM B0.0 from the original 1581 source that shows this problem. The LST file is incomplete; it ends after the included file “mrout”, and the remaining LST therefore shows 150 undefined symbols.

  • Projects like RAMDOS (a solution for exposing a RAM Expansion Units (REU) as a disk), the HCD65 assembler and its editor (EDT_C128) as well as DOS_SHELL use BSO assembler features extensively. 6502ASM fails to build it for various reasons.

The source code of 6502ASM B0.0 has been preserved through DJ 4502-asm-for-pc.img.

6502ASM V1.0 (1990)

Version V1.0 fixes a few bugs, including the ; and LDZ problems.

LST files of the source are included in c65_src.tar.gz. The reconstructed source is available as part of the cbmsrc repository.

Current Version (2021)

I adapted version V1.0 to current compilers so that it builds and runs on modern Unix systems. It is available on GitHub:

.IF has been added and the bug with macros within .INCLUDEs has been fixed. It can currently compile all known Commodore BSO source code, with the exceptions mentioned above. Contributions are welcome!

Use at Commodore

At the beginning of the C65 project, three different assemblers had been in use at Commodore:

  • Dennis Jarvis (DOS) originally had used Merlin 128, with added 65CE02 macros.
  • Fred Bowen (KERNAL, BASIC) had originally used the BSO assembler, possibly also with added 65CE02 macros.
  • The external contractor Walrus Software Inc. (graphics extensions for BASIC) had used HCD65.

All development was switched to 6502ASM in mid-1990.

The A2232 7-port serial card for the Amiga also contained a 65CE02 CPU. The project started in 1988, using the BSO assembler. The final version was built with 6502ASM on VAX1.

This marks the end of the 5-part series on the assemblers used by Commodore.

  1. The Amiga makefile in the driver source does not build the 65CE02 source, but only links an already built .OBJ file, which is a strong indication that 6502ASM did not in fact exist on the Amiga, and the source was built on VAX and transferred to the Amiga instead.

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.