Kernel 0.93++

This commit is contained in:
Rémy GIBERT 2020-01-24 15:21:08 +01:00
parent c0a6c74550
commit f3853fec17
18 changed files with 292 additions and 219 deletions

View File

@ -335,7 +335,7 @@ A = hMem To S.MD5
Add Data to MD5 computation Add Data to MD5 computation
# C # C
`void md5update (hMD5 md5, char* data, int len);` `void md5update (short int md5, char* data, int len);`
# ASM # ASM
`>PUSHB md5` `>PUSHB md5`
@ -348,7 +348,7 @@ Add Data to MD5 computation
## MD5Finalize ## MD5Finalize
# C # C
`void md5finalize (hMD5 md5, char* digest);` `void md5finalize (short int md5, char* digest);`
# ASM # ASM
`>PUSHB md5` `>PUSHB md5`
@ -433,8 +433,8 @@ Load a file in AUX memory (Stock Objects)
`int execl(const char* cmdline, short int flags);` `int execl(const char* cmdline, short int flags);`
## ASM ## ASM
`>PUSHW cmdline`
`>PUSHB flags` `>PUSHB flags`
`>LDYA cmdline`
`>SYSCALL execl` `>SYSCALL execl`
## RETURN VALUE ## RETURN VALUE
@ -529,28 +529,6 @@ CS : not found
## RETURN VALUE ## RETURN VALUE
Buffer filled with memory stats Buffer filled with memory stats
# StrVDup
**In:**
Y,A = Src StrV
## RETURN VALUE
X = hMem of new StrV
A = Str Count
# Str2StrV
Expand String and convert to ArgV List
## C
short int str2strv(char* args, char* argv[])
## ASM
`>PUSHW argv`
`>LDYA args`
`>SYSCALL Str2StrV`
## RETURN VALUE
A = Arg count
# GetPWUID # GetPWUID
## C ## C
@ -1314,6 +1292,44 @@ CS : no match
CC, Y,A=0 CC, Y,A=0
CS, Y,A > 0 or < 0 CS, Y,A > 0 or < 0
# NewStrV
**In:**
A = Initial Size (Page)
## RETURN VALUE
X = hStrV
Y,A = Ptr
# StrVGet
**In:**
A = hStrV
X = index
## RETURN VALUE
Y,A = Ptr
# StrVDup
**In:**
Y,A = Src StrV
## RETURN VALUE
X = hMem of new StrV
A = Str Count
# Str2StrV
Expand String and convert to ArgV List
## C
short int str2strv(char* args, char* argv[])
## ASM
`>PUSHW argv`
`>LDYA args`
`>SYSCALL Str2StrV`
## RETURN VALUE
A = Arg count
# Time # Time
Get System Time in Buffer Get System Time in Buffer

Binary file not shown.

View File

@ -135,6 +135,12 @@ CSH.FN
.DA #CSH.T.INT returned value .DA #CSH.T.INT returned value
.DA #CSH.Q.CONST+CSH.Q.POINTER+CSH.T.CHAR .DA #CSH.Q.CONST+CSH.Q.POINTER+CSH.T.CHAR
.DA #0 .DA #0
* int execl(const char* cmdline, short int flags);
>PSTR "execl"
.DA #CSH.T.INT returned value
.DA #CSH.Q.CONST+CSH.Q.POINTER+CSH.T.CHAR
.DA #CSH.T.UCHAR
.DA #0
* int printf ( const char * format, ... ); * int printf ( const char * format, ... );
>PSTR "printf" >PSTR "printf"
.DA #CSH.T.INT returned value .DA #CSH.T.INT returned value
@ -163,6 +169,12 @@ CSH.FN
.DA #CSH.T.INT returned value .DA #CSH.T.INT returned value
.DA #CSH.Q.CONST+CSH.Q.POINTER+CSH.T.CHAR .DA #CSH.Q.CONST+CSH.Q.POINTER+CSH.T.CHAR
.DA #0 .DA #0
* void md5 (const char* str, char* digest);
>PSTR "md5"
.DA #CSH.T.VOID
.DA #CSH.Q.CONST+CSH.Q.POINTER+CSH.T.CHAR
.DA #CSH.Q.POINTER+CSH.T.CHAR
.DA #0
* void * malloc ( int size ); * void * malloc ( int size );
>PSTR "malloc" >PSTR "malloc"
.DA #CSH.Q.POINTER+CSH.T.VOID returned value .DA #CSH.Q.POINTER+CSH.T.VOID returned value

