Kernel 0.92+

This commit is contained in:
Rémy GIBERT 2019-02-08 16:13:43 +00:00
parent 086ceb7f8f
commit 0195d8aef6
13 changed files with 210 additions and 281 deletions

View File

@ -349,13 +349,6 @@ CS: A = EC
## RETURN VALUE
Y,A = ...
# pipe
## C
`int pipe(int pipefd[2]);`
## ASM
# FAdd,FSub,FMult,FDiv,FPwr
Return X+Y, X-Y, X*Y, X/Y, X^Y
@ -684,6 +677,18 @@ return a hFILE to a new FIFO
CC = OK, CS = ERROR
A = hFILE
# pipe
## C
`hFD pipe();`
## ASM
`>SYSCALL pipe`
## RETURN VALUE
CC = OK, CS = ERROR
A = hFD
# PutChar
Print A (char) to StdOut

Binary file not shown.

View File

@ -10,20 +10,6 @@ CSH.E.OOM .EQ $7C
CSH.E.DUP .EQ $7B
CSH.E.UNDEF .EQ $7A
CSH.E.TMISMATCH .EQ $79
CSH.Q.CONST .EQ %11000000
CSH.Q.ARRAY .EQ %10001100 max 3 bounds
CSH.Q.POINTER1 .EQ %10000001 max 3 depth
CSH.Q.POINTER2 .EQ %10000010
CSH.Q.POINTER3 .EQ %10000011
CSH.T.CHAR .EQ 1
CSH.T.INT .EQ 2
CSH.T.LONG .EQ 3
CSH.T.UCHAR .EQ 4
CSH.T.UINT .EQ 5
CSH.T.ULONG .EQ 6
CSH.T.FLOAT .EQ 7
CSH.T.VARIADIC .EQ $F
*--------------------------------------
MAN
SAVE USR/SRC/BIN/CSH.E

View File

@ -88,6 +88,12 @@ CSH.FN >PSTR "printf"
.DA #CSH.T.CHAR
.DA #CSH.T.VARIADIC
.DA #0
* int puts ( const char * str );
>PSTR "printf"
.DA #CSH.T.INT returned value
.DA #CSH.Q.CONST+CSH.Q.POINTER1
.DA #CSH.T.CHAR
.DA 0
* float cos ( float x );
>PSTR "cos"
.DA #CSH.T.FLOAT returned value

View File

