NEW PREFIX /A2OSX.BUILD AUTO 4,1 */-------------------------------------- * # Args2ArgV * Expand String and convert to ArgV List * ## C * short int args2argv(char* args, char* argv[]) * ## ASM * `>PUSHW argv` * `>LDYA args` * `>SYSCALL Args2ArgV * ## RETURN VALUE * A = Arg count *\-------------------------------------- ARG.bInQuote .BS 1 *-------------------------------------- K.Args2ArgV jsr K.ExpandStr bcs .9 >STYA ZPPtr1 stx .80+1 >PULLW ZPPtr2 Get target buffer ldx #0 Arg Count stz ARG.bInQuote .1 jsr MEM.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 MEM.PutCharPtr2 bra .1 .6 jsr MEM.PutCharPtr2 .7 jsr MEM.GetCharPtr1 bne .2 inx .8 jsr MEM.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 */-------------------------------------- * # ArgV * ## ASM * **In:** * A = argument index. * ## RETURN VALUE * CC : success * Y,A = PTR To Arg[A] * CS : Out Of Bound *\-------------------------------------- K.ArgV tax save requested arg# ldy #S.PS.hARGV lda (pPs),y jsr K.GetMemPtr >STYA ZPPtr1 .1 lda (ZPPtr1) end of ARGV[] ? beq .9 yes, not found.... dex bmi .7 .3 jsr MEM.GetCharPtr1 skip str bne .3 jsr MEM.NextCharPtr1 skip \0 bra .1 .7 >LDYA ZPPtr1 .8 clc rts .9 sec rts *-------------------------------------- MAN SAVE /A2OSX.SRC/SYS/KERNEL.S.ARG LOAD /A2OSX.SRC/SYS/KERNEL.S ASM