# Commodore 64 Quick Reference ## Memory map overview | Range | Meaning | |---:|---| | `$0000-$00FF` | Page zero: BASIC/KERNAL workspace, pointers, fast addressing | | `$0100-$01FF` | Processor stack | | `$0200-$03FF` | System workspace, buffers, vectors | | `$0400-$07E7` | Default screen RAM | | `$07F8-$07FF` | Default sprite pointers | | `$0801` | Default BASIC program start | | `$A000-$BFFF` | BASIC ROM, RAM underneath | | `$C000-$CFFF` | Free RAM often used for ML routines | | `$D000-$DFFF` | I/O, color RAM, character ROM, or RAM depending on banking | | `$E000-$FFFF` | KERNAL ROM, RAM underneath | ## Common addresses | Dec | Hex | Name | |---:|---:|---| | 1 | `$0001` | 6510 memory banking port | | 43 | `$002B` | BASIC start pointer low | | 44 | `$002C` | BASIC start pointer high | | 55 | `$0037` | BASIC top pointer low | | 56 | `$0038` | BASIC top pointer high | | 198 | `$00C6` | Keyboard buffer count | | 646 | `$0286` | Current text color | | 780 | `$030C` | SYS A register save/pass | | 781 | `$030D` | SYS X register save/pass | | 782 | `$030E` | SYS Y register save/pass | | 783 | `$030F` | SYS status save/pass | | 788 | `$0314` | IRQ vector low | | 789 | `$0315` | IRQ vector high | | 792 | `$0318` | NMI vector low | | 793 | `$0319` | NMI vector high | | 1024 | `$0400` | Screen RAM | | 2040 | `$07F8` | Sprite pointer 0 | | 49152 | `$C000` | Common ML start | | 53248 | `$D000` | VIC-II base | | 53280 | `$D020` | Border color | | 53281 | `$D021` | Background color | | 54272 | `$D400` | SID base | | 55296 | `$D800` | Color RAM | | 56320 | `$DC00` | CIA #1 base | | 56576 | `$DD00` | CIA #2 base | ## KERNAL jump table | Hex | Routine | Purpose | |---:|---|---| | `$FF81` | CINT | Initialize screen editor | | `$FF84` | IOINIT | Initialize I/O | | `$FF87` | RAMTAS | RAM test/init | | `$FF8A` | RESTOR | Restore vectors | | `$FF8D` | VECTOR | Read/set vectors | | `$FF90` | SETMSG | Set system message flag | | `$FF93` | SECOND | Send secondary address after LISTEN | | `$FF96` | TKSA | Send secondary address after TALK | | `$FF99` | MEMTOP | Read/set top of memory | | `$FF9C` | MEMBOT | Read/set bottom of memory | | `$FF9F` | SCNKEY | Scan keyboard | | `$FFA2` | SETTMO | Set timeout | | `$FFA5` | ACPTR | Read serial byte | | `$FFA8` | CIOUT | Write serial byte | | `$FFAB` | UNTLK | Untalk | | `$FFAE` | UNLSN | Unlisten | | `$FFB1` | LISTEN | Listen | | `$FFB4` | TALK | Talk | | `$FFB7` | READST | Read status | | `$FFBA` | SETLFS | Set logical file/device/secondary address | | `$FFBD` | SETNAM | Set filename | | `$FFC0` | OPEN | Open file | | `$FFC3` | CLOSE | Close file | | `$FFC6` | CHKIN | Set input channel | | `$FFC9` | CHKOUT | Set output channel | | `$FFCC` | CLRCHN | Restore default I/O | | `$FFCF` | CHRIN | Input character | | `$FFD2` | CHROUT | Output character | | `$FFD5` | LOAD | Load from device | | `$FFD8` | SAVE | Save to device | | `$FFDB` | SETTIM | Set clock | | `$FFDE` | RDTIM | Read clock | | `$FFE1` | STOP | Check STOP key | | `$FFE4` | GETIN | Get input character | | `$FFE7` | CLALL | Close all files | | `$FFEA` | UDTIM | Update clock | | `$FFED` | SCREEN | Get screen dimensions | | `$FFF0` | PLOT | Read/set cursor position | | `$FFF3` | IOBASE | Return I/O base | ## Color codes | Code | Color | |---:|---| | 0 | Black | | 1 | White | | 2 | Red | | 3 | Cyan | | 4 | Purple | | 5 | Green | | 6 | Blue | | 7 | Yellow | | 8 | Orange | | 9 | Brown | | 10 | Light red | | 11 | Dark gray | | 12 | Gray | | 13 | Light green | | 14 | Light blue | | 15 | Light gray | ## BASIC snippets ```basic REM BORDER AND BACKGROUND POKE 53280,6:POKE 53281,0 REM PUT "A" AT UPPER LEFT AND COLOR IT RED POKE 1024,1:POKE 55296,2 REM CALL MACHINE LANGUAGE AT $C000 SYS 49152 ```