View File

@ -73,11 +73,13 @@ J.CSH.EXEC .DA EXEC.log
.DA EXEC.atan .DA EXEC.atan
.DA EXEC.getchar .DA EXEC.getchar
.DA EXEC.puts .DA EXEC.puts
.DA EXEC.execl
.DA EXEC.printf .DA EXEC.printf
.DA EXEC.putenv .DA EXEC.putenv
.DA EXEC.setenv .DA EXEC.setenv
.DA EXEC.getenv .DA EXEC.getenv
.DA EXEC.unsetenv .DA EXEC.unsetenv
.DA EXEC.MD5
.DA EXEC.malloc .DA EXEC.malloc
*-------------------------------------- *--------------------------------------
MAN MAN

View File

@ -346,6 +346,7 @@ CSH.fCall ldx ZPPtr1
phx phx
ldx ZPPtr2+1 local : variadic size ldx ZPPtr2+1 local : variadic size
phx phx
sta ZPPtr2 save Type sta ZPPtr2 save Type
stz ZPPtr2+1 Reset VARIADIC byte count stz ZPPtr2+1 Reset VARIADIC byte count
>LDYA L.CSH.FN >LDYA L.CSH.FN
@ -373,11 +374,9 @@ CSH.fCall ldx ZPPtr1
.11 cmp (ZPPtr1) Get Return value Type .11 cmp (ZPPtr1) Get Return value Type
bne .91 bne .91
.1 inc ZPPtr1 advance to arg list type .1 jsr CSH.ZPPtr1Next advance to arg list type
bne .2
inc ZPPtr1+1
.2 lda (ZPPtr1) get type of first arg lda (ZPPtr1) get type of first arg
beq .7 end of list, go check ending ')' beq .7 end of list, go check ending ')'
*-------------------------------------- *--------------------------------------
.3 eor #CSH.T.VARIADIC if VARIADIC, don't advance to next arg and assume type = 0 .3 eor #CSH.T.VARIADIC if VARIADIC, don't advance to next arg and assume type = 0
@ -395,11 +394,12 @@ CSH.fCall ldx ZPPtr1
adc ZPPtr2+1 adc ZPPtr2+1
sta ZPPtr2+1 Add to byte count sta ZPPtr2+1 Add to byte count
bra .51 bra .51
.5 inc ZPPtr1
bne .51 .5 jsr CSH.ZPPtr1Next
inc ZPPtr1+1
.51 jsr CSH.GetCharNB .51 jsr CSH.GetCharNB
bcs .90 bcs .90
cmp #',' cmp #','
bne .6 bne .6
@ -408,6 +408,7 @@ CSH.fCall ldx ZPPtr1
bne .3 Another ARG.... bne .3 Another ARG....
.52 bra .90 extra args....error .52 bra .90 extra args....error
.6 cmp #')' .6 cmp #')'
bne .90 bne .90
lda (ZPPtr1) lda (ZPPtr1)
@ -657,17 +658,26 @@ CSH.Lookup phy Y = len
jsr CSH.ZPPtr1AddAp1 jsr CSH.ZPPtr1AddAp1
>LDA.G CSH.LookupOpt >LDA.G CSH.LookupOpt
bpl .1 bpl .1
ldy #$ff
ldy #$0 Start at Y=1 for VOID func()
.6 iny .6 iny
lda (ZPPtr1),y lda (ZPPtr1),y
bne .6 bne .6
tya tya
jsr CSH.ZPPtr1AddAp1 jsr CSH.ZPPtr1AddAp1
bra .1 bra .1
.9 pla .9 pla
sec sec
rts rts
*-------------------------------------- *--------------------------------------
CSH.ZPPtr1Next inc ZPPtr1
bne .8
inc ZPPtr1+1
.8 rts
*--------------------------------------
CSH.ZPPtr1AddAp1 CSH.ZPPtr1AddAp1
sec sec
adc ZPPtr1 adc ZPPtr1
@ -751,8 +761,6 @@ CSH.AddVarValueFromStack
sec sec
.HS 90 BCC .HS 90 BCC
*-------------------------------------- *--------------------------------------
* Y,A = VarID, X=Type
*--------------------------------------
CSH.SetVarValueFromStack CSH.SetVarValueFromStack
clc clc
php php
@ -1227,6 +1235,10 @@ EXEC.printf >SYSCALL printf2
>PUSHYA >PUSHYA
rts rts
*-------------------------------------- *--------------------------------------
EXEC.execl >SYSCALL execl
>PUSHYA
rts
*--------------------------------------
EXEC.putenv >SYSCALL putenv EXEC.putenv >SYSCALL putenv
>PUSHYA >PUSHYA
rts rts
@ -1243,12 +1255,14 @@ EXEC.unsetenv >SYSCALL unsetenv
>PUSHYA >PUSHYA
rts rts
*-------------------------------------- *--------------------------------------
EXEC.MD5 >SYSCALL MD5
rts
*--------------------------------------
EXEC.malloc >PULLYA EXEC.malloc >PULLYA
>SYSCALL getmem >SYSCALL getmem
>PUSHYA >PUSHYA
rts rts
*-------------------------------------- *--------------------------------------
*--------------------------------------
MAN MAN
SAVE USR/SRC/BIN/CSH.S.CORE SAVE USR/SRC/BIN/CSH.S.CORE
LOAD USR/SRC/BIN/CSH.S LOAD USR/SRC/BIN/CSH.S

