Asm6502 is an assembler for the MOS Technology 6502. The generated PRG output files can be loaded into an C64 emulator.
-
Clone the repository and within the project directory type:
$ stack build --copy-bins
The commandline syntax for Asm6502 is:
asm6502 [options]
Possible options are:
-
-h,-?or--helpPrint a help message and quit. -
-vor--versionPrint the version information and quit. -
-sor--symtabFor debugging purposes. Prints information about resolved symbol addresses. -
-dor--dparseFor debugging purposes. The input program, as interpreted by the parser, is printed into a file in addition to the normal operation. If the input file is named e.g.input.asmthe debug output will be written toinput.parsed.asm. -
-o FILEor--output=FILESet the name of the output file for the assembled program. If not specified, an input file like e.g.input.asmis by default assembled toinput.prgorinput.hexdepending on the selected output format. -
-f FORMATor--format=FORMATSet the output format of the assembler to eitherPRG(a simple binary format) orHEX(a hexdump). If not specified, the default output format isPRG.
Before parsing the commandline, any argument starting with an @ symbol is interpreted as a file path. The argument on the command line is replaced with the contents of this file - each line as a new argument. Note, that there is no recursive replacement. For example, assume a file named afile with the following content:
-f
HEX
-d
-o
out.hex
Then a commandline like:
asm6502 @/path/to/afile input.asm
will be transformed to:
asm6502 -f HEX -d -o out.hex input.asm
Asm6502 supports the following directives:
-
Name EQU ConstantDefines a symbolicNameas an alias for a constant value. Example:VSCRBASE EQU $7000
-
ORG ConstantDefines the target address where Asm6502 will continue assembling its output to. Example:ORG $2000
-
Labelname:Define a new label. -
HEXDATA <list of hexadecimal values>The list of hexadecimal values is not modified and forwarded to the assembler output at the current address. Example:HEXDATA $30 $31 $32 $33 $34 $35 $36 $37
-
STRING "stringliteral"LikeHEXDATAthe given ASCII string is directly forwarded to the assembler output at the current address. Example:STRING "ABCD"
is equivalent to:
HEXDATA $41 $42 $43 $44
-
CBMSTRING "stringliteral"LikeSTRINGbut lower case letters (ASCII $61 to $7A) are mapped to the range from $01 to $1A. Example:CBMSTRING "abcd"
is equivalent to:
HEXDATA $01 $02 $03 $04
-
BYTE BytevaluePut a single byte value (8 bits) to the assembler output. Example:BYTE $a5
-
WORD WordvaluePut a single word value (16 bits) to the assembler output. Encoding is little endian. Example:WORD $a5b6
-
INCLUDE-PRG "filename"Read the specified file inPRGformat and add its contents directly to the assembler output. The specified filename can be an absolute or relative file path. The latter is interpreted as relative to the input file of Asm6502. Example:INCLUDE-PRG "/path/to/a/input.prg"
- Binary values start with a percent sign, e.g.
%1110. - Octal values start with a zero, e.g.
016. - Decimal values start with a non-zero decimal digit, e.g.
14. - Hexadecimal values start with a dollar sign, e.g.
$0e.