@ -3,6 +3,20 @@ PREFIX
AUTO 4,1
.LIST OFF
*--------------------------------------
CSH.Q.CONST .EQ %11000000
CSH.Q.ARRAY .EQ %10001100 max 3 bounds
CSH.Q.POINTER1 .EQ %10000001 max 3 depth
CSH.Q.POINTER2 .EQ %10000010
CSH.Q.POINTER3 .EQ %10000011
CSH.T.CHAR .EQ 1
CSH.T.INT .EQ 2
CSH.T.LONG .EQ 3
CSH.T.UCHAR .EQ 4
CSH.T.UINT .EQ 5
CSH.T.ULONG .EQ 6
CSH.T.FLOAT .EQ 7
CSH.T.VARIADIC .EQ $F
*--------------------------------------
CSH.Init lda #$0
>STA.G CSH.SymbolsPtr
>STA.G CSH.DataPtr
@ -335,33 +349,33 @@ CSH.TYPE >STA.G CSH.ACCT
sec
.99 rts
*--------------------------------------
CSH.FnEval jsr CSH.GetCharNB
CSH.FnEval >STYA ZPFnDefPtr
jsr CSH.GetCharNB
bcs .9
cmp #'('
bne .9
lda (ZPPtr1) Get Return value Type
lda (ZPFnDefPtr) Get Return value Type
>CMP.G CSH.ACCT Match with ACC ?
bne .99
jsr CSH.PushACCT Save Acc & T on stack
.1 inc ZPPtr1 advance to arg list type
bne .2
inc ZPPtr1+1
.2 lda (ZPPtr1)
beq .7 end of list, go check no more
jsr CSH.GetNextCharNB skip '('
bcs .9
jsr CSH.PushACCT Save Acc & T on stack
.1 inc ZPFnDefPtr advance to arg list type
bne .2
inc ZPFnDefPtr+1
.2 lda (ZPFnDefPtr)
beq .7 end of list, go check no more
.20 jsr CSH.ExpEval
bcs .90
lda (ZPPtr1)
lda (ZPFnDefPtr)
cmp #CSH.T.VARIADIC
bne .3
@ -370,10 +384,10 @@ CSH.FnEval jsr CSH.GetCharNB
.3 >CMP.G CSH.ACCT Match with ACC ?
bne .99
inc ZPPtr1 advance to next arg
inc ZPFnDefPtr advance to next arg
bne .4
inc ZPPtr1+1
.4 lda (ZPPtr1) no more arg in fn definition
inc ZPFnDefPtr+1
.4 lda (ZPFnDefPtr) no more arg in fn definition
beq .7
jsr CSH.GetNextCharNB
@ -384,7 +398,7 @@ CSH.FnEval jsr CSH.GetCharNB
jsr CSH.GetNextCharNB
bra .20
.7 jsr CSH.GetNextCharNB
.7 jsr CSH.GetCharNB
bcs .9
cmp #')'
bne .9
@ -406,13 +420,14 @@ CSH.FnEval jsr CSH.GetCharNB
rts
*--------------------------------------
CSH.ExpEval jsr CSH.ZeroACC
dec A=0
>STA.G CSH.EXPBOP1
.10 lda #$ff
>STA.G CSH.EXPBOP1 Reset BOP1
jsr CSH.GetCharNB
bcs .9
.10 jsr CSH.IsLetter Fnc or Var ?
jsr CSH.IsLetter Fnc or Var ?
bcs .2
jsr CSH.GetVar
@ -425,6 +440,7 @@ CSH.ExpEval jsr CSH.ZeroACC
.1 >LDYA L.CSH.FN
jsr CSH.LookupFn
bcs .9
>LDYA ZPPtr1
jsr CSH.FnEval
bcs .99
bra .11
@ -476,16 +492,17 @@ CSH.ExpEval jsr CSH.ZeroACC
* Old OP has precedence, compute ACC=ARG <BOP> ACC
.3 >LDA.G CSH.EXPBOP1
jsr CSA.Compute
jsr CSH.Compute
bcs .9
jsr CSH.GetCharNB
bcc .10
bra .9
bcs .9
jmp .10
.8 >LDA.G CSH.EXPBOP1
bmi .80
jmp CSA.Compute
jmp CSH.Compute
.80 clc
rts
@ -848,7 +865,8 @@ CSH.IsACC0 >LDA.G CSH.ACCT
.9 sec
rts
*--------------------------------------
CSA.Compute tax
CSH.Compute tax
jmp (J.CSH.BOPS,x)
*--------------------------------------
CSH.BOPS.ADD

View File

@ -23,6 +23,7 @@ ZPPtr2 .BS 2
ZPPtr3 .BS 2
ZPFileBuf .BS 2
ZPFileBufPtr .BS 2
ZPFnDefPtr .BS 2
ZPCSHSymbols .BS 2
ZPCSHData .BS 2

View File

@ -286,6 +286,6 @@ CL.PrintCLBuf >LDYA ZPCLBuf
rts
*--------------------------------------
MAN
SAVE USR/SRC/BIN/SHELL.S.CL
LOAD USR/SRC/BIN/SHELL.S
SAVE USR/SRC/BIN/SH.S.CL
LOAD USR/SRC/BIN/SH.S
ASM

View File