View File

@ -266,8 +266,8 @@ CMD.SET.EXEC jsr CORE.ArgV.NextChar skip "`"
jsr IO.Pipe.Out jsr IO.Pipe.Out
bcs .9 bcs .9
>PUSHW ZPArgVBufPtr
>PUSHBI S.PS.F.CLOSEONX >PUSHBI S.PS.F.CLOSEONX
>LDYA ZPArgVBufPtr
>SYSCALL execl >SYSCALL execl
bcs .9 bcs .9
@ -878,8 +878,8 @@ CMD.FOR.EXEC jsr CORE.ArgV.NextChar skip "`"
jsr IO.Pipe.Out jsr IO.Pipe.Out
bcs FOR.FILE.9 bcs FOR.FILE.9
>PUSHW ZPArgVBufPtr
>PUSHBI S.PS.F.CLOSEONX >PUSHBI S.PS.F.CLOSEONX
>LDYA ZPArgVBufPtr
>SYSCALL execl >SYSCALL execl
bcs FOR.FILE.9 bcs FOR.FILE.9

View File

@ -170,8 +170,8 @@ CS.RUN.RmDir lda bDelete
adc /S.PW.DIR adc /S.PW.DIR
>LDYA ZPStrPtr >LDYA ZPStrPtr
>SYSCALL strcat >SYSCALL strcat
>PUSHW ZPStrPtr
>PUSHBI S.PS.F.HOLD >PUSHBI S.PS.F.HOLD
>LDYA ZPStrPtr
>SYSCALL execl >SYSCALL execl
rts rts
*-------------------------------------- *--------------------------------------

View File

