-
Notifications
You must be signed in to change notification settings - Fork 78
/
c64mem_src.txt
668 lines (386 loc) · 16.9 KB
/
c64mem_src.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
- C64 RAM Map (Microsoft/Commodore)
-
- The labels and descriptions have been taken from
- Microsoft's original BASIC for M6502 source
- and
- The original C64 KERNAL source by Commodore (901227-03)
- https://github.com/mist64/cbmsrc
-
- Converted and formatted by Michael Steil <[email protected]>
-
- Corrections (typos as well as content), translations etc.
- welcome at: https://github.com/mist64/c64ref
-
------------------------------------------------------------
-
# This plain text file is formatted so that it can be automatically
# parsed in order to create cross-references etc.
# * Lines starting with "-" is top-level information. The first line
# is the title. Lines starting with "--" are separators.
# * Lines starting with "#" are internal comments.
# * Hex addresses start at column 0.
# * Symbols start at column 13.
# * The description starts at column 21.
# * All lines of the description until the first blank line are
# combined into the heading.
# * A '.' character at the end of a heading line represents a hard
# line break.
# * The remaining text is in MarkDown format.
# * All addresses are 4 digits and have a leading '$'.
# The encoding is UTF-8.
#
# KERNAL
#
$0000 D6510 6510 data direction register
$0001 R6510 6510 data register
#
# BASIC
#
$0003-$0004 ADRAY1 Store here the addr of the
routine to turn the FAC into a
two byte signed integer in [Y,A]
$0005-$0006 ADRAY2 Store here the addr of the
routine to convert [Y,A] to a floating
point number in the FAC.
$0007 CHARAC A delimiting character.
$0007 INTEGR A one-byte integer from "QINT".
$0008 ENDCHR The other delimiting character.
$0009 TRMPOS Position of terminal carriage.
$000B COUNT A general counter.
$000C DIMFLG
In getting a pointer to a variable
it is important to remember whether it
is being done for "dim" or not.
DIMFLG and VALTYP must be
consecutive locations.
$000D VALTYP The type indicator.
0=numeric 1=string.
$000E INTFLG Tells if integer.
$000F GARBFL Whether to do garbage collection.
$000F DORES Whether can or can't crunch res'd words.
Turned on when "data"
being scanned by crunch so unquoted
strings won't be crunched.
$0010 SUBFLG Flag whether sub'd variable allowed.
"FOR" and user-defined function
pointer fetching turn
this on before calling "PTRGET"
so arrays won't be detected.
"STKINI" and "PTRGET" clear it.
Also disallows integers there.
$0011 INPFLG Flags whether we are doing "INPUT"
or "READ".
$0012 TANSGN Used in determining sign of tangent.
$0012 DOMASK Mask in use by relation operations.
$0013 CHANNL Holds channel number.
$0014-$0015 LINNUM Location to store line number before BUF
so that "BLTUC" can store it all away at once.
A comma (preload or from ROM)
used by input statement since the
data pointer always starts on a
comma or terminator.
$0014-$0015 POKER Set up location used by POKE.
Temporary for input and read code
$0016 TEMPPT Pointer at first free temp descriptor.
Initialized to point to TEMPST.
$0017-$0018 LASTPT Pointer to last-used string temporary.
$0019-$0021 TEMPST Storage for NUMTMP temp descriptors.
$0022-$0025 INDEX Indexes.
$0022-$0023 INDEX1
$0024-$0025 INDEX2
$0026 RESHO Result of multiplier and divider.
$0027 RESMOH One more byte.
$0028 RESMO
$0028 ADDEND Temporary used by "UMULT".
$0029 RESLO
$002B-$002C TXTTAB Pointer to beginning of text.
Doesn't change after being
setup by "INIT".
$002D-$002E VARTAB Pointer to start of simple
variable space.
Updated whenever the size of the
program changes, set to [TXTTAB]
by "SCRATCH" ("NEW").
$002F-$0030 ARYTAB Pointer to beginning of array
table.
Incremented by 6 whenever
a new simple variable is found, and
set to [VARTAB] by "CLEARC".
$0031-$0032 STREND End of storage in use.
Increased whenever a new array
or simple variable is encountered.
set to [VARTAB] by "CLEARC".
$0033-$0034 FRETOP Top of string free space.
$0035-$0036 FRESPC Pointer to new string.
$0037-$0038 MEMSIZ Highest location in memory.
$0039-$003A CURLIN Current line #.
Set to 0,255 for direct statements.
$003B-$003C OLDLIN Old line number
Set up by ^C,"STOP"
or "END" in a program.
$003D-$003E OLDTXT Old text pointer.
Points at statement to be exec'd next.
$003F-$0040 DATLIN Data line # -- remember for errors.
$0041-$0042 DATPTR Pointer to data.
Initialized to point
at the zero in front of [TXTTAB]
by "RESTORE" which is called by "CLEARC".
updated by execution of a "READ".
$0043-$0044 INPPTR This remembers where input is coming from.
$0045-$0046 VARNAM Variable's name is stored here.
$0047-$0048 VARPNT Pointer to variable in memory.
$0047 FDECPT Pointer into power of tens of "FOUT".
$0049-$004A FORPNT A variable's pointer for "FOR" loops
and "LET" statements.
$0049 LSTPNT Pntr to list string.
$0049 ANDMSK The mask used by WAIT for ANDing.
$004A EORMSK The mask for EORing in wait.
$004B-$004C OPPTR Pointer to current op's entry in "OPTAB".
$004B VARTXT Pointer into list of variables.
$004D OPMASK Mask created by current operator.
$004E-$0052 TEMPF3 A third FAC temporary (4 bytes).
$004E-$004F DEFPNT Pointer used in function definition.
$004E GRBPNT Another used in garbage collection.
$0050-$0052 DSCPNT Pointer to a string descriptor.
$0053 FOUR6 Variable constant used by garb collect.
$0054-$0056 JMPER
$0055 SIZE
$0056 OLDOV The old overflow.
$0057-$005B TEMPF1
$0058 HIGHDS Destination of highest element in BLT.
$005A HIGHTR Source of highest element to move.
$005C-$0060 TEMPF2
$005D LOWDS Location of last byte transferred into.
$005F LOWTR Last thing to move in BLT.
$0058 ARYPNT A pointer used in array building.
$005F GRBTOP A pointer used in garbage collection.
$005D DECCNT Number of places before decimal point.
$005E TENEXP Has a DPT been input?
$005F DPTFLG Base ten exponent.
$0060 EXPSGN Sign of base ten exponent.
$0061-$0066 FAC The floating accumulator
$0061 FACEXP
$0061 DSCTMP This is where temp descs are built.
$0062 FACHO Most significant byte of mantissa.
$0063 FACMOH One more.
$0064 FACMO Middle order of mantissa.
$0064 INDICE Indice is set up here by "QINT".
$0065 FACLO Least sig byte of mantissa.
$0066 FACSGN Sign of FAC (0 or -1) when unpacked.
$0067 SGNFLG Sign of FAC is preserved bere by "FIN".
$0067 DEGREE A count used by polynomials.
$0068 BITS Something for "SHIFTR" to use.
$0069-$006E The floating argument (unpacked)
$0069 ARGEXP
$006A ARGHO
$006B ARGMOH
$006C ARGMO
$006D ARGLO
$006E ARGSGN
$006F ARISGN A sign reflecting the result.
$006F-$0070 STRNG1 Pointer to a string or descriptor.
$0070 FACOV Overflow byte of the FAC.
$0071-$0072 FBUFPT Pointer into FBUFFR used by FOUT.
$0071-$0072 BUFPTR Pointer to buf used by "CRUNCH".
$0071-$0072 STRNG2 Pointer to string or desc.
$0071-$0072 POLYPT Pointer into polynomial coefficients.
$0071-$0072 CURTOL Absolute linear index is formed here.
$0073-$008A CHRGET RAM code.
This code gets changed throughout execution.
It is made to be fast this way.
Also, [X] and [Y] are not disturbed.
"CHRGET" using [TXTPTR] as the current text pntr,
fetches a new character into ACCA after incrementing [TXTPTR]
and sets condition codes according to what's in ACCA.
* not C = numeric ("0" thru "9")
* Z = ":" or end-of-line (a null)
[ACCA] = new char.
[TXTPTR]=[TXTPTR]+1
The following exists in ROM if ROM exists and is loaded
down here by init. Otherwise it is just loaded into this
RAM like all the rest of RAM is loaded.
$008B-$008F RNDX
#
# KERNAL
#
$0090 STATUS I/O operation status byte
$0091 STKEY STOP key flag
$0092 SVXT Cassette: temp used to adjust software servo
$0093 VERCK Cassette: verify or load flag (Z - loading)
$0094 C3P0 IEEE buffered char flag
$0095 BSOUR Char buffer for IEEE
$0096 SYNO Cassette: flags if we have block SYNC (16 zero dipoles)
$0097 XSAV Temp for BASIN
$0098 LDTND Index to logical file
$0099 DFLTN Default input device #
$009A DFLTO Default output device #
$009B PRTY Cassette: holds current calculated parity bit
$009C DPSW Cassette: if NZ then expecting LL/L combination that ends a byte
$009D MSGFLG OS message flag
$009E PTR1 Cassette: count of read locations in error (pointer into bad, max 61)
$009E T1 Temporary 1
$009F PTR2 Cassette: count of re-read locations (pointer into bad, during re-read)
$009F T2 Temporary 2
$00A0-$00A2 TIME 24 hour clock in 1/60th seconds
$00A3 R2D2 Serial bus usage
$00A3 PCNTR Cassette: counts down from 8-0 for data then to ff for parity
$00A4 BSOUR1 Temp used by serial routine
$00A4 FIRT Cassette: used to indicate which half of dipole we're in
$00A5 COUNT Temp used by serial routine
$00A5 CNTDN Cassette sync countdown
$00A6 BUFPT Cassette buffer pointer
$00A7 INBIT RS-232 rcvr input bit storage
$00A7 SHCNL Cassette: holds FSBLK, used to direct routines, because of exit case
$00A8 BITCI RS-232 rcvr bit count in
$00A8 RER Cassette: flags errors (if Z then no error)
$00A9 RINONE RS-232 rcvr flag for start bit check
$00A9 REZ Cassette: counts zeros (if Z then correct # of dipoles)
$00AA RIDATA RS-232 rcvr byte buffer
$00AA RDFLG Cassette: holds function mode
MI - waiting for block SYNC
VS - in data block reading data
NE - waiting for byte SYNC
$00AB RIPRTY RS-232 rcvr parity storage
$00AB SHCNH Cassette: short cnt; left over from debugging
$00AC SAL Cassette: indirect to data storage area
$00AD SAH
$00AE EAL
$00AF EAH
$00B0 CMP0 Cassette: software servo (+/- adjust to time calcs)
$00B1 TEMP Cassette: used to hold dipole time during type calculations
$00B2-$00B3 TAPE1 Address of tape buffer #1y.
$00B4 BITTS RS-232 trns bit count
$00B4 SNSW1 Cassette: flags if we have byte SYNC (a longlong)
$00B5 NXTBIT RS-232 trns next bit to be sent
$00B5 DIFF Cassette: used to preserve SYNO (outside of bit routines)
$00B6 RODATA RS-232 trns byte buffer
$00B6 PRP Cassette: has combined error values from bit routines
$00B7 FNLEN Length current file n str
$00B8 LA Current file logical addr
$00B9 SA Current file 2nd addr
$00BA FA Current file primary addr
$00BB-$00BC FNADR Addr current file name str
$00BD ROPRTY RS-232 trns parity buffer
$00BD OCHAR
$00BE FSBLK Cassette: indicate which block we're looking at (0 to exit)
$00BF MYCH Cassette: holds input byte being built
$00C0 CAS1 Cassette manual/controlled switch
$00C1 TMP0
$00C1 STAL
$00C2 STAH
$00C3-$00C4 MEMUSS Cassette load temps (2 bytes)
$00C3-$00C4 TMP2
$00C5 LSTX Key scan index
$00C6 NDX Index to keyboard q
$00C7 RVS RVS field on flag
$00C8 INDX
$00C9 LSXP X pos at start
$00CA LSTP
$00CB SFDX SHIFT mode on print
$00CC BLNSW Cursor blink enab
$00CD BLNCT Count to toggle cur
$00CE GDBLN Char before cursor
$00CF BLNON On/off blink flag
$00D0 CRSW INPUT vs GET flag
$00D1-$00D2 PNT Pointer to row
$00D3 PNTR Pointer to column
$00D4 QTSW Quote switch
$00D5 LNMX 40/80 max positon
$00D6 TBLX
$00D7 DATA Cassette: holds most recent dipole bit value
$00D8 INSRT Insert mode flag
$00D9-$00F2 LDTB1 Line flags+endspace
$00F3-$00F4 USER Screen editor color IP
$00F5-$00F6 KEYTAB Keyscan table indirect
$00F7-$00F8 RIBUF RS-232 input buffer pointer
$00F9-$00FA ROBUF RS-232 output buffer pointer
$00FB-$00FE FREKZP Free KERNAL zero page 9/24/80
$00FF-$010A BASZPT Location ($00FF) used by BASIC
$0100-$013E BAD Cassette: storage space for bad read locations (bottom of stack)
#
# BASIC
#
$0200-$0258 BUF BASIC/MONITOR buffer
Type-in stored here.
Direct statements execute out of
here. Remember "INPUT" smashes buf.
Must be on page zero
or assignment of string
values in direct statements won't copy
into string space -- which it must.
N.B.: Two nonzero bytes must precede "BUFLNM".
#
# KERNAL
#
$0259-$0262 LAT Logical file numbers
$0263-$026C FAT Primary device numbers
$026D-$0276 SAT Secondary addresses
$0277-$0280 KEYD IRQ keyboard buffer
$0281-$0282 MEMSTR Start of memory
$0283-$0284 MEMSIZ Top of memory
$0285 TIMOUT IEEE timeout flag
$0286 COLOR Active color nybble
$0287 GDCOL Original color before cursor
$0288 HIBASE Base location of screen (top)
$0289 XMAX
$028A RPTFLG Key repeat flag
$028B KOUNT
$028C DELAY
$028D SHFLAG SHIFT flag byte
$028E LSTSHF Last SHIFT pattern
$028F-$0290 KEYLOG Indirect for keyboard table setup
$0291 MODE 0-PET mode, 1-cattacanna
$0292 AUTODN Auto scroll down flag(=0 on,<>0 off)
$0293 M51CTR 6551 control register
$0294 M51CDR 6551 command register
$0295-$0296 M51AJB Non standard (bittime/2-100)
$0297 RSSTAT RS-232 status register
$0298 BITNUM Number of bits to send (fast response)
$0299-$029A BAUDOF Baud rate full bit time (created by open)
$029B RIDBE Input buffer index to end
$029C RIDBS Input buffer pointer to start
$029D RODBS Output buffer index to start
$029E RODBE Output buffer index to end
$029F-$02A0 IRQTMP Holds irq during tape ops
$02A1 ENABL RS-232 enables (replaces ier)
$02A2 CASTON TOD sense during cassettes
$02A3 KIKA26 Cassette: holds old D1ICR after clear on read
$02A4 STUPID Cassette: hold indicator (NZ - no T1IRQ yet) for T1IRQ
$02A5 LINTMP Temporary for line index
$02A6 PALNTS PAL vs NTSC flag 0=NTSC 1=PAL
#
# BASIC
#
$0300-$0301 IERROR indirect ERROR (output error in .X)
$0302-$0303 IMAIN indirect MAIN (system direct loop)
$0304-$0305 ICRNCH indirect CRUNCH (tokenization routine)
$0306-$0307 IQPLOP indirect LIST (char list)
$0308-$0309 IGONE indirect GONE (char dispatch)
$030A-$030B IEVAL indirect EVAL (symbol evaluation)
$030C SAREG .A reg
$030D SXREG .X reg
$030E SYREG .Y reg
$030F SPREG .P reg
$0310-$0312 USRPOK user function dispatch
#
# KERNAL
#
$0314-$0315 CINV IRQ RAM vector
$0316-$0317 CBINV BRK instr RAM vector
$0318-$0319 NMINV NMI RAM vector
$031A-$032D Indirects for code
Conforms to KERNAL spec 8/19/80
$031A-$031B IOPEN
$031C-$031D ICLOSE
$031E-$031F ICHKIN
$0320-$0321 ICKOUT
$0322-$0323 ICLRCH
$0324-$0325 IBASIN
$0326-$0327 IBSOUT
$0328-$0329 ISTOP
$032A-$032B IGETIN
$032C-$032D ICLALL
$032E-$032F USRCMD
$0330-$0331 ILOAD
$0332-$0333 ISAVE savesp
$033C-$03FB TBUFFR cassette data b