@ -343,14 +343,7 @@ CMD.TIME clc
*--------------------------------------
CMD.ECHO >STZ.G bECHO.N
lda #1
>STA.G CORE.ArgIndex
.1 tax
jsr CORE.GetArgX
bcs .7
jsr CMD.IsSwitch
.1 jsr CMD.IsSwitch
bcs .2
cmp #'N'
@ -359,7 +352,6 @@ CMD.ECHO >STZ.G bECHO.N
lda #$ff
>EOR.G bECHO.N
sta (pData),y
>INC.G CORE.ArgIndex
bra .1
.2 pha
@ -663,21 +655,20 @@ CMD.LOOP jsr CORE.StkPull
sec
.99 rts
*--------------------------------------
CMD.IsSwitch >STYA ZPPtr1
lda (ZPPtr1)
CMD.IsSwitch lda (ZPInputBufPtr)
cmp #'-'
bne .9
ldy #1
lda (ZPPtr1),y
lda (ZPInputBufPtr),y
beq .9
iny
lda (ZPPtr1),y
lda (ZPInputBufPtr),y
bne .9
dey
lda (ZPPtr1),y
lda (ZPInputBufPtr),y
cmp #'a'
bcc .8
cmp #'z'+1
@ -687,11 +678,99 @@ CMD.IsSwitch >STYA ZPPtr1
.8 clc
rts
.9 >LDYA ZPPtr1
.9 sec
rts
*--------------------------------------
CMD.IOCheck >LDYA L.CMD.IO
jsr CORE.Lookup
bcs CMD.IOCheck.RTS not a IO token...should be an arg....
jmp (J.CMD.IO,x)
CMD.IOCheck.RTS rts
*--------------------------------------
CMD.IO.AMP >LDA.G CORE.PSFlags
and #$ff^S.PS.F.HOLD
sta (pData),y
clc
rts
CMD.IO.IN lda #O.RDONLY+O.TEXT
jsr CMD.IO.Open
bcs CMD.IOCheck.RTS
jmp IO.Set.In
CMD.IO.OUTA
CMD.IO.1OUTA lda #O.WRONLY+O.APPEND+O.CREATE+O.TEXT
bra CMD.IO.OUT.1
CMD.IO.OUT
CMD.IO.1OUT lda #O.WRONLY+O.TRUNC+O.CREATE+O.TEXT
CMD.IO.OUT.1 jsr CMD.IO.Open
bcs CMD.IOCheck.RTS
jmp IO.Set.Out
CMD.IO.2OUTA lda #O.WRONLY+O.APPEND+O.CREATE+O.TEXT
bra CMD.IO.2OUT.1
CMD.IO.2OUT lda #O.WRONLY+O.TRUNC+O.CREATE+O.TEXT
CMD.IO.2OUT.1 jsr CMD.IO.Open
bcs CMD.IOCheck.RTS
jmp IO.Set.Err
*--------------------------------------
CMD.IO.Open pha Open Mode
lda (ZPArgVBufPtr)
beq .9 no arg left....
>PUSHWI 0 Aux type
>PUSHBI S.FI.T.TXT ftype
pla
>PUSHA flags
>LDYA ZPArgVBufPtr
>SYSCALL fopen
rts
.9 pla
lda #E.CSYN
sec
rts
*--------------------------------------
CMD.AddArg2ArgV jsr CORE.GetCharNB
bcs .9
ldx #0
.1 cmp #'"'
bne .2
txa
eor #$ff
tax
bra .4
.2 cmp #C.SPACE
bne .3
txa
bpl .8
.3 jsr CORE.IsEndCmd
bcc .9
sta (ZPArgVBufPtr)
.4 inc ZPArgVBufPtr
bne .5
inc ZPArgVBufPtr
.5 jsr CORE.GetNextChar
bcc .1
.8 lda #0
sta (ZPArgVBufPtr)
clc
.9 rts
*--------------------------------------
MAN
SAVE USR/SRC/BIN/SHELL.S.CMD
LOAD USR/SRC/BIN/SHELL.S
SAVE USR/SRC/BIN/SH.S.CMD
LOAD USR/SRC/BIN/SH.S
ASM

View File