@ -4,7 +4,7 @@ AUTO 4,1 Enable MASM3 auto line num
.LIST OFF .LIST OFF
.OP 65C02 Target CPU, must match CPU level in header .OP 65C02 Target CPU, must match CPU level in header
.OR $2000 usualy $2000, but any value > $100 allowed .OR $2000 usualy $2000, but any value > $100 allowed
.TF SBIN/INITD .TF sbin/initd
*-------------------------------------- *--------------------------------------
.INB INC/MACROS.I .INB INC/MACROS.I
.INB INC/A2OSX.I .INB INC/A2OSX.I
@ -64,14 +64,14 @@ CS.RUN ldy #S.PS.PID
bne .1 bne .1
>LDYA L.MSG.CTRLR >LDYA L.MSG.CTRLR
>SYSCALL puts >SYSCALL puts
>PUSHW L.BINSHELL
>PUSHBI S.PS.F.HOLD >PUSHBI S.PS.F.HOLD
>LDYA L.BINSHELL
>SYSCALL ExecL >SYSCALL ExecL
>SLEEP >SLEEP
.1 >LDYA L.MSG.ETCINIT .1 >LDYA L.MSG.ETCINIT
>SYSCALL puts >SYSCALL puts
>PUSHW L.ETCINIT
>PUSHBI S.PS.F.HOLD >PUSHBI S.PS.F.HOLD
>LDYA L.ETCINIT
>SYSCALL ExecL >SYSCALL ExecL
>SLEEP >SLEEP
>LDYA L.MSG.RUNNING >LDYA L.MSG.RUNNING
@ -105,8 +105,8 @@ CS.END
*-------------------------------------- *--------------------------------------
MSG.CTRLR .AZ "INITD:Ctrl-R Pressed, entering ROOT mode..." MSG.CTRLR .AZ "INITD:Ctrl-R Pressed, entering ROOT mode..."
MSG.ETCINIT .AS "INITD:Executing ETC/INIT Script:" MSG.ETCINIT .AS "INITD:Executing ETC/INIT Script:"
ETCINIT .AZ "${ROOT}ETC/INIT" ETCINIT .AZ "${ROOT}etc/init"
BINSHELL .AZ "${ROOT}BIN/SHELL" BINSHELL .AZ "${ROOT}bin/sh"
MSG.RUNNING .AZ "INITD:Running..." MSG.RUNNING .AZ "INITD:Running..."
MSH.SHUTDOWN .AZ "INITD:Shutting down..." MSH.SHUTDOWN .AZ "INITD:Shutting down..."
*-------------------------------------- *--------------------------------------

View File

@ -294,8 +294,8 @@ CS.RUN.EXEC ldx #1
jsr CS.RUN.DumpFile jsr CS.RUN.DumpFile
jsr CS.CLEANUP jsr CS.CLEANUP
>PUSHW L.SHELL
>PUSHBI S.PS.F.HOLD >PUSHBI S.PS.F.HOLD
>LDYA L.SHELL
>SYSCALL ExecL >SYSCALL ExecL
bcs .9 bcs .9

View File

@ -194,8 +194,8 @@ CS.INIT.CONF >LDYAI 64
>LDYA L.MSG.EXEC >LDYA L.MSG.EXEC
>SYSCALL printf >SYSCALL printf
>PUSHW pBuf
>PUSHBI 0 S.PS.F.HOLD+S.PS.F.NOHUP >PUSHBI 0 S.PS.F.HOLD+S.PS.F.NOHUP
>LDYA pBuf
>SYSCALL execL >SYSCALL execL
bra .1 bra .1

View File

@ -197,8 +197,8 @@ CS.RUN.CLIENT >SLEEP give some time for TCPIP SYN/ACK
>LEA.G CmdBuf >LEA.G CmdBuf
>SYSCALL sprintf >SYSCALL sprintf
>PUSHEA.G CmdBuf
>PUSHBI 0 >PUSHBI 0
>LEA.G CmdBuf
>SYSCALL execl >SYSCALL execl
bcc .8 bcc .8

View File

