BASASM is a simple 6502 assembler made entirely in and for use with
Commodore BASIC V2 as implemented in the C64 home computer.
Included is a set of utilities that make it viable to work on machine
language programs of moderate size. No additional software, cartridges,
or other accessories are required. A floppy disk drive is recommended
to save programs.
The assembler consists of the base program, BASASM, and the table
of machine OPCODES in a separate file. These must be combined with
the user program in the form of DATA statements before RUNning.
This can be accomplished with the supplied LINEUTILs. An executable
MANUAL provides more instructions.
Beside its immediate purpose, LINEUTIL serves as a moderate-size
example program, comprising a set of base subroutines and multiple
top-level entry points for individual utilities.
One word of caution to temper expectations: The assembler is quite
slow, running entirely on the "unhurried" Commodore BASIC interpreter.
Processing the roughly 1000 lines of LINEUTIL takes several minutes,
so be prepared to take some breaks. :)
Speed woes aside, for a program of around 200 lines of code, BASASM
is perhaps surprisingly feature rich:
- Mnemonic instructions, aware of operand sizes.
- Decimal and hexadecimal notation.
- Symbolic labels, absolute and relative addressing.
- User-defined symbolic constants.
- Single-pass operation with forward references.
- Range checks for operands.
- High-byte and successor (+1) operators.
- Directives to output arbitrary bytes, words, strings.
- Directives to alter and limit the output position.
About 70 more lines implement subprograms to save PRG files, issue
drive commands, dump memory, and a few others. The opcode table
takes a further 80 lines for a total just shy of 350.
This repository contains listings of the relevant PRG files in
ASCII. The transfer is facilitated by two C programs that can
unpack a D64 disk image (und64) and output BASIC PRG files in plain
text (listprg). Note: Commit time stamps are not representative
beyond obviously providing upper bounds.
Files are naturally formatted to fit the limited 40x25 character
screen of the C64 and its line-wise editing workflow, so some
adjustment from modern "sensibilities" might be necessary when
reading. Note that several characters in the Commodore character
set appear different from ASCII. Notable examples:
ASCII Commodore "PETSCII"
----- -------------------
^ up arrow
_ left arrow
~ pi
\ pound (currency) sign
Finally, included here are a few programs that were produced "along
the way" during development:
HEXDUMP dump memory (stand-alone version)
HDFILE hexdump raw contents of a file
SAVEMEM save memory to PRG file (stand-alone version)
TEST.B nonsense program, test input for BASASM
PRINTNAT.B first assembly program: print a number
LINECNT.B first line utility: count BASIC program lines
TV text viewer, used in MANUAL
MKALLTOK write a PRG file that contains every possible BASIC
token (used for listprg)