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
# C
`void md5update (hMD5 md5, char* data, int len);`
`void md5update (short int md5, char* data, int len);`
# ASM
`>PUSHB md5`
@ -348,7 +348,7 @@ Add Data to MD5 computation
## MD5Finalize
# C
`void md5finalize (hMD5 md5, char* digest);`
`void md5finalize (short int md5, char* digest);`
# ASM
`>PUSHB md5`
@ -433,8 +433,8 @@ Load a file in AUX memory (Stock Objects)
`int execl(const char* cmdline, short int flags);`
## ASM
`>PUSHW cmdline`
`>PUSHB flags`
`>LDYA cmdline`
`>SYSCALL execl`
## RETURN VALUE
@ -529,28 +529,6 @@ CS : not found
## RETURN VALUE
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
## C
@ -1314,6 +1292,44 @@ CS : no match
CC, Y,A=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
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.Q.CONST+CSH.Q.POINTER+CSH.T.CHAR
.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, ... );
>PSTR "printf"
.DA #CSH.T.INT returned value
@ -163,6 +169,12 @@ CSH.FN
.DA #CSH.T.INT returned value
.DA #CSH.Q.CONST+CSH.Q.POINTER+CSH.T.CHAR
.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 );
>PSTR "malloc"
.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.getchar
.DA EXEC.puts
.DA EXEC.execl
.DA EXEC.printf
.DA EXEC.putenv
.DA EXEC.setenv
.DA EXEC.getenv
.DA EXEC.unsetenv
.DA EXEC.MD5
.DA EXEC.malloc
*--------------------------------------
MAN

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -13,16 +13,16 @@ PS.NewPSPtr .BS 2
* ## C
* `int execl(const char* cmdline, short int flags);`
* ## ASM
* `>PUSHW cmdline`
* `>PUSHB flags`
* `>LDYA cmdline`
* `>SYSCALL execl`
* ## RETURN VALUE
* A = Child PSID
*\--------------------------------------
K.ExecL sty .1+1
sta .2+1
>PULLB PS.Flags
K.ExecL >PULLB PS.Flags
>PULLB .1+1
>PULLB .2+1
>LDYAI 256
jsr K.GetMem
bcs .99
@ -899,137 +899,6 @@ K.GetMemStat >STYA ZPPtr1
bpl .3
clc
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
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
.INB USR/SRC/SYS/KERNEL.S.OSDX
.INB USR/SRC/SYS/KERNEL.S.SLISTX
Mem.XLoMem .EQ *
.EP
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.PWDX
.INB USR/SRC/SYS/KERNEL.S.TIMEX
.INB USR/SRC/SYS/KERNEL.S.SLISTX
.EP
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.MEM
.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.SHARED
.INB USR/SRC/SYS/KERNEL.S.STDIO2
.INB USR/SRC/SYS/KERNEL.S.MD5
.INB USR/SRC/SYS/KERNEL.S.PWD
.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
.INB USR/SRC/SYS/KERNEL.S.IO
.INB USR/SRC/SYS/KERNEL.S.PIPE