@ -166,8 +166,7 @@ Kernel.Init3C >PUSHBI 0
>PUSHBI 0 >PUSHBI 0
>LDYAI MSG.CTRLR >LDYAI MSG.CTRLR
>SYSCALL2 printf >SYSCALL2 printf
>PUSHBI 0 PS Flags >PUSHWI CTRLR.SHELL
>LDYAI CTRLR.SHELL
bra .8 bra .8
.7 >PUSHWI ETCINIT.CMDLINE .7 >PUSHWI ETCINIT.CMDLINE
@ -175,10 +174,10 @@ Kernel.Init3C >PUSHBI 0
>LDYAI MSG.EtcInit >LDYAI MSG.EtcInit
>SYSCALL2 printf >SYSCALL2 printf
>PUSHBI 0 PS Flags >PUSHWI ETCINIT.CMDLINE
>LDYAI ETCINIT.CMDLINE
.8 >SYSCALL2 ExecL .8 >PUSHBI 0 PS Flags
>SYSCALL2 ExecL
bcs Kernel.Init3.Err bcs Kernel.Init3.Err
>PUSHBI 0 >PUSHBI 0

View File

@ -369,13 +369,13 @@ K.SYSCALL.BANK .DA #RRAMWRAMBNK1 $00
.DA #$80 .DA #$80
.DA #0 .DA #0
.DA #$80 .DA #$80
.DA #$C0 $C8 : MD5X .DA #0 $C8 : MD5
.DA #$80 .DA #$80
.DA #$C0 .DA #0
.DA #$80 .DA #$80
.DA #$C0 .DA #0
.DA #$80 .DA #$80
.DA #$C0 .DA #0
.DA #$80 .DA #$80
.DA #$C0 $D0 : PWDX .DA #$C0 $D0 : PWDX

View File

@ -12,7 +12,8 @@ NEW
* ## RETURN VALUE * ## RETURN VALUE
* CC * CC
*\-------------------------------------- *\--------------------------------------
K.MD5 >PULLW FORPNT K.MD5 >DEBUG
>PULLW FORPNT
>PULLYA >PULLYA
>STYA TXTPTR >STYA TXTPTR
@ -22,12 +23,14 @@ K.MD5 >PULLW FORPNT
sta SETREADAUX sta SETREADAUX
sta SETWRITEAUX sta SETWRITEAUX
.1 jsr K.MD5Init.I .1 jsr MD5X.Init
bcs .9 bcs .9
pha save MD5 Context hMem pha save MD5 Context hMem
jsr MD5Update.I jsr MD5X.Update
jsr MD5Finalize.I jsr MD5X.Finalize
pla pla
>SYSCALL2 FreeMem Free MD5 Context >SYSCALL2 FreeMem Free MD5 Context
clc clc
@ -48,7 +51,7 @@ K.MD5 >PULLW FORPNT
K.MD5Init sta SETREADAUX K.MD5Init sta SETREADAUX
sta SETWRITEAUX sta SETWRITEAUX
jsr K.MD5Init.I jsr MD5X.Init
sta CLRREADAUX sta CLRREADAUX
sta CLRWRITEAUX sta CLRWRITEAUX
@ -57,7 +60,7 @@ K.MD5Init sta SETREADAUX
* ## MD5Update * ## MD5Update
* Add Data to MD5 computation * Add Data to MD5 computation
* # C * # C
* `void md5update (hMD5 md5, char* data, int len);` * `void md5update (short int md5, char* data, int len);`
* # ASM * # ASM
* `>PUSHB md5` * `>PUSHB md5`
* `>PUSHW data` * `>PUSHW data`
@ -74,7 +77,7 @@ K.MD5Update >PULLW ZPDataLen get LEN
sta SETREADAUX sta SETREADAUX
sta SETWRITEAUX sta SETWRITEAUX
jsr K.MD5Update.I jsr MD5X.Update
sta CLRREADAUX sta CLRREADAUX
sta CLRWRITEAUX sta CLRWRITEAUX
@ -82,7 +85,7 @@ K.MD5Update >PULLW ZPDataLen get LEN
*/-------------------------------------- */--------------------------------------
* ## MD5Finalize * ## MD5Finalize
* # C * # C
* `void md5finalize (hMD5 md5, char* digest);` * `void md5finalize (short int md5, char* digest);`
* # ASM * # ASM
* `>PUSHB md5` * `>PUSHB md5`
* `>PUSHW digest` * `>PUSHW digest`
@ -98,7 +101,7 @@ K.MD5Finalize >PULLW FORPNT
sta SETREADAUX sta SETREADAUX
sta SETWRITEAUX sta SETWRITEAUX
jsr MD5Finalize.I jsr MD5X.Finalize
.8 lda #$ff SELF MODIFIED .8 lda #$ff SELF MODIFIED
>SYSCALL2 FreeMem >SYSCALL2 FreeMem

