2015-03-14 21:48:35 +00:00
|
|
|
|
PR#3
|
2015-06-03 18:30:57 +00:00
|
|
|
|
PREFIX /A2OSX.SRC
|
2015-03-14 21:48:35 +00:00
|
|
|
|
NEW
|
|
|
|
|
INC 1
|
|
|
|
|
AUTO 6
|
|
|
|
|
.LIST OFF
|
|
|
|
|
*--------------------------------------
|
2016-09-21 15:20:37 +00:00
|
|
|
|
* K.NewPStrYA
|
2015-06-03 18:30:57 +00:00
|
|
|
|
* IN:
|
2016-08-17 06:25:58 +00:00
|
|
|
|
* Y,A = PTR to buffer
|
2015-06-03 18:30:57 +00:00
|
|
|
|
* OUT:
|
2016-08-17 06:25:58 +00:00
|
|
|
|
* Y,A = PTR to String
|
|
|
|
|
* X = hMem (PSTRING)
|
2015-06-03 18:30:57 +00:00
|
|
|
|
*--------------------------------------
|
2016-09-21 15:20:37 +00:00
|
|
|
|
K.NewPStrYA >STYA ZPQuickPtr1
|
2015-06-03 18:30:57 +00:00
|
|
|
|
lda (ZPQuickPtr1)
|
2015-03-14 21:48:35 +00:00
|
|
|
|
inc
|
|
|
|
|
tay
|
|
|
|
|
lda #0 Y,A = len of new string
|
|
|
|
|
>PUSHYA
|
2016-08-17 06:25:58 +00:00
|
|
|
|
>PUSHBI 0 0 = no option
|
2016-09-21 15:20:37 +00:00
|
|
|
|
jsr K.GetMem
|
2015-03-14 21:48:35 +00:00
|
|
|
|
bcs .9
|
2016-08-17 06:25:58 +00:00
|
|
|
|
|
2015-03-14 21:48:35 +00:00
|
|
|
|
>STYA ZPQuickPtr2
|
2016-08-17 06:25:58 +00:00
|
|
|
|
|
2016-09-21 15:20:37 +00:00
|
|
|
|
jsr K.PStrCpyPtr1Ptr2
|
2016-08-17 06:25:58 +00:00
|
|
|
|
|
|
|
|
|
>LDYA ZPQuickPtr2
|
|
|
|
|
|
|
|
|
|
clc
|
|
|
|
|
rts
|
|
|
|
|
|
|
|
|
|
.9 sec
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
2016-09-21 15:20:37 +00:00
|
|
|
|
* K.PStrCpy
|
2016-08-17 06:25:58 +00:00
|
|
|
|
* IN:
|
|
|
|
|
* PULLW = PSTR to DST (PSTRING)
|
|
|
|
|
* PULLW = PSTR to SRC (PSTRING)
|
|
|
|
|
* OUT:
|
|
|
|
|
* DST = SRC (PSTRING)
|
|
|
|
|
*--------------------------------------
|
2016-09-21 15:20:37 +00:00
|
|
|
|
K.PStrCpy >PULLW ZPQuickPtr2 save DST
|
2016-08-17 06:25:58 +00:00
|
|
|
|
>PULLW ZPQuickPtr1 save SRC
|
|
|
|
|
|
2016-09-21 15:20:37 +00:00
|
|
|
|
K.PStrCpyPtr1Ptr2
|
2015-03-14 21:48:35 +00:00
|
|
|
|
lda (ZPQuickPtr1)
|
|
|
|
|
sta (ZPQuickPtr2)
|
|
|
|
|
tay
|
|
|
|
|
beq .2
|
2016-08-17 06:25:58 +00:00
|
|
|
|
|
2015-03-14 21:48:35 +00:00
|
|
|
|
.1 lda (ZPQuickPtr1),y
|
|
|
|
|
sta (ZPQuickPtr2),y
|
|
|
|
|
dey
|
|
|
|
|
bne .1
|
2016-08-17 06:25:58 +00:00
|
|
|
|
|
|
|
|
|
.2 clc
|
2015-03-14 21:48:35 +00:00
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
2016-09-21 15:20:37 +00:00
|
|
|
|
* K.PStrCat
|
2015-03-14 21:48:35 +00:00
|
|
|
|
* IN:
|
2016-08-17 06:25:58 +00:00
|
|
|
|
* PULLW = PSTR to DST (PSTRING)
|
|
|
|
|
* PULLW = PSTR to SRC (PSTRING)
|
2015-03-14 21:48:35 +00:00
|
|
|
|
* OUT:
|
2016-08-17 06:25:58 +00:00
|
|
|
|
* DST = DST+SRC (PSTRING)
|
2015-03-14 21:48:35 +00:00
|
|
|
|
*--------------------------------------
|
2016-09-21 15:20:37 +00:00
|
|
|
|
K.PStrCat >PULLW ZPQuickPtr2 save DST
|
2016-08-17 06:25:58 +00:00
|
|
|
|
>PULLW ZPQuickPtr1 save SRC
|
|
|
|
|
|
2015-03-14 21:48:35 +00:00
|
|
|
|
lda (ZPQuickPtr1)
|
|
|
|
|
tax
|
2016-08-17 06:25:58 +00:00
|
|
|
|
|
2015-03-14 21:48:35 +00:00
|
|
|
|
lda (ZPQuickPtr2)
|
2016-08-17 06:25:58 +00:00
|
|
|
|
tay
|
|
|
|
|
|
|
|
|
|
.1 cpy #255
|
|
|
|
|
beq .8
|
|
|
|
|
|
|
|
|
|
iny
|
|
|
|
|
|
|
|
|
|
inc ZPQuickPtr1
|
|
|
|
|
bne .2
|
|
|
|
|
inc ZPQuickPtr1+1
|
|
|
|
|
|
|
|
|
|
.2 lda (ZPQuickPtr1)
|
|
|
|
|
sta (ZPQuickPtr2),y
|
2015-03-14 21:48:35 +00:00
|
|
|
|
dex
|
2016-08-17 06:25:58 +00:00
|
|
|
|
bne .1
|
|
|
|
|
|
|
|
|
|
.8 tya
|
|
|
|
|
sta (ZPQuickPtr2)
|
2015-03-14 21:48:35 +00:00
|
|
|
|
clc
|
|
|
|
|
rts
|
2016-08-17 06:25:58 +00:00
|
|
|
|
*--------------------------------------
|
2016-09-21 15:20:37 +00:00
|
|
|
|
* K.PStrMatch
|
2015-03-14 21:48:35 +00:00
|
|
|
|
* IN:
|
2016-06-23 15:56:13 +00:00
|
|
|
|
* PULLB = PTR to String (PSTRING)
|
|
|
|
|
* PULLB = PTR to Pattern (PSTRING)
|
2015-03-14 21:48:35 +00:00
|
|
|
|
* OUT:
|
|
|
|
|
* cc = match
|
|
|
|
|
* cs = no match
|
|
|
|
|
*--------------------------------------
|
2016-09-21 15:20:37 +00:00
|
|
|
|
K.PStrMatch >PULLW ZPQuickPtr2 pull String
|
2015-03-14 21:48:35 +00:00
|
|
|
|
>PULLW ZPQuickPtr1 pull Pattern
|
|
|
|
|
|
2016-06-23 15:56:13 +00:00
|
|
|
|
lda (ZPQuickPTR1) Keep Pattern Length in X
|
2015-03-14 21:48:35 +00:00
|
|
|
|
tax
|
|
|
|
|
beq .8 Match always if empty
|
|
|
|
|
ldy #0
|
|
|
|
|
|
|
|
|
|
.1 inc ZPQuickPTR1 Make PTR1 advance to next char
|
|
|
|
|
bne .2
|
|
|
|
|
inc ZPQuickPTR1+1
|
|
|
|
|
|
|
|
|
|
.2 lda (ZPQuickPTR1) get pattern char
|
|
|
|
|
cmp #'*'
|
|
|
|
|
beq .5
|
|
|
|
|
|
|
|
|
|
.3 tya we must match ? or regular char
|
|
|
|
|
cmp (ZPQuickPTR2) check if at end of string
|
|
|
|
|
beq .9 yes, no char left, exit with error
|
|
|
|
|
|
|
|
|
|
iny advance to next char to compare
|
|
|
|
|
|
|
|
|
|
lda (ZPQuickPTR1) get back pattern char
|
|
|
|
|
cmp #'?'
|
|
|
|
|
beq .4 no need to compare, any char will match
|
|
|
|
|
cmp (ZPQuickPTR2),y Regular Char, compare with string at Y
|
|
|
|
|
bne .9 no match, exit
|
|
|
|
|
|
|
|
|
|
.4 dex char matched, check if end of pattern
|
|
|
|
|
bne .1 continue if remaining char in pattern
|
|
|
|
|
|
|
|
|
|
tya end of pattern, but end of string ?
|
|
|
|
|
cmp (ZPQuickPTR2) end of string ?
|
|
|
|
|
beq .8 yes, string matched entirely
|
|
|
|
|
bra .9 no, remaining char in string, no match
|
|
|
|
|
|
|
|
|
|
.5 dex we have '*', last char of pattern ?
|
|
|
|
|
beq .8 yes, match everything, including empty string
|
|
|
|
|
|
|
|
|
|
inc ZPQuickPTR1 Make PTR1 advance to next char
|
|
|
|
|
bne .6
|
|
|
|
|
inc ZPQuickPTR1+1
|
|
|
|
|
|
|
|
|
|
.6 lda (ZPQuickPTR1) get next char of pattern
|
|
|
|
|
cmp #'*' another '*' ?
|
|
|
|
|
beq .5 yes, '**' = '*', go next char
|
|
|
|
|
cmp #'?' '*?' ??? we must match a least one char
|
|
|
|
|
beq .3
|
|
|
|
|
|
|
|
|
|
.7 tya we need at least one remaining char in string,
|
|
|
|
|
cmp (ZPQuickPTR2) check if at end of string
|
|
|
|
|
beq .9 no chance to match ? or regular char
|
|
|
|
|
|
|
|
|
|
iny
|
|
|
|
|
lda (ZPQuickPTR1) get again char in pattern
|
|
|
|
|
cmp (ZPQuickPTR2),y compare with char in string
|
|
|
|
|
bne .7 not equal to next non wildcard in pattern
|
|
|
|
|
|
|
|
|
|
bra .4 go check remaining char in pattern...
|
|
|
|
|
|
|
|
|
|
.8 clc
|
|
|
|
|
rts
|
|
|
|
|
|
|
|
|
|
.9 sec
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
2016-09-21 15:20:37 +00:00
|
|
|
|
* K.PStrUprYA
|
|
|
|
|
* K.PStrLwrYA
|
2016-09-20 06:17:20 +00:00
|
|
|
|
* IN:
|
|
|
|
|
* Y,A = PTR to String (PSTRING)
|
|
|
|
|
* OUT:
|
|
|
|
|
* Uppercased/lowercased String in Buffer
|
|
|
|
|
*--------------------------------------
|
2016-09-21 15:20:37 +00:00
|
|
|
|
K.PStrUprYA ldx #0
|
2016-09-20 06:17:20 +00:00
|
|
|
|
.HS 2C bit abs
|
2016-09-21 15:20:37 +00:00
|
|
|
|
K.PStrLwrYA ldx #2
|
2016-09-20 06:17:20 +00:00
|
|
|
|
>STYA ZPQuickPtr1
|
|
|
|
|
|
|
|
|
|
lda (ZPQuickPtr1)
|
|
|
|
|
tay
|
|
|
|
|
|
|
|
|
|
.1 lda (ZPQuickPtr1),y
|
2016-09-21 15:20:37 +00:00
|
|
|
|
cmp K.PStrUprLwr,x
|
2016-09-20 06:17:20 +00:00
|
|
|
|
bcc .2
|
2016-09-21 15:20:37 +00:00
|
|
|
|
cmp K.PStrUprLwr+1,x
|
2016-09-20 06:17:20 +00:00
|
|
|
|
bcs .2
|
|
|
|
|
eor #$20
|
|
|
|
|
sta (ZPQuickPtr1),y
|
|
|
|
|
.2 dey
|
|
|
|
|
bne .1
|
|
|
|
|
|
|
|
|
|
clc
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
2016-09-21 15:20:37 +00:00
|
|
|
|
K.PStrUprLwr .AS "azAZ"
|
2016-09-20 06:17:20 +00:00
|
|
|
|
*--------------------------------------
|
2016-09-21 15:20:37 +00:00
|
|
|
|
* K.PStr2StrArrayYA
|
2016-08-17 06:25:58 +00:00
|
|
|
|
* In :
|
|
|
|
|
* Y,A = PTR to String
|
|
|
|
|
* Out :
|
|
|
|
|
* Y,A = PTR to StrArray
|
|
|
|
|
* X = hMem
|
2015-03-14 21:48:35 +00:00
|
|
|
|
*--------------------------------------
|
2016-09-21 15:20:37 +00:00
|
|
|
|
K.PStr2StrArrayYA
|
2015-03-14 21:48:35 +00:00
|
|
|
|
>STYA ZPQuickPtr1
|
2016-08-17 06:25:58 +00:00
|
|
|
|
lda (ZPQuickPtr1) Get mem size STRLEN+1
|
|
|
|
|
ldx #0
|
|
|
|
|
inc
|
|
|
|
|
bne .1
|
|
|
|
|
inx
|
2016-06-07 06:10:18 +00:00
|
|
|
|
|
2016-08-17 06:25:58 +00:00
|
|
|
|
.1 >PUSHAX
|
|
|
|
|
>PUSHBI 0
|
2016-09-21 15:20:37 +00:00
|
|
|
|
jsr K.GetMem
|
2016-08-17 06:25:58 +00:00
|
|
|
|
bcs .9
|
|
|
|
|
phx save hMem
|
|
|
|
|
phy save PTR.LO
|
|
|
|
|
pha save PTR.HI
|
2016-06-07 06:10:18 +00:00
|
|
|
|
>STYA ZPQuickPtr2
|
2016-08-17 06:25:58 +00:00
|
|
|
|
|
|
|
|
|
lda (ZPQuickPtr1)
|
|
|
|
|
tax count in src string
|
|
|
|
|
beq .8
|
|
|
|
|
|
|
|
|
|
ldy #0 reset index in dst token
|
|
|
|
|
|
|
|
|
|
.3 inc ZPQuickPtr1 get...
|
|
|
|
|
bne .4
|
|
|
|
|
inc ZPQuickPtr1+1
|
|
|
|
|
.4 lda (ZPQuickPtr1) ...next char
|
|
|
|
|
|
|
|
|
|
cmp #' ' found a space ?
|
|
|
|
|
bne .6
|
|
|
|
|
|
|
|
|
|
tya in a token ?
|
|
|
|
|
beq .7 no, skip & go to next char
|
|
|
|
|
|
|
|
|
|
sta (ZPQuickPtr2) yes, set this token len
|
2015-03-14 21:48:35 +00:00
|
|
|
|
sec
|
2016-08-17 06:25:58 +00:00
|
|
|
|
adc ZPQuickPtr2 advance to next token
|
|
|
|
|
sta ZPQuickPtr2
|
|
|
|
|
bcc .5
|
2016-06-07 06:10:18 +00:00
|
|
|
|
inc ZPQuickPtr2+1
|
2016-08-17 06:25:58 +00:00
|
|
|
|
|
|
|
|
|
.5 ldy #0 reset index in dst token
|
|
|
|
|
bra .7
|
|
|
|
|
|
|
|
|
|
.6 iny add char to token
|
|
|
|
|
sta (ZPQuickPtr2),y
|
|
|
|
|
|
|
|
|
|
.7 dex end of src string?
|
|
|
|
|
bne .3 no...next char...
|
|
|
|
|
|
|
|
|
|
tya yes, are we in a token ?
|
|
|
|
|
beq .8
|
|
|
|
|
|
|
|
|
|
sta (ZPQuickPtr2) yes, set last token len
|
2015-03-14 21:48:35 +00:00
|
|
|
|
sec
|
2016-08-17 06:25:58 +00:00
|
|
|
|
adc ZPQuickPtr2 advance to next token
|
|
|
|
|
sta ZPQuickPtr2
|
|
|
|
|
bcc .8
|
2016-06-07 06:10:18 +00:00
|
|
|
|
inc ZPQuickPtr2+1
|
|
|
|
|
|
2016-08-17 06:25:58 +00:00
|
|
|
|
.8 lda #0
|
|
|
|
|
sta (ZPQuickPtr2) set Array Ending 0
|
2016-06-07 06:10:18 +00:00
|
|
|
|
|
2016-08-17 06:25:58 +00:00
|
|
|
|
pla get back PTR.HI
|
|
|
|
|
ply get back PTR.LO
|
|
|
|
|
plx get back hMem
|
2016-05-01 21:13:54 +00:00
|
|
|
|
clc
|
2016-08-17 06:25:58 +00:00
|
|
|
|
.9 rts
|
2016-05-01 21:13:54 +00:00
|
|
|
|
*--------------------------------------
|
2015-03-14 21:48:35 +00:00
|
|
|
|
MAN
|
|
|
|
|
SAVE SYS/KERNEL.S.STR
|
|
|
|
|
LOAD SYS/KERNEL.S
|
|
|
|
|
ASM
|