C64 Assembler

Write machine code for the C64: an editor for 6502 assembly language, an assembler with macros, loops and conditions, and a C64 next to it that runs the program at once. Breakpoints and single steps show what the processor does.

Reference
Line 1, column 1

The C64 is ready.

  • Press Ctrl+Enter to assemble and run the program.

Good to know

Writing

  • A label starts at the beginning of a line (a colon after it is allowed); instructions are indented. Labels starting with _ or @ belong to the label before them; - and + are labels without a name (bne - jumps back to the last one, ++ to the second one ahead).
  • Numbers: $c000 hexadecimal, %1010 binary, 49152 decimal, 'a' a character. < and > give the low and high byte, * the current address.
  • Keys: Tab and Shift+Tab indent, Ctrl+/ comments lines out, Ctrl+Enter runs, a click on a line number sets a breakpoint.
  • The reference buttons above the editor open a window with the instructions, the memory map, the KERNAL routines, every register of the VIC-II, SID and CIAs with its bits, the colour and character codes, and snippets of code for common jobs. F1 looks up the word at the cursor: an instruction, an address like $d020, a name like CHROUT or one of your labels. The + next to a name puts NAME = $address into the code.
  • The program starts with RUN when it begins with .basic, otherwise with SYS at the label start or at its first byte. Click the C64 screen to type on it; the number pad is a joystick in port 2.
  • The project is kept in this browser. Save it as a file to keep it for good.

Directives

* = $1000where the next bytes go
name = 5a constant
.basica BASIC line 10 SYS to the code after it (at $0801)
.byte .wordbytes and 16-bit words
.text .nulltext in PETSCII (.null adds a 0)
.screen .asciitext in screen codes, or as typed
.fill n, v  .align nn bytes; up to a multiple of n
.include .binaryanother file of the project
.if .elif .else .endifassemble only when true
name .macro a, ba macro; \a in it is the argument (.endm)
.rept nthe lines up to .endr n times
.for i = 0 to 7a loop up to .endfor
.logical $c000code that will run elsewhere (.endlogical)
.cpu "6502"no undocumented opcodes
.assert .error .warnchecks and messages