diff --git a/AGENTS.md b/AGENTS.md index 085a92a..2a271d9 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -108,13 +108,16 @@ $DD00–$DDFF CIA #2 — Serial bus, NMI timer, VIC-II bank select $E000–$FFFF Kernal ROM — Operating system (or RAM when banked out) ``` -**Memory bank control** — Location $0001 (6510 I/O port): +**Memory bank control** — Location $0001 (6510 I/O port), bits 2-0 = CHAREN HIRAM LORAM: ``` -Bits 2-0: 000 = RAM everywhere - 101 = BASIC+Kernal ROM, I/O (default) - 110 = Kernal ROM + I/O, BASIC=RAM - 111 = All ROM + I/O (normal) +%111 $37 BASIC ROM, I/O, Kernal ROM (default) +%110 $36 RAM at $A000, I/O, Kernal ROM +%101 $35 RAM at $A000 and $E000, I/O visible +%100 $34 all RAM +%011 $33 BASIC + Kernal ROM, character ROM at $D000 (no I/O) +%000 $30 all RAM ``` +BASIC ROM needs LORAM=1 and HIRAM=1. Full table: `skills/memory-map/SKILL.md`. --- @@ -122,6 +125,26 @@ Bits 2-0: 000 = RAM everywhere | Address | Dec | Name | Description | |---------|-----|------|-------------| +| $0000 | 0 | D6510 | 6510 data direction register | +| $0001 | 1 | R6510 | 6510 I/O port (memory banking, cassette) | +| $0002 | 2 | — | Unused (free for user) | +| $0014-$0015 | 20-21 | LINNUM | Integer value / line number / SYS address | +| $002B-$002C | 43-44 | TXTTAB | Start of BASIC program | +| $002D-$002E | 45-46 | VARTAB | Start of BASIC variables | +| $0033-$0034 | 51-52 | FRETOP | Bottom of string storage | +| $0037-$0038 | 55-56 | MEMSIZ | Top of BASIC RAM + 1 | +| $0061-$0066 | 97-102 | FAC1 | Floating-point accumulator #1 | +| $007A-$007B | 122-123 | TXTPTR | BASIC text pointer (inside CHRGET $73-$8A) | +| $0090 | 144 | STATUS | Kernal I/O status (ST) | +| $00A0-$00A2 | 160-162 | TIME | Jiffy clock (big-endian) | +| $00AC-$00AF | 172-175 | SAL/EAL | LOAD/SAVE current and end address | +| $00BA | 186 | FA | Current device number | +| $00C6 | 198 | NDX | Keyboard buffer count | +| $00FB-$00FE | 251-254 | FREKZP | Free zero page (user) | + +Complete table: `reference/memory-map-complete.md`. + +---------|-----|------|-------------| | $0000 | 0 | R6510 | 6510 I/O direction register | | $0001 | 1 | M6510 | 6510 I/O port (memory bank/tape) | | $0002 | 2 | — | Unused (free for user) | diff --git a/reference/memory-map-complete.md b/reference/memory-map-complete.md index 475786a..ee7998c 100644 --- a/reference/memory-map-complete.md +++ b/reference/memory-map-complete.md @@ -19,106 +19,134 @@ --- -## Zero Page — $0000–$00FF (Selected) - -| Address | Label | Description | -|---------|----------|--------------------------------------------------| -| $00 | R6510 | 6510 I/O direction register | -| $01 | R6510+1 | 6510 I/O port (RAM/ROM banking + cassette) | -| $02 | UNUSED | Free zero-page byte | -| $03–$04 | ADRAY1 | Convert float→integer vector | -| $05–$06 | ADRAY2 | Convert integer→float vector | -| $07 | CHARAC | Search character for BASIC scanner | -| $08 | ENDCHR | Flag: scan to end of BASIC line | -| $09 | TRMPOS | Terminal position for tab | -| $0A | VERCKK | LOAD (0) or VERIFY (1) flag | -| $0B | COUNT | Input buffer character count | -| $0C | DIMFLG | Default (0) or DIM flag | -| $0D | VALTYP | Type flag: 0=float, $FF=string | -| $0E | INTFLG | Integer flag | -| $0F | GARBFL | DATA scan / LIST quote / garbage collect flag | -| $10 | SUBFLG | Subscript flag for FN | -| $11 | INPFLG | INPUT (0) or GET ($40) or READ ($98) | -| $12 | TANSGN | TAN sign / comparison flag | -| $13 | CHANNL | Current I/O channel (0=keyboard/screen) | -| $14–$15 | LINNUM | Integer line number | -| $16 | TEMPPT | Pointer: next temp string | -| $17–$18 | LASTPT | Pointer: last temp string | -| $19–$21 | TEMPST | Temp string descriptor stack | -| $22–$25 | INDEX1 | Utility pointer area | -| $26–$2A | FACEXP | Floating-point accumulator #1 | -| $2B–$2C | TXTTAB | Pointer: start of BASIC text ($0801 default) | -| $2D–$2E | VARTAB | Pointer: start of BASIC variables | -| $2F–$30 | ARYTAB | Pointer: start of BASIC arrays | -| $31–$32 | STREND | Pointer: end of arrays (+1) | -| $33–$34 | FRETOP | Pointer: bottom of string storage | -| $35–$36 | FRESPC | Utility pointer for strings | -| $37–$38 | MEMSIZ | Pointer: top of memory ($A000 default) | -| $39–$3A | CURLIN | Current BASIC line number | -| $3B–$3C | OLDLIN | Previous BASIC line number | -| $3D–$3E | OLDTXT | Pointer: previous BASIC statement | -| $3F–$40 | DATLIN | Line number of current DATA statement | -| $41–$42 | DATPTR | Pointer into current DATA statement | -| $43–$44 | INPPTR | Pointer: INPUT source | -| $45–$46 | VARNAM | Current variable name | -| $47–$48 | VARPNT | Pointer: current variable value | -| $49–$4A | FORPNT | Pointer: FOR/NEXT variable | -| $4B–$4E | OPPTR | Math operator work area | -| $52–$55 | FAC2 | Floating-point accumulator #2 | -| $56 | ARGSGN | Sign comparison, FAC1 vs FAC2 | -| $57–$58 | ARISGN | Sign of result | -| $59 | FACOV | FAC1 overflow byte | -| $5A–$5B | FBUFPT | Pointer: BASIC print buffer | -| $61–$66 | FAC | FAC1 (5 bytes) | -| $69–$6E | ARG | FAC2 (5 bytes) | -| $90 | STATUS | Kernal I/O status (ST) word | -| $91 | STKEY | STOP key flag ($7F = pressed) | -| $93 | VERCK | LOAD/VERIFY flag (Kernal) | -| $94 | C3PO | Cassette: 1=write leader sent | -| $95 | BSOUR | Cassette: byte to write | -| $9A | SXREG | Serial bus I/O address | -| $9B | RDFNM | Record/file number | -| $9C | RDEVNM | Record device | -| $9D | RDSEC | Record secondary address | -| $9E | RIRQSC | RS-232 recv IRQ state | -| $9F | STATUS2 | RS-232 status | -| $A0–$A2 | TIME | 60Hz jiffy clock (24-bit, MSB=$A0) | -| $A3–$A4 | PCTR | Cassette sync / block count | -| $B0–$B5 | EAL | Kernal: device address / sector pointers | -| $BA | DFLTN | Default input device (0=keyboard) | -| $BB | DFLTO | Default output device (3=screen) | -| $BC | PRTY | Cassette parity byte | -| $BD | DPSW | Cassette EOT flag | -| $BE | MYCH | Tape character in assembly | -| $BF | CAS1 | Cassette read error correction | -| $C0 | FSBLK | Cassette read: first block flag | -| $C1–$C2 | MXPNT | Pointer: maximum BASIC variable | -| $C3–$C4 | SXPTR | Pointer to tape buffer or screen for cassette | -| $C5 | LSTX | Matrix code of last key pressed | -| $C6 | NDX | Keyboard buffer index (# chars) | -| $C7 | RVS | Reverse mode flag (1=on) | -| $C8 | INDX | Pointer: end of logical input line | -| $C9–$CA | LXSP | Cursor column and row at I/O start | -| $CB | SFDX | Flag: shift/commodore key | -| $CC | BLNSW | Cursor blink enable (0=on) | -| $CD | BLNCT | Countdown to cursor blink | -| $CE | GDBLN | Character under cursor (saved) | -| $CF | BLNON | Last blink state (0=off) | -| $D0 | CRSW | INPUT/GET mode (0=INPUT) | -| $D1–$D2 | PNT | Pointer: current screen line address | -| $D3 | PNTR | Cursor column on current line | -| $D4 | QTSW | Quoted mode flag | -| $D5 | LNMX | Logical line length (39 or 79) | -| $D6 | TBLX | Current cursor row | -| $D7 | DATA | Last character output to screen | -| $D8 | INSRT | Insert mode count | -| $D9–$F2 | LDTB1 | Screen line link table (25 entries) | -| $F3–$F4 | USER | Pointer: base of color RAM ($D800) | -| $F5–$F6 | KEYD | Pointer: keyboard decode table | -| $F7–$F8 | RIBUF | RS-232 input buffer pointer | -| $F9–$FA | ROBUF | RS-232 output buffer pointer | -| $FB–$FE | FREKZP | Free zero-page bytes (user/ML) | -| $FF | BASZPT | BASIC: temp for float-to-string | +## Zero Page – $0000–$00FF (Complete) + +> Labels follow *COMPUTE!'s Mapping the Commodore 64*. BASIC uses $02–$8F; the Kernal uses $90–$FF. +> Free for ML that keeps BASIC and the Kernal running: $02 and $FB–$FE. If BASIC is not used, +> $03–$8F may be reused (restore CHRGET at $73–$8A before returning to BASIC). + +| Address | Dec | Label | Description | +|---------|-----|-------|-------------| +| $00 | 0 | D6510 | 6510 data direction register (default $2F) | +| $01 | 1 | R6510 | 6510 I/O port: bits 0-2 LORAM/HIRAM/CHAREN banking, 3-5 cassette (default $37) | +| $02 | 2 | - | Unused; free for user programs | +| $03–$04 | 3–4 | ADRAY1 | Vector: float -> signed integer ($B1AA) | +| $05–$06 | 5–6 | ADRAY2 | Vector: integer -> float ($B391) | +| $07 | 7 | CHARAC | BASIC: search character for scanning | +| $08 | 8 | ENDCHR | BASIC: scan-for-quote / end-of-statement flag | +| $09 | 9 | TRMPOS | Cursor column before last TAB/SPC | +| $0A | 10 | VERCK | BASIC: 0 = LOAD, 1 = VERIFY | +| $0B | 11 | COUNT | Input buffer index / array dimension count | +| $0C | 12 | DIMFLG | Flag: default array DIM | +| $0D | 13 | VALTYP | Data type: $FF = string, $00 = numeric | +| $0E | 14 | INTFLG | Numeric type: $80 = integer, $00 = float | +| $0F | 15 | GARBFL | DATA scan / LIST quote / garbage-collection flag | +| $10 | 16 | SUBFLG | Subscript reference / FN call flag | +| $11 | 17 | INPFLG | 0 = INPUT, $40 = GET, $98 = READ | +| $12 | 18 | TANSGN | TAN/SIN sign; comparison result | +| $13 | 19 | CHANNL | Current I/O channel (CMD logical file); 0 = default | +| $14–$15 | 20–21 | LINNUM | Integer value / target line number (GOTO, PEEK, POKE, SYS address) | +| $16 | 22 | TEMPPT | Index to next free temporary string descriptor | +| $17–$18 | 23–24 | LASTPT | Pointer to last temporary string | +| $19–$21 | 25–33 | TEMPST | Temporary string descriptor stack (3 x 3 bytes) | +| $22–$25 | 34–37 | INDEX | Miscellaneous temporary pointers | +| $26–$2A | 38–42 | RESHO | Floating-point multiply/divide product area | +| $2B–$2C | 43–44 | TXTTAB | Start of BASIC program text (default $0801) | +| $2D–$2E | 45–46 | VARTAB | Start of BASIC variables (= end of program + 1) | +| $2F–$30 | 47–48 | ARYTAB | Start of BASIC arrays | +| $31–$32 | 49–50 | STREND | End of arrays + 1 (bottom of free RAM) | +| $33–$34 | 51–52 | FRETOP | Bottom of string storage (strings grow down) | +| $35–$36 | 53–54 | FRESPC | Utility string pointer | +| $37–$38 | 55–56 | MEMSIZ | Top of BASIC memory + 1 (default $A000) | +| $39–$3A | 57–58 | CURLIN | Current BASIC line number ($FFxx = direct mode) | +| $3B–$3C | 59–60 | OLDLIN | Line number for CONT | +| $3D–$3E | 61–62 | OLDTXT | Statement pointer for CONT | +| $3F–$40 | 63–64 | DATLIN | Line number of current DATA statement | +| $41–$42 | 65–66 | DATPTR | Pointer to current DATA item | +| $43–$44 | 67–68 | INPPTR | Pointer to INPUT/GET/READ source | +| $45–$46 | 69–70 | VARNAM | Current variable name | +| $47–$48 | 71–72 | VARPNT | Pointer to current variable's value | +| $49–$4A | 73–74 | FORPNT | Pointer to FOR/NEXT index variable | +| $4B–$4C | 75–76 | OPPTR | Math operator table displacement / temp TXTPTR save | +| $4D | 77 | OPMASK | Comparison operator mask | +| $4E–$4F | 78–79 | DEFPNT | Pointer to current FN descriptor | +| $50–$52 | 80–82 | DSCPNT | Temporary string descriptor | +| $53 | 83 | FOUR6 | Garbage-collection string step size | +| $54–$56 | 84–86 | JMPER | JMP opcode + address for function dispatch | +| $57–$60 | 87–96 | - | BASIC floating-point work area (TEMPF1/TEMPF2) | +| $61–$66 | 97–102 | FAC1 | Floating-point accumulator #1: $61 exponent, $62-$65 mantissa, $66 sign | +| $67 | 103 | SGNFLG | Series evaluation term count / sign | +| $68 | 104 | BITS | FAC1 overflow digit | +| $69–$6E | 105–110 | ARG | Floating-point accumulator #2: $69 exponent, $6A-$6D mantissa, $6E sign | +| $6F | 111 | ARISGN | Sign comparison of FAC1 vs FAC2 | +| $70 | 112 | FACOV | FAC1 low-order rounding byte | +| $71–$72 | 113–114 | FBUFPT | Pointer to number-to-string buffer / series pointer | +| $73–$8A | 115–138 | CHRGET | Self-modifying get-next-BASIC-character routine (copied from ROM at reset) | +| $79 | 121 | CHRGOT | Entry inside CHRGET: re-read current character | +| $7A–$7B | 122–123 | TXTPTR | BASIC text pointer (operand of the LDA inside CHRGET) | +| $8B–$8F | 139–143 | RNDX | RND seed (5-byte float) | +| $90 | 144 | STATUS | Kernal I/O status word ST (read with READST $FFB7) | +| $91 | 145 | STKEY | STOP-key row flag ($7F = STOP pressed) | +| $92 | 146 | SVXT | Tape timing constant | +| $93 | 147 | VERCK | Kernal: 0 = LOAD, 1 = VERIFY | +| $94 | 148 | C3PO | Serial: deferred-character flag | +| $95 | 149 | BSOUR | Serial: buffered output character | +| $96 | 150 | SYNO | Tape: block sync number | +| $97 | 151 | XSAV | Temp X/Y save for BASIN/BSOUT | +| $98 | 152 | LDTND | Number of open files (index into $0259 tables) | +| $99 | 153 | DFLTN | Current input device (0 = keyboard) | +| $9A | 154 | DFLTO | Current output device (3 = screen) | +| $9B | 155 | PRTY | Tape: character parity | +| $9C | 156 | DPSW | Tape: byte-received flag | +| $9D | 157 | MSGFLG | Kernal message control (SETMSG): $80 = direct-mode msgs, $40 = errors, 0 = none | +| $9E | 158 | PTR1 | Tape pass-1 error log / temp | +| $9F | 159 | PTR2 | Tape pass-2 error log / temp | +| $A0–$A2 | 160–162 | TIME | Jiffy clock, 24-bit big-endian (TI); updated by UDTIM each IRQ | +| $A3–$A4 | 163–164 | - | Serial/tape temp (bit counter, EOI flag) | +| $A5 | 165 | CNTDN | Tape sync countdown | +| $A6 | 166 | BUFPNT | Tape buffer index | +| $A7–$AB | 167–171 | INBIT..RIPRTY | RS-232 / tape receive work bytes | +| $AC–$AD | 172–173 | SAL | Pointer: current LOAD/SAVE/screen-scroll address | +| $AE–$AF | 174–175 | EAL | Pointer: LOAD end address + 1 / SAVE end address | +| $B0–$B1 | 176–177 | CMP0 | Tape timing | +| $B2–$B3 | 178–179 | TAPE1 | Pointer to tape buffer (default $033C) | +| $B4–$B6 | 180–182 | BITTS..RODATA | RS-232 transmit work bytes | +| $B7 | 183 | FNLEN | Current filename length (SETNAM) | +| $B8 | 184 | LA | Current logical file number (SETLFS) | +| $B9 | 185 | SA | Current secondary address (SETLFS) | +| $BA | 186 | FA | Current device number (SETLFS; last-used drive, 8 = first disk) | +| $BB–$BC | 187–188 | FNADR | Pointer to current filename (SETNAM) | +| $BD | 189 | ROPRTY | RS-232 output parity / tape byte being built | +| $BE | 190 | FSBLK | Tape: blocks remaining to read/write | +| $BF | 191 | MYCH | Tape: byte being assembled | +| $C0 | 192 | CAS1 | Tape motor interlock | +| $C1–$C2 | 193–194 | STAL | LOAD/SAVE start address | +| $C3–$C4 | 195–196 | MEMUSS | LOAD destination for secondary address 0 (relocating load) | +| $C5 | 197 | LSTX | Matrix code of last key pressed ($40 = none) | +| $C6 | 198 | NDX | Number of characters in keyboard buffer ($0277) | +| $C7 | 199 | RVS | Reverse-video flag (non-zero = on) | +| $C8 | 200 | INDX | End of logical line for INPUT | +| $C9–$CA | 201–202 | LXSP | Cursor row ($C9) / column ($CA) at start of input | +| $CB | 203 | SFDX | Matrix code of current key ($40 = none) | +| $CC | 204 | BLNSW | Cursor blink enable: 0 = flash cursor | +| $CD | 205 | BLNCT | Countdown to next cursor toggle | +| $CE | 206 | GDBLN | Screen code under cursor | +| $CF | 207 | BLNON | Cursor phase: 0 = original char shown | +| $D0 | 208 | CRSW | Input from screen (non-zero) or keyboard (0) | +| $D1–$D2 | 209–210 | PNT | Pointer to start of current screen line | +| $D3 | 211 | PNTR | Cursor column on logical line (0-79) | +| $D4 | 212 | QTSW | Quote mode flag (non-zero = on) | +| $D5 | 213 | LNMX | Current logical line length (39 or 79) | +| $D6 | 214 | TBLX | Cursor physical row (0-24) | +| $D7 | 215 | - | Temp: last character output (ASCII) / checksum | +| $D8 | 216 | INSRT | Pending inserts count | +| $D9–$F2 | 217–242 | LDTB1 | Screen line link table / line-start high bytes (25 entries) | +| $F3–$F4 | 243–244 | USER | Pointer to color RAM for current line | +| $F5–$F6 | 245–246 | KEYTAB | Pointer to current keyboard decode table | +| $F7–$F8 | 247–248 | RIBUF | Pointer to RS-232 input buffer | +| $F9–$FA | 249–250 | ROBUF | Pointer to RS-232 output buffer | +| $FB–$FE | 251–254 | FREKZP | Free zero page for user programs (4 bytes) | +| $FF | 255 | BASZPT | BASIC float-to-string temp | --- @@ -140,7 +168,7 @@ The 6510 stack grows **downward** from $01FF. SP register holds low byte of curr | $0283–$0284 | MEMSIZ | Top of memory ($A000 default) | | $0285 | TIMOUT | Serial IEEE timeout flag | | $0286 | COLOR | Current foreground color code | -| $0287 | BG COL | Color under cursor | +| $0287 | GDCOL | Color under cursor | | $0288 | HIBASE | Screen RAM page ($04 = $0400) | | $0289 | XMAX | Keyboard buffer max size (10 default) | | $028A | RPTFLG | Key repeat flag ($40=repeat all) | @@ -255,9 +283,11 @@ When HIRAM=0 or banking overrides I/O region, character ROM or RAM appears inste **Common values:** - `$37` (binary 00110111) — default: BASIC+Kernal+I/O visible - `$36` — Kernal+I/O visible, BASIC RAM underneath -- `$35` — I/O visible, both ROMs as RAM -- `$34` — all RAM, no I/O (character ROM at $D000) -- `$33` — Kernal ROM, character ROM at $D000, no I/O +- `$35` — I/O visible, RAM at $A000 and $E000 +- `$34` — all RAM (no ROM, no I/O) +- `$33` — BASIC + Kernal ROM, character ROM at $D000 instead of I/O + +BASIC ROM is visible only when LORAM and HIRAM are both 1; with both 0, $D000 is RAM regardless of CHAREN. --- diff --git a/skills/memory-map/SKILL.md b/skills/memory-map/SKILL.md index 880963c..c86bbfe 100644 --- a/skills/memory-map/SKILL.md +++ b/skills/memory-map/SKILL.md @@ -15,110 +15,137 @@ description: > ``` Address Decimal Contents (default banking) ----------- ------------- ---------------------------------------- -$0000 0 6510 I/O direction register -$0001 1 6510 I/O port (bank control/tape/motor) -$0002 2 Unused (3 free bytes: $02) -$0003-$0004 3-4 Float→integer vector (ADRAY1) -$0005-$0006 5-6 Integer→float vector (ADRAY2) -$0007 7 Search character (BASIC) -$0008 8 Quote mode flag -$0009 9 TAB column counter -$000A 10 Load/Verify flag (0=LOAD, 1=VERIFY) -$000B 11 Input buffer pointer / subscript counter -$000C 12 Default DIM flag -$000E 14 Type flag (80=integer, 00=float) -$000F 15 DATA scan / LIST quote / memory flag -$0010 16 Subscript / FNx flag -$0011 17 0=INPUT, $40=GET, $98=READ -$0012 18 ATN sign / comparison flag -$0013 19 Current I/O prompt flag -$0014-$0015 20-21 Integer value temporary -$0016 22 Pointer to temp string stack -$0017-$0018 23-24 Last temp string vector -$0019-$0021 25-33 Stack for temporary strings -$0022-$0025 34-37 Miscellaneous work area -$0026-$002A 38-42 Product area (math) -$002B-$002C 43-44 TXTTAB — pointer to start of BASIC text -$002D-$002E 45-46 VARTAB — start of variable storage -$002F-$0030 47-48 ARYTAB — start of array storage -$0031-$0032 49-50 STREND — end of array storage (+1) -$0033-$0034 51-52 FRETOP — top of free string space -$0035-$0036 53-54 FRESPC — string utility pointer -$0037-$0038 55-56 MEMSIZ — pointer to end of memory / bottom of strings -$0039-$003A 57-58 CURLIN — current BASIC line number -$003B-$003C 59-60 OLDLIN — previous BASIC line number -$003D-$003E 61-62 OLDTXT — pointer to previous BASIC statement -$003F-$0040 63-64 DATLIN — line number of current DATA statement -$0041-$0042 65-66 DATPTR — pointer to current DATA item -$0043-$0044 67-68 INPPTR — INPUT source pointer -$0045-$0046 69-70 VARNAM — name of current variable -$0047-$0048 71-72 VARPNT — pointer to current variable -$0049-$004A 73-74 FORPNT — pointer to FOR/NEXT variable -$004B 75 OPPTR — operator precedence -$004C 76 OPMASK — mask for operator -$004D-$0050 77-80 TEMPPT — temp string and area -$0051 81 LASTPT — pointer to last temp string -$0052-$0053 82-83 TEMPST — pointer to string -$0054 84 INDEX (low), INDEX+1 (high) -$005E 94 FAC#2 (floating point accumulator #2) -$0060-$0066 96-102 FAC#1 (floating point accumulator #1, 5 bytes + sign/exp) -$006F 111 Pointer to start of string being processed -$0071-$0072 113-114 RESULT — pointer to end of string -$0073 115 Jump instruction for USR -$0074-$0075 116-117 USR function address (JSR target) -$0076 118 CHARAC — search character -$007A-$007B 122-123 FNPNT — pointer for FN functions -$00AC-$00AD 172-173 STRNG1 — string 1 pointer -$00AE-$00AF 174-175 STRNG2 — string 2 pointer -$00B7 183 FNLEN — length of filename -$00B8 184 LOGICAL — logical file number -$00B9 185 DFLTO — output device number -$00BA 186 DFLTI — input device number -$00BB 187 SA — secondary address -$00BC 188 EAL — tape end address (low) -$00BD 189 EAH — tape end address (high) -$00BE 190 TAPE1 — tape buffer pointer -$00BF 191 COUNT — tape character counter -$00C0 192 INIT — tape signal level -$00C1 193 SKPO — skip byte count -$00C2 194 BPTR — tape data pointer -$00C3-$00C4 195-196 TAPE2 — tape end buffer pointer -$00C5 197 LSTX — last key pressed (keyboard matrix row) -$00C6 198 NDX — number of characters in keyboard buffer -$00C7 199 RVS — reverse mode flag (1=reverse on) -$00C8 200 INDX — end-of-line pointer for current screen line -$00C9-$00CA 201-202 LNMX — pointer to cursor on screen -$00CB 203 SCHAR — character under cursor -$00CC 204 BLNSW — cursor blink switch (0=blink) -$00CD 205 BLNCT — countdown to cursor blink -$00CE 206 GDBLN — char under cursor (save) -$00CF 207 BLNON — cursor blink status (0=off) -$00D0 208 CRSW — flag: 0=cursor in key queue, 1=not -$00D1-$00D2 209-210 PNT — pointer to cursor line in screen RAM -$00D3 211 PNTR — column of cursor on screen -$00D4 212 QTSW — quote mode flag -$00D5 213 LNMX — screen line length (39 or 79) -$00D6 214 TBLX — current cursor row (0-24) -$00D7 215 Spare byte -$00D8 216 INSRT — insert mode count -$00D9-$00F2 217-242 LDTB1 — line link table (25 lines) -$00F3-$00F4 243-244 USER — pointer to color RAM for cursor line -$00F5-$00F6 245-246 KEYTAB — pointer to keyboard decode table -$00F7-$00F8 247-248 RIBUF — RS-232 input buffer pointer -$00F9-$00FA 249-250 ROBUF — RS-232 output buffer pointer -$00FB-$00FE 251-254 FREKZP — FREE ZERO PAGE (user programs) -$00FF 255 (used by BASIC math) +$0000 0 D6510 – 6510 data direction register (default $2F) +$0001 1 R6510 – 6510 I/O port: bits 0-2 LORAM/HIRAM/CHAREN banking, 3-5 cassette (default $37) +$0002 2 Unused; free for user programs +$0003-$0004 3-4 ADRAY1 – Vector: float -> signed integer ($B1AA) +$0005-$0006 5-6 ADRAY2 – Vector: integer -> float ($B391) +$0007 7 CHARAC – BASIC: search character for scanning +$0008 8 ENDCHR – BASIC: scan-for-quote / end-of-statement flag +$0009 9 TRMPOS – Cursor column before last TAB/SPC +$000A 10 VERCK – BASIC: 0 = LOAD, 1 = VERIFY +$000B 11 COUNT – Input buffer index / array dimension count +$000C 12 DIMFLG – Flag: default array DIM +$000D 13 VALTYP – Data type: $FF = string, $00 = numeric +$000E 14 INTFLG – Numeric type: $80 = integer, $00 = float +$000F 15 GARBFL – DATA scan / LIST quote / garbage-collection flag +$0010 16 SUBFLG – Subscript reference / FN call flag +$0011 17 INPFLG – 0 = INPUT, $40 = GET, $98 = READ +$0012 18 TANSGN – TAN/SIN sign; comparison result +$0013 19 CHANNL – Current I/O channel (CMD logical file); 0 = default +$0014-$0015 20-21 LINNUM – Integer value / target line number (GOTO, PEEK, POKE, SYS address) +$0016 22 TEMPPT – Index to next free temporary string descriptor +$0017-$0018 23-24 LASTPT – Pointer to last temporary string +$0019-$0021 25-33 TEMPST – Temporary string descriptor stack (3 x 3 bytes) +$0022-$0025 34-37 INDEX – Miscellaneous temporary pointers +$0026-$002A 38-42 RESHO – Floating-point multiply/divide product area +$002B-$002C 43-44 TXTTAB – Start of BASIC program text (default $0801) +$002D-$002E 45-46 VARTAB – Start of BASIC variables (= end of program + 1) +$002F-$0030 47-48 ARYTAB – Start of BASIC arrays +$0031-$0032 49-50 STREND – End of arrays + 1 (bottom of free RAM) +$0033-$0034 51-52 FRETOP – Bottom of string storage (strings grow down) +$0035-$0036 53-54 FRESPC – Utility string pointer +$0037-$0038 55-56 MEMSIZ – Top of BASIC memory + 1 (default $A000) +$0039-$003A 57-58 CURLIN – Current BASIC line number ($FFxx = direct mode) +$003B-$003C 59-60 OLDLIN – Line number for CONT +$003D-$003E 61-62 OLDTXT – Statement pointer for CONT +$003F-$0040 63-64 DATLIN – Line number of current DATA statement +$0041-$0042 65-66 DATPTR – Pointer to current DATA item +$0043-$0044 67-68 INPPTR – Pointer to INPUT/GET/READ source +$0045-$0046 69-70 VARNAM – Current variable name +$0047-$0048 71-72 VARPNT – Pointer to current variable's value +$0049-$004A 73-74 FORPNT – Pointer to FOR/NEXT index variable +$004B-$004C 75-76 OPPTR – Math operator table displacement / temp TXTPTR save +$004D 77 OPMASK – Comparison operator mask +$004E-$004F 78-79 DEFPNT – Pointer to current FN descriptor +$0050-$0052 80-82 DSCPNT – Temporary string descriptor +$0053 83 FOUR6 – Garbage-collection string step size +$0054-$0056 84-86 JMPER – JMP opcode + address for function dispatch +$0057-$0060 87-96 BASIC floating-point work area (TEMPF1/TEMPF2) +$0061-$0066 97-102 FAC1 – Floating-point accumulator #1: $61 exponent, $62-$65 mantissa, $66 sign +$0067 103 SGNFLG – Series evaluation term count / sign +$0068 104 BITS – FAC1 overflow digit +$0069-$006E 105-110 ARG – Floating-point accumulator #2: $69 exponent, $6A-$6D mantissa, $6E sign +$006F 111 ARISGN – Sign comparison of FAC1 vs FAC2 +$0070 112 FACOV – FAC1 low-order rounding byte +$0071-$0072 113-114 FBUFPT – Pointer to number-to-string buffer / series pointer +$0073-$008A 115-138 CHRGET – Self-modifying get-next-BASIC-character routine (copied from ROM at reset) +$0079 121 CHRGOT – Entry inside CHRGET: re-read current character +$007A-$007B 122-123 TXTPTR – BASIC text pointer (operand of the LDA inside CHRGET) +$008B-$008F 139-143 RNDX – RND seed (5-byte float) +$0090 144 STATUS – Kernal I/O status word ST (read with READST $FFB7) +$0091 145 STKEY – STOP-key row flag ($7F = STOP pressed) +$0092 146 SVXT – Tape timing constant +$0093 147 VERCK – Kernal: 0 = LOAD, 1 = VERIFY +$0094 148 C3PO – Serial: deferred-character flag +$0095 149 BSOUR – Serial: buffered output character +$0096 150 SYNO – Tape: block sync number +$0097 151 XSAV – Temp X/Y save for BASIN/BSOUT +$0098 152 LDTND – Number of open files (index into $0259 tables) +$0099 153 DFLTN – Current input device (0 = keyboard) +$009A 154 DFLTO – Current output device (3 = screen) +$009B 155 PRTY – Tape: character parity +$009C 156 DPSW – Tape: byte-received flag +$009D 157 MSGFLG – Kernal message control (SETMSG): $80 = direct-mode msgs, $40 = errors, 0 = none +$009E 158 PTR1 – Tape pass-1 error log / temp +$009F 159 PTR2 – Tape pass-2 error log / temp +$00A0-$00A2 160-162 TIME – Jiffy clock, 24-bit big-endian (TI); updated by UDTIM each IRQ +$00A3-$00A4 163-164 Serial/tape temp (bit counter, EOI flag) +$00A5 165 CNTDN – Tape sync countdown +$00A6 166 BUFPNT – Tape buffer index +$00A7-$00AB 167-171 INBIT..RIPRTY – RS-232 / tape receive work bytes +$00AC-$00AD 172-173 SAL – Pointer: current LOAD/SAVE/screen-scroll address +$00AE-$00AF 174-175 EAL – Pointer: LOAD end address + 1 / SAVE end address +$00B0-$00B1 176-177 CMP0 – Tape timing +$00B2-$00B3 178-179 TAPE1 – Pointer to tape buffer (default $033C) +$00B4-$00B6 180-182 BITTS..RODATA – RS-232 transmit work bytes +$00B7 183 FNLEN – Current filename length (SETNAM) +$00B8 184 LA – Current logical file number (SETLFS) +$00B9 185 SA – Current secondary address (SETLFS) +$00BA 186 FA – Current device number (SETLFS; last-used drive, 8 = first disk) +$00BB-$00BC 187-188 FNADR – Pointer to current filename (SETNAM) +$00BD 189 ROPRTY – RS-232 output parity / tape byte being built +$00BE 190 FSBLK – Tape: blocks remaining to read/write +$00BF 191 MYCH – Tape: byte being assembled +$00C0 192 CAS1 – Tape motor interlock +$00C1-$00C2 193-194 STAL – LOAD/SAVE start address +$00C3-$00C4 195-196 MEMUSS – LOAD destination for secondary address 0 (relocating load) +$00C5 197 LSTX – Matrix code of last key pressed ($40 = none) +$00C6 198 NDX – Number of characters in keyboard buffer ($0277) +$00C7 199 RVS – Reverse-video flag (non-zero = on) +$00C8 200 INDX – End of logical line for INPUT +$00C9-$00CA 201-202 LXSP – Cursor row ($C9) / column ($CA) at start of input +$00CB 203 SFDX – Matrix code of current key ($40 = none) +$00CC 204 BLNSW – Cursor blink enable: 0 = flash cursor +$00CD 205 BLNCT – Countdown to next cursor toggle +$00CE 206 GDBLN – Screen code under cursor +$00CF 207 BLNON – Cursor phase: 0 = original char shown +$00D0 208 CRSW – Input from screen (non-zero) or keyboard (0) +$00D1-$00D2 209-210 PNT – Pointer to start of current screen line +$00D3 211 PNTR – Cursor column on logical line (0-79) +$00D4 212 QTSW – Quote mode flag (non-zero = on) +$00D5 213 LNMX – Current logical line length (39 or 79) +$00D6 214 TBLX – Cursor physical row (0-24) +$00D7 215 Temp: last character output (ASCII) / checksum +$00D8 216 INSRT – Pending inserts count +$00D9-$00F2 217-242 LDTB1 – Screen line link table / line-start high bytes (25 entries) +$00F3-$00F4 243-244 USER – Pointer to color RAM for current line +$00F5-$00F6 245-246 KEYTAB – Pointer to current keyboard decode table +$00F7-$00F8 247-248 RIBUF – Pointer to RS-232 input buffer +$00F9-$00FA 249-250 ROBUF – Pointer to RS-232 output buffer +$00FB-$00FE 251-254 FREKZP – Free zero page for user programs (4 bytes) +$00FF 255 BASZPT – BASIC float-to-string temp $0100-$01FF 256-511 6510 Stack (grows down from $01FF) $0200-$0258 512-600 Basic input buffer (80 chars) -$0259-$0262 601-610 LDTB2 — open file logical-number table -$0263-$026C 611-620 LATBL — open file device-number table -$026D-$0276 621-630 SATBL — open file secondary-address table +$0259-$0262 601-610 LAT — open-file logical-number table +$0263-$026C 611-620 FAT — open-file device-number table +$026D-$0276 621-630 SAT — open-file secondary-address table $0277-$0280 631-640 Keyboard buffer (10 chars, FIFO) $0281-$0282 641-642 MEMBOT — bottom of memory pointer $0283-$0284 643-644 MEMTOP — top of memory pointer $0285 645 TIMOUT — serial bus timeout flag $0286 646 COLOR — current text foreground color -$0287 647 BDRCLR — border color at cursor +$0287 647 GDCOL — color under cursor $0288 648 HIBASE — high byte of screen RAM base ($04 = $0400) $0289 649 XMAX — max chars in keyboard buffer (default: 10) $028A 650 RPTFLG — key repeat flag (0=cursor keys+INS/DEL only) @@ -191,16 +218,18 @@ $E000-$FFFF 57344-65535 Kernal ROM (or RAM when banked out) The C64 uses **soft banking** via location $0001 (6510 I/O port). -| $0001 Bits 2-0 | LORAM | HIRAM | CHAREN | Memory Configuration | -|-----------------|-------|-------|--------|---------------------| -| %111 (7) | BASIC ROM | Kernal ROM | I/O | **Normal (default)** | -| %110 (6) | RAM | Kernal ROM | I/O | ML programs using Kernal | -| %101 (5) | BASIC ROM | Kernal ROM | Char ROM | Character ROM visible | -| %100 (4) | RAM | RAM | I/O | All RAM + I/O | -| %011 (3) | RAM | RAM | Char ROM | All RAM + Char ROM | -| %010 (2) | RAM | RAM | Char ROM | All RAM + Char ROM | -| %001 (1) | RAM | RAM | RAM | All 64KB RAM | -| %000 (0) | RAM | RAM | RAM | All 64KB RAM | +| $0001 bits 2-0 (CHAREN HIRAM LORAM) | $A000-$BFFF | $D000-$DFFF | $E000-$FFFF | Typical use | +|-----------------|-------------|-------------|-------------|-------------| +| %111 (7) `$37` | BASIC ROM | I/O | Kernal ROM | **Normal (default)** | +| %110 (6) `$36` | RAM | I/O | Kernal ROM | ML program that still calls the Kernal | +| %101 (5) `$35` | RAM | I/O | RAM | All RAM + I/O (own IRQ vector at $FFFE) | +| %100 (4) `$34` | RAM | RAM | RAM | All 64KB RAM | +| %011 (3) `$33` | BASIC ROM | Char ROM | Kernal ROM | Read character ROM (SEI first) | +| %010 (2) `$32` | RAM | Char ROM | Kernal ROM | Read character ROM, BASIC banked out | +| %001 (1) `$31` | RAM | Char ROM | RAM | Character ROM only | +| %000 (0) `$30` | RAM | RAM | RAM | All 64KB RAM | + +BASIC ROM is visible only when LORAM and HIRAM are both 1. When LORAM and HIRAM are both 0, $D000-$DFFF is RAM regardless of CHAREN. Cartridge lines (EXROM/GAME) override this table. The VIC-II never sees these ROMs except the character ROM at $1000-$1FFF/$9000-$9FFF in VIC banks 0 and 2. Direction register at $0000 should have bits 0, 1, 2, 3, 5 as outputs: `POKE 0, 47` (default).