2017-12-22 21:24:30 +00:00
|
|
|
|
NEW
|
2017-03-29 15:48:15 +00:00
|
|
|
|
PREFIX /A2OSX.BUILD
|
2017-12-22 21:24:30 +00:00
|
|
|
|
AUTO 4,1
|
2016-10-24 15:54:43 +00:00
|
|
|
|
*/--------------------------------------
|
2018-10-16 15:48:03 +00:00
|
|
|
|
* # Args2ArgV
|
2018-10-18 15:32:57 +00:00
|
|
|
|
* int args2argv(char* args, char* argv[])
|
2018-10-16 15:48:03 +00:00
|
|
|
|
* ## ASM
|
|
|
|
|
* `>PUSHW argv`
|
|
|
|
|
* `>LDYA args`
|
|
|
|
|
* `>SYSCALL Args2ArgV
|
|
|
|
|
* ## RETURN VALUE
|
|
|
|
|
*\--------------------------------------
|
|
|
|
|
ARG.bInQuote .BS 1
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
K.Args2ArgV jsr MEM.SPtr1PPtr2
|
|
|
|
|
|
|
|
|
|
ldx #0 Arg Count
|
|
|
|
|
|
2018-10-18 15:32:57 +00:00
|
|
|
|
stz ARG.bInQuote
|
|
|
|
|
|
|
|
|
|
.1 jsr ARG.GetCharPtr1
|
|
|
|
|
beq .8
|
|
|
|
|
cmp #C.SPACE
|
|
|
|
|
beq .1 skip leading spaces
|
|
|
|
|
|
|
|
|
|
.2 cmp #'"' found a quote ?
|
|
|
|
|
bne .3
|
2018-10-16 15:48:03 +00:00
|
|
|
|
|
|
|
|
|
lda ARG.bInQuote
|
|
|
|
|
eor #$ff
|
|
|
|
|
sta ARG.bInQuote
|
2018-10-18 15:32:57 +00:00
|
|
|
|
bra .7 skip quote and check next char
|
2018-10-16 15:48:03 +00:00
|
|
|
|
|
2018-10-18 15:32:57 +00:00
|
|
|
|
.3 cmp #C.SPACE
|
|
|
|
|
bne .6 regular char ...store...
|
2018-10-16 15:48:03 +00:00
|
|
|
|
|
|
|
|
|
bit ARG.bInQuote
|
2018-10-18 15:32:57 +00:00
|
|
|
|
bmi .6 between quotes... store space...
|
|
|
|
|
|
2018-10-16 15:48:03 +00:00
|
|
|
|
inx Found one arg !!!
|
|
|
|
|
lda #0 set this token End
|
2018-10-18 15:32:57 +00:00
|
|
|
|
jsr ARG.PutCharPtr2
|
|
|
|
|
bra .1
|
2018-10-16 15:48:03 +00:00
|
|
|
|
|
2018-10-18 15:32:57 +00:00
|
|
|
|
.6 jsr ARG.PutCharPtr2
|
2018-10-16 15:48:03 +00:00
|
|
|
|
|
2018-10-18 15:32:57 +00:00
|
|
|
|
.7 jsr ARG.GetCharPtr1
|
|
|
|
|
bne .2
|
2018-10-16 15:48:03 +00:00
|
|
|
|
|
2018-10-18 15:32:57 +00:00
|
|
|
|
inx
|
2018-10-16 15:48:03 +00:00
|
|
|
|
|
2018-10-18 15:32:57 +00:00
|
|
|
|
.8 jsr ARG.PutCharPtr2 set Argv[x] Ending 0
|
|
|
|
|
|
|
|
|
|
sta (ZPPtr2) set Array Ending 0
|
2018-10-16 15:48:03 +00:00
|
|
|
|
|
|
|
|
|
txa X=Arg Count
|
|
|
|
|
|
|
|
|
|
clc
|
|
|
|
|
.9 rts
|
|
|
|
|
*/--------------------------------------
|
|
|
|
|
* # ArgV
|
2018-06-18 06:22:50 +00:00
|
|
|
|
* ## ASM
|
2018-06-14 15:31:36 +00:00
|
|
|
|
* **In:**
|
|
|
|
|
* 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#
|
2016-08-17 06:25:58 +00:00
|
|
|
|
|
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
|
|
|
|
|
2018-10-18 15:32:57 +00:00
|
|
|
|
>STYA ZPPtr1
|
|
|
|
|
|
2018-10-16 15:48:03 +00:00
|
|
|
|
.1 lda (ZPPtr1) 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
|
2017-08-24 06:47:31 +00:00
|
|
|
|
|
2018-10-18 15:32:57 +00:00
|
|
|
|
.3 jsr ARG.GetCharPtr1 skip str
|
2017-09-25 15:50:33 +00:00
|
|
|
|
bne .3
|
|
|
|
|
|
2018-10-18 15:32:57 +00:00
|
|
|
|
jsr ARG.NextCharPtr1 skip \0
|
|
|
|
|
bra .1
|
2017-09-25 15:50:33 +00:00
|
|
|
|
|
2018-10-18 15:32:57 +00:00
|
|
|
|
.7 >LDYA ZPPtr1
|
2018-10-16 15:48:03 +00:00
|
|
|
|
|
2018-06-14 15:31:36 +00:00
|
|
|
|
.8 clc
|
2017-09-25 15:50:33 +00:00
|
|
|
|
rts
|
|
|
|
|
|
|
|
|
|
.9 sec
|
|
|
|
|
rts
|
2016-08-17 06:25:58 +00:00
|
|
|
|
*--------------------------------------
|
2018-10-18 15:32:57 +00:00
|
|
|
|
ARG.GetCharPtr1 lda (ZPPtr1)
|
|
|
|
|
beq ARG.GetCharPtr1.8
|
|
|
|
|
ARG.NextCharPtr1
|
2018-10-16 15:48:03 +00:00
|
|
|
|
inc ZPPtr1
|
2018-10-18 15:32:57 +00:00
|
|
|
|
bne ARG.GetCharPtr1.8
|
2018-10-16 15:48:03 +00:00
|
|
|
|
inc ZPPtr1+1 never Z
|
2018-10-18 15:32:57 +00:00
|
|
|
|
ARG.GetCharPtr1.8
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
ARG.PutCharPtr2 sta (ZPPtr2)
|
|
|
|
|
inc ZPPtr2
|
|
|
|
|
bne .8
|
|
|
|
|
inc ZPPtr2+1
|
2018-10-16 15:48:03 +00:00
|
|
|
|
.8 rts
|
|
|
|
|
*--------------------------------------
|
2016-08-17 06:25:58 +00:00
|
|
|
|
MAN
|
2017-03-29 15:48:15 +00:00
|
|
|
|
SAVE /A2OSX.SRC/SYS/KERNEL.S.ARG
|
|
|
|
|
LOAD /A2OSX.SRC/SYS/KERNEL.S
|
2016-08-17 06:25:58 +00:00
|
|
|
|
ASM
|