-
Notifications
You must be signed in to change notification settings - Fork 1
/
gmon1.2.s
1827 lines (1827 loc) · 55.7 KB
/
gmon1.2.s
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
10 ! see line 8332 brk
20 ! bug in mikro abs,y mode thinks
30 ! it's ok in zero page !!!
40 !
100 * = $c000
110 !
130 chrin = $ffcf
140 buffer = $0200
150 kerload = $ffd5
160 kersave = $ffd8
190 temp = $f7
200 temp1 = $f9
210 stopkey = $ffe1
220 getkey = $ffe4
230 upclock = $ffea
240 byte = $19
250 numbytes = $1a
260 mode = $1b
270 regs = $0240
280 warmstart = $a002
290 breakvec = $0316
300 regs1 = regs+2
310 temp2 = $14
320 hbuffer = $0228
330 ysave = $1e
340 optemp = $20
350 caltemp = $1f
360 astemp = $26
370 astemp1 = $28
380 ntemp = $248
390 overtop = $1c
400 nat = $247
410 ciout = $ffa8
420 listen = $ffb1
430 close = $ffc3
440 sendchr = $ffd2
450 chkout = $ffc9
460 open = $ffc0
470 clrchn = $ffcc
480 linnum = $bdcd
490 second = $ff93
500 clall = $ffe7
510 shift = $028d
520 st = $90
530 setnam = $ffbd
540 setlfs = $ffba
550 chkin = $ffc6
560 talk = $ffb4
570 unlsn = $ffae
580 tksa = $ff96
590 acptr = $ffa5
600 untlk = $ffab
610 tracknum = optemp
620 secnum = optemp+1
630 track = $0207
640 sector = $020a
650 eos = $f642
660 storeof1 = $249
990 !
1000 lda breaklo
1010 sta breakvec
1020 lda breakhi
1030 sta breakvec+1
1040 lda #$80
1050 sta $9d
1060 break1 brk
1070 break cld
1080 pla
1090 sta regs+5
1100 pla
1110 sta regs+4
1120 pla
1130 sta regs+3
1140 pla
1150 sta regs+2
1160 pla
1170 adc #$ff
1180 sta regs+1
1190 pla
1200 adc #$ff
1210 sta regs
1220 !
1230 lda $01
1240 sta storeof1
1250 lda #$37
1260 sta $01
1270 tsx
1280 stx regs+6
1290 ldx #0
1300 ll0 lda title,x
1310 beq ll1
1320 jsr chrout
1330 inx
1340 bne ll0
1350 ll1 lda #$52
1360 bne command
1370 start ldx #$0d
1380 lda #$2e
1390 jsr prxta
1392 lda #60
1394 sta $dc05
1396 lda $08
1398 sta $07
1400 jsr inputline
1410 assmore jsr scandot
1420 jsr scanspaces
1430 lda buffer,x
1440 command ldy #caddr-clist
1450 ll2 cmp clist,y
1460 beq foundcmd
1470 dey
1480 bpl ll2
1490 jmp question
1500 foundcmd inx
1510 tya
1520 asl a
1530 tay
1540 lda caddr+1,y
1550 pha
1560 lda caddr,y
1570 pha
1580 rts
1590 !
1592 regaddr lda #>regs1
1594 sta temp
1596 lda #<regs1
1598 sta temp+1
1600 lda #5
1601 bcc reghere
1602 byt $2c
1604 pr8bytes lda #8
1610 prbytes sta numbytes
1620 ldy #0
1630 ll3 jsr space
1640 jsr peek
1650 jsr prbyte
1660 jsr inctemp
1670 dec numbytes
1680 bne ll3
1690 reghere rts
1700 !
1710 question ldx regs+6
1720 txs
1730 ldx #$20
1740 lda #$3f
1750 jsr prxta
1760 jmp start
1770 !
1772 inctemp2 jsr inctemp
1780 inctemp inc temp
1790 bne ll4
1800 inc temp+1
1802 bne ll4
1804 inc overtop
1810 ll4 rts
1820 !
1830 inputline ldy #0
1840 inline jsr chrin
1850 assin cmp #13
1860 beq retchar
1870 sta buffer,y
1880 iny
1890 cpy #64
1900 bne inline
1910 retchar lda #0
1920 sta buffer,y
1922 sta overtop
1930 rts
1940 !
1950 scandot ldx #0
1960 lda buffer,x
1970 cmp #$2e
1980 bne nodot
1990 inx
2000 nodot rts
2010 !
2092 hexaddr lda temp+1
2094 jsr prbyte
2096 lda temp
2098 !
2100 prbyte pha
2110 lsr a
2120 lsr a
2130 lsr a
2140 lsr a
2150 jsr prby
2160 pla
2170 and #15
2180 prby tax
2190 lda hexT,x
2200 jmp chrout
2210 !
2220 gbyte lda buffer,x
2230 ldy #0
2240 ll5 cmp hexT,y
2250 beq gbout
2260 iny
2270 cpy #16
2280 bne ll5
2290 jmp question
2300 gbout tya
2310 rts
2320 !
2330 getbyte jsr scanspaces
2332 getbyte1 jsr gbyte
2340 asl a
2350 asl a
2360 asl a
2370 asl a
2380 sta byte
2390 inx
2400 jsr gbyte
2410 ora byte
2412 inx
2420 rts
2430 !
2440 getaddr jsr getbyte
2450 sta temp+1
2460 jsr getbyte
2470 sta temp
2472 scanspaces lda buffer,x
2474 cmp #$20
2476 bne nospace
2478 inx
2480 cpx #64
2482 bne scanspaces
2484 nospace rts
2490 !
2500 prtdty tya
2510 pha
2520 jsr ret
2530 pla
2540 ldx #$2e
2550 prxta pha
2560 txa
2570 jsr chrout
2580 pla
2590 jmp chrout
2600 !
2610 !
2620 registers ldx #0
2630 ll6 lda regchars,x
2640 beq ll7
2650 jsr chrout
2660 inx
2670 bne ll6
2680 ll7 ldy #$3b
2690 jsr prtdty
2700 lda regs+0
2710 jsr prbyte
2720 lda regs+1
2730 jsr prbyte
2740 sec
2750 jsr regaddr
2760 jmp start
2770 !
2960 memory jsr get2addrs
3120 mem3 jsr showbytes
3130 !
3140 jsr getkey
3150 beq ll10
3160 ll11 jsr getkey
3170 beq ll11
3180 ll10 jsr upclock
3190 jsr stopkey
3200 beq memout
3210 jsr checkless
3250 bcs mem3
3252 memout lda #0
3260 sta 212
3262 !
3264 jsr crsrup
3266 jmp start
3268 !
3270 showbytes ldy #$3a
3280 jsr prtdty
3290 jsr copytemp
3300 jsr hexaddr
3310 jsr pr8bytes
3320 lda #$27
3330 jsr chrout
3340 ldy #0
3350 ll8 jsr peek2
3360 and #$7f
3370 cmp #$20
3380 bcs ll9
3390 ora #$40
3400 ll9 jsr chrout
3410 iny
3420 cpy #8
3430 bne ll8
3440 rts
3500 !
3510 swaptemps txa
3512 pha
3514 ldx #1
3520 swap1 lda temp,x
3530 pha
3540 lda temp1,x
3550 sta temp,x
3560 pla
3570 sta temp1,x
3580 dex
3590 bpl swap1
3592 pla
3594 tax
3600 rts
3610 !
3620 copytemp lda temp
3630 sta temp2
3640 lda temp+1
3650 sta temp2+1
3660 rts
3670 !
3680 exit ldx regs+6
3690 txs
3700 lda #$37
3710 sta $01
3720 jmp (warmstart)
3730 !
3740 modregs jsr getaddr
3750 jsr setregs
3752 clc
3760 jsr regaddr
3770 bne mbyte1
3780 modify jsr getaddr
3790 lda #8
3800 mbyte1 sta numbytes
3810 sta mode
3812 jsr copytemp
3814 domod jsr enterbytes
3816 lda mode
3820 cmp #5
3830 beq exitmod
3850 jsr crsrup
3852 jsr tempcopy
3860 jsr showbytes
3870 exitmod jmp start
3880 !
3890 enterbytes jsr getbyte
3910 ldy #0
3920 jsr poke
3930 jsr inctemp
3940 dec numbytes
3950 bne enterbytes
3960 rts
3970 !
3980 setregs lda temp
3990 sta regs+1
4000 lda temp+1
4010 sta regs
4020 rts
4030 !
4040 tempcopy lda temp2
4050 sta temp
4060 lda temp2+1
4070 sta temp+1
4080 rts
4090 !
4092 jay lda #$00
4094 byt $2c
4096 go lda #$ff
4098 sta caltemp
4100 jsr scanspaces
4110 lda buffer,x
4120 beq go1
4130 jsr getaddr
4140 jsr setregs
4150 go1 ldx regs+6
4152 txs
4154 lda caltemp
4156 bmi go2
4160 lda breakhi1
4162 pha
4164 lda breaklo1
4166 pha
4170 go2 sei
4180 lda regs
4190 pha
4200 lda regs+1
4210 pha
4220 lda regs+2
4230 pha
4232 lda storeof1
4234 sta $01
4240 lda regs+3
4250 ldx regs+4
4260 ldy regs+5
4270 rti
4280 !
4300 transfer jsr get2addrs
4310 jsr swaptemps
4350 jsr copytemp
4370 jsr getaddr
4380 jsr swaptemps
4386 !
4390 ldy #0
4400 tran jsr peek
4410 jsr poke1
4420 lda temp2+1
4430 cmp temp+1
4432 bne there
4440 lda temp2
4450 cmp temp
4460 beq trout
4470 there jsr inctemp
4480 jsr inctemp1
4490 bcs tran
4492 trout jmp start
4500 !
4510 inctemp1 inc temp1
4520 bne temp1ret
4530 inc temp1+1
4540 temp1ret rts
4550 !
4560 fill jsr get2addrs
4630 jsr getbyte
4640 sta mode
4660 ldy #0
4670 loopfill lda mode
4680 jsr poke
4690 jsr checkfin
4730 beq trout
4740 jsr inctemp
4750 bcs loopfill
4760 !
4770 checkfin lda temp1+1
4772 cmp temp+1
4774 bne cout
4776 lda temp1
4778 cmp temp
4780 cout rts
4782 !
4790 checkless lda temp1
4792 cmp temp
4794 lda temp1+1
4796 sbc temp+1
4798 rts
4820 !
4830 hunt jsr get2addrs
4910 cmp #$27
4920 bne huntbytes
4930 inx
4940 ldy #0
4950 ll12 lda buffer,x
4960 beq ll16 ! ll13
4970 sta hbuffer,y
4980 inx
4990 iny
5000 cpy #20
5010 bne ll12
5020 beq ll16
5030 huntbytes ldy #0
5040 ll14 sty ysave
5050 jsr getbyte
5060 ldy ysave
5070 sta hbuffer,y
5090 lda buffer,x
5100 beq ll13
5120 iny
5130 cpy #20
5140 bne ll14
5150 ll16 dey
5160 !
5170 ll13 sty numbytes
5200 jsr ret
5210 hloop ldx #0
5220 ldy #0
5230 match jsr peek
5240 cmp hbuffer,x
5250 bne ll15
5260 cpx numbytes
5262 beq haddr
5270 iny
5280 inx
5290 bne match
5292 beq hout
5300 haddr jsr hsaddr
5320 ll15 jsr checkfin
5330 beq hout
5340 jsr inctemp
5342 bne hloop
5350 hout jmp start
5360 !
5370 get2addrs jsr getaddr
5390 jsr swaptemps
5392 lda buffer,x
5394 bne adr1
5396 lda #$ff
5398 sta temp
5400 sta temp+1
5402 bne adr2
5410 adr1 jsr getaddr
5420 adr2 jsr swaptemps
5430 jmp scanspaces
5440 !
5500 propcode tay
5510 lda opcodeb,y
5520 sta optemp
5530 lda opcodea,y
5540 sta optemp+1
5550 prop1 lda #0
5560 ldy #5
5570 prop2 asl optemp+1
5500 rol optemp
5590 rol a
5600 dey
5610 bne prop2
5620 adc #$3f
5630 jsr chrout
5640 dex
5650 bne prop1
5660 space lda #$20
5670 byt $2c
5680 ret lda #$0d
5682 byt $2c
5684 crsrup lda #$91
5690 jmp chrout
5700 !
5710 decodeop pha
5720 pha
5730 and #$f0
5740 lsr a
5750 lsr a
5760 lsr a
5770 tax
5780 lda modep,x
5790 sta optemp
5792 inx
5800 lda modep,x
5810 sta optemp+1
5820 pla
5830 and #15
5840 tay
5850 lda (optemp),y
5860 sta mode
5870 and #3
5880 sta numbytes
5890 pla
5900 tay
5910 lda opnum,y
5912 ldy #0
5920 pran2 rts
5930 !
5940 pran28 cmp optemp
5950 beq pran2
5960 jmp chrout
5970 !
5980 !
6000 disaline ldy #$2c
6010 disline jsr prtdty
6020 jsr space
6030 jsr hsaddr
6050 ldy #0
6060 jsr peek
6070 jsr decodeop
6080 pha
6090 jsr disbytes
6100 pla
6110 jsr propcode
6120 ldx #6
6130 dis1 cpx #3
6140 bne dis3
6150 ldy numbytes
6160 beq dis3
6170 dis2 lda mode
6180 cmp #$e8
6190 jsr peek
6200 bcs calcaddr
6210 jsr calcad2
6220 dey
6230 bne dis2
6240 dis3 asl mode
6250 bcc dis4
6260 lda moreinfa,x
6270 jsr pran28
6280 lda moreinfb,x
6290 beq dis4
6300 jsr pran28
6310 dis4 dex
6320 bne dis1
6322 !
6324 ldx $d3
6326 dis5 cpx #39
6328 beq disexit
6330 jsr space
6332 inx
6334 bne dis5
6336 disexit rts
6340 !
6350 calcaddr jsr calcad3
6360 tax
6370 inx
6380 bne calcad1
6390 iny
6400 calcad1 tya
6410 jsr calcad2
6420 txa
6430 calcad2 stx caltemp
6440 jsr prbyte
6450 ldx caltemp
6460 rts
6470 calcad5 lda numbytes
6480 sec
6490 calcad3 ldy temp+1
6500 tax
6510 bpl calcad4
6520 dey
6530 calcad4 adc temp
6540 bcc calcad6
6550 iny
6560 calcad6 rts
6570 !
6630 disbytes jsr peek
6640 jsr prbyte
6650 ldx #1
6660 db1 jsr space
6662 dex
6664 bne db1
6670 cpy numbytes
6680 iny
6690 bcc disbytes
6700 ldx #3
6710 cpy #4
6720 bcc db1
6730 rts
6740 !
6750 disassemble jsr get2addrs
6760 ldx #0
6770 stx caltemp
6780 dli jsr disaline
6790 jsr calcad5
6800 sta temp
6810 sty temp+1
6820 jsr getkey
6830 beq dli1
6840 dli2 jsr getkey
6850 beq dli2
6860 dli1 jsr upclock
6870 jsr stopkey
6880 beq dlout
6890 jsr checkless
6900 bcs dli
6910 dlout jmp start
6920 !
7000 moddis jsr dismod
7160 jsr crsrup
7170 jsr disaline
7180 jmp start
7190 !
7200 assemble jsr dismod
7210 jsr swaptemps
7220 lda #0
7230 sta hbuffer+1
7240 jsr scanspaces
7250 ldy #3
7260 ass1 lda buffer,x
7270 pha
7272 inx
7280 dey
7290 bne ass1
7300 stx ysave
7310 ldx #3
7320 ass2 pla
7330 sec
7340 sbc #$3f
7350 ldy #5
7360 ass3 lsr a
7370 ror hbuffer+1
7380 ror hbuffer
7390 dey
7400 bne ass3
7410 dex
7420 bne ass2
7430 !
7432 ldx ysave
7440 ldy #2
7442 jsr scanspaces
7444 dex
7445 sec
7446 php
7448 ass4 plp
7450 bcc ass41
7452 ass40 inx
7454 ass41 lda buffer,x
7460 beq ass6
7462 cmp #$3a
7464 beq ass6
7470 cmp #$20
7480 beq ass40
7510 jsr checkrange
7512 php
7520 bcs ass5
7530 sty ysave
7540 jsr getbyte1
7550 ldy temp
7560 sty temp+1
7570 sta temp
7580 ldy ysave
7590 lda #$30
7600 sta hbuffer,y
7610 iny
7620 ass5 sta hbuffer,y
7630 iny
7640 bne ass4
7650 !
7660 ass6 sty temp2+1
7670 lda #0
7672 sta hbuffer,y
7680 sta temp2
7690 beq ass7
7700 ass8 inc temp2
7710 beq aserror
7720 ass7 ldx #0
7730 stx astemp+1
7740 lda temp2
7750 jsr decodeop
7760 ldx mode
7770 stx astemp
7780 tax
7790 ldy opcodeb,x
7800 lda opcodea,x
7810 jsr chvalid1
7820 bne ass8
7830 ldx #6
7840 ass14 cpx #3
7850 bne ass10
7860 ldy numbytes
7870 beq ass10
7880 ass12 lda mode
7890 cmp #$e8
7900 lda #$30
7910 bcs ass11
7920 jsr chvalid2
7930 bne ass8
7940 jsr chvalid3
7950 bne ass8
7960 dey
7970 bne ass12
7980 ass10 asl mode
7990 bcc ass13
8000 ldy moreinfb,x
8010 lda moreinfa,x
8020 jsr chvalid1
8030 bne ass8
8040 ass13 dex
8050 bne ass14
8060 beq ass15
8070 ass11 jsr chvalid
8080 bne ass8
8090 jsr chvalid
8100 bne ass8
8110 ass15 lda temp2+1
8120 cmp astemp+1
8130 bne ass8
8140 jsr swaptemps
8150 ldy numbytes
8160 beq ass16
8170 lda astemp
8180 cmp #$9d
8190 bne ass17
8200 jsr asaddr
8210 bcc ass18
8220 tya
8230 bne aserror
8240 lda astemp1
8250 bpl ass19
8260 aserror jmp question
8270 ass18 iny
8280 bne aserror
8290 lda astemp1
8300 bpl aserror
8310 ass19 ldy numbytes
8320 bne ass20
8330 ass17 lda temp+1,y
8332 brk
8340 ass20 jsr poke
8350 dey
8360 bne ass17
8370 ass16 lda temp2
8380 jsr poke
8382 jsr copytemp
8390 jsr calcad5
8400 pha
8410 tya
8412 pha
8416 jsr crsrup
8417 ldy #$41
8418 jsr disline
8420 pla
8422 sta temp+1
8424 pla
8426 sta temp
8428 ldy #$41
8430 sty buffer
8432 jsr prtdty
8434 jsr space
8436 jsr hsaddr
8438 lda temp+1
8440 jsr assval
8442 stx buffer+2
8444 sta buffer+3
8446 lda temp
8448 jsr assval
8450 stx buffer+4
8452 sta buffer+5
8454 lda #$20
8456 sta buffer+1
8458 sta buffer+6
8460 jsr chrin
8461 cmp #$2e
8462 bne assok
8463 ldy #0
8464 byt $2c
8465 assok ldy #7
8466 jsr assin
8467 jmp assmore
8468 assval pha
8470 lsr a
8472 lsr a
8474 lsr a
8476 lsr a
8478 jsr asval1
8480 tax
8482 pla
8484 and #15
8486 asval1 clc
8488 adc #$f6
8490 bcc asval2
8492 adc #6
8494 asval2 adc #$3a
8496 rts
8498 !
8500 chvalid tay
8502 chvalid1 jsr chvalid2
8510 bne chvalid4
8520 tya
8530 chvalid2 beq chvalid4
8540 chvalid3 stx astemp1+1
8550 ldx astemp+1
8560 cmp hbuffer,x
8570 php
8580 inx
8590 stx astemp+1
8600 ldx astemp1+1
8610 plp
8620 chvalid4 rts
8630 !
8640 checkrange cmp #$30
8650 bcc chranout
8660 cmp #$47
8670 rts
8680 chranout sec
8690 rts
8700 !
8710 asaddr lda temp1
8720 ldy temp1+1
8730 sec
8740 sbc #2
8750 bcs asad1
8760 dey
8770 asad1 sec
8780 sbc temp
8790 sta astemp1
8800 tya
8810 sbc temp+1
8820 tay
8830 ora astemp1
8840 rts
8850 !
8860 dismod jsr getaddr
8870 ldy #0
8880 dm1 sty temp2
8890 lda buffer,x
8900 jsr checkrange
8910 bcs dm2
8912 lda buffer+2,x
8914 cmp #$20
8916 bne dm2
8920 jsr getbyte
8930 ldy temp2
8940 jsr poke
8950 inx
8960 lda buffer,x
8970 iny
8980 cpy #3
8990 beq dm2
9000 cmp #$20
9010 bne dm1
9020 dm2 rts
9030 !
9040 ioparams ldy #1
9050 sty $ba
9060 sty $b9
9070 dey
9080 sty $b7
9090 lda #>hbuffer
9100 sta $bb
9110 lda #<hbuffer
9120 sta $bc
9130 jsr scanspaces
9140 lda buffer,x
9150 beq noname
9160 cmp #$22
9170 bne ioerror
9180 iolbl1 inx
9190 lda buffer,x
9200 beq iofinname
9210 cmp #$22
9220 beq iofin1
9230 sta ($bb),y
9240 iny
9250 cpy #16
9260 bne iolbl1
9270 ioerror jmp question
9272 iofin1 inx
9280 iofinname sty $b7
9290 jsr scanspaces
9300 jsr crange
9340 jsr getbyte
9350 and #15
9360 cmp #3
9370 beq ioerror
9380 sta $ba
9390 lda buffer,x
9400 noname rts
9410 !
9412 verify lda #1
9414 byt $2c
9416 load lda #0
9418 sta $93
9420 jsr ioparams
9430 beq defload
9432 dec $b9
9460 inx
9470 jsr getaddr
9480 defload lda $ba
9482 cmp #1
9484 bne defl1
9486 jmp tload
9488 defl1 ldx temp
9490 ldy temp+1
9500 lda $93
9510 jsr kerload
9520 tload1 lda st
9530 and #16
9540 bne ioerror
9542 jsr ret
9544 ldx #$4f
9546 lda #$4b
9548 jsr prxta
9550 jmp start
9560 !
9570 save jsr ioparams
9580 save0 beq ioerror
9610 jsr crange
9620 jsr getaddr
9630 jsr crange
9670 jsr swaptemps
9680 jsr getaddr
9690 lda buffer,x
9700 beq specnorm
9710 jsr crange
9740 lda $ba
9742 beq save0
9750 cmp #3
9760 bcc normalsave
9762 jsr copytemp
9764 jsr getaddr
9766 jsr swaptemps
9768 jsr scheck
9770 bcc specsave
9772 jsr ssave
9774 firstblood jmp start
9776 !
9778 specnorm jsr swaptemps
9780 jsr scheck
9782 bcs nsave1
9784 jsr swaptemps
9786 jsr copytemp
9788 jsr rambo
9790 !
9792 !
9794 specsave jsr stortemps
9796 jsr swapmem1
9798 jsr resttemps
9800 jsr snsubr
9802 !
9804 jsr swapmem2
9806 bne firstblood
9808 !
9810 snsubr sec
9812 lda temp+1
9814 sbc #$a0
9816 sta temp+1
9818 sec
9820 lda temp2+1
9822 sbc #$a0
9824 sta temp2+1
9826 !