- Assembly 96.2%
- Shell 2.7%
- Makefile 1.1%
|
|
||
|---|---|---|
| assembler | ||
| examples | ||
| loader | ||
| scripts | ||
| tass | ||
| .envrc | ||
| .gitignore | ||
| assembler_x16.code-workspace | ||
| LICENSE | ||
| README.md | ||
CBM Macro Assembler
This is a port of the CBM Macro Assembler (the "Resident Assembler") for Commodore 64, to X16 and (expanded with at least one 8K bank) VIC-20.
Along the way, I've added some fixes and QoL updates to make it friendly to mixed-case and ISO encodings.
The original source may be found on Github at Michael Steil's CBMSRC repo.
Differences
There are several differences between this version and the 072982 source from which it was derived. These include:
- It runs on the X16, and on an expanded VIC-20.
- It now accepts input ASCII/PETSCII codes $61-7E (lower case in ASCII; upper/graphics in PETSCII). The original version accepts only character codes below $60. This means that mixed-case ISO files for the X16 will work fine. Labels and mnemonics are case-insensitive.
- It now respects LF as a line ending character, and correctly assembles files with CR (CBM), LF (Unix), or CRLF (DOS) line endings.
- It now correctly rejects lines >80 characters instead of blowing its state by overflowing the buffer.
How to use it
The original documentation describes how to use the system on the Commodore 64.
On the X16, use the in-ROM editor to create source files. The syntax is an ancestor of 64tass. On the VIC-20, well, you probably want to create your source files elsewhere.
To build your program, use ^ASSEMBLER.PRG give it the name of the object file to be created, answer no to hardcopy and cross ref, and give it the source file name. After it creates your .OBJ file, run either HILOADER.PRG or LOLOADER.PRG, depending on where your program is going to be loaded. Choose the one that doesn't conflict:
HILOADER.PRGloads at address$A000(in Banked RAM), and you run it withSYS $A000. Use this if your program resides in low memory, or BASIC memory with a stub.LOLOADER.PRGloads at address$0801(BASIC memory) and has a BASIC stub. Use this if your program doesn't infringe on BASIC memory (if it lives in Banked RAM, for example).
Example Programs
In examples there is HWORLD.ASM which loads at $A000, and HW2.ASM which loads at $0801 and has a BASIC stub.
(Note: on the VIC-20 you will only be able to run HW2, as there is RAM in Bank 5 at $A000 on the VIC-20. You will not be able to run HW2 on a C64. On the C64 you can run HWORLD because there is BASIC memory at $0801, but you will not be able to run HWORLD on a VIC-20 because the BASIC memory doesn't start there. You can run either on an X16.)
To run HWORLD, copy the programs and source onto your X16 (I like to call the programs ASSM, HILO and LOLO), along with the source code. Then:
^ASSM # Assembler: Answer "HWORLD.OBJ", "", "", and "HWORLD.ASM" to its prompts
^LOLO # Loader: Answer "", "HWORLD.OBJ", and "HWORLD" to its prompts
SYS $A000 # to run HWORLD right now
%HWORLD # to load HWORLD later
SYS $A000 # to run it after that
To run HW2, copy as above, and then:
^ASSM # Assembler: Answer as above
%HILO # Loader: load into banked RAM
SYS $A000 # Run the loader. Answer "", "HW2.OBJ", and "HW2" to its prompts
RUN # to run HW2 now
^HW2 # to run it later
LLM Assistance
I used Claude Code to help me convert the syntax to 64tass, and to help me rearrange ZP variables and ROM calls for the X16. I also used Claude to add the PRG-output option to the loader, and to help implement the case-folding and line-ending functionality. In all cases, I told it what to do and how to do it, and let it chase down the loose ends; not exactly a YOLO vibe coding session.
Future Plans
See the Open issues list on this repo.
My overall goal is to have a native macro assembler toolchain on the X16 (mainly) and VIC-20 (hopefully). A stretch goal is to have it be able to build itself and be fully self-hosted.