View File

@ -80,46 +80,46 @@ ZS.END .ED
bne :2 bne :2
.EM .EM
*-------------------------------------- *--------------------------------------
K.MD5Init.I >LDYAI S.MD5 MD5X.Init >LDYAI S.MD5
>SYSCALL2 getmem >SYSCALL2 getmem0
bcs .9 bcs .9
>STYA ZPCtxPtr >STYA ZPCtxPtr
ldy #0
ldy #15
.1 lda MD5.ABCDINIT,y .1 lda MD5.ABCDINIT,y
sta (ZPCtxPtr),y sta (ZPCtxPtr),y
iny dey
cpy #S.MD5.BITCOUNT bpl .1
bne .1
lda #0
.2 sta (ZPCtxPtr),y
iny
cpy #S.MD5 Includes S.MD5.FINALIZED Flag
bne .2
txa txa
clc clc
.9 rts .9 rts
*-------------------------------------- *--------------------------------------
MD5Update.I ldy #S.MD5.FINALIZED MD5X.Update ldy #S.MD5.FINALIZED
lda (ZPCtxPtr),y lda (ZPCtxPtr),y
beq .1 beq .1
sec sec
rts rts
.1 lda ZPDataLen+1 More than 256 Bytes remaining to hash ? .1 lda ZPDataLen+1 More than 256 Bytes remaining to hash ?
bne .3 yes bne .3 yes
lda ZPDataLen lda ZPDataLen
bne .2 Len = O ? bne .2 Len = O ?
clc All data processed clc All data processed
rts rts
.2 cmp #64 More than 64 Bytes remaining to hash ? .2 cmp #64 More than 64 Bytes remaining to hash ?
bcc .50 yes bcc .50 yes
.3 lda #64 .3 lda #64
.50 sta ZPChunkLen Save Chunk Len .50 sta ZPChunkLen Save Chunk Len
jsr MD5UpdateBitCount jsr MD5UpdateBitCount
ldy #0 ldy #0
@ -166,7 +166,7 @@ MD5Update.I ldy #S.MD5.FINALIZED
inc TXTPTR+1 inc TXTPTR+1
bra .1 bra .1
*-------------------------------------- *--------------------------------------
MD5Finalize.I ldy #S.MD5.FINALIZED MD5X.Finalize ldy #S.MD5.FINALIZED
lda (ZPCtxPtr),y lda (ZPCtxPtr),y
bne .11 bne .11

View File

