-
Notifications
You must be signed in to change notification settings - Fork 78
/
c64disasm_mm.txt
8532 lines (8107 loc) · 279 KB
/
c64disasm_mm.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
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
- Fully Commented Commodore 64 ROM Disassembly (Marko Mäkelä)
-
- CBMBASIC and KERNAL
-
- The comments have been taken from
- Commodore 64 BASIC/KERNAL ROM Disassembly
- Version 1.0 (June 1994), by Marko Mäkelä
-
- The ROM is the 901227-03 version ($FF80 = 3).
-
- Converted and formatted by Michael Steil <mist64@mac.com>
-
- Corrections (typos, formatting, content) 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.
# * Lines starting with ".," indicate code to be disassembled.
# * Lines starting with ".:" indicate bytes to be dumped.
# * Comments start at the 33rd column.
# * 32 leading spaces and "***" indicate a heading. (Please leave one
# line blank above every heading.)
# * Otherwise, 32 leading spaces indicate an overflow comment.
# The encoding is UTF-8.
.:A000 94 E3 RESET
.:A002 7B E3 Warm Start
*** CBMBASIC
.:A004 43 42 4D 42 41 53 49 43
*** address table for commands
(address minus 1 used)
.:A00C 30 A8 end
.:A00E 41 A7 for
.:A010 1D AD next
.:A012 F7 A8 data
.:A014 A4 AB input#
.:A016 BE AB input
.:A018 80 B0 dim
.:A01A 05 AC read
.:A01C A4 A9 let
.:A01E 9F A8 goto
.:A020 70 A8 run
.:A022 27 A9 if
.:A024 1C A8 restore
.:A026 82 A8 gosub
.:A028 D1 A8 return
.:A02A 3A A9 rem
.:A02C 2E A8 stop
.:A02E 4A A9 on
.:A030 2C B8 wait
.:A032 67 E1 load
.:A034 55 E1 save
.:A036 64 E1 verify
.:A038 B2 B3 def
.:A03A 23 B8 poke
.:A03C 7F AA print#
.:A03E 9F AA print
.:A040 56 A8 cont
.:A042 9B A6 list
.:A044 5D A6 clr
.:A046 85 AA cmd
.:A048 29 E1 sys
.:A04A BD E1 open
.:A04C C6 E1 close
.:A04E 7A AB get
.:A050 41 A6 new
*** address table for functions
.:A052 39 BC sgn
.:A054 CC BC int
.:A056 58 BC abs
.:A058 10 03 usr
.:A05A 7D B3 fre
.:A05C 9E B3 pos
.:A05E 71 BF sqr
.:A060 97 E0 rnd
.:A062 EA B9 log
.:A064 ED BF exp
.:A066 64 E2 cos
.:A068 6B E2 sin
.:A06A B4 E2 tan
.:A06C 0E E3 atn
.:A06E 0D B8 peek
.:A070 7C B7 len
.:A072 65 B4 str$
.:A074 AD B7 val
.:A076 8B B7 asc
.:A078 EC B6 chr$
.:A07A 00 B7 left$
.:A07C 2C B7 right$
.:A07E 37 B7 mid$
*** priority and address table for operators
(address minus 1 used)
.:A080 79 69 B8 plus
.:A083 79 52 B8 minus
.:A086 7B 2A BA multiply
.:A089 7B 11 BB divide
.:A08C 7F 7A BF power
.:A08F 50 E8 AF AND
.:A092 46 E5 AF OR
.:A095 7D B3 BF negative
.:A098 5A D3 AE NOT
.:A09B 64 15 B0 greater / equal / less
*** table of commands
each ended with a +$80
.:A09E 45 4E C4 end
.:A0A1 46 4F D2 for
.:A0A4 4E 45 58 D4 next
.:A0A8 44 41 54 C1 data
.:A0AC 49 4E 50 55 54 A3 input#
.:A0B2 49 4E 50 55 D4 input
.:A0B7 44 49 CD dim
.:A0BA 52 45 41 C4 read
.:A0BE 4C 45 D4 let
.:A0C1 47 4F 54 CF goto
.:A0C5 52 55 CE run
.:A0C8 49 C6 if
.:A0CA 52 45 53 54 4F 52 C5 restore
.:A0D1 47 4F 53 55 C2 gosub
.:A0D6 52 45 54 55 52 CE return
.:A0DC 52 45 CD rem
.:A0DF 53 54 4F D0 stop
.:A0E3 4F CE on
.:A0E5 57 41 49 D4 wait
.:A0E9 4C 4F 41 C4 load
.:A0ED 53 41 56 C5 save
.:A0F1 56 45 52 49 46 D9 verify
.:A0F7 44 45 C6 def
.:A0FA 50 4F 4B C5 poke
.:A0FE 50 52 49 4E 54 A3 print#
.:A104 50 52 49 4E D4 print
.:A109 43 4F 4E D4 cont
.:A10D 4C 49 53 D4 list
.:A111 43 4C D2 clr
.:A114 43 4D C4 cmd
.:A117 53 59 D3 sys
.:A11A 4F 50 45 CE open
.:A11E 43 4C 4F 53 C5 close
.:A123 47 45 D4 get
.:A126 4E 45 D7 new
*** table of functions
each ended with a +$80
.:A129 54 41 42 A8 tab(
.:A12D 54 CF to
.:A12F 46 CE fn
.:A131 53 50 43 A8 spc(
.:A135 54 48 45 CE then
.:A139 4E 4F D4 not
.:A13C 53 54 45 D0 step
.:A140 AB plus
.:A141 AD minus
.:A142 AA multiply
.:A143 AF divide
.:A144 DE power
.:A145 41 4E C4 and
.:A148 4F D2 on
.:A14A BE greater
.:A14B BD equal
.:A14C BC less
.:A14D 53 47 CE sgn
.:A150 49 4E D4 int
.:A153 41 42 D3 abs
.:A156 55 53 D2 usr
.:A159 46 52 C5 fre
.:A15C 50 4F D3 pos
.:A15F 53 51 D2 sqr
.:A162 52 4E C4 rnd
.:A165 4C 4F C7 log
.:A168 45 58 D0 exp
.:A16B 43 4F D3 cos
.:A16E 53 49 CE sin
.:A171 54 41 CE tan
.:A174 41 54 CE atn
.:A177 50 45 45 CB peek
.:A17B 4C 45 CE len
.:A17E 53 54 52 A4 str$
.:A182 56 41 CC val
.:A185 41 53 C3 asc
.:A188 43 48 52 A4 chr$
.:A18C 4C 45 46 54 A4 left$
.:A191 52 49 47 48 54 A4 right$
.:A197 4D 49 44 A4 mid$
*** other commands
.:A198 49 44 A4 47 CF
.:A19D 00
*** table of error messages
each ended with a +$80
.:A19E 54 4F 4F 20 4D 41 4E 59 too many files
.:A1A6 20 46 49 4C 45 D3
.:A1AC 46 49 4C 45 20 4F 50 45 file open
.:A1B4 CE
.:A1B5 46 49 4C 45 20 4E 4F 54 file not open
.:A1BD 20 4F 50 45 CE
.:A1C2 46 49 4C 45 20 4E 4F 54 file not found
.:A1CA 20 46 4F 55 4E C4
.:A1D0 44 45 56 49 43 45 20 4E device not present
.:A1D8 4F 54 20 50 52 45 53 45
.:A1E0 4E D4
.:A1E2 4E 4F 54 20 49 4E 50 55 not input file
.:A1EA 54 20 46 49 4C C5
.:A1F0 4E 4F 54 20 4F 55 54 50 not output file
.:A1F8 55 54 20 46 49 4C C5
.:A1FF 4D 49 53 53 49 4E 47 20 missing file name
.:A207 46 49 4C 45 20 4E 41 4D
.:A20F C5
.:A210 49 4C 4C 45 47 41 4C 20 illegal device number
.:A218 44 45 56 49 43 45 20 4E
.:A220 55 4D 42 45 D2
.:A225 4E 45 58 54 20 57 49 54 next without for
.:A22D 48 4F 55 54 20 46 4F D2
.:A235 53 59 4E 54 41 D8 syntax
.:A23B 52 45 54 55 52 4E 20 57 return without gosub
.:A243 49 54 48 4F 55 54 20 47
.:A24B 4F 53 55 C2
.:A24F 4F 55 54 20 4F 46 20 44 out of data
.:A257 41 54 C1
.:A25A 49 4C 4C 45 47 41 4C 20 illegal quantity
.:A262 51 55 41 4E 54 49 54 D9
.:A26A 4F 56 45 52 46 4C 4F D7 overflow
.:A272 4F 55 54 20 4F 46 20 4D out of memory
.:A27A 45 4D 4F 52 D9
.:A27F 55 4E 44 45 46 27 44 20 undef'd statement
.:A287 53 54 41 54 45 4D 45 4E
.:A28F D4
.:A290 42 41 44 20 53 55 42 53 bad subscript
.:A298 43 52 49 50 D4
.:A29D 52 45 44 49 4D 27 44 20 redim'd array
.:A2A5 41 52 52 41 D9
.:A2AA 44 49 56 49 53 49 4F 4E division by zero
.:A2B2 20 42 59 20 5A 45 52 CF
.:A2BA 49 4C 4C 45 47 41 4C 20 illegal direct
.:A2C2 44 49 52 45 43 D4
.:A2C8 54 59 50 45 20 4D 49 53 type mismatch
.:A2D0 4D 41 54 43 C8
.:A2D5 53 54 52 49 4E 47 20 54 string to long
.:A2DD 4F 4F 20 4C 4F 4E C7
.:A2E4 46 49 4C 45 20 44 41 54 file data
.:A2EC C1
.:A2ED 46 4F 52 4D 55 4C 41 20 formula too complex
.:A2D5 54 4F 4F 20 43 4F 4D 50
.:A2DD 4C 45 D8
.:A300 43 41 4E 27 54 20 43 4F can't continue
.:A308 4E 54 49 4E 55 C5
.:A30E 55 4E 44 45 46 27 44 20 undef'd function
.:A316 46 55 4E 43 54 49 4F CE
.:A31E 56 45 52 49 46 D9 verify
.:A324 4C 4F 41 C4 load
*** error message address locations
.:A328 9E A1 01 too many files
.:A32A AC A1 02 file open
.:A32C B5 A1 03 file not open
.:A32E C2 A1 04 file not found
.:A330 D0 A1 05 device not present
.:A332 E2 A1 06 not input file
.:A334 F0 A1 07 not output file
.:A336 FF A1 08 missing file name
.:A338 10 A2 09 illegal device number
.:A33A 25 A2 0A next without for
.:A33C 35 A2 0B syntax
.:A33E 3B A2 0C return without gosub
.:A340 4F A2 0D out of data
.:A342 5A A2 0E illegal quantity
.:A344 6A A2 0F overflow
.:A346 72 A2 10 out of memory
.:A348 7F A2 11 undef'd statment
.:A34A 90 A2 12 bad subscript
.:A34C 9D A2 13 redim'd array
.:A34E AA A2 14 devision by zero
.:A350 BA A2 15 illegal direct
.:A352 C8 A2 16 type mismatch
.:A354 D5 A2 17 string too long
.:A356 E4 A2 18 file data
.:A358 ED A2 19 formula too complex
.:A35A 00 A3 1A can't continue
.:A35C 0E A3 1B undef'd function
.:A35E 1E A3 1C verify
.:A360 24 A3 1D load
.:A362 83 A3 1E break
*** other messages
.:A364 0D 4F 4B 0D 00 ok
.:A369 20 20 45 52 52 4F 52 00 error
.:A371 20 49 4E 20 00 in
.:A376 0D 0A 52 45 41 44 59 2E ready.
.:A37D 0D 0A 00
.:A381 0D 0A 42 52 45 41 4B 00 break
.:A389 A0
*** search for "for" blocks on stack
.,A38A BA TSX
.,A38B E8 INX
.,A38C E8 INX
.,A38D E8 INX
.,A38E E8 INX
.,A38F BD 01 01 LDA $0101,X
.,A392 C9 81 CMP #$81 for block code
.,A394 D0 21 BNE $A3B7
.,A396 A5 4A LDA $4A
.,A398 D0 0A BNE $A3A4
.,A39A BD 02 01 LDA $0102,X
.,A39D 85 49 STA $49
.,A39F BD 03 01 LDA $0103,X
.,A3A2 85 4A STA $4A
.,A3A4 DD 03 01 CMP $0103,X
.,A3A7 D0 07 BNE $A3B0
.,A3A9 A5 49 LDA $49
.,A3AB DD 02 01 CMP $0102,X
.,A3AE F0 07 BEQ $A3B7
.,A3B0 8A TXA
.,A3B1 18 CLC
.,A3B2 69 12 ADC #$12
.,A3B4 AA TAX
.,A3B5 D0 D8 BNE $A38F
.,A3B7 60 RTS
*** move bytes after check for space
.,A3B8 20 08 A4 JSR $A408
.,A3BB 85 31 STA $31
.,A3BD 84 32 STY $32
*** move bytes routine
$5F/$60 source start address
$5A/$5B source end address
$58/$59 destination end address
.,A3BF 38 SEC
.,A3C0 A5 5A LDA $5A
.,A3C2 E5 5F SBC $5F
.,A3C4 85 22 STA $22
.,A3C6 A8 TAY
.,A3C7 A5 5B LDA $5B
.,A3C9 E5 60 SBC $60
.,A3CB AA TAX
.,A3CC E8 INX
.,A3CD 98 TYA
.,A3CE F0 23 BEQ $A3F3
.,A3D0 A5 5A LDA $5A
.,A3D2 38 SEC
.,A3D3 E5 22 SBC $22
.,A3D5 85 5A STA $5A
.,A3D7 B0 03 BCS $A3DC
.,A3D9 C6 5B DEC $5B
.,A3DB 38 SEC
.,A3DC A5 58 LDA $58
.,A3DE E5 22 SBC $22
.,A3E0 85 58 STA $58
.,A3E2 B0 08 BCS $A3EC
.,A3E4 C6 59 DEC $59
.,A3E6 90 04 BCC $A3EC
.,A3E8 B1 5A LDA ($5A),Y
.,A3EA 91 58 STA ($58),Y
.,A3EC 88 DEY
.,A3ED D0 F9 BNE $A3E8
.,A3EF B1 5A LDA ($5A),Y
.,A3F1 91 58 STA ($58),Y
.,A3F3 C6 5B DEC $5B
.,A3F5 C6 59 DEC $59
.,A3F7 CA DEX
.,A3F8 D0 F2 BNE $A3EC
.,A3FA 60 RTS
*** test for 2 * A bytes free on stack
.,A3FB 0A ASL
.,A3FC 69 3E ADC #$3E
.,A3FE B0 35 BCS $A435
.,A400 85 22 STA $22
.,A402 BA TSX
.,A403 E4 22 CPX $22
.,A405 90 2E BCC $A435
.,A407 60 RTS
*** array area overflow check
.,A408 C4 34 CPY $34
.,A40A 90 28 BCC $A434
.,A40C D0 04 BNE $A412
.,A40E C5 33 CMP $33
.,A410 90 22 BCC $A434
.,A412 48 PHA
.,A413 A2 09 LDX #$09
.,A415 98 TYA
.,A416 48 PHA
.,A417 B5 57 LDA $57,X
.,A419 CA DEX
.,A41A 10 FA BPL $A416
.,A41C 20 26 B5 JSR $B526
.,A41F A2 F7 LDX #$F7
.,A421 68 PLA
.,A422 95 61 STA $61,X
.,A424 E8 INX
.,A425 30 FA BMI $A421
.,A427 68 PLA
.,A428 A8 TAY
.,A429 68 PLA
.,A42A C4 34 CPY $34
.,A42C 90 06 BCC $A434
.,A42E D0 05 BNE $A435
.,A430 C5 33 CMP $33
.,A432 B0 01 BCS $A435
.,A434 60 RTS
*** out of memory error
.,A435 A2 10 LDX #$10 error number
*** handle error messages
.,A437 6C 00 03 JMP ($0300) normally A43A
*** standard error message handler
.,A43A 8A TXA
.,A43B 0A ASL
.,A43C AA TAX
.,A43D BD 26 A3 LDA $A326,X
.,A440 85 22 STA $22
.,A442 BD 27 A3 LDA $A327,X
.,A445 85 23 STA $23
.,A447 20 CC FF JSR $FFCC
.,A44A A9 00 LDA #$00
.,A44C 85 13 STA $13
.,A44E 20 D7 AA JSR $AAD7
.,A451 20 45 AB JSR $AB45
.,A454 A0 00 LDY #$00
.,A456 B1 22 LDA ($22),Y
.,A458 48 PHA
.,A459 29 7F AND #$7F
.,A45B 20 47 AB JSR $AB47
.,A45E C8 INY
.,A45F 68 PLA
.,A460 10 F4 BPL $A456
.,A462 20 7A A6 JSR $A67A
.,A465 A9 69 LDA #$69 low A369
.,A467 A0 A3 LDY #$A3 high A369
.,A469 20 1E AB JSR $AB1E
.,A46C A4 3A LDY $3A
.,A46E C8 INY
.,A46F F0 03 BEQ $A474
.,A471 20 C2 BD JSR $BDC2
.,A474 A9 76 LDA #$76 low A376
.,A476 A0 A3 LDY #$A3 low A376
.,A478 20 1E AB JSR $AB1E
.,A47B A9 80 LDA #$80
.,A47D 20 90 FF JSR $FF90
.,A480 6C 02 03 JMP ($0302) normally A483
*** standard warm start routine
.,A483 20 60 A5 JSR $A560
.,A486 86 7A STX $7A
.,A488 84 7B STY $7B
.,A48A 20 73 00 JSR $0073
.,A48D AA TAX
.,A48E F0 F0 BEQ $A480
.,A490 A2 FF LDX #$FF
.,A492 86 3A STX $3A
.,A494 90 06 BCC $A49C
.,A496 20 79 A5 JSR $A579
.,A499 4C E1 A7 JMP $A7E1
*** handle insert/delete basic lines
.,A49C 20 6B A9 JSR $A96B
.,A49F 20 79 A5 JSR $A579
.,A4A2 84 0B STY $0B
.,A4A4 20 13 A6 JSR $A613
.,A4A7 90 44 BCC $A4ED
*** delete old line
.,A4A9 A0 01 LDY #$01
.,A4AB B1 5F LDA ($5F),Y
.,A4AD 85 23 STA $23
.,A4AF A5 2D LDA $2D
.,A4B1 85 22 STA $22
.,A4B3 A5 60 LDA $60
.,A4B5 85 25 STA $25
.,A4B7 A5 5F LDA $5F
.,A4B9 88 DEY
.,A4BA F1 5F SBC ($5F),Y
.,A4BC 18 CLC
.,A4BD 65 2D ADC $2D
.,A4BF 85 2D STA $2D
.,A4C1 85 24 STA $24
.,A4C3 A5 2E LDA $2E
.,A4C5 69 FF ADC #$FF
.,A4C7 85 2E STA $2E
.,A4C9 E5 60 SBC $60
.,A4CB AA TAX
.,A4CC 38 SEC
.,A4CD A5 5F LDA $5F
.,A4CF E5 2D SBC $2D
.,A4D1 A8 TAY
.,A4D2 B0 03 BCS $A4D7
.,A4D4 E8 INX
.,A4D5 C6 25 DEC $25
.,A4D7 18 CLC
.,A4D8 65 22 ADC $22
.,A4DA 90 03 BCC $A4DF
.,A4DC C6 23 DEC $23
.,A4DE 18 CLC
.,A4DF B1 22 LDA ($22),Y
.,A4E1 91 24 STA ($24),Y
.,A4E3 C8 INY
.,A4E4 D0 F9 BNE $A4DF
.,A4E6 E6 23 INC $23
.,A4E8 E6 25 INC $25
.,A4EA CA DEX
.,A4EB D0 F2 BNE $A4DF
*** insert new line
.,A4ED 20 59 A6 JSR $A659
.,A4F0 20 33 A5 JSR $A533
.,A4F3 AD 00 02 LDA $0200
.,A4F6 F0 88 BEQ $A480
.,A4F8 18 CLC
.,A4F9 A5 2D LDA $2D
.,A4FB 85 5A STA $5A
.,A4FD 65 0B ADC $0B
.,A4FF 85 58 STA $58
.,A501 A4 2E LDY $2E
.,A503 84 5B STY $5B
.,A505 90 01 BCC $A508
.,A507 C8 INY
.,A508 84 59 STY $59
.,A50A 20 B8 A3 JSR $A3B8
.,A50D A5 14 LDA $14
.,A50F A4 15 LDY $15
.,A511 8D FE 01 STA $01FE
.,A514 8C FF 01 STY $01FF
.,A517 A5 31 LDA $31
.,A519 A4 32 LDY $32
.,A51B 85 2D STA $2D
.,A51D 84 2E STY $2E
.,A51F A4 0B LDY $0B
.,A521 88 DEY
.,A522 B9 FC 01 LDA $01FC,Y
.,A525 91 5F STA ($5F),Y
.,A527 88 DEY
.,A528 10 F8 BPL $A522
.,A52A 20 59 A6 JSR $A659
.,A52D 20 33 A5 JSR $A533
.,A530 4C 80 A4 JMP $A480
*** relink basic program
.,A533 A5 2B LDA $2B
.,A535 A4 2C LDY $2C
.,A537 85 22 STA $22
.,A539 84 23 STY $23
.,A53B 18 CLC
.,A53C A0 01 LDY #$01
.,A53E B1 22 LDA ($22),Y
.,A540 F0 1D BEQ $A55F
.,A542 A0 04 LDY #$04
.,A544 C8 INY
.,A545 B1 22 LDA ($22),Y
.,A547 D0 FB BNE $A544
.,A549 C8 INY
.,A54A 98 TYA
.,A54B 65 22 ADC $22
.,A54D AA TAX
.,A54E A0 00 LDY #$00
.,A550 91 22 STA ($22),Y
.,A552 A5 23 LDA $23
.,A554 69 00 ADC #$00
.,A556 C8 INY
.,A557 91 22 STA ($22),Y
.,A559 86 22 STX $22
.,A55B 85 23 STA $23
.,A55D 90 DD BCC $A53C
.,A55F 60 RTS
*** get statement into buffer
.,A560 A2 00 LDX #$00
.,A562 20 12 E1 JSR $E112
.,A565 C9 0D CMP #$0D
.,A567 F0 0D BEQ $A576
.,A569 9D 00 02 STA $0200,X
.,A56C E8 INX
.,A56D E0 59 CPX #$59
.,A56F 90 F1 BCC $A562
.,A571 A2 17 LDX #$17 error number
.,A573 4C 37 A4 JMP $A437
.,A576 4C CA AA JMP $AACA goto end of line
*** crunch tokens
.,A579 6C 04 03 JMP ($0304) normally A57C
*** standard token cruncher
.,A57C A6 7A LDX $7A
.,A57E A0 04 LDY #$04
.,A580 84 0F STY $0F
.,A582 BD 00 02 LDA $0200,X
.,A585 10 07 BPL $A58E
.,A587 C9 FF CMP #$FF PI
.,A589 F0 3E BEQ $A5C9
.,A58B E8 INX
.,A58C D0 F4 BNE $A582
.,A58E C9 20 CMP #$20 space
.,A590 F0 37 BEQ $A5C9
.,A592 85 08 STA $08
.,A594 C9 22 CMP #$22 quote mark
.,A596 F0 56 BEQ $A5EE
.,A598 24 0F BIT $0F
.,A59A 70 2D BVS $A5C9
.,A59C C9 3F CMP #$3F question mark
.,A59E D0 04 BNE $A5A4
.,A5A0 A9 99 LDA #$99 PRINT code
.,A5A2 D0 25 BNE $A5C9
.,A5A4 C9 30 CMP #$30 0
.,A5A6 90 04 BCC $A5AC
.,A5A8 C9 3C CMP #$3C
.,A5AA 90 1D BCC $A5C9
.,A5AC 84 71 STY $71
.,A5AE A0 00 LDY #$00
.,A5B0 84 0B STY $0B
.,A5B2 88 DEY
.,A5B3 86 7A STX $7A
.,A5B5 CA DEX
.,A5B6 C8 INY
.,A5B7 E8 INX
.,A5B8 BD 00 02 LDA $0200,X
.,A5BB 38 SEC
.,A5BC F9 9E A0 SBC $A09E,Y
.,A5BF F0 F5 BEQ $A5B6
.,A5C1 C9 80 CMP #$80
.,A5C3 D0 30 BNE $A5F5
.,A5C5 05 0B ORA $0B
.,A5C7 A4 71 LDY $71
.,A5C9 E8 INX
.,A5CA C8 INY
.,A5CB 99 FB 01 STA $01FB,Y
.,A5CE B9 FB 01 LDA $01FB,Y
.,A5D1 F0 36 BEQ $A609
.,A5D3 38 SEC
.,A5D4 E9 3A SBC #$3A colon
.,A5D6 F0 04 BEQ $A5DC
.,A5D8 C9 49 CMP #$49 DATA code
.,A5DA D0 02 BNE $A5DE
.,A5DC 85 0F STA $0F
.,A5DE 38 SEC
.,A5DF E9 55 SBC #$55 REM code
.,A5E1 D0 9F BNE $A582
.,A5E3 85 08 STA $08
.,A5E5 BD 00 02 LDA $0200,X
.,A5E8 F0 DF BEQ $A5C9
.,A5EA C5 08 CMP $08
.,A5EC F0 DB BEQ $A5C9
.,A5EE C8 INY
.,A5EF 99 FB 01 STA $01FB,Y
.,A5F2 E8 INX
.,A5F3 D0 F0 BNE $A5E5
.,A5F5 A6 7A LDX $7A
.,A5F7 E6 0B INC $0B
.,A5F9 C8 INY
.,A5FA B9 9D A0 LDA $A09D,Y
.,A5FD 10 FA BPL $A5F9
.,A5FF B9 9E A0 LDA $A09E,Y
.,A602 D0 B4 BNE $A5B8
.,A604 BD 00 02 LDA $0200,X
.,A607 10 BE BPL $A5C7
.,A609 99 FD 01 STA $01FD,Y
.,A60C C6 7B DEC $7B
.,A60E A9 FF LDA #$FF
.,A610 85 7A STA $7A
.,A612 60 RTS
*** search for a line in a program
.,A613 A5 2B LDA $2B
.,A615 A6 2C LDX $2C
.,A617 A0 01 LDY #$01
.,A619 85 5F STA $5F
.,A61B 86 60 STX $60
.,A61D B1 5F LDA ($5F),Y
.,A61F F0 1F BEQ $A640
.,A621 C8 INY
.,A622 C8 INY
.,A623 A5 15 LDA $15
.,A625 D1 5F CMP ($5F),Y
.,A627 90 18 BCC $A641
.,A629 F0 03 BEQ $A62E
.,A62B 88 DEY
.,A62C D0 09 BNE $A637
.,A62E A5 14 LDA $14
.,A630 88 DEY
.,A631 D1 5F CMP ($5F),Y
.,A633 90 0C BCC $A641
.,A635 F0 0A BEQ $A641
.,A637 88 DEY
.,A638 B1 5F LDA ($5F),Y
.,A63A AA TAX
.,A63B 88 DEY
.,A63C B1 5F LDA ($5F),Y
.,A63E B0 D7 BCS $A617
.,A640 18 CLC
.,A641 60 RTS
*** NEW command
.,A642 D0 FD BNE $A641
.,A644 A9 00 LDA #$00
.,A646 A8 TAY
.,A647 91 2B STA ($2B),Y
.,A649 C8 INY
.,A64A 91 2B STA ($2B),Y
.,A64C A5 2B LDA $2B
.,A64E 18 CLC
.,A64F 69 02 ADC #$02
.,A651 85 2D STA $2D
.,A653 A5 2C LDA $2C
.,A655 69 00 ADC #$00
.,A657 85 2E STA $2E
.,A659 20 8E A6 JSR $A68E
.,A65C A9 00 LDA #$00
*** CLR command
.,A65E D0 2D BNE $A68D
.,A660 20 E7 FF JSR $FFE7
.,A663 A5 37 LDA $37
.,A665 A4 38 LDY $38
.,A667 85 33 STA $33
.,A669 84 34 STY $34
.,A66B A5 2D LDA $2D
.,A66D A4 2E LDY $2E
.,A66F 85 2F STA $2F
.,A671 84 30 STY $30
.,A673 85 31 STA $31
.,A675 84 32 STY $32
.,A677 20 1D A8 JSR $A81D
*** reset stack and program pointers
.,A67A A2 19 LDX #$19
.,A67C 86 16 STX $16
.,A67E 68 PLA
.,A67F A8 TAY
.,A680 68 PLA
.,A681 A2 FA LDX #$FA
.,A683 9A TXS
.,A684 48 PHA
.,A685 98 TYA
.,A686 48 PHA
.,A687 A9 00 LDA #$00
.,A689 85 3E STA $3E
.,A68B 85 10 STA $10
.,A68D 60 RTS
*** set current character pointer to start of basic - 1
.,A68E 18 CLC
.,A68F A5 2B LDA $2B
.,A691 69 FF ADC #$FF
.,A693 85 7A STA $7A
.,A695 A5 2C LDA $2C
.,A697 69 FF ADC #$FF
.,A699 85 7B STA $7B
.,A69B 60 RTS
*** LIST command
.,A69C 90 06 BCC $A6A4
.,A69E F0 04 BEQ $A6A4
.,A6A0 C9 AB CMP #$AB
.,A6A2 D0 E9 BNE $A68D
.,A6A4 20 6B A9 JSR $A96B
.,A6A7 20 13 A6 JSR $A613
.,A6AA 20 79 00 JSR $0079
.,A6AD F0 0C BEQ $A6BB
.,A6AF C9 AB CMP #$AB
.,A6B1 D0 8E BNE $A641
.,A6B3 20 73 00 JSR $0073
.,A6B6 20 6B A9 JSR $A96B
.,A6B9 D0 86 BNE $A641
.,A6BB 68 PLA
.,A6BC 68 PLA
.,A6BD A5 14 LDA $14
.,A6BF 05 15 ORA $15
.,A6C1 D0 06 BNE $A6C9
.,A6C3 A9 FF LDA #$FF
.,A6C5 85 14 STA $14
.,A6C7 85 15 STA $15
*** list lines from $5F/$60 to $14/$15
.,A6C9 A0 01 LDY #$01
.,A6CB 84 0F STY $0F
.,A6CD B1 5F LDA ($5F),Y
.,A6CF F0 43 BEQ $A714
.,A6D1 20 2C A8 JSR $A82C
.,A6D4 20 D7 AA JSR $AAD7
.,A6D7 C8 INY
.,A6D8 B1 5F LDA ($5F),Y
.,A6DA AA TAX
.,A6DB C8 INY
.,A6DC B1 5F LDA ($5F),Y
.,A6DE C5 15 CMP $15
.,A6E0 D0 04 BNE $A6E6
.,A6E2 E4 14 CPX $14
.,A6E4 F0 02 BEQ $A6E8
.,A6E6 B0 2C BCS $A714
.,A6E8 84 49 STY $49
.,A6EA 20 CD BD JSR $BDCD
.,A6ED A9 20 LDA #$20
.,A6EF A4 49 LDY $49
.,A6F1 29 7F AND #$7F
.,A6F3 20 47 AB JSR $AB47
.,A6F6 C9 22 CMP #$22
.,A6F8 D0 06 BNE $A700
.,A6FA A5 0F LDA $0F
.,A6FC 49 FF EOR #$FF
.,A6FE 85 0F STA $0F
.,A700 C8 INY
.,A701 F0 11 BEQ $A714
.,A703 B1 5F LDA ($5F),Y
.,A705 D0 10 BNE $A717
.,A707 A8 TAY
.,A708 B1 5F LDA ($5F),Y
.,A70A AA TAX
.,A70B C8 INY
.,A70C B1 5F LDA ($5F),Y
.,A70E 86 5F STX $5F
.,A710 85 60 STA $60
.,A712 D0 B5 BNE $A6C9
.,A714 4C 86 E3 JMP $E386
*** print tokens routine
.,A717 6C 06 03 JMP ($0306) normally A71A
*** standard token printer
.,A71A 10 D7 BPL $A6F3
.,A71C C9 FF CMP #$FF
.,A71E F0 D3 BEQ $A6F3
.,A720 24 0F BIT $0F
.,A722 30 CF BMI $A6F3
.,A724 38 SEC
.,A725 E9 7F SBC #$7F
.,A727 AA TAX
.,A728 84 49 STY $49
.,A72A A0 FF LDY #$FF
.,A72C CA DEX
.,A72D F0 08 BEQ $A737
.,A72F C8 INY
.,A730 B9 9E A0 LDA $A09E,Y
.,A733 10 FA BPL $A72F
.,A735 30 F5 BMI $A72C
*** print keyword
.,A737 C8 INY
.,A738 B9 9E A0 LDA $A09E,Y
.,A73B 30 B2 BMI $A6EF
.,A73D 20 47 AB JSR $AB47
.,A740 D0 F5 BNE $A737
*** FOR command
.,A742 A9 80 LDA #$80
.,A744 85 10 STA $10
.,A746 20 A5 A9 JSR $A9A5
.,A749 20 8A A3 JSR $A38A
.,A74C D0 05 BNE $A753
.,A74E 8A TXA
.,A74F 69 0F ADC #$0F
.,A751 AA TAX
.,A752 9A TXS
.,A753 68 PLA
.,A754 68 PLA
.,A755 A9 09 LDA #$09
.,A757 20 FB A3 JSR $A3FB
.,A75A 20 06 A9 JSR $A906
.,A75D 18 CLC
.,A75E 98 TYA
.,A75F 65 7A ADC $7A
.,A761 48 PHA
.,A762 A5 7B LDA $7B
.,A764 69 00 ADC #$00
.,A766 48 PHA
.,A767 A5 3A LDA $3A
.,A769 48 PHA
.,A76A A5 39 LDA $39
.,A76C 48 PHA
.,A76D A9 A4 LDA #$A4
.,A76F 20 FF AE JSR $AEFF
.,A772 20 8D AD JSR $AD8D
.,A775 20 8A AD JSR $AD8A
.,A778 A5 66 LDA $66
.,A77A 09 7F ORA #$7F
.,A77C 25 62 AND $62
.,A77E 85 62 STA $62
.,A780 A9 8B LDA #$8B low A78B
.,A782 A0 A7 LDY #$A7 high A78B
.,A784 85 22 STA $22
.,A786 84 23 STY $23
.,A788 4C 43 AE JMP $AE43
.,A78B A9 BC LDA #$BC low B9BC
.,A78D A0 B9 LDY #$B9 high B9BC
.,A78F 20 A2 BB JSR $BBA2
.,A792 20 79 00 JSR $0079
.,A795 C9 A9 CMP #$A9
.,A797 D0 06 BNE $A79F
.,A799 20 73 00 JSR $0073
.,A79C 20 8A AD JSR $AD8A
.,A79F 20 2B BC JSR $BC2B
.,A7A2 20 38 AE JSR $AE38
.,A7A5 A5 4A LDA $4A
.,A7A7 48 PHA
.,A7A8 A5 49 LDA $49
.,A7AA 48 PHA
.,A7AB A9 81 LDA #$81 FOR block code
.,A7AD 48 PHA
*** execute next statement
.,A7AE 20 2C A8 JSR $A82C
.,A7B1 A5 7A LDA $7A
.,A7B3 A4 7B LDY $7B
.,A7B5 C0 02 CPY #$02
.,A7B7 EA NOP
.,A7B8 F0 04 BEQ $A7BE
.,A7BA 85 3D STA $3D
.,A7BC 84 3E STY $3E
.,A7BE A0 00 LDY #$00
.,A7C0 B1 7A LDA ($7A),Y
.,A7C2 D0 43 BNE $A807
.,A7C4 A0 02 LDY #$02
.,A7C6 B1 7A LDA ($7A),Y
.,A7C8 18 CLC
.,A7C9 D0 03 BNE $A7CE
.,A7CB 4C 4B A8 JMP $A84B
.,A7CE C8 INY
.,A7CF B1 7A LDA ($7A),Y
.,A7D1 85 39 STA $39
.,A7D3 C8 INY
.,A7D4 B1 7A LDA ($7A),Y
.,A7D6 85 3A STA $3A
.,A7D8 98 TYA
.,A7D9 65 7A ADC $7A
.,A7DB 85 7A STA $7A
.,A7DD 90 02 BCC $A7E1
.,A7DF E6 7B INC $7B
.,A7E1 6C 08 03 JMP ($0308) normally A7E4
*** execute a statement
.,A7E4 20 73 00 JSR $0073
.,A7E7 20 ED A7 JSR $A7ED
.,A7EA 4C AE A7 JMP $A7AE
*** execute command in A
.,A7ED F0 3C BEQ $A82B
.,A7EF E9 80 SBC #$80
.,A7F1 90 11 BCC $A804
.,A7F3 C9 23 CMP #$23
.,A7F5 B0 17 BCS $A80E
.,A7F7 0A ASL
.,A7F8 A8 TAY
.,A7F9 B9 0D A0 LDA $A00D,Y
.,A7FC 48 PHA
.,A7FD B9 0C A0 LDA $A00C,Y
.,A800 48 PHA
.,A801 4C 73 00 JMP $0073
.,A804 4C A5 A9 JMP $A9A5
.,A807 C9 3A CMP #$3A colon
.,A809 F0 D6 BEQ $A7E1
.,A80B 4C 08 AF JMP $AF08
.,A80E C9 4B CMP #$4B GO code
.,A810 D0 F9 BNE $A80B
.,A812 20 73 00 JSR $0073
.,A815 A9 A4 LDA #$A4 TO code
.,A817 20 FF AE JSR $AEFF
.,A81A 4C A0 A8 JMP $A8A0 do GOTO
*** RESTORE command
.,A81D 38 SEC
.,A81E A5 2B LDA $2B
.,A820 E9 01 SBC #$01
.,A822 A4 2C LDY $2C
.,A824 B0 01 BCS $A827
.,A826 88 DEY
.,A827 85 41 STA $41
.,A829 84 42 STY $42
.,A82B 60 RTS
.,A82C 20 E1 FF JSR $FFE1 test stop key
*** STOP command
.,A82F B0 01 BCS $A832
*** END command
.,A831 18 CLC
.,A832 D0 3C BNE $A870
.,A834 A5 7A LDA $7A
.,A836 A4 7B LDY $7B
.,A838 A6 3A LDX $3A
.,A83A E8 INX
.,A83B F0 0C BEQ $A849
.,A83D 85 3D STA $3D
.,A83F 84 3E STY $3E
.,A841 A5 39 LDA $39
.,A843 A4 3A LDY $3A
.,A845 85 3B STA $3B
.,A847 84 3C STY $3C
.,A849 68 PLA
.,A84A 68 PLA
.,A84B A9 81 LDA #$81 low A381