-
Notifications
You must be signed in to change notification settings - Fork 84
/
exten3.src
145 lines (121 loc) · 2.65 KB
/
exten3.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
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
.page
.subttl 'extensions-3 02/17/84'
; alternate use of the mid$ fn., as the target of an assignment stmt.
;
; mid$(string_var,starting_position [,length]) = string_expression
midd2
midwrk =midd2-1
jsr chkopn ;check for '('
jsr ptrget ;get pointer to descriptor of string-var
sta forpnt ;store for later use
sty forpnt+1
jsr chkstr ;check if string
jsr combyt ;look for comma, followed by 1 byte starting address
dex ;adjust starting addr.
stx hulp ;store " "
cmp #')' ;finished?
beq md10 ;branch if so (use default length)
jsr combyt ;..else get length
.byte $2c
md10
ldx #$ff ;default length
stx hulp+1
jsr chkcls ;look for ')'
lda #equltk ;look for '='
jsr synchr
jsr frmevl ;bring on the source!
jsr chkstr ;nothing funny.
ldy #2 ;get string descriptors
md20
lda #forpnt ;target
jsr indsub ;lda (forpnt),y
sta str1,y
jsr indfmo ;source
sta str2,y
dey
bpl md20
; test for target string in text was removed- all strings in ted are
; copied to string ram when they are created.
sec ;adjust pointer to source string so that the same
lda str2+1 ;..index can load & save
sbc hulp
sta str2+1
bcs *+4
dec str2+2
lda hulp+1 ;get specified length (or default)
cmp str2 ;compare with length of source
bcc *+4 ;ok if less,
lda str2 ;..else use length of source
tax
beq md80 ;done if length=0
clc
adc hulp ;add length to starting posn.
bcs md98 ;error if > 256,
cmp str1
bcc *+4
bne md98 ;...or if > target length.
ldy hulp ;get adjusted starting address
md70
jsr inds2p
sta (str1+1),y ;this is what it's all about
iny
dex
bne md70 ;keep going for specified length
md80
jmp frefac ;free up temp. string, rts
md98
jmp fcerr ;illegal quantity error
; auto increment
; syntax : auto {line-number}
; line-number = 0 means turn off
auto
jsr errind
jsr linget
lda linnum
sta autinc
lda linnum+1
sta autinc+1
jmp ready
errind ;goto error if not in direct mode
bit runmod
bmi errin2 ;in run mode
rts
errin2
ldx #erroid
jmp error
help
ldx errnum ;anything to do?
inx
beq help01 ;no errors
lda errlin
ldy errlin+1
sta linnum
sty linnum+1
jsr fndlin ;find the beginning of line with error
bcc help01 ;we've been deceived!
ror helper ;ok, set help flag
jsr crdo ;new line
ldx linnum
lda linnum+1
jsr p1line ;show him where error was
help01
jmp crdo ;and return to caller
helpsb
ldx lowtr+1 ;has 'list' reached code in error?
tya
clc
adc lowtr ;add .y index to line pointer...
bcc helps1
inx
helps1
cpx errtxt+1 ;and compare to error pointer
bne helps2 ;no
cmp errtxt
bcc helps2
beq helps2
lsr helper ;yes: remove list wedge...
lda #130 ;and initiate flash mode
jmp outdo
helps2
rts
;.end