Projects‎ > ‎

QASM - QBRADQ's Assembler for 6502


QASM is my attempt at creating an assembler with many of the good qualities of CC65's assembler with the simplicity of one-shot assemblers like ASM6. There are also a few things about CA65 that I wanted to fix, like the inability to forward reference a scope.

QASM also seeks to duplicate some of CA65's more powerful features, such as the memory usage map and debugging information.

QASM requires Python 2.5 or later.


QASM is capable of assembling large, multi-file projects. It supports all official 6502 instructions and addressing modes and a small set of directives. Labels, equates, variable declarations, segments, scoping and procedures are all supported, as are macros and complex expressions.

QASM is still in an "alpha" status as it has not yet been used for a large program, and may still contain bugs. Furthermore the syntax of QASM assembler files may change prior to a 1.0 release.

Development version 0.8 jumpped the shark a bit. I am reverting back to version 0.7 and continuing on with a focus on 6502 development only.


QASM is released under the terms of the GNU GPL version 3. See the download package for details.

Planned Features

  • Version 0.9
    • Add the .alias directive to rename existing labels within a scope. This supports the pattern of using global temporary variables as local variables.
  • Version 1.0
    • Probably will never happen. There is not much community interest in "yet another assembler", so this will be maintained for my personal use only.

Things that Bug Me

  • There is no clean way to write RAM program chunks to ROM
  • It is way too easy to get memory segments all messed up
  • There is no way to get the length of a .text directive
  • There is no convenient way of defining a text table

Known Bugs

  • Semicolons in string litterals are not handled properly

Change History

Version 0.9

  • Added label file generation, including system address and ROM offset address, for external tool support

Version 0.8 (Aborted Development Branch)

  • Made assembler re-target-able
  • Implemented the 6502 target
  • Added the -t and --target command line options
  • Implemented the LMVM target (a virtual machine project I am fiddling with)
  • Added syntax highlighting definitions for the LMVM target for Notepad++
  • Added label alignment option to assembly target
  • Added field size option to assembly target
  • Added high-level language debug info interface with the .hl directive

Version 0.7

  • Macro parameter expressions are now scoped to the line invoking the macro, not the macro body
  • Added offset and length parameters to the .incbin directive
  • Added option to print the memory map to the screen following assembly
  • Added support for custom character encodings
  • Added the .encoding, .endencoding, .char, .range and .text directives
  • Fixed a bug that created invalid addresses when forward-referencing zero-page labels
  • Fixed a bug that prevented the use of labels within macros defined outside of a segment block
  • Added .__size__ default labels for data structure definitions, objects, object arrays and data tables
  • Added .__count__ default labels for objects, object arrays and data tables
  • Added .__size__ and .__count__ default labels to all .res labels

Version 0.06

  • Fixed missed requirement: macro bodies are scopes without an associated label address
  • More useful error messages for bad named value pairs
  • Fixed a crash bug that occurred when a macro parameter name masked the name of a label within the macro's parent scope
  • Added the .error directive
  • Added support for multiple symbols to the .ifdef and .ifndef directives

Version 0.05

  • Added support for data structures
  • Added .datastruct, .enddatastruct, .struct, .data, .table, .endtable, .field and .row directives
  • Fixed a large number of bugs dealing with scope resolution, duplicate label names, macro expansion and bad error messages
  • Fixed a bug that did not allow labels to be on the same line as many directives
  • Fixed a bug that did not allow labels to be on the same line as an include directive
  • Fixed a bug that prevented scope labels from being scoped themselves, or other such recursive nonsense
  • Fixed a bug that threw errors when scopes were declared outside of a segment
  • Fixed a bug that prevented expansion of a macro parameter within an expression
  • Fixed a bug that created less than useful error messages when a scope name was followed by a colon
  • Fixed a bug that caused the last line of a nested scope to be placed in the parent scope
  • Fixed a bug that assigned the wrong segment to lines created through macro expansion
  • Fixed a bug that did not allow negative 8-bit values
  • Fixed a bug that caused incorrect symbol resolution when forward-referencing a symbol within a nested scope
  • Fixed many minor issues with error messages and generally made them more helpful
  • Added a syntax highlighting definition for notepad++

Version 0.04

  • Changed from a two-pass assembler to a multi-pass assembler to make adding features easier.
  • Added support for conditional assembly
  • Renamed directive .define to .memory
  • Added directives .define, .undefine, .ifdef, .ifndef, .else and .endif
  • Removed the integer modulus operator '%'
  • Fixed a bug that prevented %00000000 binary notation from being used

Version 0.03

  • Added complex expression support

Version 0.02

  • Added macro support
  • Cleaned up some of the internal interfaces

Version 0.01

  • Added segment support
  • Added scope support
  • Added label support
  • Added equate support
  • Added procedure support
  • Added support for all official instructions and addressing modes
  • Added directives: define, segment, endsegment, ascii, byte, word, res, advance, include, incbin, scope, endscope, proc, endproc, equ, org
Subpages (1): QASM Documentation
Norman Lancaster,
Oct 23, 2012, 4:45 PM
Norman Lancaster,
May 28, 2011, 8:51 AM
Norman Lancaster,
May 31, 2011, 8:02 AM
Norman Lancaster,
May 31, 2011, 11:31 AM
Norman Lancaster,
Jun 2, 2011, 1:50 PM
Norman Lancaster,
Jun 6, 2011, 6:47 AM
Norman Lancaster,
Jun 13, 2011, 6:18 AM
Norman Lancaster,
Jun 30, 2011, 9:36 AM
Norman Lancaster,
Oct 23, 2012, 4:44 PM