mirror of
https://github.com/A2osX/A2osX.git
synced 2024-09-10 07:54:37 +00:00
122 lines
2.1 KiB
Plaintext
122 lines
2.1 KiB
Plaintext
NEW
|
||
PREFIX /A2OSX.BUILD
|
||
AUTO 4,1
|
||
*/--------------------------------------
|
||
* # Args2ArgV
|
||
* ## ASM
|
||
* `>PUSHW argv`
|
||
* `>LDYA args`
|
||
* `>SYSCALL Args2ArgV
|
||
* ## RETURN VALUE
|
||
*\--------------------------------------
|
||
ARG.bInQuote .BS 1
|
||
*--------------------------------------
|
||
K.Args2ArgV jsr MEM.SPtr1PPtr2
|
||
|
||
stz ARG.bInQuote
|
||
|
||
ldy #$ff
|
||
ldx #0 Arg Count
|
||
|
||
.4 iny
|
||
lda (ZPPtr1),y
|
||
beq .7
|
||
|
||
cmp #'"' found a quote ?
|
||
bne .5
|
||
lda ARG.bInQuote
|
||
eor #$ff
|
||
sta ARG.bInQuote
|
||
bra .4
|
||
|
||
.5 cmp #' '
|
||
bne .6
|
||
|
||
bit ARG.bInQuote
|
||
bmi .6
|
||
|
||
inx Found one arg !!!
|
||
lda #0 set this token End
|
||
|
||
.6 sta (ZPPtr2)
|
||
|
||
inc ZPPtr2
|
||
bne .4
|
||
inc ZPPtr2+1
|
||
bra .4
|
||
|
||
.7 sta (ZPPtr2) set Arg Ending 0
|
||
|
||
inc ZPPtr2
|
||
bne .8
|
||
inc ZPPtr2+1
|
||
|
||
.8 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 pha save requested arg#
|
||
|
||
ldy #S.PS.hARGV
|
||
lda (pPs),y
|
||
jsr K.GetMemPtr
|
||
|
||
plx we want 0 ?
|
||
|
||
beq .8 yes, returns MemPtr
|
||
|
||
>STYA ZPPtr1 no, save it
|
||
|
||
.1 lda (ZPPtr1) end of ARGV[] ?
|
||
beq .9 yes, not found....
|
||
|
||
.3 inc ZPPtr1 skip next one....
|
||
bne .4
|
||
inc ZPPtr1+1
|
||
|
||
.4 lda (ZPPtr1)
|
||
bne .3
|
||
|
||
inc ZPPtr1 ....and point to next, or ending 0
|
||
bne .5
|
||
inc ZPPtr1+1
|
||
|
||
.5 dex
|
||
bne .1 stop here....
|
||
|
||
lda (ZPPtr1) at end of ARGV[] ?
|
||
beq .9
|
||
|
||
>LDYA ZPPtr1
|
||
|
||
.8 clc
|
||
rts
|
||
|
||
.9 sec
|
||
rts
|
||
*--------------------------------------
|
||
ARG.NextChrPtr1 lda (ZPPtr1)
|
||
beq .8
|
||
|
||
inc ZPPtr1
|
||
bne .8
|
||
inc ZPPtr1+1 never Z
|
||
.8 rts
|
||
*--------------------------------------
|
||
MAN
|
||
SAVE /A2OSX.SRC/SYS/KERNEL.S.ARG
|
||
LOAD /A2OSX.SRC/SYS/KERNEL.S
|
||
ASM
|