2017-12-22 21:24:30 +00:00
|
|
|
|
NEW
|
2019-05-25 19:24:07 +00:00
|
|
|
|
AUTO 3,1
|
2016-10-24 15:54:43 +00:00
|
|
|
|
*/--------------------------------------
|
2020-02-06 16:23:59 +00:00
|
|
|
|
* # Shift
|
|
|
|
|
* ## ASM
|
|
|
|
|
* A = argument index.
|
|
|
|
|
* ## RETURN VALUE
|
|
|
|
|
* CC : success
|
|
|
|
|
* Y,A = PTR To Arg[A]
|
|
|
|
|
* CS : Out Of Bound
|
|
|
|
|
*\--------------------------------------
|
|
|
|
|
K.Shift jsr K.ArgV
|
|
|
|
|
bcs .9
|
|
|
|
|
|
|
|
|
|
>STYA ZPPtr1
|
|
|
|
|
* >STYA ZPPtr2 already set from ArgV
|
|
|
|
|
|
|
|
|
|
ldy #$ff
|
|
|
|
|
|
|
|
|
|
.1 iny
|
|
|
|
|
lda (ZPPtr1),y
|
|
|
|
|
bne .1
|
|
|
|
|
|
|
|
|
|
.2 jsr SHARED.AddYp1ToPtr1
|
|
|
|
|
|
|
|
|
|
ldy #$ff
|
|
|
|
|
|
|
|
|
|
.3 iny
|
|
|
|
|
lda (ZPPtr1),y
|
|
|
|
|
sta (ZPPtr2),y
|
|
|
|
|
bne .3
|
|
|
|
|
|
|
|
|
|
tya
|
|
|
|
|
beq .8
|
|
|
|
|
|
|
|
|
|
jsr SHARED.AddYp1ToPtr2
|
|
|
|
|
bra .2
|
|
|
|
|
|
|
|
|
|
.8 ldy #S.PS.ARGC
|
|
|
|
|
lda (pPS),y
|
|
|
|
|
dec
|
|
|
|
|
sta (pPS),y
|
|
|
|
|
clc
|
|
|
|
|
|
|
|
|
|
.9 rts
|
|
|
|
|
*/--------------------------------------
|
2018-10-16 15:48:03 +00:00
|
|
|
|
* # ArgV
|
2018-06-18 06:22:50 +00:00
|
|
|
|
* ## ASM
|
2018-06-14 15:31:36 +00:00
|
|
|
|
* A = argument index.
|
2018-10-11 15:23:06 +00:00
|
|
|
|
* ## RETURN VALUE
|
2018-06-14 15:31:36 +00:00
|
|
|
|
* CC : success
|
|
|
|
|
* Y,A = PTR To Arg[A]
|
|
|
|
|
* CS : Out Of Bound
|
2016-10-24 15:54:43 +00:00
|
|
|
|
*\--------------------------------------
|
2018-10-18 15:32:57 +00:00
|
|
|
|
K.ArgV tax save requested arg#
|
2018-10-16 15:48:03 +00:00
|
|
|
|
ldy #S.PS.hARGV
|
2016-08-17 06:25:58 +00:00
|
|
|
|
lda (pPs),y
|
2018-06-21 15:12:10 +00:00
|
|
|
|
jsr K.GetMemPtr
|
2017-09-25 15:50:33 +00:00
|
|
|
|
|
2019-09-10 10:22:57 +00:00
|
|
|
|
>STYA ZPPtr2 Use Ptr2, called from ExpandStr
|
|
|
|
|
.1 lda (ZPPtr2) end of ARGV[] ?
|
2018-10-18 15:32:57 +00:00
|
|
|
|
|
2017-09-25 15:50:33 +00:00
|
|
|
|
beq .9 yes, not found....
|
2018-10-18 15:32:57 +00:00
|
|
|
|
dex
|
|
|
|
|
bmi .7
|
2019-09-10 10:22:57 +00:00
|
|
|
|
.3 jsr SHARED.GetCharPtr2 skip str
|
2017-09-25 15:50:33 +00:00
|
|
|
|
bne .3
|
|
|
|
|
|
2019-09-10 10:22:57 +00:00
|
|
|
|
jsr SHARED.NextCharPtr2 skip \0
|
2018-10-18 15:32:57 +00:00
|
|
|
|
bra .1
|
2017-09-25 15:50:33 +00:00
|
|
|
|
|
2019-09-10 10:22:57 +00:00
|
|
|
|
.7 >LDYA ZPPtr2
|
2018-06-14 15:31:36 +00:00
|
|
|
|
.8 clc
|
2017-09-25 15:50:33 +00:00
|
|
|
|
rts
|
|
|
|
|
|
2019-02-19 16:34:43 +00:00
|
|
|
|
.9 lda #E.OOB
|
|
|
|
|
sec
|
2017-09-25 15:50:33 +00:00
|
|
|
|
rts
|
2020-02-07 12:53:46 +00:00
|
|
|
|
*/--------------------------------------
|
|
|
|
|
* # Arg2ArgV
|
|
|
|
|
* Expand String and convert to StrV List
|
|
|
|
|
* ## C
|
|
|
|
|
* short int arg2argv(char* args, char* argv[])
|
|
|
|
|
* ## ASM
|
|
|
|
|
* `>PUSHW argv`
|
|
|
|
|
* `>LDYA args`
|
|
|
|
|
* `>SYSCALL Arg2ArgV`
|
|
|
|
|
* ## RETURN VALUE
|
|
|
|
|
* A = Arg count
|
|
|
|
|
*\--------------------------------------
|
|
|
|
|
K.Arg2ArgV jsr K.Expand
|
|
|
|
|
|
|
|
|
|
bcs .9
|
|
|
|
|
>STYA ZPPtr1
|
|
|
|
|
stx .80+1
|
|
|
|
|
|
|
|
|
|
>PULLW ZPPtr2 Get target buffer
|
|
|
|
|
ldx #0 Arg Count
|
|
|
|
|
ldy #0 bInQuote
|
|
|
|
|
|
|
|
|
|
.1 jsr SHARED.GetCharPtr1
|
|
|
|
|
beq .8
|
|
|
|
|
|
|
|
|
|
cmp #C.SPACE
|
|
|
|
|
beq .1 skip leading spaces
|
|
|
|
|
|
|
|
|
|
.2 cmp #'"' found a quote ?
|
|
|
|
|
bne .3
|
|
|
|
|
|
|
|
|
|
tya
|
|
|
|
|
eor #$ff
|
|
|
|
|
tay
|
|
|
|
|
bra .7 skip quote and check next char
|
|
|
|
|
|
|
|
|
|
.3 cmp #C.SPACE
|
|
|
|
|
bne .6 regular char ...store...
|
|
|
|
|
tya
|
|
|
|
|
bmi .4 between quotes... store space...
|
|
|
|
|
|
|
|
|
|
inx Found one arg !!!
|
|
|
|
|
lda #0 set this token End
|
|
|
|
|
jsr SHARED.PutCharPtr2
|
|
|
|
|
bra .1
|
|
|
|
|
|
|
|
|
|
.4 lda #C.SPACE
|
|
|
|
|
.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
|
2020-02-07 15:35:52 +00:00
|
|
|
|
*/--------------------------------------
|
|
|
|
|
* # ArgVDup
|
|
|
|
|
* ## ASM
|
|
|
|
|
* Y,A = Src StrV
|
|
|
|
|
* ## RETURN VALUE
|
|
|
|
|
* X = hMem of new StrV
|
|
|
|
|
* A = Str Count
|
|
|
|
|
*\--------------------------------------
|
|
|
|
|
K.ArgVDup >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 ARG.Ptr1Ptr2cpy
|
|
|
|
|
|
|
|
|
|
txa Count
|
|
|
|
|
plx hMem
|
|
|
|
|
|
|
|
|
|
clc
|
|
|
|
|
.9 rts
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
ARG.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
|
2016-08-17 06:25:58 +00:00
|
|
|
|
*--------------------------------------
|
|
|
|
|
MAN
|
2018-11-17 17:17:13 +00:00
|
|
|
|
SAVE USR/SRC/SYS/KERNEL.S.ARG
|
|
|
|
|
LOAD USR/SRC/SYS/KERNEL.S
|
2016-08-17 06:25:58 +00:00
|
|
|
|
ASM
|