A2osX/SYS/KERNEL.S.STRV.txt
2020-02-07 13:53:46 +01:00

271 lines
3.9 KiB
Plaintext
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

NEW
AUTO 3,1
*/--------------------------------------
* # StrVShift
* ## ASM
* `>PUSHB hSTRV`
* `>PUSHB index`
* `>SYSCALL StrVShift`
* ## RETURN VALUE
*\--------------------------------------
K.StrVShift sta CLRREADAUX
>PULLA index
eor #$ff
tax
>PULLA
sta SETREADAUX
jsr K.GetMemPtr
>STYA ZPPtr1 strV
.1 inx
beq .2
jsr STRV.NStrPtr1
bcc .1
rts
.2 >LDYA ZPPtr1
>STYA ZPPtr2
jsr STRV.NStrPtr1
jsr STRV.Ptr1Ptr2cpy
clc
rts
*/--------------------------------------
* # StrVGet
* ## ASM
* `>PUSHB hSTRV`
* `>PUSHB index`
* `>PUSHW ptr`
* `>SYSCALL StrVGet`
* ## RETURN VALUE
* CC: Y,A = Ptr
* CS: Y,A = NULL
*\--------------------------------------
K.StrVGet sta CLRREADAUX
>PULLW FORPNT ptr
>PULLA index
eor #$ff
tax
>PULLA
sta SETREADAUX
jsr K.GetMemPtr
>STYA ZPPtr1 strV
.1 inx
beq .2
jsr STRV.NStrPtr1
bcc .1
rts
.2 lda (ZPPtr1)
tay
bne .3
sec
rts Y,A = 0
.3 lda FORPNT+1
beq .8
.4 ldy #$ff
.5 iny
lda (ZPPtr1),y
jsr SHARED.FORPNT.PutY
bne .5
>LDYA FORPNT
clc
rts
.8 >LDYA ZPPtr1
clc
.9 rts
*/--------------------------------------
* # StrVAdd
* ## ASM
* `>PUSHB hSTRV`
* `>PUSHW str`
* `>SYSCALL StrVAdd`
* ## RETURN VALUE
* CC : str added to hSTRV
* CS : hSTRV full
*\--------------------------------------
K.StrVAdd sta CLRREADAUX
>PULLW TXTPTR str
>PULLA
sta SETREADAUX
jsr K.GetMemPtr
>STYA ZPPtr1
lda TXTPTR+1
bne .10
sta (ZPPtr1)
clc
rts
.10 lda #1 for \0
sta ZPPtr2
stz ZPPtr2+1
.1 jsr STRV.NStrPtr1
bcs .2
jsr SHARED.AddYp1ToPtr2
bra .1
.2 ldy #$ff
.3 iny
jsr SHARED.TXTPTR.GetY
bne .3
tya
sec
adc ZPPtr2
bcc .4
inc ZPPtr2+1
ldy #S.MEM.LEN
lda (ZPMemMgrSPtr),y
cmp ZPPtr2
iny
lda (ZPMemMgrSPtr),y
sbc ZPPtr2+1
bcs .4
lda #E.OOM
sec
rts
.4 ldy #$ff
.5 iny
jsr SHARED.TXTPTR.GetY
sta (ZPPtr1),y
bne .5
iny
sta (ZPPtr1),y StrV Ending \0
clc
rts
*--------------------------------------
STRV.NStrPtr1 ldy #$ff
.1 iny
lda (ZPPtr1)
beq .2
inc ZPPtr1
bne .1
inc ZPPtr1+1
bra .1
.2 tya
beq .9
inc ZPPtr1
bne .8
inc ZPPtr1+1 skip \0
.8 clc
rts
.9 sec Y,A = 0
rts
*/--------------------------------------
* # StrVDup
* ## ASM
* Y,A = Src StrV
* ## RETURN VALUE
* X = hMem of new StrV
* A = Str Count
*\--------------------------------------
K.StrVDup >STYA ZPPtr1
>STYA ZPPtr2
ldy #0
ldx #0
.1 lda (ZPPtr2),y
beq .2
.11 iny
bne .1
inx
inc ZPPtr2+1
bra .1
.2 iny
bne .3
inx
inc ZPPtr2+1
.3 lda (ZPPtr2),y
bne .11
txa
jsr K.getmem
bcs .9
>STYA ZPPtr2
phx
jsr STRV.Ptr1Ptr2cpy
txa Count
plx hMem
clc
.9 rts
*--------------------------------------
STRV.Ptr1Ptr2cpy
ldx #0
ldy #0
.4 lda (ZPPtr1),y
sta (ZPPtr2),y
beq .6
.5 iny
bne .4
inc ZPPtr1+1
inc ZPPtr2+1
bra .4
.6 inx
iny
bne .7
inc ZPPtr1+1
inc ZPPtr2+1
.7 lda (ZPPtr1),y
sta (ZPPtr2),y Ending \0 ?
bne .5
rts
*--------------------------------------
MAN
SAVE USR/SRC/SYS/KERNEL.S.STRV
LOAD USR/SRC/SYS/KERNEL.S
ASM