A2osX/SYS/KERNEL.S.ARG.txt

79 lines
1.3 KiB
Plaintext
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

PR#3
PREFIX /A2OSX.BUILD
LOMEM $A00
INC 1
AUTO 6
*/--------------------------------------
* # GetArgC
* Returns argument count in the process command line.
* ## In:
* none.
* ## Out:
* A = Command line Arg Count (Including /path/cmd)
*\--------------------------------------
K.GetArgC jsr ARG.InitArgPtr1
ldx #0
.1 lda (ZPPtr1)
beq .8
jsr ARG.NextArgPtr1
inx
bne .1
.8 txa
rts
*/--------------------------------------
* # GetArgA
* ## In:
* A = argument index.
* ## Out:
* CC : success
* Y,A = PStr To Arg[A]
* CS : Out Of Bound
*\--------------------------------------
K.GetArgA sta .2+1
jsr ARG.InitArgPtr1
lda .2+1
beq .8
ldx #0
.1 lda (ZPPtr1)
beq .9
.2 cpx #$ff Self Modified
beq .8
jsr ARG.NextArgPtr1
inx
bra .1
.8 >LDYA ZPPtr1
clc
rts
.9 sec
rts
*--------------------------------------
ARG.InitArgPtr1 ldy #S.PS.hCMDLINE
lda (pPs),y
jsr K.GetMemPtrA
>STYA ZPPtr1
rts
*--------------------------------------
ARG.NextArgPtr1 lda ZPPtr1
sec
adc (ZPPtr1)
sta ZPPtr1
bcc .8
inc ZPPtr1+1
.8 rts
*--------------------------------------
MAN
SAVE /A2OSX.SRC/SYS/KERNEL.S.ARG
LOAD /A2OSX.SRC/SYS/KERNEL.S
ASM