@ -17,67 +17,6 @@ CORE.Quit >LDA.G CORE.hArgVBuf
.9 rts
*--------------------------------------
* Input : ZPCLBuf/ZPFileBuf
* Get Line from buf until ;, CR, \0 (EOL / EOF) -> ZPArgVBuf
*--------------------------------------
CORE.GetCmd >LDYA ZPInputBufPtr Save Actual cmd for looping
>STYA ZPInputCmdPtr
lda (ZPInputBufPtr)
beq .9
ldx #0 reset "" flag
ldy #0
.1 lda (ZPInputBufPtr),y
beq .7
cmp #C.CR
beq .6
cmp #'"'
bne .2
txa
eor #$80 toggle "" flag
tax
lda #'"'
bra .5
.2 cmp #';'
bne .5
txa
beq .6 not between ""
lda #';'
.5 sta (ZPArgVBuf),y
iny
bne .1
lda #E.SYN Line Too long !!!
.9 sec
rts
.6 sec skip CR or ;
.HS 90 BCC
.7 clc
tya
adc ZPInputBufPtr
sta ZPInputBufPtr
bcc .8
inc ZPInputBufPtr+1
.8 lda #0
sta (ZPArgVBuf),y
clc
rts
*--------------------------------------
* Input : ZPArgVBuf (String)
* Tokenize ZPArgVBuf
* :LOOP
@ -144,7 +83,7 @@ CORE.Exec >PUSHW ZPArgVBuf
sta (pData),y
jsr CORE.ShiftArgVToken and skip this token
.2 jsr CORE.IO.Check
.2 jsr CMD.IOCheck
bcc .7 IO token & related args processed
tay an error ?
bne .90 yes...I/O error...
@ -201,7 +140,7 @@ CORE.ExecCmd ldy #$ff
.11 >PUSHW ZPArgVBuf
>LDYA L.CORE.CMD
jsr Lookup no / found, search internal...
jsr CORE.Lookup no / found, search internal...
bcc .13 not internal
.12 ldx #$ff found a / in Arg0 .. external
@ -236,6 +175,11 @@ CORE.ExecCmd ldy #$ff
CORE.Run >LDYA ZPInputBufPtr Save Actual cmd for looping
>STYA ZPInputCmdPtr
>LDYA ZPArgVBuf
>STYA ZPArgVBufPtr
lda #0
sta (ZPArgVBuf) Reset Arg Buffer
jsr CORE.GetCharNB
bcs CORE.Run.RTS Ending 0, CS,A=0
@ -365,7 +309,7 @@ CORE.Lookup >STYA ZPPtr1
lda (ZPInputBufPtr),y
beq .3 Src Keyword end
jsr CORE.IsSep
jsr CORE.IsSpaceOrEndCmd
bcc .3 Src Keyword end
lda (ZPPtr1),y
@ -412,16 +356,20 @@ CORE.Lookup >STYA ZPPtr1
sec
rts
*--------------------------------------
CORE.IsSep cmp #C.SPACE
beq .8
CORE.IsSpaceOrEndCmd
cmp #C.SPACE
beq CORE.IsEndCmd.8
CORE.IsEndCmd cmp #C.CR
beq CORE.IsEndCmd.8
cmp #';'
beq .8
beq CORE.IsEndCmd.8
cmp #'|'
beq .8
beq CORE.IsEndCmd.8
sec
rts
.8 clc
CORE.IsEndCmd.8 clc
rts
*--------------------------------------
CORE.GetCharNB jsr CORE.GetChar
@ -535,79 +483,7 @@ CORE.StkGet lda (pData) StackPtr
sec
rts
*--------------------------------------
CORE.IO.Check >PUSHW ZPArgVBufPtr
>LDYA L.CORE.IO
jsr Lookup
bcs .9 not a IO token...should be an arg....
phx
jsr CORE.ShiftArgVToken skip this IO token
plx
jmp (J.CORE.IO,x)
.9 lda #0
rts
*--------------------------------------
CORE.IO.AMP >LDA.G CORE.PSFlags
and #$ff^S.PS.F.HOLD
sta (pData),y
clc
rts
CORE.IO.IN lda #O.RDONLY+O.TEXT
jsr CORE.IO.Open
bcs .9
jsr IO.Set.In
jsr CORE.ShiftArgVToken skip arg
clc
.9 rts
CORE.IO.OUTA
CORE.IO.1OUTA lda #O.WRONLY+O.APPEND+O.CREATE+O.TEXT
bra CORE.IO.OUT.1
CORE.IO.OUT
CORE.IO.1OUT lda #O.WRONLY+O.TRUNC+O.CREATE+O.TEXT
CORE.IO.OUT.1 jsr CORE.IO.Open
bcs .9
jsr IO.Set.Out
jsr CORE.ShiftArgVToken skip arg
clc
.9 rts
CORE.IO.2OUTA lda #O.WRONLY+O.APPEND+O.CREATE+O.TEXT
bra CORE.IO.2OUT.1
CORE.IO.2OUT lda #O.WRONLY+O.TRUNC+O.CREATE+O.TEXT
CORE.IO.2OUT.1 jsr CORE.IO.Open
bcs .9
jsr IO.Set.Err
jsr CORE.ShiftArgVToken skip arg
clc
.9 rts
*--------------------------------------
CORE.IO.Open pha
lda (ZPArgVBufPtr)
beq .9 no arg left....
>PUSHWI 0 Aux type
>PUSHBI S.FI.T.TXT ftype
pla
>PUSHA flags
>LDYA ZPArgVBufPtr
>SYSCALL fopen
rts
.9 pla
lda #E.CSYN
sec
rts
*--------------------------------------
MAN
SAVE USR/SRC/BIN/SHELL.S.CORE
LOAD USR/SRC/BIN/SHELL.S
SAVE USR/SRC/BIN/SH.S.CORE
LOAD USR/SRC/BIN/SH.S
ASM

