mirror of
https://github.com/A2osX/A2osX.git
synced 2024-11-26 13:49:18 +00:00
118 lines
2.2 KiB
Plaintext
118 lines
2.2 KiB
Plaintext
NEW
|
||
PREFIX /A2OSX.BUILD
|
||
AUTO 4,1
|
||
*/--------------------------------------
|
||
* # Args2ArgV
|
||
* int args2argv(char* args, char* argv[])
|
||
* ## ASM
|
||
* `>PUSHW argv`
|
||
* `>LDYA args`
|
||
* `>SYSCALL Args2ArgV
|
||
* ## RETURN VALUE
|
||
*\--------------------------------------
|
||
ARG.bInQuote .BS 1
|
||
*--------------------------------------
|
||
K.Args2ArgV jsr MEM.SPtr1PPtr2
|
||
|
||
ldx #0 Arg Count
|
||
|
||
stz ARG.bInQuote
|
||
|
||
.1 jsr ARG.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 ARG.PutCharPtr2
|
||
bra .1
|
||
|
||
.6 jsr ARG.PutCharPtr2
|
||
|
||
.7 jsr ARG.GetCharPtr1
|
||
bne .2
|
||
|
||
inx
|
||
|
||
.8 jsr ARG.PutCharPtr2 set Argv[x] Ending 0
|
||
|
||
sta (ZPPtr2) set Array Ending 0
|
||
|
||
txa X=Arg Count
|
||
|
||
clc
|
||
.9 rts
|
||
*/--------------------------------------
|
||
* # 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 ARG.GetCharPtr1 skip str
|
||
bne .3
|
||
|
||
jsr ARG.NextCharPtr1 skip \0
|
||
bra .1
|
||
|
||
.7 >LDYA ZPPtr1
|
||
|
||
.8 clc
|
||
rts
|
||
|
||
.9 sec
|
||
rts
|
||
*--------------------------------------
|
||
ARG.GetCharPtr1 lda (ZPPtr1)
|
||
beq ARG.GetCharPtr1.8
|
||
ARG.NextCharPtr1
|
||
inc ZPPtr1
|
||
bne ARG.GetCharPtr1.8
|
||
inc ZPPtr1+1 never Z
|
||
ARG.GetCharPtr1.8
|
||
rts
|
||
*--------------------------------------
|
||
ARG.PutCharPtr2 sta (ZPPtr2)
|
||
inc ZPPtr2
|
||
bne .8
|
||
inc ZPPtr2+1
|
||
.8 rts
|
||
*--------------------------------------
|
||
MAN
|
||
SAVE /A2OSX.SRC/SYS/KERNEL.S.ARG
|
||
LOAD /A2OSX.SRC/SYS/KERNEL.S
|
||
ASM
|