-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathDragon 64 in 32 mode.txt
4234 lines (3724 loc) · 135 KB
/
Dragon 64 in 32 mode.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
###############################################################################
# Information about Dragon 64 ROM - 32K mode
#
# Collected from:
# http://archive.worldofdragon.org/phpBB3/viewtopic.php?f=5&t=4370&start=10#p11378
# AUTHOR: Stewart Orchard alias sorchard
#
# copyleft: 2014 by the 6809 team, see AUTHORS for more details.
# license: GNU GPL v3 or above, see LICENSE for more details.
#
###############################################################################
$8000-$8012 ; * standard JMP vectors
$8000-$8012 ; * hardware routines
$8000 ; reset
$8003 ; set up $8f - $9b
$8006 ; scan keyboard (A)
$8009 ; blink cursor
$800c ; write to VDU (A)
$800f ; write to printer (A)
$8012 ; update joysticks
$8015-$8027 ; * tape routines
$8015 ; motoron
$8018 ; motoroff
$801b ; write leader
$801e ; byte out (A)
$8021 ; read leader
$8024 ; byte in (A)
$8027 ; bit in (C)
$802a-$8030 ; * serial routines
$802a ; read serial (A)
$802d ; write serial (A)
$8030 ; baud rate select
$8033-$814f ; * command table : last byte of each string has MSB set
$8033-$814f ; * (token in final column)
$8033 ; FOR 80
$8036 ; GO 81
$8038 ; REM 82
$803b ; ' 83
$803c ; ELSE 84
$8040 ; IF 85
$8042 ; DATA 86
$8046 ; PRINT 87
$804b ; ON 88
$804d ; INPUT 89
$8052 ; END 8A
$8055 ; NEXT 8B
$8059 ; DIM 8C
$805c ; READ 8D
$8060 ; LET 8E
$8063 ; RUN 8F
$8066 ; RESTORE 90
$806d ; RETURN 91
$8073 ; STOP 92
$8077 ; POKE 93
$807b ; CONT 94
$807f ; LIST 95
$8083 ; CLEAR 96
$8088 ; NEW 97
$808b ; DEF 98
$808e ; CLOAD 99
$8093 ; CSAVE 9A
$8098 ; OPEN 9B
$809c ; CLOSE 9C
$80a1 ; LLIST 9D
$80a6 ; SET 9E
$80a9 ; RESET 9F
$80ae ; CLS A0
$80b1 ; MOTOR A1
$80b6 ; SOUND A2
$80bb ; AUDIO A3
$80c0 ; EXEC A4
$80c4 ; SKIPF A5
$80c9 ; DEL A6
$80cc ; EDIT A7
$80d0 ; TRON A8
$80d4 ; TROFF A9
$80d9 ; LINE AA
$80dd ; PCLS AB
$80e1 ; PSET AC
$80e5 ; PRESET AD
$80eb ; SCREEN AE
$80f1 ; PCLEAR AF
$80f7 ; COLOR B0
$80fc ; CIRCLE B1
$8102 ; PAINT B2
$8107 ; GET B3
$810a ; PUT B4
$810d ; DRAW B5
$8111 ; PCOPY B6
$8116 ; PMODE B7
$811b ; PLAY B8
$811f ; DLOAD B9
$8124 ; RENUM BA
$8129 ; TAB( BB
$812d ; TO BC
$812f ; SUB BD
$8132 ; FN BE
$8134 ; THEN BF
$8138 ; NOT C0
$813b ; STEP C1
$813f ; OFF C2
$8142 ; + C3
$8143 ; - C4
$8144 ; * C5
$8145 ; / C6
$8146 ; ^ C7
$8147 ; AND C8
$814a ; OR C9
$814c ; > CA
$814d ; = CB
$814e ; < CC
$814f ; USING CD
$8154-$81c4 ; * command vectors
$8154 ; for go rem '
$815c ; else if data print
$8164 ; on input end next
$816c ; dim read let run
$8174 ; restore return stop poke
$817c ; cont list clear new
$8184 ; def cload csave open
$818c ; close llist set reset
$8194 ; cls motor sound audio
$819c ; exec skipf del edit
$81a4 ; tron troff line pcls
$81ac ; pset preset screen pclear
$81b4 ; color circle paint get
$81bc ; put draw pcopy pmode
$81c4 ; play dload renum
$81ca-$824d ; * function table : last byte of each string has MSB set
$81ca-$824d ; * (token in final column)
$81ca ; SGN FF80
$81cd ; INT FF81
$81d0 ; ABS FF82
$81d3 ; POS FF83
$81d6 ; RND FF84
$81d9 ; SQR FF85
$81dc ; LOG FF86
$81df ; EXP FF87
$81e2 ; SIN FF88
$81e5 ; COS FF89
$81e8 ; TAN FF8A
$81eb ; ATN FF8B
$81ee ; PEEK FF8C
$81f2 ; LEN FF8D
$81f5 ; STR$ FF8E
$81f9 ; VAL FF8F
$81fc ; ASC FF90
$81ff ; CHR$ FF91
$8203 ; EOF FF92
$8206 ; JOYSTK FF93
$820c ; FIX FF94
$820f ; HEX$ FF95
$8213 ; LEFT$ FF96
$8218 ; RIGHT$ FF97
$821e ; MID$ FF98
$8222 ; POINT FF99
$8227 ; INKEY$ FF9A
$822d ; MEM FF9B
$8230 ; VARPTR FF9C
$8236 ; INSTR FF9D
$823b ; TIMER FF9E
$8240 ; PPOINT FF9F
$8246 ; STRING$ FFA0
$824d ; USR FFA1
$8250-$8290 ; * function vectors
$8250 ; sgn int abs pos
$8258 ; rnd sqr log exp
$8260 ; sin cos tan atn
$8268 ; peek len str$ val
$8270 ; asc chr$ eof joystk
$8278 ; fix hex$ left$ right$
$8280 ; mid$ point inkey$ mem
$8288 ; varptr instr timer ppoint
$8290 ; string$ usr
$8294-$82a6 ; * binary operator table used during expression evaluation
$8294-$82a6 ; * (1st byte is precedence level followed by address of handler)
$8294 ; +
$8297 ; -
$829a ; *
$829d ; /
$82a0 ; ^
$82a3 ; AND
$82a6 ; OR
$82a9-$82dd ; * error code strings
$82df-$82f0 ; * misc strings
$82df ; /ERROR /
$82e6 ; / IN /
$82eb ; CR/OK/CR
$82f0 ; CR/BREAK/
$82f7-$831b ; * examine BASIC stack (maintained 'under' machine return addresses)
$82f7-$831b ; * $3b = varptr of FOR control variable to search for (zero if none)
$82f7-$831b ; * set $3b to #$ff to skip all FOR entries
$82f7-$831b ; * returns X = $0f = pointer to matching entry for FOR / NEXT
$82f7-$831b ; * $3b = varptr of control variable for unspecified NEXT
$82f7-$831b ; * Z = 0 if matching FOR entry not found
$82f7 ; point X past 2 return addresses
$82f9 ; size of FOR stack entry
$82fb ; $0f = this entry
$8301 ; not a FOR entry
$8305 ; varptr of control variable
$8309 ; we were called by NEXT with no variable
$830d ; found a matching entry
$8311 ; point X to next stack entry
$8312 ; examine next entry
$8314 ; set $3b up with varptr of control variable
$8316 ; for unspecified NEXT
$831c-$8330 ; * move memory contents up
$831c-$8330 ; * start address - $47
$831c-$8330 ; * end address - $43
$831c-$8330 ; * new end address - $41 (D = new end address for memory check)
$831c-$8330 ; * returns $45 = U = start of relocated block
$831c ; memory check
$8331-$8342 ; * check if there are B free words of storage left
$8333 ; end of BASIC storage
$8338 ; ?OM ERROR
$8340 ; RTS
$8342 ; ?OM ERROR
$8344-$836e ; * ?xx ERROR - error code in B
$8344 ; user error trap
$8347 ; system error trap
$834a ; cassette relay off
$834d ; disable audio
$8350 ; reset stack & bits & pieces
$8353 ; DEVN
$8355 ; initialise virtual DEVN device & new line
$8358 ; print '?' to DEVN
$835b ; error string table
$835f ; output to DEVN from ,X+
$8361 ; output to DEVN from ,X+
$8363 ; 'ERROR'
$8366 ; print string to DEVN
$8369 ; current line number
$836c ; command mode
$836e ; print 'IN xxxx' (current line number)
$8371-$839b ; * command mode
$8371 ; initialise virtual DEVN device & new line
$8377 ; print 'OK'
$837a ; line input from DEVN
$8380 ; current line number
$8382 ; command mode without 'OK'
$8384 ; eof flag
$8386 ; close file & return to command mode
$838a ; BASIC source pointer
$838c ; get next character from BASIC source
$838e ; command mode without 'OK'
$8390 ; enter BASIC line
$8392 ; ?DS ERROR
$8394 ; DEVN
$8396 ; cause error
$8398 ; tokenize BASIC line
$839b ; enter interpreter loop
$839e-$83a0 ; * used by error routine to print error code
$83a0 ; output character to DEVN
$83a3-$83eb ; * enter a BASIC line
$83a3 ; read line number & store in $2b
$83ab ; tokenize BASIC line
$83ae ; line length
$83b0 ; search program for line number in <$2b
$83b2 ; line number doesn't exist
$83b4 ; address where line needs to go
$83b6 ; subtract next line pointer (-ve result)
$83b8 ; start of simple variables
$83ba ; new end of program
$83be ; move program down, erasing existing line
$83c2 ; start of simple variables
$83c9 ; new line is empty
$83cb ; start of simple variables
$83cf ; new line length
$83d5 ; move memory contents up
$83dd ; copy new line into space just created
$83e5 ; new end of program
$83e7 ; clear variables and reset stack & cmd ptr
$83e9 ; set up next line pointers in BASIC program
$83eb ; command mode without 'OK'
$83ed-$83fd ; * set up next line pointers in BASIC program
$83ed ; start of BASIC program
$83f1 ; RTS
$83ff-$8401 ; * search program for line number in <$2b
$8401 ; start of BASIC program
$8403-$8414 ; * scan ahead for line in D & store address in $47
$8403-$8414 ; * (first line after if it doesn't exist - carry clear if found)
$8405 ; end of program
$8407 ; scan program until line no. is greater
$840a ; than D
$840c ; next line
$8415-$8446 ; * NEW
$8417 ; start of BASIC program
$841d ; start of simple variables
$841f ; start of BASIC program
$8421 ; subtract 1 from X & store in $a6
$8424 ; PATCH - reset BASIC memory
$8427 ; top of BASIC RAM
$8429 ; top of free string space
$842b ; RESTORE
$842e ; start of simple variables
$8430 ; start of array variables
$8432 ; end of BASIC storage
$843b ; stack root / string storage start
$8440 ; CONT source address
$8448-$849d ; * FOR
$8448-$849d ; * creates following 18 byte stack entry:
$8448-$849d ; * ,S #$80
$8448-$849d ; * 1,S varptr of control variable
$8448-$849d ; * 3,S STEP value (unsigned FP)
$8448-$849d ; * 8,S sign of STEP value (-1, 0 ,1)
$8448-$849d ; * 9,S TO value (signed FP)
$8448-$849d ; * 14,S line number of FOR statement
$8448-$849d ; * 16,S address of statement after FOR
$844a ; array illegal flag
$844c ; LET
$844f ; examine BASIC stack
$8452 ; lose return address
$8454 ; no FOR with same control variable already
$8458 ; overwrite duplicate FOR entry
$845c ; memory check
$845f ; find end of statement
$8462 ; current line number
$8464 ; push next statement ptr & current line no.
$8466 ; token TO
$8468 ; skip character in B
$846b ; validate numeric expression
$846e ; read numeric expression into FPA1
$8473 ; convert FPA1 back to standard variable
$847d ; push FPA1 onto stack & JMP ,Y
$8480 ; FP constant 1
$8483 ; load variable into FPA1 (X is varptr)
$8486 ; get current character from BASIC source
$8488 ; token STEP
$848a ; no STEP value specified
$848c ; get next character from BASIC source
$848e ; read numeric expression into FPA1
$8491 ; sets B to -1, 0 or 1 as per sign of FPA1
$8494 ; push B then FPA1 onto stack
$8497 ; varptr of control variable
$849b ; FOR signature on stack
$849f-$84da ; * interpreter loop
$849f ; PATCH - get command
$84a2 ; unmask interrupts
$84a4 ; scan for BREAK / pause
$84a6 ; BASIC source pointer
$84a8 ; address of current BASIC statement
$84ac ; end of line
$84b2 ; ?SN ERROR
$84b7 ; this will be zero when end reached
$84b9 ; end of program
$84bf ; current line number
$84c1 ; BASIC source pointer
$84c3 ; trace flag
$84c5 ; trace off
$84c9 ; output character to DEVN
$84cc ; current line number
$84ce ; print unsigned number in D
$84d3 ; output character to DEVN
$84d6 ; get next character from BASIC source
$84d8 ; interpret statement
$84da ; interpreter loop
$84dc-$8512 ; * interpret statement
$84dc ; RTS
$84de ; PATCH - interpreter
$84e2 ; variable on LHS (LET)
$84e8 ; not a BASIC command
$84ea ; command JMP table
$84f1 ; get next character from BASIC source
$84f7 ; function
$84fb ; ?SN ERROR
$84fd ; must be disk command
$8501 ; get next character from BASIC source
$8505 ; MID$ on LHS
$850b ; TIMER on LHS
$850f ; PATCH - CLS GET PUT ???
$8512 ; ?SN ERROR
$8514-$851a ; * RESTORE
$8514 ; start of BASIC program
$8518 ; READ pointer
$851b-$8530 ; * scan keyboard for break & pause
$851b ; scan keyboard
$8522 ; BREAK
$8526 ; SHIFT + @
$852b ; scan keyboard
$8532-$8537 ; * END
$8532 ; close cassette stream
$8535 ; get current character from BASIC source
$8539-$855d ; * STOP
$853b ; RTS
$853d ; BASIC source pointer
$853f ; address of current BASIC statement
$8541 ; make -ve for STOP
$8543 ; lose return address
$8545 ; current line number
$854a ; already in command mode
$854c ; CONT line number
$854e ; address of current BASIC statement
$8550 ; CONT source address
$8552 ; DEVN
$8554 ; /BREAK/
$8559 ; command mode
$855d ; print BREAK message
$8560-$8570 ; * CONT
$8560 ; RTS
$8562 ; ?CN ERROR
$8564 ; CONT source address
$8566 ; cause error
$856a ; BASIC source pointer
$856c ; CONT line number
$856e ; current line number
$8571-$85a2 ; * CLEAR
$8571 ; clear variables & reset stack
$8573 ; read unsigned number into $52 & D
$8578 ; top of BASIC RAM
$857a ; get current character from BASIC source
$857e ; skip comma
$8581 ; read 16 bit number into X
$8586 ; top of RAM
$8588 ; ?OM ERROR
$858e ; ?OM ERROR
$8595 ; ?OM ERROR
$8597 ; start of simple variables
$8599 ; ?OM ERROR
$859b ; new stack address
$859d ; new top of BASIC RAM
$859f ; clear variables & reset stack
$85a2 ; ?OM ERROR
$85a5-$85b7 ; * RUN
$85a5 ; PATCH - run
$85a8 ; set up sound & graphics variables
$85ab ; close cassette stream
$85ae ; get current character from BASIC source
$85b0 ; clear variables and reset stack & cmd ptr
$85b4 ; clear variables & reset stack
$85b7 ; perform GOTO
$85b9-$85d4 ; * GO (TO/SUB)
$85b9-$85d4 ; * GOSUB creates following 5 byte stack entry:
$85b9-$85d4 ; * ,S #$BD
$85b9-$85d4 ; * 1,S line number of GOSUB statement
$85b9-$85d4 ; * 3,S address of GOSUB statement (points to SUB token)
$85bb ; get next character from BASIC source
$85bd ; token TO
$85bf ; perform GOTO
$85c1 ; token SUB
$85c3 ; ?SN ERROR
$85c7 ; memory check
$85ca ; BASIC source pointer
$85cc ; current line number
$85ce ; token SUB
$85d2 ; perform GOTO
$85d4 ; interpreter loop
$85d7-$85f2 ; * perform GOTO
$85d7 ; get current character from BASIC source
$85d9 ; read line number & store in $2b
$85dc ; find end of line
$85e2 ; current line number
$85e7 ; start of BASIC program
$85e9 ; scan for line D
$85ec ; ?UL ERROR
$85f0 ; BASIC source pointer
$85f3-$8604 ; * RETURN
$85f3 ; RTS
$85f7 ; set $3b to skip all FOR entries
$85f9 ; examine BASIC stack
$85fc ; point stack to this entry
$8600 ; GOSUB signature (#$BD - #$80)
$8602 ; ?RG ERROR
$8607-$8611 ; * (8605 C60E LDB #$0E) ;?UL ERROR
$8607 ; cause error
$860a ; ?SN ERROR
$860f ; current line number
$8611 ; BASIC source pointer
$8613-$8615 ; * DATA
$8613-$8615 ; * (simply skips to next statement)
$8613 ; find end of statement
$8618-$861a ; * REM / ELSE
$8618-$861a ; * (8616 8D06 BSR $861E) ;find end of line
$8618 ; BASIC source pointer
$861b-$861d ; * find end of statement
$861f-$8645 ; * (861E 5F CLRB)
$8622 ; BASIC source pointer
$862c ; RTS
$8632 ; RTS
$863f ; token IF (+1)
$8643 ; increment for each IF token encountered
$8647-$8672 ; * IF
$8647-$8672 ; * IF condition (THEN/GOTO) [IF...THEN [IF...THEN...ELSE] ELSE] ELSE
$8647-$8672 ; * -- ----
$8647-$8672 ; * ELSEs are tied to previous IFs
$8647 ; read numeric expression into FPA1
$864a ; get current character from BASIC source
$864c ; token GO
$8650 ; token THEN
$8652 ; skip character in B
$8657 ; IF condition true
$8659 ; clear IF counter
$865b ; skip to start of next statement
$865e ; RTS
$8660 ; get next character from BASIC source
$8662 ; token ELSE
$8664 ; we're looking for ELSE
$8666 ; any IFs skipped?
$8668 ; this ELSE doesn't go with this IF
$866a ; get next character from BASIC source
$866c ; get current character from BASIC source
$866e ; it's a number - perform GOTO
$8672 ; interpret statement
$8675-$8698 ; * ON
$8675 ; get number into B
$8678 ; token GO
$867a ; skip character in B
$867f ; token SUB
$8683 ; token TO
$8685 ; ?SN ERROR
$8687 ; control variable
$868d ; GO (cmd pointer now at desired choice)
$8690 ; get next character from BASIC source
$8692 ; read line number & store in $2b
$869a-$86ba ; * read line number from command & store in $2b
$869a ; zero
$869e ; not a digit - RTS
$86a6 ; D > 6399?
$86a8 ; ?SN ERROR
$86ac ; D = D * 10
$86b2 ; add new digit
$86b8 ; get next character from BASIC source
$86ba ; process another digit
$86bc-$8704 ; * LET
$86bc ; get varptr of variable in X
$86c1 ; token =
$86c3 ; skip character in B
$86c6 ; numeric / string flag
$86ca ; get expression
$86cf ; check that variable & expression
$86d0 ; are of same type
$86d3 ; assign FPA1 to varptr in <$3b
$86d7 ; PATCH - assign string variable
$86dc ; stack root / string storage start
$86e3 ; start of simple variables
$86e9 ; reserve B bytes of string space
$86ee ; copy string (len B) from varptr X to ($25)+
$86f6 ; if X is top of string stack then pull it
$8705 ; * string used by INPUT
$8705 ; /?REDO/CR
$870c-$872a ; * take action for illegal input
$870c ; ?FD ERROR
$870e ; DEVN
$8712 ; cause error
$8719 ; line number of current DATA statement
$871b ; current line number
$871d ; ?SN ERROR
$8720 ; /?REDO/
$8723 ; print string to DEVN
$8726 ; address of current BASIC statement
$8728 ; BASIC source pointer
$872b-$8776 ; * INPUT
$872b ; test for command mode
$8730 ; DEVN
$8737 ; read #-n & set up DEVN
$873a ; test cassette status OK for input
$873d ; skip comma
$8742 ; no prompt
$8744 ; read literal string
$8749 ; skip character in B
$874c ; print prompt
$8754 ; DEVN
$8758 ; get something into input buffer
$875e ; read input into variables
$8760 ; print '?' to DEVN
$8763 ; print a space to DEVN
$8766 ; line input from DEVN
$876d ; BREAK
$8770 ; ?IE ERROR
$8772 ; eof flag
$8777-$8818 ; * READ
$8777 ; READ pointer
$877f ; get varptr of variable in X
$8784 ; BASIC source pointer
$8792 ; PATCH - re-request input
$8795 ; print '?' to DEVN
$879a ; BASIC source pointer
$879c ; get next character from BASIC source
$879e ; numeric / string flag
$87a2 ; BASIC source pointer
$87af ; initialise virtual DEVN device
$87b2 ; cassette IO flag
$87b4 ; IO in progress
$87be ; compile literal string at X
$87c4 ; assign string variable
$87c9 ; read numeric constant into FPA1
$87cc ; assign FPA1 to varptr in <$3b
$87cf ; get current character from BASIC source
$87d5 ; take action for illegal input
$87d9 ; BASIC source pointer
$87df ; BASIC source pointer
$87e1 ; get current character from BASIC source
$87e5 ; skip comma
$87ea ; BASIC source pointer
$87ec ; find end of statement
$87fc ; line number of current DATA statement
$8815 ; print string to DEVN
$8819 ; * string used by INPUT
$8819 ; /?EXTRA IGNORED/CR
$8829-$8870 ; * NEXT
$8829 ; control variable specified
$882b ; zero
$882f ; get varptr of variable in X
$8834 ; examine BASIC stack
$8837 ; found match
$8839 ; ?NF ERROR
$883d ; point stack to this entry
$883f ; point X to STEP value
$8841 ; load variable into FPA1 (X is varptr)
$8844 ; sign of STEP value
$8848 ; varptr of control variable
$884a ; add varptr X to FPA1
$884d ; assign FPA1 to varptr in <$3b
$8850 ; point X to terminating value
$8852 ; compare FPA1 - varptr X
$8855 ; test depends on step direction
$8857 ; terminating condition met
$885b ; current line number
$8860 ; BASIC source pointer
$8862 ; interpreter loop
$8865 ; finished with this entry
$8868 ; get current character from BASIC source
$886c ; no more variables after NEXT
$886e ; get next character from BASIC source
$8870 ; BSR used for correct stack structure
$8872 ; * ;(never returns to $8872)
$8872 ; * get numeric expression into FPA1
$8872 ; get expression
$8874-$8876 ; * cause error if expression last evaluated not numeric
$8879-$887f ; * cause error if expression last evaluated not string
$8879-$887f ; * (8877 1A01 ORCC #$01)
$8879 ; numeric / string flag
$887d ; RTS
$8882-$8884 ; * (8880 2B96 BMI $8818) ;RTS
$8882 ; ?TM ERROR
$8884 ; cause error
$8887-$888a ; * get expression
$8887 ; move source pointer back one
$888d-$88b0 ; * (888B 3404 PSHS B)
$8891 ; memory check
$8894 ; evaluate sub-expression
$8897 ; flag used for relational operators
$8899 ; get current character from BASIC source
$889b ; branch to $88B2 if token is not in the set
$889d ; [ >, =, < ]
$88a3 ; map [0, 1, 2] to [1, 2, 4]
$88a6 ; determine valid combination of > = <
$88aa ; ?SN ERROR
$88ae ; get next character from BASIC source
$88b2-$88e7 ; *
$88b2 ; $3f = [ 1, 2, 3, 4, 5, 6 ]
$88b4 ; for [ > = >= < <> <= ]
$88bc ; not a binary operator
$88be ; A = A + 1 + ($06)
$88c0 ; '+' in a string expression
$88c4 ; A = A - 1 if numeric expression
$88c9 ; A = A * 3
$88cb ; binary operator precedence table
$88d0 ; precedence of last operator
$88d4 ; new op. has a lower precedence
$88d6 ; validate numeric expression
$88da ; push op handler & FPA1 / get expression
$88e3 ; LDB <$4F RTS
$88e9-$88f5 ; * set up precedence / handler for rel. op.
$88e9 ; numeric / string flag
$88ec ; move source pointer back one
$88f3 ; numeric / string flag
$88f7-$88f9 ; * move source pointer back one
$88f7 ; BASIC source pointer
$88f9 ; subtract 1 from X & store in $a6
$88fc-$8903 ; * rel. op. precedence & handler
$8905-$8910 ; * push op handler & FPA1 onto stack / get expression
$8905 ; op handler
$8909 ; push FPA1 onto stack
$890b ; rel. op. flag
$890d ; get expression
$8910 ; ?SN ERROR
$8913-$8923 ; * push FPA1 onto stack
$8925-$8953 ; * end of expression / execute operator
$8925 ; zero
$8929 ; LDB <$4F RTS
$892f ; validate numeric expression
$8938 ; RTS
$893c ; RTS
$893e ; sets carry if rel. op. was for string
$8941 ; pull FPA2 off stack
$8943 ; set $62 up with sign difference
$8947 ; LDB <$4F
$894b ; RTS calls operator handler
$894d ; (with carry from above)
$8954-$89a1 ; * evaluate sub-expression ('+' & '-' treated as signs)
$8954 ; PATCH - evaluate expression
$8957 ; numeric / string flag
$8959 ; get next character from BASIC source
$895d ; read numeric constant into FPA1
$8960 ; carry clear if A-Z
$8963 ; evaluate variable
$8969 ; token -
$896b ; read expression & negate
$896d ; token +
$896f ; ignore +
$8975 ; BASIC source pointer
$8977 ; compile literal string at X
$897c ; move source pointer to end of string
$897f ; token NOT
$8988 ; read signed number from FPA1 to $52 & D
$898d ; assign D to FPA1
$8990 ; token FN
$8998 ; read octal or hex number into $52 / $53
$899d ; evaluate function
$899f ; skip open bracket (only legal chr. left)
$89a1 ; get expression
$89a4-$89a6 ; * check for close bracket
$89a9 ; * check for open bracket
$89a9 ; * (89A7 C628 LDB #$28)
$89ac-$89b6 ; * check for comma
$89ac-$89b6 ; * (89AA C62C LDB #$2C)
$89ac-$89b6 ; * check for character in B
$89b0 ; ?SN ERROR
$89b2 ; get next character from BASIC source
$89b4 ; ?SN ERROR
$89b6 ; cause error
$89b9-$89be ; * read expression & negate FPA1
$89be ; COM $54 if FPA1 non zero
$89c1-$89ca ; * evaluate variable
$89c1 ; get varptr of variable in X
$89c6 ; numeric / string flag
$89c8 ; RTS (string)
$89ca ; load variable into FPA1 (X is varptr)
$89cd-$8a03 ; * evaluate function
$89cd ; get next character from BASIC source
$89d2 ; get next character from BASIC source
$89d8 ; disk function despatch
$89e0 ; functions with single arguments
$89e4 ; functions with special or no arguments
$89e6 ; skip open bracket
$89ec ; not LEFT$, RIGHT$ or MID$
$89ee ; get expression
$89f1 ; skip comma
$89f3 ; validate string
$89fc ; get number into B
$8a06-$8a0e ; * (8A04 8D99 BSR $899F) ;get expression inside brackets
$8a08 ; function despatch table
$8a0e ; validate numeric expression
$8a11 ; * OR
$8a13-$8a2e ; * AND
$8a13-$8a2e ; * (8A12 4F CLRA)
$8a15 ; read signed number from FPA1 to $52 & D
$8a1a ; copy FPA2 to FPA1
$8a1d ; read signed number from FPA1 to $52 & D
$8a2e ; assign D to FPA1
$8a31-$8a88 ; * handler for relational operators
$8a31 ; validate string / numeric using carry
$8a34 ; valid string
$8a3e ; FPA2
$8a41 ; compare FPA1 - varptr X
$8a46 ; numeric / string flag
$8a4a ; point X to string just compiled & len in B
$8a53 ; point X to string & length in B
$8a7c ; map [-1, 0, 1] to [1, 2, 4]
$8a7f ; rel. op. number
$8a85 ; assign B to FPA1 (result of relation)
$8a88 ; skip comma
$8a8b-$8a93 ; * DIM
$8a8d ; create variable
$8a8f ; get current character from BASIC source
$8a91 ; skip comma & read next array
$8a94-$8a95 ; * gets VARPTR address of following variable
$8a94-$8a95 ; * set $08 to #$80 to exclude array variables
$8a94-$8a95 ; * creates new variable if not found
$8a94-$8a95 ; * returns $39 = X = varptr address
$8a95 ; get current character from BASIC source
$8a97-$8add ; * set B to cause error if array variable already exists
$8a9b ; get current character from BASIC source
$8a9d ; carry clear if A-Z
$8a9f ; ?SN ERROR
$8aa4 ; numeric / string flag
$8aa6 ; get next character from BASIC source
$8aaa ; carry clear if A-Z
$8ab0 ; get next character from BASIC source
$8ab4 ; carry clear if A-Z
$8aba ; numeric variable
$8abc ; numeric / string flag
$8ac0 ; get next character from BASIC source
$8ac4 ; set $08 to #$80 to exclude array variables
$8ac8 ; array variable
$8ace ; start of simple variables
$8ad2 ; start of array variables
$8ad4 ; not found - create variable
$8ad9 ; found existing variable - STX <$39 & RTS
$8add ; keep looking
$8adf-$8ae7 ; * clear carry if A contains 'A'-'Z'
$8ae8-$8b1c ; * create variable
$8aed ; if called by evaluate variable routine - RTS
$8af1 ; (with X pointing to zero)
$8af3 ; end of BASIC storage
$8afc ; start of array variables
$8b00 ; move memory contents up
$8b05 ; end of BASIC storage
$8b09 ; start of array variables
$8b0d ; variable name
$8b1c ; FP constant -32768
$8b21-$8b26 ; * read unsigned number into $52 & D
$8b21 ; get next character from BASIC source
$8b23 ; read numeric expression into FPA1
$8b26 ; validate numeric expression
$8b29-$8b2b ; * read +ve number from FPA1 into $52 & D
$8b2b ; ?FC ERROR
$8b2d-$8b43 ; * read signed number from FPA1 into $52 & D
$8b2d ; validate numeric expression
$8b36 ; only 16 bit number allowed is -32768
$8b39 ; compare FPA1 - varptr X
$8b3c ; ?FC ERROR
$8b3e ; denormalize FPA1 to an integer
$8b44-$8b8c ; * get varptr of variable continued (handle arrays)
$8b46 ; numeric / string flag
$8b4f ; read unsigned number into $52 & D
$8b5a ; get current character from BASIC source
$8b5e ; get next dimension
$8b60 ; number of dimensions
$8b62 ; skip close bracket
$8b67 ; numeric / string flag
$8b6b ; start of array variables
$8b6d ; end of BASIC storage
$8b6f ; not found - create new array
$8b76 ; found array name
$8b7c ; keep looking
$8b7e ; ?DD ERROR
$8b82 ; cause error if array exists & $05 set
$8b88 ; correct number of dimensions
$8b8a ; ?BS ERROR
$8b8f-$8c10 ; * (8B8D C608 LDB #$08) ;?FC ERROR
$8b8f ; cause error
$8b92 ; bytes per element
$8b99 ; array name
$8b9d ; number of dimensions
$8b9f ; memory check
$8ba2 ; start of array header
$8ba4 ; default number of elements
$8bb2 ; D = word at 5,X * word at $64
$8bba ; next dimension
$8bbc ; start of array element storage
$8bbe ; D = end of array
$8bc0 ; ?OM ERROR
$8bc6 ; memory check (also adds #$3a to D)
$8bcc ; end of BASIC storage
$8bcf ; clear array
$8bd7 ; array header
$8bd9 ; end of BASIC storage
$8bdd ; offset to next array (when it's created)
$8be1 ; RTS
$8bf2 ; ?BS ERROR
$8bf8 ; D = word at 5,X * word at $64
$8c08 ; D = D * 5
$8c11-$8c2e ; * D = word at 5,X * word at $64
$8c1d ; ?BS ERROR
$8c27 ; ?BS ERROR
$8c2e ; ?BS ERROR
$8c31-$8c33 ; * MEM
$8c33 ; ...continued
$8c36 ; * assign B to FPA1
$8c37-$8c3d ; * assign D to FPA1 (signed)
$8c37 ; numeric / string flag
$8c3d ; signed assign!
$8c40-$8c4e ; * STR$
$8c40 ; validate numeric expression
$8c46 ; convert FPA1 to string at U
$8c49 ; lose return address
$8c4e ; compile literal string at X
$8c50-$8c58 ; * reserve B bytes of string space
$8c50-$8c58 ; * returns X = $58 = start of requested block
$8c50-$8c58 ; * B = $56 = length of block
$8c52 ; reserve B bytes of string space
$8c59-$8cb2 ; * register a delimited string pointed to by X
$8c59-$8cb2 ; * if string is in keyboard buffer, then copy it into free string space.
$8c59-$8cb2 ; * stores string start, end & length in $62, $64 & $56
$8c59-$8cb2 ; * string start also in $58
$8c59-$8cb2 ; * if copied to string space, start & end also in $58 & $4d
$8c80 ; PATCH - reset BASIC memory
$8c89 ; push temp string onto varptr stack
$8c8b ; reserve B bytes of string space
$8c8f ; copy string of length B from X+ to ($25)+
$8c99 ; ?ST ERROR
$8c9b ; cause error
$8ca8 ; numeric / string flag
$8cb3-$8cd5 ; * reserve B bytes of string space
$8cb3-$8cd5 ; * returns X = pointer to requested block & B = length
$8cb3-$8cd5 ; * requested block also in $25
$8cb8 ; top of free string space
$8cbc ; stack root / string storage start
$8cbf ; not enough space
$8cc1 ; new free pointer
$8cc7 ; points to requested block
$8ccb ; ?OS ERROR
$8ccf ; already done garbage collect - give up
$8cd1 ; string garbage collect
$8cd5 ; try to reserve space again
$8cd7-$8d52 ; * string space garbage collect
$8cd7 ; top of BASIC RAM
$8cd9 ; top of free string space
$8cdf ; stack root / string storage start
$8cee ; start of simple variables
$8cf0 ; start of array variables
$8cfc ; end of BASIC storage
$8d24 ; top of free string space
$8d41 ; top of free string space
$8d45 ; move memory contents up (no memory check)
$8d55-$8d86 ; * handle '+' in a string expression (concatenate)