View File

@ -7,9 +7,8 @@ EXP.EVAL ldx #1
jsr CORE.GetArgX
beq .9
>PUSHYA
>LDYA L.EXP.BEGIN
jsr Lookup
jsr CORE.Lookup
bcs .9
@ -28,9 +27,8 @@ EXP.EVAL ldx #1
jsr CORE.GetArgX
beq .9
>PUSHYA
>LDYA L.EXP.OP.UNARY -d -e -f ?
jsr Lookup
jsr CORE.Lookup
bcs .1
@ -54,9 +52,8 @@ EXP.EVAL ldx #1
jsr CORE.GetArgX
beq .9
>PUSHYA
>LDYA L.EXP.OP.BINARY -eq -ne .... ?
jsr Lookup
jsr CORE.Lookup
bcs .9
txa
>STA.G CORE.Operator
@ -227,9 +224,8 @@ EXP.GET >LDA.G CORE.ArgIndex
jsr EXP.GetNext
.2 >PUSHYA
>LDYA L.EXP.OP.MATH + - .... ?
jsr Lookup
.2 >LDYA L.EXP.OP.MATH + - .... ?
jsr CORE.Lookup
bcs .9
txa
@ -274,6 +270,6 @@ EXP.GetNext >INC.G CORE.ArgIndex
rts
*--------------------------------------
MAN
SAVE USR/SRC/BIN/SHELL.S.EXP
LOAD USR/SRC/BIN/SHELL.S
SAVE USR/SRC/BIN/SH.S.EXP
LOAD USR/SRC/BIN/SH.S
ASM

View File

@ -180,6 +180,6 @@ HIS.Quit >LDA.G HIS.hBuf
.9 rts
*--------------------------------------
MAN
SAVE USR/SRC/BIN/SHELL.S.HIS
LOAD USR/SRC/BIN/SHELL.S
SAVE USR/SRC/BIN/SH.S.HIS
LOAD USR/SRC/BIN/SH.S
ASM

View File

@ -214,6 +214,6 @@ IO.PrintErrMsg pha Save EC for PrintF
rts
*--------------------------------------
MAN
SAVE USR/SRC/BIN/SHELL.S.IO
LOAD USR/SRC/BIN/SHELL.S
SAVE USR/SRC/BIN/SH.S.IO
LOAD USR/SRC/BIN/SH.S
ASM

