mirror of
https://github.com/A2osX/A2osX.git
synced 2024-11-29 17:50:18 +00:00
157 lines
2.7 KiB
Plaintext
157 lines
2.7 KiB
Plaintext
NEW
|
||
AUTO 3,1
|
||
*/--------------------------------------
|
||
* # NewStrV
|
||
* **In:**
|
||
* A = Initial Size (Page)
|
||
* ## RETURN VALUE
|
||
* X = hStrV
|
||
* Y,A = Ptr
|
||
*\--------------------------------------
|
||
K.NewStrV
|
||
*/--------------------------------------
|
||
* # StrVGet
|
||
* **In:**
|
||
* A = hStrV
|
||
* X = index
|
||
* ## RETURN VALUE
|
||
* Y,A = Ptr
|
||
*\--------------------------------------
|
||
K.StrVGet
|
||
*/--------------------------------------
|
||
* # StrVDup
|
||
* **In:**
|
||
* 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
|
||
|
||
ldx #0
|
||
|
||
ldy #0
|
||
|
||
.4 lda (ZPPtr1),y
|
||
.5 sta (ZPPtr2),y
|
||
beq .6
|
||
|
||
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
|
||
bne .5
|
||
sta (ZPPtr2),y Ending \0
|
||
|
||
txa
|
||
plx hMem
|
||
|
||
clc
|
||
.9 rts
|
||
*/--------------------------------------
|
||
* # Str2StrV
|
||
* Expand String and convert to ArgV List
|
||
* ## C
|
||
* short int str2strv(char* args, char* argv[])
|
||
* ## ASM
|
||
* `>PUSHW argv`
|
||
* `>LDYA args`
|
||
* `>SYSCALL Str2StrV`
|
||
* ## RETURN VALUE
|
||
* A = Arg count
|
||
*\--------------------------------------
|
||
ARG.bInQuote .EQ ZPPtr3
|
||
*--------------------------------------
|
||
K.Str2StrV jsr K.Expand
|
||
|
||
bcs .9
|
||
>STYA ZPPtr1
|
||
stx .80+1
|
||
|
||
>PULLW ZPPtr2 Get target buffer
|
||
ldx #0 Arg Count
|
||
stz ARG.bInQuote
|
||
|
||
.1 jsr SHARED.GetCharPtr1
|
||
beq .8
|
||
cmp #C.SPACE
|
||
beq .1 skip leading spaces
|
||
.2 cmp #'"' found a quote ?
|
||
bne .3
|
||
lda ARG.bInQuote
|
||
eor #$ff
|
||
sta ARG.bInQuote
|
||
bra .7 skip quote and check next char
|
||
.3 cmp #C.SPACE
|
||
bne .6 regular char ...store...
|
||
bit ARG.bInQuote
|
||
bmi .6 between quotes... store space...
|
||
|
||
inx Found one arg !!!
|
||
lda #0 set this token End
|
||
jsr SHARED.PutCharPtr2
|
||
bra .1
|
||
.6 jsr SHARED.PutCharPtr2
|
||
|
||
.7 jsr SHARED.GetCharPtr1
|
||
bne .2
|
||
inx
|
||
.8 jsr SHARED.PutCharPtr2 set Argv[x] Ending 0
|
||
|
||
sta (ZPPtr2) set Array Ending 0
|
||
phx
|
||
.80 lda #$FF SELF MODIFIED
|
||
jsr K.FreeMem Discard expanded string
|
||
pla get back Arg Count
|
||
|
||
* clc
|
||
rts
|
||
.9 >RET 2 Discard target buffer
|
||
*--------------------------------------
|
||
MAN
|
||
SAVE USR/SRC/SYS/KERNEL.S.STRV
|
||
LOAD USR/SRC/SYS/KERNEL.S
|
||
ASM
|