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.
Line 1, column 1
Click here to type on the C64
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:
$c000hexadecimal,%1010binary,49152decimal,'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 likeCHROUTor one of your labels. The + next to a name putsNAME = $addressinto the code. - The program starts with RUN when it begins with
.basic, otherwise with SYS at the labelstartor 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
| * = $1000 | where the next bytes go |
|---|---|
| name = 5 | a constant |
| .basic | a BASIC line 10 SYS to the code after it (at $0801) |
| .byte .word | bytes and 16-bit words |
| .text .null | text in PETSCII (.null adds a 0) |
| .screen .ascii | text in screen codes, or as typed |
| .fill n, v .align n | n bytes; up to a multiple of n |
| .include .binary | another file of the project |
| .if .elif .else .endif | assemble only when true |
| name .macro a, b | a macro; \a in it is the argument (.endm) |
| .rept n | the lines up to .endr n times |
| .for i = 0 to 7 | a loop up to .endfor |
| .logical $c000 | code that will run elsewhere (.endlogical) |
| .cpu "6502" | no undocumented opcodes |
| .assert .error .warn | checks and messages |