View File

@ -138,15 +138,15 @@ J.CORE.CMD .DA CMD.NOHUP
.DA CMD.IF
.DA CMD.ELSE
.DA CMD.FI
L.CORE.IO .DA CORE.IO
J.CORE.IO .DA CORE.IO.AMP
.DA CORE.IO.IN
.DA CORE.IO.OUTA
.DA CORE.IO.OUT
.DA CORE.IO.1OUTA
.DA CORE.IO.1OUT
.DA CORE.IO.2OUTA
.DA CORE.IO.2OUT
L.CMD.IO .DA CMD.IO
J.CMD.IO .DA CMD.IO.AMP
.DA CMD.IO.IN
.DA CMD.IO.OUTA
.DA CMD.IO.OUT
.DA CMD.IO.1OUTA
.DA CMD.IO.1OUT
.DA CMD.IO.2OUTA
.DA CMD.IO.2OUT
L.EXP.BEGIN .DA EXP.BEGIN
L.EXP.OP.UNARY .DA EXP.OP.UNARY
J.EXP.OP.UNARY .DA EXP.OP.UNARY.D
@ -463,44 +463,6 @@ CheckSleep ldy #Sleep+3
ora (pData),y
rts
*--------------------------------------
Lookup >STYA ZPPtr2
>PULLW ZPPtr1
ldx #0
.1 phx
>PUSHW ZPPtr2
>LDYA ZPPtr1
>SYSCALL StrCaseCmp
bcs .2
plx
>LDYA ZPPtr2
clc
rts
.2 inc ZPPtr2
bne .3
inc ZPPtr2+1
.3 lda (ZPPtr2)
bne .2
inc ZPPtr2
bne .4
inc ZPPtr2+1
.4 plx
inx
inx
lda (ZPPtr2) Array Ending 0, must be an external Cmd....
bne .1
sec
rts
*--------------------------------------
RemoveStrFromArgV
>STYA ZPPtr1
>STYA ZPPtr2
@ -536,16 +498,16 @@ RemoveStrFromArgV
.8 rts
*--------------------------------------
.INB USR/SRC/BIN/SHELL.S.CL
.INB USR/SRC/BIN/SHELL.S.HIS
.INB USR/SRC/BIN/SHELL.S.CORE
.INB USR/SRC/BIN/SHELL.S.IO
.INB USR/SRC/BIN/SHELL.S.CMD
.INB USR/SRC/BIN/SHELL.S.EXP
.INB USR/SRC/BIN/SH.S.CL
.INB USR/SRC/BIN/SH.S.HIS
.INB USR/SRC/BIN/SH.S.CORE
.INB USR/SRC/BIN/SH.S.IO
.INB USR/SRC/BIN/SH.S.CMD
.INB USR/SRC/BIN/SH.S.EXP
*--------------------------------------
CS.END
*--------------------------------------
MSG.GREETINGS .AZ "\r\nA2osX-Shell %d.%d\r\n\r\n"
MSG.GREETINGS .AZ "\r\nA2osX-SH %d.%d\r\n\r\n"
MSG.PROMPT .AZ "\e[7h$ "
MSG.TRACE .AZ ">%s\r\n"
MSG.BATCHERR .AZ "^\r\nLine #%D:"
@ -595,7 +557,7 @@ CORE.CMD .AZ "NOHUP"
*--------------------------------------
* https://www.tldp.org/LDP/abs/html/io-redirection.html
*--------------------------------------
CORE.IO .AZ "&"
CMD.IO .AZ "&"
.AZ "<"
.AZ ">>"
.AZ ">"
@ -697,5 +659,5 @@ M32.TMP .BS 4
DS.END .ED
*--------------------------------------
MAN
SAVE USR/SRC/BIN/SHELL.S
SAVE USR/SRC/BIN/SH.S
ASM