@ -13,16 +13,16 @@ PS.NewPSPtr .BS 2
* ## C * ## C
* `int execl(const char* cmdline, short int flags);` * `int execl(const char* cmdline, short int flags);`
* ## ASM * ## ASM
* `>PUSHW cmdline`
* `>PUSHB flags` * `>PUSHB flags`
* `>LDYA cmdline`
* `>SYSCALL execl` * `>SYSCALL execl`
* ## RETURN VALUE * ## RETURN VALUE
* A = Child PSID * A = Child PSID
*\-------------------------------------- *\--------------------------------------
K.ExecL sty .1+1 K.ExecL >PULLB PS.Flags
sta .2+1 >PULLB .1+1
>PULLB PS.Flags >PULLB .2+1
>LDYAI 256 >LDYAI 256
jsr K.GetMem jsr K.GetMem
bcs .99 bcs .99
@ -899,137 +899,6 @@ K.GetMemStat >STYA ZPPtr1
bpl .3 bpl .3
clc clc
rts rts
*/--------------------------------------
* # StrVDup
* **In:**
* Y,A = Src StrV
* ## RETURN VALUE
* X = hMem of new StrV
* A = Str Count
*\--------------------------------------
K.StrVDup >STYA ZPPtr1
>STYA ZPPtr2
ldy #0
ldx #0
.1 lda (ZPPtr2),y
beq .2
.11 iny
bne .1
inx
inc ZPPtr2+1
bra .1
.2 iny
bne .3
inx
inc ZPPtr2+1
.3 lda (ZPPtr2),y
bne .11
txa
jsr K.getmem
bcs .9
>STYA ZPPtr2
phx
ldx #0
ldy #0
.4 lda (ZPPtr1),y
.5 sta (ZPPtr2),y
beq .6
iny
bne .4
inc ZPPtr1+1
inc ZPPtr2+1
bra .4
.6 inx
iny
bne .7
inc ZPPtr1+1
inc ZPPtr2+1
.7 lda (ZPPtr1),y
bne .5
sta (ZPPtr2),y Ending \0
txa
plx hMem
clc
.9 rts
*/--------------------------------------
* # Str2StrV
* Expand String and convert to ArgV List
* ## C
* short int str2strv(char* args, char* argv[])
* ## ASM
* `>PUSHW argv`
* `>LDYA args`
* `>SYSCALL Str2StrV`
* ## RETURN VALUE
* A = Arg count
*\--------------------------------------
ARG.bInQuote .EQ ZPPtr3
*--------------------------------------
K.Str2StrV jsr K.Expand
bcs .9
>STYA ZPPtr1
stx .80+1
>PULLW ZPPtr2 Get target buffer
ldx #0 Arg Count
stz ARG.bInQuote
.1 jsr SHARED.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 SHARED.PutCharPtr2
bra .1
.6 jsr SHARED.PutCharPtr2
.7 jsr SHARED.GetCharPtr1
bne .2
inx
.8 jsr SHARED.PutCharPtr2 set Argv[x] Ending 0
sta (ZPPtr2) set Array Ending 0
phx
.80 lda #$FF SELF MODIFIED
jsr K.FreeMem Discard expanded string
pla get back Arg Count
* clc
rts
.9 >RET 2 Discard target buffer
*-------------------------------------- *--------------------------------------
MAN MAN
SAVE USR/SRC/SYS/KERNEL.S.PS SAVE USR/SRC/SYS/KERNEL.S.PS

156
SYS/KERNEL.S.STRV.txt Normal file
View File

@ -0,0 +1,156 @@
NEW
AUTO 3,1
*/--------------------------------------
* # NewStrV
* **In:**
* A = Initial Size (Page)
* ## RETURN VALUE
* X = hStrV
* Y,A = Ptr
*\--------------------------------------
K.NewStrV
*/--------------------------------------
* # StrVGet
* **In:**
* A = hStrV
* X = index
* ## RETURN VALUE
* Y,A = Ptr
*\--------------------------------------
K.StrVGet
*/--------------------------------------
* # StrVDup
* **In:**
* Y,A = Src StrV
* ## RETURN VALUE
* X = hMem of new StrV
* A = Str Count
*\--------------------------------------
K.StrVDup >STYA ZPPtr1
>STYA ZPPtr2
ldy #0
ldx #0
.1 lda (ZPPtr2),y
beq .2
.11 iny
bne .1
inx
inc ZPPtr2+1
bra .1
.2 iny
bne .3
inx
inc ZPPtr2+1
.3 lda (ZPPtr2),y
bne .11
txa
jsr K.getmem
bcs .9
>STYA ZPPtr2
phx
ldx #0
ldy #0
.4 lda (ZPPtr1),y
.5 sta (ZPPtr2),y
beq .6
iny
bne .4
inc ZPPtr1+1
inc ZPPtr2+1
bra .4
.6 inx
iny
bne .7
inc ZPPtr1+1
inc ZPPtr2+1
.7 lda (ZPPtr1),y
bne .5
sta (ZPPtr2),y Ending \0
txa
plx hMem
clc
.9 rts
*/--------------------------------------
* # Str2StrV
* Expand String and convert to ArgV List
* ## C
* short int str2strv(char* args, char* argv[])
* ## ASM
* `>PUSHW argv`
* `>LDYA args`
* `>SYSCALL Str2StrV`
* ## RETURN VALUE
* A = Arg count
*\--------------------------------------
ARG.bInQuote .EQ ZPPtr3
*--------------------------------------
K.Str2StrV jsr K.Expand
bcs .9
>STYA ZPPtr1
stx .80+1
>PULLW ZPPtr2 Get target buffer
ldx #0 Arg Count
stz ARG.bInQuote
.1 jsr SHARED.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 SHARED.PutCharPtr2
bra .1
.6 jsr SHARED.PutCharPtr2
.7 jsr SHARED.GetCharPtr1
bne .2
inx
.8 jsr SHARED.PutCharPtr2 set Argv[x] Ending 0
sta (ZPPtr2) set Array Ending 0
phx
.80 lda #$FF SELF MODIFIED
jsr K.FreeMem Discard expanded string
pla get back Arg Count
* clc
rts
.9 >RET 2 Discard target buffer
*--------------------------------------
MAN
SAVE USR/SRC/SYS/KERNEL.S.STRV
LOAD USR/SRC/SYS/KERNEL.S
ASM

