-
Notifications
You must be signed in to change notification settings - Fork 82
/
lineget.src
47 lines (43 loc) · 953 Bytes
/
lineget.src
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
.page
.subttl 'lineget subroutine
; linget reads a line # from the current txtptr position
; and stores it in linnum (valid range is 0-63999).
;
; on exit txtptr is pointing to the terminating char
; which is in .a with condition codes set.
; endchr will be =0 if no digit input, else >0. use it
; to distinguish between line # 0 & null input.
linget ldx #0
stx endchr ;flags line # input
stx linnum ;init line # to 0
stx linnum+1
1$ bcs 4$ ;it's not a digit, do rts
inc endchr ;indicate line # input
sbc #$2f ;'0'-1 since c=0
sta charac ;save for later
lda linnum+1
sta index
cmp #25 ;line number will be .lt. 64000?
bcc 2$
jmp snerr ;..no, syntax error.
2$ lda linnum
asl a ;multiply by 10
rol index
asl a
rol index
adc linnum
sta linnum
lda index
adc linnum+1
sta linnum+1
asl linnum
rol linnum+1
lda linnum
adc charac ;add in digit
sta linnum
bcc 3$
inc linnum+1
3$ jsr chrget
jmp 1$
4$ rts
;end