A2osX/SYS/KERNEL.S.ARG.txt

122 lines
2.1 KiB
Plaintext
Raw Normal View History

2017-12-22 21:24:30 +00:00
NEW
PREFIX /A2OSX.BUILD
2017-12-22 21:24:30 +00:00
AUTO 4,1
*/--------------------------------------
2018-10-16 15:48:03 +00:00
* # 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
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
*\--------------------------------------
2018-10-16 15:48:03 +00:00
K.ArgV pha 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
plx we want 0 ?
2018-06-14 15:31:36 +00:00
beq .8 yes, returns MemPtr
>STYA ZPPtr1 no, save it
2018-10-16 15:48:03 +00:00
.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
2017-01-12 17:43:45 +00:00
inc ZPPtr1+1
.5 dex
bne .1 stop here....
2018-10-16 15:48:03 +00:00
lda (ZPPtr1) at end of ARGV[] ?
beq .9
2018-06-14 15:31:36 +00:00
>LDYA ZPPtr1
2018-10-16 15:48:03 +00:00
2018-06-14 15:31:36 +00:00
.8 clc
rts
.9 sec
rts
2016-08-17 06:25:58 +00:00
*--------------------------------------
2018-10-16 15:48:03 +00:00
ARG.NextChrPtr1 lda (ZPPtr1)
beq .8
inc ZPPtr1
bne .8
inc ZPPtr1+1 never Z
.8 rts
*--------------------------------------
2016-08-17 06:25:58 +00:00
MAN
SAVE /A2OSX.SRC/SYS/KERNEL.S.ARG
LOAD /A2OSX.SRC/SYS/KERNEL.S
2016-08-17 06:25:58 +00:00
ASM