-
Notifications
You must be signed in to change notification settings - Fork 15
/
tinybasic.asm
1499 lines (1425 loc) · 37.2 KB
/
tinybasic.asm
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
;----------------------------------------------------------------------------------
; Tiny Basic port to MKHBC-8-R1 6502 computer
; by Marek Karcz 2012.
;
; Based on the work by:
;
; ================= ORIGINAL HEADER ======================================
;
; OMS-02 Firmware
;
; Bill O'Neill - Last update: 2008/12/06
;
; Tiny Basic and minimal Monitor (BIOS)
;
; This version is for the assembler that comes with
; Michal Kowalski's 6502 emulator. To run it, load it
; into the emulator, assemle it, begin debug mode then,
; set the PC to $1CF0 then run.
;
; The emulator was used to help figure out Tiny Basic
; and this code is only documented to that extent.
;
; It should be easy enough to configure this to run any-
; where in memory or convert it to assemble with any 6502
; assembler. The current location is being used as this is
; to be placed into a controller I designed (OMS-02) around
; a 6507 CPU (a 6502 variant) that has only 8k off memory.
; The memory map for the OMS-02 is;
;
; $0000-$0FFF RAM
; $1000-$13FF I/O space (ACIA is at $1200)
; $1400-$1FFF Tiny Basic and simple monitor
;
;
; Next steps:
; Write a BREAK routine that will enable a break if any charater is typed at the console
; More comments to document this code
; Investigate using assembler variables and directives to make it easy to re-locate this code
;
; ============ END OF ORIGINAL HEADER =========================================
;
; Revision history (MKHBC-8-R1 port):
;
; 1/4/2012:
; TB port created.
;
; 1/5/2012:
; Version 1.0.1.
; Added 2-byte peek routine.
;
; 1/11/2012:
; Figured out jump addresses for routines and used symbolic labels
; instead of hardcoded addresses. Relocated TB to $0400 (from $1400).
;
; 2/15/2016
; Ported to my own 6502 emulator.
;
; 3/30/2016
;
; Changed char input address from blocking to non-blocking.
;
;
;--------------------------------------------------------------------------------------
.segment "BEGN"
.ORG $0000
.segment "BASIC"
;
; Tiny Basic starts here
;
.ORG $4400 ; Start of Basic. First 1K of ROM is shaded by I/O on the OMS-02
SOBAS:
C_00BC = $00BC ; These are needed because my assembler
C_20 = $20 ; does not hanle standard 6502 notation
C_22 = $22 ; properly
C_24 = $24 ;
C_2A = $2A ; I may just fix this someday - HA!
C_2C = $2C ;
C_2E = $2E ;
C_B8 = $B8 ;
C_BC = $BC ;
C_C1 = $C1 ;
C_C2 = $C2 ;
C_C6 = $C6 ;
SR_V_L = SOBAS + $1E ; Base address for subroutine vector lo byte
SR_V_H = SOBAS + $1F ; Base address for subroutine vector hi byte
CV: jmp COLD_S ; Cold start vector
WV: jmp WARM_S ; Warm start vector
IN_V: jmp GetCh ; Input routine address.
OUT_V: jmp PutCh ; Output routine address.
BREAK: nop ; Begin dummy break routine
clc ; Clear the carry flag
rts ; End break routine
;
; Some codes
;
BSC: .byte $5f ; Backspace code
LSC: .byte $18 ; Line cancel code
PCC: .byte $80 ; Pad character control
TMC: .byte $00 ; Tape mode control
;SSS: .byte $04 ; Spare Stack size. (was $04 but documentation suggests $20 ?)
SSS: .byte $20 ; Spare Stack size. (was $04 but documentation suggests $20 ?)
;
; Code fragment
; Seems to store or retreive a byte to/from memory and the accumulator
; ---
; M.K.: I think this code it is used from Tiny Basic programs by calling USR to store/retrieve
; data (since TB does not support arrays, this is one way to emulate them).
; This location is at exactly 20 bytes distance from the start of TB code.
; TB programs typically make USR calls to locations:
; SOBAS+20
; SOBAS+24
; E.g:
; LET S=_SOBAS_ REM (_SOBAS_ is TB start)
; LET B=_ARRAY_SIZE_+2 (_ARRAY_SIZE_ is the size of 2-dim array)
; Get byte from location V(I,J), store in Z.
; LET Z=USR(S+20,V+B*I+J,0)
; Store Z in location V(I,J)
; LET Z=USR(S+24,V+B*I+J,Z)
; From TB documentation:
; For your convenience two subroutines have been included in the TINY BASIC interpreter to access memory.
; If S contains the address of the beginning of the TINY BASIC interpreter (256 for standard 6800, 512
; for standard 6502, etc.), then location S+20 (hex 0114) is the entry point of a subroutine to read one
; byte from the memory address in the index register, and location S+24 (hex 0118) is the entry point of
; a subroutine to store one byte into memory.
;-------------------------------------------------
; USR (address)
; USR (address,Xreg)
; USR (address,Xreg,Areg)
;
; This function is actually a machine-language subroutine call to the address in the first argument.
; If the second argument is included the index registers contain that value on entry to the subroutine,
; with the most significant part in X. If the third argument is included, the accumulators contain that
; value on entry to the subroutine, with the least significant part in A. On exit, the value in the
; Accumulators (for the 6800; A and Y for the 6502) becomes the value of the function, with the least
; significant part in A. All three arguments are evaluated as normal expressions.
; It should be noted that machine language subroutine addresses are 16-bit Binary numbers. TINY BASIC
; evaluates all expressions to 16-bit binary numbers, so any valid expression may be used to define a
; subroutine address. However, most addresses are expressed in hexadecimal whereas TINY BASIC only accepts
; numerical constants in decimal. Thus to jump to a subroutine at hex address 40AF, you must code USR(16559).
; Hex address FFB5 is similarly 65461 in decimal, though the equivalent (-75) may be easier to use.
;
OneBytePeek:
stx $C3 ; read one byte from memory address in the index register
bcc LBL008
OneBytePoke:
stx $C3 ; store one byte into memory
sta (C_C2),Y
rts
LBL008: lda (C_C2),Y
ldy #$00
rts
; These seem to be addresses associated with the IL branch instructions
;.byte $62,$15, $64,$15, $D8,$15, $05,$16, $33,$16, $FD,$15
.byte <JUMP01,>JUMP01
.byte <LBL027,>LBL027
.byte <JUMP02,>JUMP02
.byte <JUMP03,>JUMP03
.byte <JUMP04,>JUMP04
.byte <JUMP05,>JUMP05
; NOTE: The original comment below is obsolete now, since I found the jump
; addresses locations and put them in this table. Now assembler will
; take care of the reallocation.
; START OF ORIGINAL COMMENT
; This appears to be a table of
; execution addresses to jump to ML routines
; that handle the the IL instructions.
; You cannot add code to or relocate this program
; without updating these
; END OF ORIGINAL COMMENT
;.byte $9F,$17, $42,$1B, $3F,$1B, $7A,$17, $FC,$18, $95,$17, $9F,$17, $9F,$17
.byte <LBL067,>LBL067
.byte <LBL132,>LBL132
.byte <JUMP06,>JUMP06
.byte <JUMP07,>JUMP07
.byte <LBL035,>LBL035
.byte <LBL097,>LBL097
.byte <LBL067,>LBL067
.byte <LBL067,>LBL067
;.byte $BD,$1A, $C1,$1A, $8A,$1A, $9B,$1A, $E9,$1A, $61,$17, $51,$17, $41,$1A
.byte <JUMP08,>JUMP08
.byte <JUMP09,>JUMP09
.byte <JUMP10,>JUMP10
.byte <JUMP11,>JUMP11
.byte <JUMP12,>JUMP12
.byte <JUMP13,>JUMP13
.byte <JUMP14,>JUMP14
.byte <LBL071,>LBL071
;.byte $52,$1A, $4F,$1A, $62,$1A, $E7,$19, $CD,$16, $06,$17, $9F,$17, $15,$18
.byte <JUMP15,>JUMP15
.byte <JUMP16,>JUMP16
.byte <JUMP17,>JUMP17
.byte <JUMP18,>JUMP18
.byte <JUMP19,>JUMP19
.byte <JUMP20,>JUMP20
.byte <LBL067,>LBL067
.byte <JUMP21,>JUMP21
;.byte $A7,$17, $B7,$16, $BF,$16, $83,$18, $A1,$16, $9F,$17, $9F,$17, $A8,$18
.byte <JUMP22,>JUMP22
.byte <JUMP23,>JUMP23
.byte <LBL047,>LBL047
.byte <LBL081,>LBL081
.byte <LBL013,>LBL013
.byte <LBL067,>LBL067
.byte <LBL067,>LBL067
.byte <JUMP24,>JUMP24
;.byte $4F,$1B, $4D,$1B, $07,$19, $AA,$14, $37,$17, $BD,$14, $1B,$1B, $B1,$1A
.byte <JUMP25,>JUMP25
.byte <JUMP26,>JUMP26
.byte <JUMP27,>JUMP27
.byte <MEM_T2,>MEM_T2
.byte <JUMP28,>JUMP28
.byte <WARM_S,>WARM_S
.byte <JUMP29,>JUMP29
.byte <JUMP30,>JUMP30
.byte $20,$41, $54,$20 ; No idea ????
.byte $80 ; No idea
LBL002: .byte <ILTBL ;$70 ; $70 - lo byte of IL address
LBL003: .byte >ILTBL ;$1B ; $1B - hi byte of IL address
;
;Begin Cold Start
;
;
;
; Load start of free ram ($1C00) into locations $0020 and $0022
; The memory between $1000 and $1Bff (3 kB) is free for assembler programs
; that can be loaded and used simultaneously with TB.
; $1C00 to the end of writable memory is the BASIC memory space.
;
COLD_S: lda #$00 ; Load accumulator with lo byte of lower and upper prg memory limits
sta $20 ; Store in $20
sta $22 ; Store in $22
lda #$50 ; Load accumulator with hi byte of lower and upper prg memory limits
sta $21 ; Store in $21
sta $23 ; Store in $23
; NOTE: $22,$23 vector will be updated by routine below to be the upper RAM limit for TB.
;
;
; Begin test for free ram
; As a result, memory locations $20,$21 will contain lo,hi byte order address of lower RAM boundary
; and $22,$23 upper RAM boundary respectively.
;
ldy #$01 ; Load register Y with $01
MEM_T: lda (C_22),Y ; Load accumulator With the contents of a byte of memory
tax ; Save it to X
eor #$FF ; Next 4 instuctions test to see if this memeory location
sta (C_22),Y ; is ram by trying to write something new to it - new value
cmp (C_22),Y ; gets created by XORing the old value with $FF - store the
php ; result of the test on the stack to look at later
txa ; Retrieve the old memory value
sta (C_22),Y ; Put it back where it came from
inc $22 ; Increment $22 (for next memory location)
bne SKP_PI ; Goto $14A6 if we don't need to increment page
inc $23 ; Increment $23 (for next memory page)
SKP_PI: plp ; Now look at the result of the memory test
beq MEM_T ; Go test the next mempry location if the last one was ram
dey ; If last memory location did not test as ram, decrement Y (should be $00 now)
MEM_T2: cld ; Make sure we're not in decimal mode
lda $20 ; Load up the low-order by of the start of free ram
adc SSS ; Add to the spare stack size
sta $24 ; Store the result in $0024
tya ; Retrieve Y
adc $21 ; And add it to the high order byte of the start of free ram (this does not look right)
sta $25 ; Store the result in $0025
tya ; Retrieve Y again
sta (C_20),Y ; Store A in the first byte of program memory
iny ; Increment Y
sta (C_20),Y ; Store A in the second byte of program memory
;
;Begin Warm Start;
;
WARM_S: lda $22
sta $C6
sta $26
lda $23
sta $C7
sta $27
jsr LBL001 ; Go print CR, LF and pad charachters
LBL014: lda LBL002
sta $2A
lda LBL003
sta $2B
lda #$80
sta $C1
lda #$30
sta $C0
ldx #$00
stx $BE
stx $C2
dex
txs
LBL006: cld
jsr LBL004 ; Go read a byte from the TBIL table
jsr LBL005
jmp LBL006
;
;
;
.byte $83 ; No idea about this
.byte $65 ; No idea about this
;
;
; Routine to service the TBIL Instructions
;
LBL005: cmp #$30 ;
bcs LBL011 ; If it's $30 or higher, it's a Branch or Jump - go handle it
cmp #$08 ;
bcc LBL007 ; If it's less than $08 it's a stack exchange - go handle it
asl ; Multiply the OP code by 2
tax ; Transfer it to X
LBL022: lda SR_V_H,X ; Get the hi byte of the OP Code handling routine
pha ; and save it on the stack
lda SR_V_L,X ; Get the lo byte
pha ; and save it on the stack
php ; save the processor status too
rti ; now go execute the OP Code handling routine
;
;
; Routine to handle the stack exchange
;
LBL007: adc $C1
tax
lda (C_C1),Y
pha
lda $00,X
sta (C_C1),Y
pla
sta $00,X
rts
;
;
;
LBL015: jsr LBL001 ; Go print CR, LF and pad charachters
lda #$21 ; Load an ASCII DC2
jsr OUT_V ; Go print it
lda $2A ; Load the current TBIL pointer (lo)
sec ; Set the carry flag
sbc LBL002 ; Subtract the TBIL table origin (lo)
tax ; Move the difference to X
lda $2B ; Load the current TBIL pointer (hi)
sbc LBL003 ; Subtract the TBIL table origin (hi)
jsr LBL010
lda $BE
beq LBL012
lda #$7E
sta $2A
lda #$20
sta $2B
jsr LBL013
ldx $28
lda $29
jsr LBL010
LBL012: lda #$07 ; ASCII Bell
jsr OUT_V ; Go ring Bell
jsr LBL001 ; Go print CR, LF and pad charachters
LBL060: lda $26
sta $C6
lda $27
sta $C7
jmp LBL014
;
;
;
LBL115: ldx #$7C
LBL048: cpx $C1
LBL019: bcc LBL015
ldx $C1
inc $C1
inc $C1
clc
rts
;
;
;
JUMP01: dec $BD
LBL027: lda $BD
beq LBL015
LBL017: lda $BC
sta $2A
lda $BD
sta $2B
rts
;
; Branch handling routine
;
LBL011: cmp #$40 ;
bcs LBL016 ; If it's not a Jump, go to branch handler
pha
jsr LBL004 ; Go read a byte from the TBIL table
adc LBL002
sta $BC
pla
pha
and #$07
adc LBL003
sta $BD
pla
and #$08
bne LBL017
lda $BC
ldx $2A
sta $2A
stx $BC
lda $BD
ldx $2B
sta $2B
stx $BD
LBL126: lda $C6
sbc #$01
sta $C6
bcs LBL018
dec $C7
LBL018: cmp $24
lda $C7
sbc $25
bcc LBL019
lda $BC
sta (C_C6),Y
iny
lda $BD
sta (C_C6),Y
rts
;
;Branch handler
;
LBL016: pha
lsr
lsr
lsr
lsr
and #$0E
tax
pla
cmp #$60
and #$1F
bcs LBL020
ora #$E0
LBL020: clc
beq LBL021
adc $2A
sta $BC
tya
adc $2B
LBL021: sta $BD
JMP LBL022
;
;
;
JUMP02: lda $2C
sta $B8
lda $2D
sta $B9
LBL025: jsr LBL023
jsr LBL024
eor (C_2A),Y
tax
jsr LBL004 ; Go read a byte from the TBIL table
txa
beq LBL025
asl
beq LBL026
lda $B8
sta $2C
lda $B9
sta $2D
LBL028: jmp LBL027
JUMP05: jsr LBL023
cmp #$0D
bne LBL028
LBL026: rts
;
;
;
JUMP03: jsr LBL023
cmp #$5B
bcs LBL028
cmp #$41
bcc LBL028
asl
jsr LBL029
LBL024: ldy #$00
lda (C_2C),Y
inc $2C
bne LBL030
inc $2D
LBL030: cmp #$0D
clc
rts
;
;
LBL031: jsr LBL024
LBL023: lda (C_2C),Y
cmp #$20
beq LBL031
cmp #$3A
clc
bpl LBL032
cmp #$30
LBL032: rts
;
;
;
JUMP04: jsr LBL023
bcc LBL028
sty $BC
sty $BD
LBL033: lda $BC
ldx $BD
asl $BC
rol $BD
asl $BC
rol $BD
clc
adc $BC
sta $BC
txa
adc $BD
asl $BC
rol
sta $BD
jsr LBL024
and #$0F
adc $BC
sta $BC
tya
adc $BD
sta $BD
jsr LBL023
bcs LBL033
jmp LBL034
LBL061: jsr LBL035
lda $BC
ora $BD
beq LBL036
LBL065: lda $20
sta $2C
lda $21
sta $2D
LBL040: jsr LBL037
beq LBL038
lda $28
cmp $BC
lda $29
sbc $BD
bcs LBL038
LBL039: jsr LBL024
bne LBL039
jmp LBL040
LBL038: lda $28
eor $BC
bne LBL041
lda $29
eor $BD
LBL041: rts
;
;
;
LBL043: jsr LBL042
LBL013: jsr LBL004 ; Entry point for TBIL PC (print literal) - Go read a byte from the TBIL table
bpl LBL043 ;
LBL042: inc $BF
bmi LBL044
jmp OUT_V ; Go print it
LBL044: dec $BF
LBL045: rts
;
;
;
LBL046: cmp #$22
beq LBL045
jsr LBL042
JUMP23: jsr LBL024
bne LBL046
LBL036: jmp LBL015
LBL047: lda #$20
jsr LBL042
lda $BF
and #$87
bmi LBL045
bne LBL047
rts
;
;
;
JUMP19: ldx #$7B
jsr LBL048
inc $C1
inc $C1
inc $C1
sec
lda $03,X
sbc $00,X
sta $00,X
lda $04,X
sbc $01,X
bvc LBL052
eor #$80
ora #$01
LBL052: bmi LBL053
bne LBL054
ora $00,X
beq LBL049
LBL054: lsr $02,X
LBL049: lsr $02,X
LBL053: lsr $02,X
bcc LBL050
LBL004: ldy #$00 ; Read a byte from the TBIL Table
lda (C_2A),Y ;
inc $2A ; Increment TBIL Table pointer as required
bne LBL051 ;
inc $2B ;
LBL051: ora #$00 ; Check for $00 and set the 'Z' flag acordingly
LBL050: rts ; Return
;
;
;
JUMP20: lda $BE
beq LBL055
LBL056: jsr LBL024
bne LBL056
jsr LBL037
beq LBL057
LBL062: jsr LBL058
jsr BREAK
bcs LBL059
lda $C4
sta $2A
lda $C5
sta $2B
rts
;
;
;
LBL059: lda LBL002
sta $2A
lda LBL003
sta $2B
LBL057: jmp LBL015
LBL055: sta $BF
jmp LBL060
JUMP28: lda $20
sta $2C
lda $21
sta $2D
jsr LBL037
beq LBL057
lda $2A
sta $C4
lda $2B
sta $C5
LBL058: lda #$01
sta $BE
rts
;
;
;
JUMP14: jsr LBL061
beq LBL062
LBL066: lda $BC
sta $28
lda $BD
sta $29
jmp LBL015
JUMP13: jsr LBL063
jsr LBL064
jsr LBL065
bne LBL066
rts
;
;
;
LBL037: jsr LBL024
sta $28
jsr LBL024
sta $29
ora $28
rts
;
;
;
JUMP07: jsr LBL035
jsr LBL034
LBL034: lda $BD
LBL131: jsr LBL029
lda $BC
LBL029: ldx $C1
dex
sta $00,X
stx $C1
cpx $C0
bne LBL067
LBL068: jmp LBL015
LBL097: ldx $C1
cpx #$80
bpl LBL068
lda $00,X
inc $C1
LBL067: rts
;
;
;
LBL010: sta $BD
stx $BC
jmp LBL069
JUMP22: ldx $C1 ; entry point to TBIL PN (print number)
lda $01,X
bpl LBL070
jsr LBL071
lda #$2D
jsr LBL042
LBL070: jsr LBL035
LBL069: lda #$1F
sta $B8
sta $BA
lda #$2A
sta $B9
sta $BB
ldx $BC
ldy $BD
sec
LBL072: inc $B8
txa
sbc #$10
tax
tya
sbc #$27
tay
bcs LBL072
LBL073: dec $B9
txa
adc #$E8
tax
tya
adc #$03
tay
bcc LBL073
txa
LBL074: sec
inc $BA
sbc #$64
bcs LBL074
dey
bpl LBL074
LBL075: dec $BB
adc #$0A
bcc LBL075
ora #$30
sta $BC
lda #$20
sta $BD
ldx #$FB
LBL199: stx $C3
lda $BD,X
ora $BD
cmp #$20
beq LBL076
ldy #$30
sty $BD
ora $BD
jsr LBL042
LBL076: ldx $C3
inx
bne LBL199
rts
;
;
;
JUMP21: lda $2D
pha
lda $2C
pha
lda $20
sta $2C
lda $21
sta $2D
lda $24
ldx $25
jsr LBL077
beq LBL078
jsr LBL077
LBL078: lda $2C
sec
sbc $B6
lda $2D
sbc $B7
bcs LBL079
jsr LBL037
beq LBL079
ldx $28
lda $29
jsr LBL010
lda #$20
LBL080: jsr LBL042
jsr BREAK
bcs LBL079
jsr LBL024
bne LBL080
jsr LBL081
jmp LBL078
LBL077: sta $B6
inc $B6
bne LBL082
inx
LBL082: stx $B7
ldy $C1
cpy #$80
beq LBL083
jsr LBL061
LBL099: lda $2C
ldx $2D
sec
sbc #$02
bcs LBL084
dex
LBL084: sta $2C
jmp LBL085
LBL079: pla
sta $2C
pla
sta $2D
LBL083: rts
LBL081: lda $BF
bmi LBL083
;
;
; Routine to handle CR, LF and pad characters in the ouput
;
LBL001: lda #$0D ; Load up a CR
jsr OUT_V ; Go print it
lda PCC ; Load the pad character code
and #$7F ; Test to see -
sta $BF ; how many pad charachters to print
beq LBL086 ; Skip if 0
LBL088: jsr LBL087 ; Go print pad charcter
dec $BF ; One less
bne LBL088 ; Loop until 0
LBL086: lda #$0A ; Load up a LF
jmp LBL089 ; Go print it
;
;
;
LBL092: ldy TMC
LBL091: sty $BF
bcs LBL090
JUMP24: lda #$30 ; Entry pont for TBIL GL (get input line)
sta $2C
sta $C0
sty $2D
jsr LBL034
LBL090: eor $80
sta $80
jsr IN_V
ldy #$00
ldx $C0
and #$7F
beq LBL090
cmp #$7F
beq LBL090
cmp #$13
beq LBL091
cmp #$0A
beq LBL092
cmp LSC
beq LBL093
cmp BSC
bne LBL094
cpx #$30
bne LBL095
LBL093: ldx $2C
sty $BF
lda #$0D
LBL094: cpx $C1
bmi LBL096
lda #$07
jsr LBL042
jmp LBL090
LBL096: sta $00,X
inx
inx
LBL095: dex
stx $C0
cmp #$0D
bne LBL090
jsr LBL081
LBL035: jsr LBL097
sta $BC
jsr LBL097
sta $BD
rts
;
;
;
JUMP27: jsr LBL098
jsr LBL061
php
jsr LBL099
sta $B8
stx $B9
lda $BC
sta $B6
lda $BD
sta $B7
ldx #$00
plp
bne LBL100
jsr LBL037
dex
dex
LBL101: dex
jsr LBL024
bne LBL101
LBL100: sty $28
sty $29
jsr LBL098
lda #$0D
cmp (C_2C),Y
beq LBL102
inx
inx
inx
LBL103: inx
iny
cmp (C_2C),Y
bne LBL103
lda $B6
sta $28
lda $B7
sta $29
LBL102: lda $B8
sta $BC
lda $B9
sta $BD
clc
ldy #$00
txa
beq LBL104
bpl LBL105
adc $2E
sta $B8
lda $2F
sbc #$00
sta $B9
LBL109: lda (C_2E),Y
sta (C_B8),Y
ldx $2E
cpx $24
bne LBL106
lda $2F
cmp $25
beq LBL107
LBL106: inx
stx $2E
bne LBL108
inc $2F
LBL108: inc $B8
bne LBL109
inc $B9
bne LBL109
LBL105: adc $24
sta $B8
sta $2E
tya
adc $25
sta $B9
sta $2F
lda $2E
sbc $C6
lda $2F
sbc $C7
bcc LBL110
dec $2A
jmp LBL015
LBL110: lda (C_24),Y
sta (C_2E),Y