View File

@ -46,7 +46,6 @@ A2osX.AUX .DA #0
A2osX.AUX.B .PH $1000 A2osX.AUX.B .PH $1000
.INB USR/SRC/SYS/KERNEL.S.OSDX .INB USR/SRC/SYS/KERNEL.S.OSDX
.INB USR/SRC/SYS/KERNEL.S.SLISTX
Mem.XLoMem .EQ * Mem.XLoMem .EQ *
.EP .EP
A2osX.AUX.S .EQ *-A2osX.AUX.B A2osX.AUX.S .EQ *-A2osX.AUX.B
@ -59,6 +58,7 @@ A2osX.AUXH.B .PH Mem.XHiMem
.INB USR/SRC/SYS/KERNEL.S.MD5X .INB USR/SRC/SYS/KERNEL.S.MD5X
.INB USR/SRC/SYS/KERNEL.S.PWDX .INB USR/SRC/SYS/KERNEL.S.PWDX
.INB USR/SRC/SYS/KERNEL.S.TIMEX .INB USR/SRC/SYS/KERNEL.S.TIMEX
.INB USR/SRC/SYS/KERNEL.S.SLISTX
.EP .EP
A2osX.AUXH.S .EQ *-A2osX.AUXH.B A2osX.AUXH.S .EQ *-A2osX.AUXH.B
@ -107,11 +107,13 @@ A2osX.E0.B .PH $E000
.INB USR/SRC/SYS/KERNEL.S.IRQ .INB USR/SRC/SYS/KERNEL.S.IRQ
.INB USR/SRC/SYS/KERNEL.S.MEM .INB USR/SRC/SYS/KERNEL.S.MEM
.INB USR/SRC/SYS/KERNEL.S.MATH .INB USR/SRC/SYS/KERNEL.S.MATH
.INB USR/SRC/SYS/KERNEL.S.STRV
.INB USR/SRC/SYS/KERNEL.S.TERM .INB USR/SRC/SYS/KERNEL.S.TERM
.INB USR/SRC/SYS/KERNEL.S.SHARED .INB USR/SRC/SYS/KERNEL.S.MD5
.INB USR/SRC/SYS/KERNEL.S.STDIO2
.INB USR/SRC/SYS/KERNEL.S.PWD .INB USR/SRC/SYS/KERNEL.S.PWD
.INB USR/SRC/SYS/KERNEL.S.TIME .INB USR/SRC/SYS/KERNEL.S.TIME
.INB USR/SRC/SYS/KERNEL.S.SHARED
.INB USR/SRC/SYS/KERNEL.S.STDIO2
* go to A2osX.D1 * go to A2osX.D1
.INB USR/SRC/SYS/KERNEL.S.IO .INB USR/SRC/SYS/KERNEL.S.IO
.INB USR/SRC/SYS/KERNEL.S.PIPE .INB USR/SRC/SYS/KERNEL.S.PIPE