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-25 15:31:41 +00:00
|
|
|
|
* Expand String and convert to ArgV List
|
|
|
|
|
* ## C
|
|
|
|
|
* short int args2argv(char* args, char* argv[])
|
2018-10-16 15:48:03 +00:00
|
|
|
|
* ## ASM
|
|
|
|
|
* `>PUSHW argv`
|
|
|
|
|
* `>LDYA args`
|
|
|
|
|
* `>SYSCALL Args2ArgV
|
2018-10-25 15:31:41 +00:00
|
|
|
|
* ## RETURN VALUE
|
|
|
|
|
* A = Arg count
|
2018-10-16 15:48:03 +00:00
|
|
|
|
*\--------------------------------------
|
|
|
|
|
ARG.bInQuote .BS 1
|
|
|
|
|
*--------------------------------------
|
2018-10-25 15:31:41 +00:00
|
|
|
|
K.Args2ArgV pha
|
|
|
|
|
>PULLW ZPPtr2 Get target buffer
|
|
|
|
|
pla
|
|
|
|
|
|
|
|
|
|
K.Args2ArgV.I jsr K.ExpandStr
|
|
|
|
|
bcs .9
|
|
|
|
|
|
|
|
|
|
>STYA ZPPtr1
|
|
|
|
|
stx .80+1
|
2018-10-16 15:48:03 +00:00
|
|
|
|
|
2018-10-25 15:31:41 +00:00
|
|
|
|
ldx #0 Arg Count
|
2018-10-16 15:48:03 +00:00
|
|
|
|
|
2018-10-18 15:32:57 +00:00
|
|
|
|
stz ARG.bInQuote
|
|
|
|
|
|
2018-10-25 15:31:41 +00:00
|
|
|
|
.1 jsr MEM.GetCharPtr1
|
2018-10-18 15:32:57 +00:00
|
|
|
|
beq .8
|
2018-10-23 15:36:57 +00:00
|
|
|
|
|
2018-10-18 15:32:57 +00:00
|
|
|
|
cmp #C.SPACE
|
2018-10-25 15:31:41 +00:00
|
|
|
|
beq .1 skip leading spaces
|
2018-10-18 15:32:57 +00:00
|
|
|
|
|
2018-10-25 15:31:41 +00:00
|
|
|
|
.2 cmp #'"' found a quote ?
|
2018-10-18 15:32:57 +00:00
|
|
|
|
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-25 15:31:41 +00:00
|
|
|
|
jsr MEM.PutCharPtr2
|
2018-10-18 15:32:57 +00:00
|
|
|
|
bra .1
|
2018-10-16 15:48:03 +00:00
|
|
|
|
|
2018-10-25 15:31:41 +00:00
|
|
|
|
.6 jsr MEM.PutCharPtr2
|
2018-10-16 15:48:03 +00:00
|
|
|
|
|
2018-10-25 15:31:41 +00:00
|
|
|
|
.7 jsr MEM.GetCharPtr1
|
2018-10-18 15:32:57 +00:00
|
|
|
|
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-25 15:31:41 +00:00
|
|
|
|
.8 jsr MEM.PutCharPtr2 set Argv[x] Ending 0
|
2018-10-18 15:32:57 +00:00
|
|
|
|
|
|
|
|
|
sta (ZPPtr2) set Array Ending 0
|
2018-10-25 15:31:41 +00:00
|
|
|
|
phx
|
2018-10-16 15:48:03 +00:00
|
|
|
|
|
2018-10-25 15:31:41 +00:00
|
|
|
|
.80 lda #$FF SELF MODIFIED
|
|
|
|
|
jsr K.FreeMem Discard expanded string
|
|
|
|
|
|
|
|
|
|
pla get back Arg Count
|
2018-10-16 15:48:03 +00:00
|
|
|
|
|
2018-10-25 15:31:41 +00:00
|
|
|
|
* 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
|
|
|
|
* **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-25 15:31:41 +00:00
|
|
|
|
.3 jsr MEM.GetCharPtr1 skip str
|
2017-09-25 15:50:33 +00:00
|
|
|
|
bne .3
|
|
|
|
|
|
2018-10-25 15:31:41 +00:00
|
|
|
|
jsr MEM.NextCharPtr1 skip \0
|
2018-10-18 15:32:57 +00:00
|
|
|
|
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
|
|
|
|
*--------------------------------------
|
|
|
|
|
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
|