-
Notifications
You must be signed in to change notification settings - Fork 78
/
c64disasm_sc.txt
5215 lines (4829 loc) · 208 KB
/
c64disasm_sc.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 BASIC ROM Disassembly (English, "S-C")
-
- The comments have been taken from
- Bob Sander-Cederlof: S-C DocuMentor for Applesoft
- http://www.txbobsc.com/scsc/scdocumentor/
-
- The original comments are based on a disassembly of Applesoft BASIC
- as found in the ROMs of the Apple II. C64 BASIC V2 and Applesoft BASIC
- are both based on Microsoft BASIC for 6502, albeit on different versions,
- and they both add incompatible extensions. Nevertheless, they are still
- extremely similar, so that Bob Sander-Cederlof's Applestoft comments could
- be semi-automatically ported over to the version of BASIC in the ROM of
- the Commodore 64.
-
- Converted, formatted and adapted 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
.:A002 7B E3
.:A004 43 42 4D 42 41 53 49 43 'cbmbasic'
*** BRANCH TABLE FOR TOKENS
.:A00C 30 A8 $80 $A831 END
.:A00E 41 A7 $81 $A742 FOR
.:A010 1D AD $82 $AD1E NEXT
.:A012 F7 A8 $83 $A8F8 DATA
.:A014 A4 AB $84 $ABA5 INPUT#
.:A016 BE AB $85 $ABBF INPUT
.:A018 80 B0 $86 $B081 DIM
.:A01A 05 AC $87 $AC06 READ
.:A01C A4 A9 $88 $A9A5 LET
.:A01E 9F A8 $89 $A8A0 GOTO
.:A020 70 A8 $8A $A871 RUN
.:A022 27 A9 $8B $A928 IF
.:A024 1C A8 $8C $A81D RESTORE
.:A026 82 A8 $8D $A883 GOSUB
.:A028 D1 A8 $8E $A8D2 RETURN
.:A02A 3A A9 $8F $A93B REM
.:A02C 2E A8 $90 $A82F STOP
.:A02E 4A A9 $91 $A94B ON
.:A030 2C B8 $92 $B82D WAIT
.:A032 67 E1 $93 $E168 LOAD
.:A034 55 E1 $94 $E156 SAVE
.:A036 64 E1 $95 $E165 VERIFY
.:A038 B2 B3 $96 $B3B3 DEF
.:A03A 23 B8 $97 $B824 POKE
.:A03C 7F AA $98 $AA80 PRINT#
.:A03E 9F AA $99 $AAA0 PRINT
.:A040 56 A8 $9A $A857 CONT
.:A042 9B A6 $9B $A69C LIST
.:A044 5D A6 $9C $A65E CLR
.:A046 85 AA $9D $AA86 CMD
.:A048 29 E1 $9E $E12A SYS
.:A04A BD E1 $9F $E1BE OPEN
.:A04C C6 E1 $A0 $E1C7 CLOSE
.:A04E 7A AB $A1 $AB7B GET
.:A050 41 A6 $A2 $A642 NEW
.:A052 39 BC $B4 $BC39 SGN
.:A054 CC BC $B5 $BCCC INT
.:A056 58 BC $B6 $BC58 ABS
.:A058 10 03 $B7 $0310 USR
.:A05A 7D B3 $B8 $B37D FRE
.:A05C 9E B3 $B9 $B39E POS
.:A05E 71 BF $BA $BF71 SQR
.:A060 97 E0 $BB $E097 RND
.:A062 EA B9 $BC $B9EA LOG
.:A064 ED BF $BD $BFED EXP
.:A066 64 E2 $BE $E264 COS
.:A068 6B E2 $BF $E26B SIN
.:A06A B4 E2 $C0 $E2B4 TAN
.:A06C 0E E3 $C1 $E30E ATN
.:A06E 0D B8 $C2 $B80D PEEK
.:A070 7C B7 $C3 $B77C LEN
.:A072 65 B4 $C4 $B465 STR$
.:A074 AD B7 $C5 $B7AD VAL
.:A076 8B B7 $C6 $B78B ASC
.:A078 EC B6 $C7 $B6EC CHR$
.:A07A 00 B7 $C8 $B700 LEFT$
.:A07C 2C B7 $C9 $B72C RIGHT$
.:A07E 37 B7 $CA $B737 MID$
*** MATH OPERATOR BRANCH TABLE
ONE-BYTE PRECEDENCE CODE
TWO-BYTE ADDRESS
.:A080 79 69 B8 $79, $B86A +
.:A083 79 52 B8 $79, $B853 -
.:A086 7B 2A BA $7B, $BA2B *
.:A089 7B 11 BB $7B, $BB12 /
.:A08C 7F 7A BF $7F, $BF7B ^
.:A08F 50 E8 AF $50, $AFE9 AND
.:A092 46 E5 AF $46, $AFE6 OR (LOWEST PRECEDENCE)
.:A095 7D B3 BF $7D, $BFB4 >
.:A098 5A D3 AE $5A, $AED4 =
.:A09B 64 15 B0 $64, $B016 <
*** TOKEN NAME TABLE
.:A09E 45 4E end
.:A0A0 C4 46 4F D2 4E 45 58 D4 for next
.:A0A8 44 41 54 C1 49 4E 50 55 data input#
.:A0B0 54 A3 49 4E 50 55 D4 44 input dim
.:A0B8 49 CD 52 45 41 C4 4C 45 read let
.:A0C0 D4 47 4F 54 CF 52 55 CE goto run
.:A0C8 49 C6 52 45 53 54 4F 52 if restore
.:A0D0 C5 47 4F 53 55 C2 52 45 gosub return
.:A0D8 54 55 52 CE 52 45 CD 53 rem stop
.:A0E0 54 4F D0 4F CE 57 41 49 on wait
.:A0E8 D4 4C 4F 41 C4 53 41 56 load save
.:A0F0 C5 56 45 52 49 46 D9 44 verify def
.:A0F8 45 C6 50 4F 4B C5 50 52 poke print#
.:A100 49 4E 54 A3 50 52 49 4E print
.:A108 D4 43 4F 4E D4 4C 49 53 cont list
.:A110 D4 43 4C D2 43 4D C4 53 clr cmd sys
.:A118 59 D3 4F 50 45 CE 43 4C open close
.:A120 4F 53 C5 47 45 D4 4E 45 get new
.:A128 D7 54 41 42 A8 54 CF 46 tab( to
.:A130 CE 53 50 43 A8 54 48 45 spc( then
.:A138 CE 4E 4F D4 53 54 45 D0 not step
.:A140 AB AD AA AF DE 41 4E C4 + - * / ' and
.:A148 4F D2 BE BD BC or <=>
.:A14D 53 47 CE sgn
.:A150 49 4E D4 41 42 D3 55 53 int abs usr
.:A158 D2 46 52 C5 50 4F D3 53 fre pos sqr
.:A160 51 D2 52 4E C4 4C 4F C7 rnd log
.:A168 45 58 D0 43 4F D3 53 49 exp cos sin
.:A170 CE 54 41 CE 41 54 CE 50 tan atn peek
.:A178 45 45 CB 4C 45 CE 53 54 len str$
.:A180 52 A4 56 41 CC 41 53 C3 val asc
.:A188 43 48 52 A4 4C 45 46 54 chr$ left$
.:A190 A4 52 49 47 48 54 A4 4D right$ mid$
.:A198 49 44 A4 47 CF go
.:A19D 00 END OF TOKEN NAME TABLE
*** ERROR MESSAGES
.:A19E 54 4F 1 too many files
.:A1A0 4F 20 4D 41 4E 59 20 46
.:A1A8 49 4C 45 D3 46 49 4C 45 2 file open
.:A1B0 20 4F 50 45 CE 46 49 4C 3 file not open
.:A1B8 45 20 4E 4F 54 20 4F 50
.:A1C0 45 CE 46 49 4C 45 20 4E 4 file not found
.:A1C8 4F 54 20 46 4F 55 4E C4 5 device not present
.:A1D0 44 45 56 49 43 45 20 4E
.:A1D8 4F 54 20 50 52 45 53 45
.:A1E0 4E D4 4E 4F 54 20 49 4E 6 not input file
.:A1E8 50 55 54 20 46 49 4C C5
.:A1F0 4E 4F 54 20 4F 55 54 50 7 not output file
.:A1F8 55 54 20 46 49 4C C5 4D
.:A200 49 53 53 49 4E 47 20 46 8 missing filename
.:A208 49 4C 45 20 4E 41 4D C5
.:A210 49 4C 4C 45 47 41 4C 20 9 illegal device number
.:A218 44 45 56 49 43 45 20 4E
.:A220 55 4D 42 45 D2 4E 45 58 10 next without for
.:A228 54 20 57 49 54 48 4F 55
.:A230 54 20 46 4F D2 53 59 4E 11 syntax
.:A238 54 41 D8 52 45 54 55 52 12 return without gosub
.:A240 4E 20 57 49 54 48 4F 55
.:A248 54 20 47 4F 53 55 C2 4F 13 out of data
.:A250 55 54 20 4F 46 20 44 41
.:A258 54 C1 49 4C 4C 45 47 41 14 illegal quantity
.:A260 4C 20 51 55 41 4E 54 49
.:A268 54 D9 4F 56 45 52 46 4C 15 overflow
.:A270 4F D7 4F 55 54 20 4F 46 16 out of memory
.:A278 20 4D 45 4D 4F 52 D9 55 17 undef'd statement
.:A280 4E 44 45 46 27 44 20 53
.:A288 54 41 54 45 4D 45 4E D4
.:A290 42 41 44 20 53 55 42 53 18 bad subscript
.:A298 43 52 49 50 D4 52 45 44 19 redim'd array
.:A2A0 49 4D 27 44 20 41 52 52
.:A2A8 41 D9 44 49 56 49 53 49 20 division by zero
.:A2B0 4F 4E 20 42 59 20 5A 45
.:A2B8 52 CF 49 4C 4C 45 47 41 21 illegal direct
.:A2C0 4C 20 44 49 52 45 43 D4
.:A2C8 54 59 50 45 20 4D 49 53 22 type mismatch
.:A2D0 4D 41 54 43 C8 53 54 52 23 string too long
.:A2D8 49 4E 47 20 54 4F 4F 20
.:A2E0 4C 4F 4E C7 46 49 4C 45 24 file data
.:A2E8 20 44 41 54 C1 46 4F 52 25 formula too complex
.:A2F0 4D 55 4C 41 20 54 4F 4F
.:A2F8 20 43 4F 4D 50 4C 45 D8
.:A300 43 41 4E 27 54 20 43 4F 26 can't continue
.:A308 4E 54 49 4E 55 C5 55 4E 27 undef'd function
.:A310 44 45 46 27 44 20 46 55
.:A318 4E 43 54 49 4F CE 56 45 28 verify
.:A320 52 49 46 D9 4C 4F 41 C4 29 load
.:A328 9E A1 AC A1 B5 A1 C2 A1
.:A330 D0 A1 E2 A1 F0 A1 FF A1
.:A338 10 A2 25 A2 35 A2 3B A2
.:A340 4F A2 5A A2 6A A2 72 A2
.:A348 7F A2 90 A2 9D A2 AA A2
.:A350 BA A2 C8 A2 D5 A2 E4 A2
.:A358 ED A2 00 A3 0E A3 1E A3
.:A360 24 A3 83 A3
.:A364 0D 4F 4B 0D OK
.:A368 00 20 20 45 52 52 4F 52 ERROR
.:A370 00 20 49 4E 20 00 0D 0A IN
.:A378 52 45 41 44 59 2E 0D 0A READY.
.:A380 00 0D 0A 42 52 45 41 4B BREAK
.:A388 00
.:A389 A0
*** CALLED BY "NEXT" AND "FOR" TO SCAN THROUGH
*** THE STACK FOR A FRAME WITH THE SAME VARIABLE.
(FORPNT) = ADDRESS OF VARIABLE IF "FOR" OR "NEXT"
= $XXFF IF CALLED FROM "RETURN"
<<< BUG: SHOULD BE $FFXX >>>
RETURNS .NE. IF VARIABLE NOT FOUND,
(X) = STACK PNTR AFTER SKIPPING ALL FRAMES
.EQ. IF FOUND
(X) = STACK PNTR OF FRAME FOUND
.,A38A BA TSX
.,A38B E8 INX
.,A38C E8 INX
.,A38D E8 INX
.,A38E E8 INX
.,A38F BD 01 01 LDA $0101,X "FOR" FRAME HERE?
.,A392 C9 81 CMP #$81
.,A394 D0 21 BNE $A3B7 NO
.,A396 A5 4A LDA $4A YES -- "NEXT" WITH NO VARIABLE?
.,A398 D0 0A BNE $A3A4 NO, VARIABLE SPECIFIED
.,A39A BD 02 01 LDA $0102,X YES, SO USE THIS FRAME
.,A39D 85 49 STA $49
.,A39F BD 03 01 LDA $0103,X
.,A3A2 85 4A STA $4A
.,A3A4 DD 03 01 CMP $0103,X IS VARIABLE IN THIS FRAME?
.,A3A7 D0 07 BNE $A3B0 NO
.,A3A9 A5 49 LDA $49 LOOK AT 2ND BYTE TOO
.,A3AB DD 02 01 CMP $0102,X SAME VARIABLE?
.,A3AE F0 07 BEQ $A3B7 YES
.,A3B0 8A TXA NO, SO TRY NEXT FRAME (IF ANY)
.,A3B1 18 CLC 18 BYTES PER FRAME
.,A3B2 69 12 ADC #$12
.,A3B4 AA TAX
.,A3B5 D0 D8 BNE $A38F ...ALWAYS?
.,A3B7 60 RTS
*** MOVE BLOCK OF MEMORY UP
ON ENTRY:
(Y,A) = (HIGHDS) = DESTINATION END+1
(LOWTR) = LOWEST ADDRESS OF SOURCE
(HIGHTR) = HIGHEST SOURCE ADDRESS+1
.,A3B8 20 08 A4 JSR $A408 BE SURE (Y,A) < FRETOP
.,A3BB 85 31 STA $31 NEW TOP OF ARRAY STORAGE
.,A3BD 84 32 STY $32
.,A3BF 38 SEC
.,A3C0 A5 5A LDA $5A COMPUTE # OF BYTES TO BE MOVED
.,A3C2 E5 5F SBC $5F (FROM LOWTR THRU HIGHTR-1)
.,A3C4 85 22 STA $22 PARTIAL PAGE AMOUNT
.,A3C6 A8 TAY
.,A3C7 A5 5B LDA $5B
.,A3C9 E5 60 SBC $60
.,A3CB AA TAX # OF WHOLE PAGES IN X-REG
.,A3CC E8 INX
.,A3CD 98 TYA # BYTES IN PARTIAL PAGE
.,A3CE F0 23 BEQ $A3F3 NO PARTIAL PAGE
.,A3D0 A5 5A LDA $5A BACK UP HIGHTR # BYTES IN PARTIAL PAGE
.,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 BACK UP HIGHDS # BYTES IN PARTIAL PAGE
.,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 ...ALWAYS
.,A3E8 B1 5A LDA ($5A),Y MOVE THE BYTES
.,A3EA 91 58 STA ($58),Y
.,A3EC 88 DEY
.,A3ED D0 F9 BNE $A3E8 LOOP TO END OF THIS 256 BYTES
.,A3EF B1 5A LDA ($5A),Y MOVE ONE MORE BYTE
.,A3F1 91 58 STA ($58),Y
.,A3F3 C6 5B DEC $5B DOWN TO NEXT BLOCK OF 256
.,A3F5 C6 59 DEC $59
.,A3F7 CA DEX ANOTHER BLOCK OF 256 TO MOVE?
.,A3F8 D0 F2 BNE $A3EC YES
.,A3FA 60 RTS NO, FINISHED
*** CHECK IF ENOUGH ROOM LEFT ON STACK
*** FOR "FOR", "GOSUB", OR EXPRESSION EVALUATION
.,A3FB 0A ASL
.,A3FC 69 3E ADC #$3E
.,A3FE B0 35 BCS $A435 ...MEM FULL ERR
.,A400 85 22 STA $22
.,A402 BA TSX
.,A403 E4 22 CPX $22
.,A405 90 2E BCC $A435 ...MEM FULL ERR
.,A407 60 RTS
*** CHECK IF ENOUGH ROOM BETWEEN ARRAYS AND STRINGS
(Y,A) = ADDR ARRAYS NEED TO GROW TO
.,A408 C4 34 CPY $34 HIGH BYTE
.,A40A 90 28 BCC $A434 PLENTY OF ROOM
.,A40C D0 04 BNE $A412 NOT ENOUGH, TRY GARBAGE COLLECTION
.,A40E C5 33 CMP $33 LOW BYTE
.,A410 90 22 BCC $A434 ENOUGH ROOM
.,A412 48 PHA SAVE (Y,A), TEMP1, AND TEMP2
.,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 MAKE AS MUCH ROOM AS POSSIBLE
.,A41F A2 F7 LDX #$F7 RESTORE TEMP1 AND TEMP2
.,A421 68 PLA AND (Y,A)
.,A422 95 61 STA $61,X
.,A424 E8 INX
.,A425 30 FA BMI $A421
.,A427 68 PLA
.,A428 A8 TAY
.,A429 68 PLA DID WE FIND ENOUGH ROOM?
.,A42A C4 34 CPY $34 HIGH BYTE
.,A42C 90 06 BCC $A434 YES, AT LEAST A PAGE
.,A42E D0 05 BNE $A435 NO, MEM FULL ERR
.,A430 C5 33 CMP $33 LOW BYTE
.,A432 B0 01 BCS $A435 NO, MEM FULL ERR
.,A434 60 RTS YES, RETURN
.,A435 A2 10 LDX #$10
*** HANDLE AN ERROR
(X)=OFFSET IN ERROR MESSAGE TABLE
(ERRFLG) > 128 IF "ON ERR" TURNED ON
(CURLIN+1) = $FF IF IN DIRECT MODE
*** WARM RESTART ENTRY
COME HERE FROM MONITOR BY CTL-C, 0G, 3D0G, OR E003G
.,A437 6C 00 03 JMP ($0300)
.,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
.,A467 A0 A3 LDY #$A3
.,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
.,A476 A0 A3 LDY #$A3
.,A478 20 1E AB JSR $AB1E
.,A47B A9 80 LDA #$80
.,A47D 20 90 FF JSR $FF90
.,A480 6C 02 03 JMP ($0302)
.,A483 20 60 A5 JSR $A560 READ A LINE
.,A486 86 7A STX $7A SET UP CHRGET TO SCAN THE LINE
.,A488 84 7B STY $7B
.,A48A 20 73 00 JSR $0073
.,A48D AA TAX
.,A48E F0 F0 BEQ $A480 EMPTY LINE
.,A490 A2 FF LDX #$FF $FF IN HI-BYTE OF CURLIN MEANS
.,A492 86 3A STX $3A WE ARE IN DIRECT MODE
.,A494 90 06 BCC $A49C CHRGET SAW DIGIT, NUMBERED LINE
.,A496 20 79 A5 JSR $A579 NO NUMBER, SO PARSE IT
.,A499 4C E1 A7 JMP $A7E1 AND TRY EXECUTING IT
*** HANDLE NUMBERED LINE
.,A49C 20 6B A9 JSR $A96B
.,A49F 20 79 A5 JSR $A579
.,A4A2 84 0B STY $0B SAVE INDEX TO INPUT BUFFER
.,A4A4 20 13 A6 JSR $A613 IS THIS LINE # ALREADY IN PROGRAM?
.,A4A7 90 44 BCC $A4ED NO
.,A4A9 A0 01 LDY #$01 YES, SO DELETE IT
.,A4AB B1 5F LDA ($5F),Y LOWTR POINTS AT LINE
.,A4AD 85 23 STA $23 GET HIGH BYTE OF FORWARD PNTR
.,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 MOVE HIGHER LINES OF PROGRAM
.,A4E1 91 24 STA ($24),Y DOWN OVER THE DELETED LINE.
.,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
.,A4ED 20 59 A6 JSR $A659
.,A4F0 20 33 A5 JSR $A533
.,A4F3 AD 00 02 LDA $0200 ANY CHARACTERS AFTER LINE #?
.,A4F6 F0 88 BEQ $A480 NO, SO NOTHING TO INSERT.
.,A4F8 18 CLC
.,A4F9 A5 2D LDA $2D SET UP BLTU SUBROUTINE
.,A4FB 85 5A STA $5A INSERT NEW LINE.
.,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 MAKE ROOM FOR THE LINE
.,A50D A5 14 LDA $14 PUT LINE NUMBER IN LINE IMAGE
.,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
COPY LINE INTO PROGRAM
.,A522 B9 FC 01 LDA $01FC,Y
.,A525 91 5F STA ($5F),Y
.,A527 88 DEY
.,A528 10 F8 BPL $A522
*** CLEAR ALL VARIABLES
RE-ESTABLISH ALL FORWARD LINKS
.,A52A 20 59 A6 JSR $A659 CLEAR ALL VARIABLES
.,A52D 20 33 A5 JSR $A533
.,A530 4C 80 A4 JMP $A480
.,A533 A5 2B LDA $2B POINT INDEX AT START OF PROGRAM
.,A535 A4 2C LDY $2C
.,A537 85 22 STA $22
.,A539 84 23 STY $23
.,A53B 18 CLC
.,A53C A0 01 LDY #$01 HI-BYTE OF NEXT FORWARD PNTR
.,A53E B1 22 LDA ($22),Y END OF PROGRAM YET?
.,A540 F0 1D BEQ $A55F
.,A542 A0 04 LDY #$04 FIND END OF THIS LINE
.,A544 C8 INY (NOTE MAXIMUM LENGTH < 256)
.,A545 B1 22 LDA ($22),Y
.,A547 D0 FB BNE $A544
.,A549 C8 INY COMPUTE ADDRESS OF NEXT LINE
.,A54A 98 TYA
.,A54B 65 22 ADC $22
.,A54D AA TAX
.,A54E A0 00 LDY #$00 STORE FORWARD PNTR IN THIS LINE
.,A550 91 22 STA ($22),Y
.,A552 A5 23 LDA $23
.,A554 69 00 ADC #$00 (NOTE: THIS CLEARS CARRY)
.,A556 C8 INY
.,A557 91 22 STA ($22),Y
.,A559 86 22 STX $22
.,A55B 85 23 STA $23
.,A55D 90 DD BCC $A53C ...ALWAYS
.,A55F 60 RTS
.,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
.,A573 4C 37 A4 JMP $A437
.,A576 4C CA AA JMP $AACA
.,A579 6C 04 03 JMP ($0304)
*** TOKENIZE THE INPUT LINE
.,A57C A6 7A LDX $7A INDEX INTO UNPARSED LINE
.,A57E A0 04 LDY #$04 INDEX TO PARSED OUTPUT LINE
.,A580 84 0F STY $0F CLEAR SIGN-BIT OF DATAFLG
.,A582 BD 00 02 LDA $0200,X
.,A585 10 07 BPL $A58E
.,A587 C9 FF CMP #$FF
.,A589 F0 3E BEQ $A5C9
.,A58B E8 INX
.,A58C D0 F4 BNE $A582
.,A58E C9 20 CMP #$20 IGNORE BLANKS
.,A590 F0 37 BEQ $A5C9
.,A592 85 08 STA $08
.,A594 C9 22 CMP #$22 START OF QUOTATION?
.,A596 F0 56 BEQ $A5EE
.,A598 24 0F BIT $0F
.,A59A 70 2D BVS $A5C9 BRANCH IF IN "DATA" STATEMENT
.,A59C C9 3F CMP #$3F SHORTHAND FOR "PRINT"?
.,A59E D0 04 BNE $A5A4 NO
.,A5A0 A9 99 LDA #$99 YES, REPLACE WITH "PRINT" TOKEN
.,A5A2 D0 25 BNE $A5C9 ...ALWAYS
.,A5A4 C9 30 CMP #$30 IS IT A DIGIT, COLON, OR SEMI-COLON?
.,A5A6 90 04 BCC $A5AC NO, PUNCTUATION !"#$%&'()*+,-./
.,A5A8 C9 3C CMP #$3C
.,A5AA 90 1D BCC $A5C9 YES, NOT A TOKEN
*** SEARCH TOKEN NAME TABLE FOR MATCH STARTING
*** WITH CURRENT CHAR FROM INPUT LINE
.,A5AC 84 71 STY $71 SAVE INDEX TO OUTPUT LINE
.,A5AE A0 00 LDY #$00 USE Y-REG WITH (FAC) TO ADDRESS TABLE
.,A5B0 84 0B STY $0B HOLDS CURRENT TOKEN-$80
.,A5B2 88 DEY PREPARE FOR "INY" A FEW LINES DOWN
.,A5B3 86 7A STX $7A SAVE POSITION IN INPUT LINE
.,A5B5 CA DEX PREPARE FOR "INX" A FEW LINES DOWN
.,A5B6 C8 INY ADVANCE POINTER TO TOKEN TABLE
.,A5B7 E8 INX
.,A5B8 BD 00 02 LDA $0200,X NEXT CHAR FROM INPUT LINE
.,A5BB 38 SEC NO, COMPARE TO CHAR IN TABLE
.,A5BC F9 9E A0 SBC $A09E,Y SAME AS NEXT CHAR OF TOKEN NAME?
.,A5BF F0 F5 BEQ $A5B6 YES, CONTINUE MATCHING
.,A5C1 C9 80 CMP #$80 MAYBE; WAS IT SAME EXCEPT FOR BIT 7?
.,A5C3 D0 30 BNE $A5F5 NO, SKIP TO NEXT TOKEN
.,A5C5 05 0B ORA $0B YES, END OF TOKEN; GET TOKEN #
.,A5C7 A4 71 LDY $71 GET INDEX TO OUTPUT LINE IN Y-REG
.,A5C9 E8 INX ADVANCE INPUT INDEX
.,A5CA C8 INY ADVANCE OUTPUT INDEX
.,A5CB 99 FB 01 STA $01FB,Y STORE CHAR OR TOKEN
.,A5CE B9 FB 01 LDA $01FB,Y TEST FOR EOL OR EOS
.,A5D1 F0 36 BEQ $A609 END OF LINE
.,A5D3 38 SEC
.,A5D4 E9 3A SBC #$3A END OF STATEMENT?
.,A5D6 F0 04 BEQ $A5DC YES, CLEAR DATAFLG
.,A5D8 C9 49 CMP #$49 "DATA" TOKEN?
.,A5DA D0 02 BNE $A5DE NO, LEAVE DATAFLG ALONE
.,A5DC 85 0F STA $0F DATAFLG = 0 OR $83-$3A = $49
.,A5DE 38 SEC IS IT A "REM" TOKEN?
.,A5DF E9 55 SBC #$55
.,A5E1 D0 9F BNE $A582 NO, CONTINUE PARSING LINE
.,A5E3 85 08 STA $08 YES, CLEAR LITERAL FLAG
*** HANDLE LITERAL (BETWEEN QUOTES) OR REMARK,
*** BY COPYING CHARS UP TO ENDCHR.
.,A5E5 BD 00 02 LDA $0200,X
.,A5E8 F0 DF BEQ $A5C9 END OF LINE
.,A5EA C5 08 CMP $08
.,A5EC F0 DB BEQ $A5C9 FOUND ENDCHR
.,A5EE C8 INY NEXT OUTPUT CHAR
.,A5EF 99 FB 01 STA $01FB,Y
.,A5F2 E8 INX NEXT INPUT CHAR
.,A5F3 D0 F0 BNE $A5E5 ...ALWAYS
*** ADVANCE POINTER TO NEXT TOKEN NAME
.,A5F5 A6 7A LDX $7A GET POINTER TO INPUT LINE IN X-REG
.,A5F7 E6 0B INC $0B BUMP (TOKEN # - $80)
.,A5F9 C8 INY NEXT TOKEN ONE BEYOND THAT
.,A5FA B9 9D A0 LDA $A09D,Y YES, AT NEXT NAME. END OF TABLE?
.,A5FD 10 FA BPL $A5F9
.,A5FF B9 9E A0 LDA $A09E,Y
.,A602 D0 B4 BNE $A5B8 NO, NOT END OF TABLE
.,A604 BD 00 02 LDA $0200,X YES, SO NOT A KEYWORD
.,A607 10 BE BPL $A5C7 ...ALWAYS, COPY CHAR AS IS
END OF LINE
.,A609 99 FD 01 STA $01FD,Y STORE ANOTHER 00 ON END
.,A60C C6 7B DEC $7B SET TXTPTR = INPUT.BUFFER-1
.,A60E A9 FF LDA #$FF
.,A610 85 7A STA $7A
.,A612 60 RTS
*** SEARCH FOR LINE
(LINNUM) = LINE # TO FIND
IF NOT FOUND: CARRY = 0
LOWTR POINTS AT NEXT LINE
IF FOUND: CARRY = 1
LOWTR POINTS AT LINE
.,A613 A5 2B LDA $2B SEARCH FROM BEGINNING OF PROGRAM
.,A615 A6 2C LDX $2C
.,A617 A0 01 LDY #$01 SEARCH FROM (X,A)
.,A619 85 5F STA $5F
.,A61B 86 60 STX $60
.,A61D B1 5F LDA ($5F),Y
.,A61F F0 1F BEQ $A640 END OF PROGRAM, AND NOT FOUND
.,A621 C8 INY
.,A622 C8 INY
.,A623 A5 15 LDA $15
.,A625 D1 5F CMP ($5F),Y
.,A627 90 18 BCC $A641 IF NOT FOUND
.,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 PAST LINE, NOT FOUND
.,A635 F0 0A BEQ $A641 IF FOUND
.,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 ALWAYS
.,A640 18 CLC RETURN CARRY = 0
.,A641 60 RTS
*** "NEW" STATEMENT
.,A642 D0 FD BNE $A641 IGNORE IF MORE TO THE STATEMENT
.,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 SET TXTPTR TO TXTTAB - 1
.,A65C A9 00 LDA #$00 (THIS COULD HAVE BEEN ".HS 2C")
*** "CLEAR" STATEMENT
.,A65E D0 2D BNE $A68D IGNORE IF NOT AT END OF STATEMENT
.,A660 20 E7 FF JSR $FFE7
.,A663 A5 37 LDA $37 CLEAR STRING AREA
.,A665 A4 38 LDY $38
.,A667 85 33 STA $33
.,A669 84 34 STY $34
.,A66B A5 2D LDA $2D CLEAR ARRAY AREA
.,A66D A4 2E LDY $2E
.,A66F 85 2F STA $2F
.,A671 84 30 STY $30
.,A673 85 31 STA $31 LOW END OF FREE SPACE
.,A675 84 32 STY $32
.,A677 20 1D A8 JSR $A81D SET "DATA" POINTER TO BEGINNING
.,A67A A2 19 LDX #$19
.,A67C 86 16 STX $16
.,A67E 68 PLA SAVE RETURN ADDRESS
.,A67F A8 TAY
.,A680 68 PLA
.,A681 A2 FA LDX #$FA START STACK AT $F8,
.,A683 9A TXS LEAVING ROOM FOR PARSING LINES
.,A684 48 PHA RESTORE RETURN ADDRESS
.,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 TXTPTR TO BEGINNING OF PROGRAM
.,A68E 18 CLC TXTPTR = TXTTAB - 1
.,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" STATEMENT
.,A69C 90 06 BCC $A6A4 NO LINE # SPECIFIED
.,A69E F0 04 BEQ $A6A4 ---DITTO---
.,A6A0 C9 AB CMP #$AB IF DASH OR COMMA, START AT LINE 0
.,A6A2 D0 E9 BNE $A68D NO, ERROR
.,A6A4 20 6B A9 JSR $A96B CONVERT LINE NUMBER IF ANY
.,A6A7 20 13 A6 JSR $A613 POINT LOWTR TO 1ST LINE
.,A6AA 20 79 00 JSR $0079 RANGE SPECIFIED?
.,A6AD F0 0C BEQ $A6BB NO
.,A6AF C9 AB CMP #$AB
.,A6B1 D0 8E BNE $A641
.,A6B3 20 73 00 JSR $0073 GET NEXT CHAR
.,A6B6 20 6B A9 JSR $A96B CONVERT SECOND LINE #
.,A6B9 D0 86 BNE $A641 BRANCH IF SYNTAX ERR
.,A6BB 68 PLA POP RETURN ADRESS
.,A6BC 68 PLA (GET BACK BY "JMP NEWSTT")
.,A6BD A5 14 LDA $14 IF NO SECOND NUMBER, USE $FFFF
.,A6BF 05 15 ORA $15
.,A6C1 D0 06 BNE $A6C9 THERE WAS A SECOND NUMBER
.,A6C3 A9 FF LDA #$FF MAX END RANGE
.,A6C5 85 14 STA $14
.,A6C7 85 15 STA $15
.,A6C9 A0 01 LDY #$01
.,A6CB 84 0F STY $0F
.,A6CD B1 5F LDA ($5F),Y HIGH BYTE OF LINK
.,A6CF F0 43 BEQ $A714 END OF PROGRAM
.,A6D1 20 2C A8 JSR $A82C CHECK IF CONTROL-C HAS BEEN TYPED
.,A6D4 20 D7 AA JSR $AAD7 NO, PRINT <RETURN>
.,A6D7 C8 INY
.,A6D8 B1 5F LDA ($5F),Y GET LINE #, COMPARE WITH END RANGE
.,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 ON LAST LINE OF RANGE
.,A6E6 B0 2C BCS $A714 FINISHED THE RANGE
LIST ONE LINE
.,A6E8 84 49 STY $49
.,A6EA 20 CD BD JSR $BDCD PRINT LINE # FROM X,A
.,A6ED A9 20 LDA #$20 PRINT SPACE AFTER LINE #
.,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 NOT END OF LINE YET
.,A707 A8 TAY END OF LINE
.,A708 B1 5F LDA ($5F),Y GET LINK TO NEXT LINE
.,A70A AA TAX
.,A70B C8 INY
.,A70C B1 5F LDA ($5F),Y
.,A70E 86 5F STX $5F POINT TO NEXT LINE
.,A710 85 60 STA $60
.,A712 D0 B5 BNE $A6C9 BRANCH IF NOT END OF PROGRAM
.,A714 4C 86 E3 JMP $E386 TO NEXT STATEMENT
.,A717 6C 06 03 JMP ($0306)
.,A71A 10 D7 BPL $A6F3 BRANCH IF NOT A TOKEN
.,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 CONVERT TOKEN TO INDEX
.,A727 AA TAX
.,A728 84 49 STY $49 SAVE LINE POINTER
.,A72A A0 FF LDY #$FF
.,A72C CA DEX SKIP KEYWORDS UNTIL REACH THIS ONE
.,A72D F0 08 BEQ $A737
.,A72F C8 INY
.,A730 B9 9E A0 LDA $A09E,Y
.,A733 10 FA BPL $A72F NOT AT END OF KEYWORD YET
.,A735 30 F5 BMI $A72C END OF KEYWORD, ALWAYS BRANCHES
.,A737 C8 INY
.,A738 B9 9E A0 LDA $A09E,Y
.,A73B 30 B2 BMI $A6EF LAST CHAR OF KEYWORD
.,A73D 20 47 AB JSR $AB47
.,A740 D0 F5 BNE $A737 ...ALWAYS
*** "FOR" STATEMENT
FOR PUSHES 18 BYTES ON THE STACK:
2 -- TXTPTR
2 -- LINE NUMBER
5 -- INITIAL (CURRENT) FOR VARIABLE VALUE
1 -- STEP SIGN
5 -- STEP VALUE
2 -- ADDRESS OF FOR VARIABLE IN VARTAB
1 -- FOR TOKEN ($81)
.,A742 A9 80 LDA #$80
.,A744 85 10 STA $10 SUBSCRIPTS NOT ALLOWED
.,A746 20 A5 A9 JSR $A9A5 DO <VAR> = <EXP>, STORE ADDR IN FORPNT
.,A749 20 8A A3 JSR $A38A IS THIS FOR VARIABLE ACTIVE?
.,A74C D0 05 BNE $A753 NO
.,A74E 8A TXA YES, CANCEL IT AND ENCLOSED LOOPS
.,A74F 69 0F ADC #$0F CARRY=1, THIS ADDS 16
.,A751 AA TAX X WAS ALREADY S+2
.,A752 9A TXS
.,A753 68 PLA POP RETURN ADDRESS TOO
.,A754 68 PLA
.,A755 A9 09 LDA #$09 BE CERTAIN ENOUGH ROOM IN STACK
.,A757 20 FB A3 JSR $A3FB
.,A75A 20 06 A9 JSR $A906 SCAN AHEAD TO NEXT STATEMENT
.,A75D 18 CLC PUSH STATEMENT ADDRESS ON STACK
.,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 PUSH LINE NUMBER ON STACK
.,A769 48 PHA
.,A76A A5 39 LDA $39
.,A76C 48 PHA
.,A76D A9 A4 LDA #$A4
.,A76F 20 FF AE JSR $AEFF REQUIRE "TO"
.,A772 20 8D AD JSR $AD8D <VAR> = <EXP> MUST BE NUMERIC
.,A775 20 8A AD JSR $AD8A GET FINAL VALUE, MUST BE NUMERIC
.,A778 A5 66 LDA $66 PUT SIGN INTO VALUE IN FAC
.,A77A 09 7F ORA #$7F
.,A77C 25 62 AND $62
.,A77E 85 62 STA $62
.,A780 A9 8B LDA #$8B SET UP FOR RETURN
.,A782 A0 A7 LDY #$A7 TO STEP
.,A784 85 22 STA $22
.,A786 84 23 STY $23
.,A788 4C 43 AE JMP $AE43 RETURNS BY "JMP (INDEX)"
*** "STEP" PHRASE OF "FOR" STATEMENT
.,A78B A9 BC LDA #$BC STEP DEFAULT=1
.,A78D A0 B9 LDY #$B9
.,A78F 20 A2 BB JSR $BBA2
.,A792 20 79 00 JSR $0079
.,A795 C9 A9 CMP #$A9
.,A797 D0 06 BNE $A79F USE DEFAULT VALUE OF 1.0
.,A799 20 73 00 JSR $0073 STEP SPECIFIED, GET IT
.,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
.,A7AD 48 PHA
*** PERFORM NEXT STATEMENT
.,A7AE 20 2C A8 JSR $A82C SEE IF CONTROL-C HAS BEEN TYPED
.,A7B1 A5 7A LDA $7A NO, KEEP EXECUTING
.,A7B3 A4 7B LDY $7B
.,A7B5 C0 02 CPY #$02
.,A7B7 EA NOP
.,A7B8 F0 04 BEQ $A7BE IN DIRECT MODE
.,A7BA 85 3D STA $3D IN RUNNING MODE
.,A7BC 84 3E STY $3E
.,A7BE A0 00 LDY #$00
.,A7C0 B1 7A LDA ($7A),Y END OF LINE YET?
.,A7C2 D0 43 BNE $A807 NO
.,A7C4 A0 02 LDY #$02 YES, SEE IF END OF PROGRAM
.,A7C6 B1 7A LDA ($7A),Y
.,A7C8 18 CLC
.,A7C9 D0 03 BNE $A7CE
.,A7CB 4C 4B A8 JMP $A84B YES, END OF PROGRAM
.,A7CE C8 INY
.,A7CF B1 7A LDA ($7A),Y GET LINE # OF NEXT LINE
.,A7D1 85 39 STA $39
.,A7D3 C8 INY
.,A7D4 B1 7A LDA ($7A),Y
.,A7D6 85 3A STA $3A
.,A7D8 98 TYA ADJUST TXTPTR TO START
.,A7D9 65 7A ADC $7A OF NEW LINE
.,A7DB 85 7A STA $7A
.,A7DD 90 02 BCC $A7E1
.,A7DF E6 7B INC $7B
.,A7E1 6C 08 03 JMP ($0308)
.,A7E4 20 73 00 JSR $0073 GET FIRST CHR OF STATEMENT
.,A7E7 20 ED A7 JSR $A7ED AND START PROCESSING
.,A7EA 4C AE A7 JMP $A7AE BACK FOR MORE
*** EXECUTE A STATEMENT
(A) IS FIRST CHAR OF STATEMENT
CARRY IS SET
.,A7ED F0 3C BEQ $A82B END OF LINE, NULL STATEMENT
.,A7EF E9 80 SBC #$80 FIRST CHAR A TOKEN?
.,A7F1 90 11 BCC $A804 NOT TOKEN, MUST BE "LET"
.,A7F3 C9 23 CMP #$23 STATEMENT-TYPE TOKEN?
.,A7F5 B0 17 BCS $A80E NO, SYNTAX ERROR
.,A7F7 0A ASL DOUBLE TO GET INDEX
.,A7F8 A8 TAY INTO ADDRESS TABLE
.,A7F9 B9 0D A0 LDA $A00D,Y
.,A7FC 48 PHA PUT ADDRESS ON STACK
.,A7FD B9 0C A0 LDA $A00C,Y
.,A800 48 PHA
.,A801 4C 73 00 JMP $0073 GET NEXT CHR & RTS TO ROUTINE
.,A804 4C A5 A9 JMP $A9A5 MUST BE <VAR> = <EXP>
.,A807 C9 3A CMP #$3A
.,A809 F0 D6 BEQ $A7E1
.,A80B 4C 08 AF JMP $AF08
.,A80E C9 4B CMP #$4B
.,A810 D0 F9 BNE $A80B
.,A812 20 73 00 JSR $0073
.,A815 A9 A4 LDA #$A4
.,A817 20 FF AE JSR $AEFF
.,A81A 4C A0 A8 JMP $A8A0
*** "RESTORE" STATEMENT
.,A81D 38 SEC SET DATPTR TO BEGINNING OF PROGRAM
.,A81E A5 2B LDA $2B
.,A820 E9 01 SBC #$01
.,A822 A4 2C LDY $2C
.,A824 B0 01 BCS $A827
.,A826 88 DEY
SET DATPTR TO Y,A
.,A827 85 41 STA $41
.,A829 84 42 STY $42
.,A82B 60 RTS
*** SEE IF CONTROL-C TYPED
.,A82C 20 E1 FF JSR $FFE1
*** "STOP" STATEMENT
.,A82F B0 01 BCS $A832 CARRY=1 TO FORCE PRINTING "BREAK AT.."
*** "END" STATEMENT
.,A831 18 CLC CARRY=0 TO AVOID PRINTING MESSAGE
.,A832 D0 3C BNE $A870 IF NOT END OF STATEMENT, DO NOTHING
.,A834 A5 7A LDA $7A
.,A836 A4 7B LDY $7B
.,A838 A6 3A LDX $3A
.,A83A E8 INX RUNNING?
.,A83B F0 0C BEQ $A849 NO, DIRECT MODE
.,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 " BREAK" AND BELL
.,A84D A0 A3 LDY #$A3
.,A84F 90 03 BCC $A854
.,A851 4C 69 A4 JMP $A469
.,A854 4C 86 E3 JMP $E386
*** "CONT" COMMAND
.,A857 D0 17 BNE $A870 IF NOT END OF STATEMENT, DO NOTHING
.,A859 A2 1A LDX #$1A
.,A85B A4 3E LDY $3E MEANINGFUL RE-ENTRY?
.,A85D D0 03 BNE $A862 YES
.,A85F 4C 37 A4 JMP $A437 NO
.,A862 A5 3D LDA $3D RESTORE TXTPTR
.,A864 85 7A STA $7A
.,A866 84 7B STY $7B
.,A868 A5 3B LDA $3B RESTORE LINE NUMBER
.,A86A A4 3C LDY $3C
.,A86C 85 39 STA $39
.,A86E 84 3A STY $3A
.,A870 60 RTS
*** "RUN" COMMAND
.,A871 08 PHP SAVE STATUS WHILE SUBTRACTING
.,A872 A9 00 LDA #$00
.,A874 20 90 FF JSR $FF90
.,A877 28 PLP GET STATUS AGAIN (FROM CHRGET)
.,A878 D0 03 BNE $A87D PROBABLY A LINE NUMBER
.,A87A 4C 59 A6 JMP $A659 START AT BEGINNING OF PROGRAM
.,A87D 20 60 A6 JSR $A660 CLEAR VARIABLES
.,A880 4C 97 A8 JMP $A897 JOIN GOSUB STATEMENT
*** "GOSUB" STATEMENT
LEAVES 7 BYTES ON STACK:
2 -- RETURN ADDRESS (NEWSTT)
2 -- TXTPTR
2 -- LINE #
1 -- GOSUB TOKEN ($B0)
.,A883 A9 03 LDA #$03 BE SURE ENOUGH ROOM ON STACK
.,A885 20 FB A3 JSR $A3FB
.,A888 A5 7B LDA $7B
.,A88A 48 PHA
.,A88B A5 7A LDA $7A
.,A88D 48 PHA
.,A88E A5 3A LDA $3A