A2osX/SYS/KERNEL.S.ARG.txt

120 lines
2.2 KiB
Plaintext
Raw Normal View History

2017-12-22 21:24:30 +00:00
NEW
2019-05-25 19:24:07 +00:00
AUTO 3,1
*/--------------------------------------
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`
2019-02-26 16:50:42 +00:00
* `>SYSCALL Args2ArgV`
2018-10-25 15:31:41 +00:00
* ## RETURN VALUE
* A = Arg count
2018-10-16 15:48:03 +00:00
*\--------------------------------------
2019-01-26 14:01:05 +00:00
ARG.bInQuote .EQ ZPPtr3
2018-10-16 15:48:03 +00:00
*--------------------------------------
2018-10-26 14:46:11 +00:00
K.Args2ArgV jsr K.ExpandStr
2018-10-25 15:31:41 +00:00
bcs .9
>STYA ZPPtr1
stx .80+1
2018-10-16 15:48:03 +00:00
2018-10-26 14:46:11 +00:00
>PULLW ZPPtr2 Get target buffer
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
2019-07-28 20:39:30 +00:00
.1 jsr SHARED.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
2019-07-28 20:39:30 +00:00
jsr SHARED.PutCharPtr2
2018-10-18 15:32:57 +00:00
bra .1
2018-10-16 15:48:03 +00:00
2019-07-28 20:39:30 +00:00
.6 jsr SHARED.PutCharPtr2
2018-10-16 15:48:03 +00:00
2019-07-28 20:39:30 +00:00
.7 jsr SHARED.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
2019-07-28 20:39:30 +00:00
.8 jsr SHARED.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
2018-10-26 14:46:11 +00:00
rts
.9 >RET 2 Discard target buffer
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
*\--------------------------------------
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
2019-09-10 10:22:57 +00:00
>STYA ZPPtr2 Use Ptr2, called from ExpandStr
2018-10-18 15:32:57 +00:00
2019-09-10 10:22:57 +00:00
.1 lda (ZPPtr2) end of ARGV[] ?
2018-10-18 15:32:57 +00:00
beq .9 yes, not found....
2018-10-18 15:32:57 +00:00
dex
bmi .7
2019-09-10 10:22:57 +00:00
.3 jsr SHARED.GetCharPtr2 skip str
bne .3
2019-09-10 10:22:57 +00:00
jsr SHARED.NextCharPtr2 skip \0
2018-10-18 15:32:57 +00:00
bra .1
2019-09-10 10:22:57 +00:00
.7 >LDYA ZPPtr2
2018-10-16 15:48:03 +00:00
2018-06-14 15:31:36 +00:00
.8 clc
rts
2019-02-19 16:34:43 +00:00
.9 lda #E.OOB
sec
rts
2016-08-17 06:25:58 +00:00
*--------------------------------------
MAN
2018-11-17 17:17:13 +00:00
SAVE USR/SRC/SYS/KERNEL.S.ARG
LOAD USR/SRC/SYS/KERNEL.S
2016-08-17 06:25:58 +00:00
ASM