Kernel 0.92+

This commit is contained in:
Rémy GIBERT 2019-02-11 06:58:33 +00:00
parent 0195d8aef6
commit f3624cb542
5 changed files with 344 additions and 543 deletions

View File

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

View File

@ -8,7 +8,6 @@ CMD.NOHUP >LDA.G CORE.PSFlags
sta (pData),y sta (pData),y
>LDYA ZPArgVBuf >LDYA ZPArgVBuf
jsr RemoveStrFromArgV
jmp CORE.ExecExtCmd jmp CORE.ExecExtCmd
*-------------------------------------- *--------------------------------------
CMD.SHIFT lda #1 CMD.SHIFT lda #1
@ -41,9 +40,8 @@ CMD.PUSHD >LDA.G PUSHD.STACK
txa txa
sta (pData),y sta (pData),y
ldx #1 lda (ZPArgVBufPtr)
jsr CORE.GetArgX bne CMD.CD.1
bcc CMD.CD.1
.8 clc .8 clc
.9 rts .9 rts
@ -69,9 +67,8 @@ CMD.PWD ldy #S.PS.hPREFIX
>SYSCALL puts >SYSCALL puts
rts rts
*-------------------------------------- *--------------------------------------
CMD.CD ldx #1 CMD.CD lda (ZPArgVBufPtr)
jsr CORE.GetArgX bne CMD.CD.1
bcc CMD.CD.1
CMD.CD.HOME >LDYA L.ENV.HOME CMD.CD.HOME >LDYA L.ENV.HOME
>SYSCALL GetEnv >SYSCALL GetEnv
@ -172,9 +169,8 @@ CMD.Exec.SSYN lda #E.SSYN
sec sec
rts rts
*-------------------------------------- *--------------------------------------
CMD.SET ldx #1 CMD.SET lda (ZPArgVBufPtr)
jsr CORE.GetArgX bne CMD.SET.1
bcc CMD.SET.1
* No arg, print all ENV * No arg, print all ENV
@ -226,16 +222,8 @@ CMD.SET ldx #1
*-------------------------------------- *--------------------------------------
* SET +X VAR = VALUE1 op VALUE2 op VALUE3 ... * SET +X VAR = VALUE1 op VALUE2 op VALUE3 ...
*-------------------------------------- *--------------------------------------
CMD.SET.1 >STZ.G CORE.Varname CMD.SET.1 >DEBUG
.1 jsr CMD.IsSwitch
lda #1
>STA.G CORE.ArgIndex
.1 tax
jsr CORE.GetArgX
bcs .8
jsr CMD.IsSwitch
bcs .6 bcs .6
cmp #'C' cmp #'C'
@ -251,41 +239,32 @@ CMD.SET.1 >STZ.G CORE.Varname
.5 eor #$ff .5 eor #$ff
sta (pData),y sta (pData),y
>INC.G CORE.ArgIndex jsr CORE.ArgV.Next
bra .1 bne .1
clc
rts
.6 >LDA.G CORE.ArgIndex .6 >LDYA ZPArgVBufPtr
>STA.G CORE.Varname >STYA ZPVarNamePtr
>INC.G CORE.ArgIndex jsr CORE.ArgV.Next
tax beq CMD.SET.GET
jsr CORE.GetArgX
bcs CMD.SET.GET
>STYA ZPPTR1
lda (ZPPTR1)
cmp #'=' cmp #'='
bne .99 bne .99
ldy #1 ldy #1
lda (ZPPTR1),y lda (ZPArgVBufPtr),y
bne .99 bne .99
>INC.G CORE.ArgIndex jsr CORE.ArgV.Next
tax beq CMD.SET.UNSET
jsr CORE.GetArgX
bcs CMD.SET.UNSET
jsr EXP.GET jsr EXP.GET
bcs .99 bcs .99
>PUSHYA >PUSHYA
>LDA.G CORE.Varname >LDYA ZPVarNamePtr
tax
jsr CORE.GetArgX
>SYSCALL SetEnv >SYSCALL SetEnv
rts rts
@ -294,24 +273,18 @@ CMD.SET.1 >STZ.G CORE.Varname
.99 jmp CMD.Exec.CSYN .99 jmp CMD.Exec.CSYN
CMD.SET.UNSET >LDA.G CORE.Varname CMD.SET.UNSET >LDYA ZPVarNamePtr
tax
jsr CORE.GetArgX
>SYSCALL UnsetEnv >SYSCALL UnsetEnv
rts rts
CMD.SET.GET >LDA.G CORE.Varname CMD.SET.GET >LDYA ZPVarNamePtr
tax
jsr CORE.GetArgX
>SYSCALL GetEnv >SYSCALL GetEnv
bcc .1 bcc .1
clc clc
rts rts
.1 >PUSHYA push value .1 >PUSHYA push value
>LDA.G CORE.Varname >LDYA ZPVarNamePtr
tax
jsr CORE.GetArgX
>PUSHYA push name >PUSHYA push name
*-------------------------------------- *--------------------------------------
CMD.SET.PRINT >PUSHBI 4 CMD.SET.PRINT >PUSHBI 4
@ -343,6 +316,9 @@ CMD.TIME clc
*-------------------------------------- *--------------------------------------
CMD.ECHO >STZ.G bECHO.N CMD.ECHO >STZ.G bECHO.N
lda (ZPArgVBufPtr)
beq .8
.1 jsr CMD.IsSwitch .1 jsr CMD.IsSwitch
bcs .2 bcs .2
@ -352,40 +328,17 @@ CMD.ECHO >STZ.G bECHO.N
lda #$ff lda #$ff
>EOR.G bECHO.N >EOR.G bECHO.N
sta (pData),y sta (pData),y
bra .1 bra .7
.2 pha .2 >PUSHBI 0
>PUSHBI 0 >LDYA ZPArgVBufPtr
pla
>SYSCALL printf >SYSCALL printf
bcs .9 bcs .9
>INC.G CORE.ArgIndex .7 jsr CORE.ArgV.Next
tax bne .1
jsr CORE.GetArgX >LDA.G bECHO.N
bcs .7
.6 lda #C.SPACE
>SYSCALL putchar
bcs .9
>PUSHBI 0
>LDA.G CORE.ArgIndex
tax
jsr CORE.GetArgX
>SYSCALL printf
bcs .9
>INC.G CORE.ArgIndex
tax
jsr CORE.GetArgX
bcc .6
.7 >LDA.G bECHO.N
bmi .8 bmi .8
>PUSHBI 0 >PUSHBI 0
@ -400,9 +353,8 @@ CMD.ECHO >STZ.G bECHO.N
sec sec
rts rts
*-------------------------------------- *--------------------------------------
CMD.GETKEY ldx #1 CMD.GETKEY lda (ZPArgVBufPtr)
jsr CORE.GetArgX beq .99
bcs .99
>SYSCALL getchar >SYSCALL getchar
bcc .1 bcc .1
@ -418,19 +370,14 @@ CMD.GETKEY ldx #1
>PUSHEA.G M32.BUF >PUSHEA.G M32.BUF
ldx #1 >LDYA ZPArgVBufPtr
jsr CORE.GetArgX
>SYSCALL SetEnv >SYSCALL SetEnv
.9 rts .9 rts
.99 jmp CMD.Exec.CSYN .99 jmp CMD.Exec.CSYN
*-------------------------------------- *--------------------------------------
CMD.READ lda #1 CMD.READ lda (ZPArgVBufPtr)
>STA.G CORE.ArgIndex beq .9
tax
jsr CORE.GetArgX
bcs .9
.1 jsr CMD.IsSwitch .1 jsr CMD.IsSwitch
bcs .4 bcs .4
@ -445,13 +392,11 @@ CMD.READ lda #1
.2 cmp #'P' .2 cmp #'P'
bne .9 bne .9
>INC.G CORE.ArgIndex jsr CORE.ArgV.Next
tax beq .9
jsr CORE.GetArgX
bcs .9
pha
>PUSHBI 0 >PUSHBI 0
pla >LDYA ZPArgVBufPtr
>SYSCALL printf >SYSCALL printf
bcs .99 bcs .99
bra .7 bra .7
@ -461,10 +406,9 @@ CMD.READ lda #1
txa txa
>STA.G hVarName >STA.G hVarName
.7 >INC.G CORE.ArgIndex .7 jsr CORE.ArgV.Next
tax lda (ZPArgVBufPtr)
jsr CORE.GetArgX bne .1
bcc .1
>LDA.G hVarName >LDA.G hVarName
beq .9 beq .9
@ -473,10 +417,10 @@ CMD.READ lda #1
.9 jmp CMD.Exec.CSYN .9 jmp CMD.Exec.CSYN
*-------------------------------------- *--------------------------------------
CMD.SLEEP ldx #1 CMD.SLEEP lda (ZPArgVBufPtr)
jsr CORE.GetArgX beq .9
bcs .9
>LDYA ZPArgVBufPtr
>SYSCALL AToL >SYSCALL AToL
bcs .9 bcs .9
@ -491,10 +435,10 @@ CMD.PAUSE lda #$FF
clc clc
rts rts
*-------------------------------------- *--------------------------------------
CMD.EXIT ldx #1 CMD.EXIT lda (ZPArgVBufPtr)
jsr CORE.GetArgX beq .8 no arg, exit 0
bcs .8 no arg, exit 0
>LDYA ZPArgVBufPtr
>SYSCALL AToL >SYSCALL AToL
bcs .9 bcs .9
@ -513,35 +457,35 @@ CMD.EXIT ldx #1
clc clc
.9 rts .9 rts
*-------------------------------------- *--------------------------------------
CMD.MD ldx #1 CMD.MD lda (ZPArgVBufPtr)
jsr CORE.GetArgX beq .9
bcs .9
>LDYA ZPArgVBufPtr
>SYSCALL MKDir >SYSCALL MKDir
rts rts
.9 jmp CMD.Exec.CSYN .9 jmp CMD.Exec.CSYN
*-------------------------------------- *--------------------------------------
CMD.REN ldx #2 CMD.REN lda (ZPArgVBufPtr)
jsr CORE.GetArgX beq .9
bcs .9 >PUSHW ZPArgVBufPtr
>PUSHYA
ldx #1
jsr CORE.GetArgX
jsr CORE.ArgV.Next
lda (ZPArgVBufPtr)
beq .90
>LDYA ZPArgVBufPtr
>SYSCALL Rename >SYSCALL Rename
rts rts
.90 >PULLYA
.9 jmp CMD.Exec.CSYN .9 jmp CMD.Exec.CSYN
*-------------------------------------- *--------------------------------------
CMD.RD ldx #1 CMD.RD lda (ZPArgVBufPtr)
jsr CORE.GetArgX beq .9
bcs .9
phy
pha
>PUSHEA.G StatBuf >PUSHEA.G StatBuf
pla >LDYA ZPArgVBufPtr
ply
>SYSCALL STAT >SYSCALL STAT
bcs .99 bcs .99
@ -549,8 +493,7 @@ CMD.RD ldx #1
cmp #S.FI.T.DIR cmp #S.FI.T.DIR
bne .9 bne .9
ldx #1 >LDYA ZPArgVBufPtr
jsr CORE.GetArgX
>SYSCALL Remove >SYSCALL Remove
.99 rts .99 rts
@ -583,7 +526,7 @@ CMD.IF jsr CORE.StkGet
bit #$40 Parent is true ? bit #$40 Parent is true ?
beq .3 beq .3
jsr EXP.EVAL jsr EXP.TEST
bcs .9 bcs .9
.3 >LDA.G CORE.IntCmd .3 >LDA.G CORE.IntCmd
@ -655,121 +598,32 @@ CMD.LOOP jsr CORE.StkPull
sec sec
.99 rts .99 rts
*-------------------------------------- *--------------------------------------
CMD.IsSwitch lda (ZPInputBufPtr) CMD.IsSwitch lda (ZPArgVBufPtr)
cmp #'-' cmp #'-'
bne .9 bne .9
ldy #1 ldy #1
lda (ZPInputBufPtr),y lda (ZPArgVBufPtr),y
beq .9 beq .9
tax
iny iny
lda (ZPInputBufPtr),y lda (ZPArgVBufPtr),y
bne .9 bne .9
dey txa
lda (ZPInputBufPtr),y
cmp #'a' cmp #'a'
bcc .8 bcc .8
cmp #'z'+1 cmp #'z'+1
bcs .8 bcs .8
eor #$20 eor #$20
jsr CORE.ArgV.NextChar
jsr CORE.ArgV.NextChar
.8 clc .8 clc
rts rts
.9 sec .9 sec
rts 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 MAN
SAVE USR/SRC/BIN/SH.S.CMD SAVE USR/SRC/BIN/SH.S.CMD
LOAD USR/SRC/BIN/SH.S LOAD USR/SRC/BIN/SH.S

View File

@ -39,146 +39,18 @@ CORE.Quit >LDA.G CORE.hArgVBuf
* set hStdIn = hStdOut * set hStdIn = hStdOut
* set hStdOut = Std * set hStdOut = Std
*-------------------------------------- *--------------------------------------
CORE.Exec >PUSHW ZPArgVBuf CORE.Run.CSYN lda #E.CSYN
>LDYA ZPArgVBuf sec
>STYA ZPArgVBufPtr rts
>SYSCALL Args2ArgV TOKENIZE CL in ZPArgVBuf
>STZ.G CL.CmdSep
lda (ZPArgVBufPtr) empty line ?
beq .80
cmp #'#' comment ?
beq .80
*************** LOOP Cmd Arg
.10 lda #S.PS.F.HOLD+S.PS.F.DUPENV
>STA.G CORE.PSFlags
>LDA.G CL.CmdSep
cmp #'|'
bne .1
jsr IO.Pipe.In
bcs .90
*************** LOOP Token
.1 cmp #'#' comment ?
beq .80 yes, ignore remaining
ldy #1
lda (ZPArgVBufPtr),y only one char ?
bne .2
lda (ZPArgVBufPtr)
cmp #'.' leading dot ?
bne .2
>LDA.G CORE.PSFlags yes, child process will run in same ENV
and #$ff^S.PS.F.DUPENV
sta (pData),y
jsr CORE.ShiftArgVToken and skip this token
.2 jsr CMD.IOCheck
bcc .7 IO token & related args processed
tay an error ?
bne .90 yes...I/O error...
jsr CORE.NextArgVToken no...keep as cmd or arg
.7 lda (ZPArgVBufPtr)
beq .71 EOL...
cmp #';'
bne .70
>STA.G CL.CmdSep
jsr CORE.ShiftArgVToken Skip ;
bra .72 exec
.70 cmp #'|'
bne .1 another token...
>STA.G CL.CmdSep
jsr IO.Pipe.Out
bcs .90
jsr CORE.ShiftArgVToken Skip |
bra .72 and exec
jsr CORE.ShiftArgVToken Skip ;
lda #0
.71 >STA.G CL.CmdSep
.72 jsr CORE.ExecCmd
bcs .90
>LDA.G CL.CmdSep
bne .10 if sep is ; or |...loop
.80 clc
.90 rts
*--------------------------------------
* Input : ZPArgVBuf
*--------------------------------------
CORE.ExecCmd ldy #$ff
.1 iny
lda (ZPArgVBuf),y
beq .11
cmp #'/'
bne .1
bra .12
.11 >PUSHW ZPArgVBuf
>LDYA L.CORE.CMD
jsr CORE.Lookup no / found, search internal...
bcc .13 not internal
.12 ldx #$ff found a / in Arg0 .. external
.13 txa
>STA.G CORE.IntCmd
.10 jsr CORE.StkGet IF,WHILE,FOR ?
bcs .3 no particular context, exec...
tax
>LDA.G CORE.IntCmd
bmi .2 external ...
and #$3F
cmp #C.FOR
bcs .3 FOR...FI : always execute
.2 txa
bpl .8 context is FALSE, skip line
asl
bpl .8 parent context is FALSE, skip line
.3 >LDA.G CORE.IntCmd
bmi CORE.ExecExtCmd
tax
jmp (J.CORE.CMD,x)
.8 clc
.9 rts
*--------------------------------------
CORE.Run >LDYA ZPInputBufPtr Save Actual cmd for looping CORE.Run >LDYA ZPInputBufPtr Save Actual cmd for looping
>STYA ZPInputCmdPtr >STYA ZPInputCmdPtr
>LDYA ZPArgVBuf >LDYA ZPArgVBuf
>STYA ZPArgVBufPtr >STYA ZPArgVBufPtr
lda #0
sta (ZPArgVBuf) Reset Arg Buffer lda #$ff
>STA.G CORE.IntCmd assume external
jsr CORE.GetCharNB jsr CORE.GetCharNB
bcs CORE.Run.RTS Ending 0, CS,A=0 bcs CORE.Run.RTS Ending 0, CS,A=0
@ -190,15 +62,24 @@ CORE.Run >LDYA ZPInputBufPtr Save Actual cmd for looping
bcs CORE.Run.RTS A=0, CS bcs CORE.Run.RTS A=0, CS
eor #C.CR eor #C.CR
bne .1 bne .1
rts EOL, CC,A=0 .9 rts EOL, CC,A=0
.2 cmp #'.' .2 cmp #'|'
bne .3 bne .3
jsr IO.Pipe.In
bcs CORE.Run.RTS
jsr CORE.GetNextCharNB
bcs CORE.Run.CSYN
.3 cmp #'.'
bne .4
ldy #1 ldy #1
lda (ZPInputBufPtr),y lda (ZPInputBufPtr),y
cmp #C.SPACE cmp #C.SPACE
bne .1 bne .4
>LDA.G CORE.PSFlags yes, child process will run in same ENV >LDA.G CORE.PSFlags yes, child process will run in same ENV
and #$ff^S.PS.F.DUPENV and #$ff^S.PS.F.DUPENV
@ -207,18 +88,56 @@ CORE.Run >LDYA ZPInputBufPtr Save Actual cmd for looping
jsr CORE.GetNextCharNB skip ". " jsr CORE.GetNextCharNB skip ". "
bcs CORE.Run.RTS nothing to execute... bcs CORE.Run.RTS nothing to execute...
.3 >LDYA L.CORE.CMD internal command ? .4 >LDYA L.CMD internal command ?
jsr CORE.Lookup jsr CORE.Lookup
bcs .4 bcs .6 external, add token
txa
>STA.G CORE.IntCmd
bra .7 internal, do not add token
jmp (J.CORE.CMD,x) .5 >LDYA L.CORE.IO
jsr CORE.Lookup
bcs .6
.4 jsr CORE.GetNextCharNB
bcs CORE.Run.CSYN
jsr CORE.IO.JMP
bcs CORE.Run.RTS
bra .7
.6 jsr CORE.ArgV.Add
.7 jsr CORE.GetCharNB
bcs CORE.ExecCmd
jsr CORE.IsEndCmd
bcs .5
cmp #'|'
beq CORE.ExecCmd
jsr CORE.GetNextCharNB
jsr IO.Pipe.Out
bcs CORE.Run.RTS
bra CORE.ExecCmd
.8 clc .8 clc
CORE.Run.RTS rts CORE.Run.RTS rts
*-------------------------------------- *--------------------------------------
* Input : ZPArgVBuf
*--------------------------------------
CORE.ExecCmd lda #0
jsr CORE.ArgV.PutChar
>LDA.G CORE.IntCmd
bmi CORE.ExecExtCmd
tax
>LDYA ZPArgVBuf
>STYA ZPArgVBufPtr
jmp (J.CMD,x)
CORE.ExecExtCmd >PUSHB.G CORE.PSFlags CORE.ExecExtCmd >PUSHB.G CORE.PSFlags
>LDYA ZPArgVBuf >LDYA ZPArgVBuf
>SYSCALL execv >SYSCALL execv
@ -247,55 +166,7 @@ CORE.ExecExtCmd >PUSHB.G CORE.PSFlags
.8 clc .8 clc
.9 rts .9 rts
*-------------------------------------- *--------------------------------------
CORE.NextArgVToken
lda (ZPArgVBufPtr)
inc ZPArgVBufPtr
bne .1
inc ZPArgVBufPtr+1
.1 tax
bne CORE.NextArgVToken
rts
*--------------------------------------
CORE.ShiftArgVToken
>LDYA ZPArgVBufPtr
jmp RemoveStrFromArgV
*--------------------------------------
CORE.GetArgX >LDYA ZPArgVBuf
dex
bmi .8
>STYA ZPPtr1
.1 lda (ZPPtr1)
beq .9
.2 inc ZPPtr1
bne .3
inc ZPPtr1+1
.3 lda (ZPPtr1)
bne .2
inc ZPPtr1
bne .4
inc ZPPtr1+1
.4 lda (ZPPtr1)
beq .9
dex
bpl .1
>LDYA ZPPtr1
.8 clc
rts
.9 sec
rts
*--------------------------------------
* search ZPInputBufPtr in Y,A table * search ZPInputBufPtr in Y,A table
*
*-------------------------------------- *--------------------------------------
CORE.Lookup >STYA ZPPtr1 CORE.Lookup >STYA ZPPtr1
@ -324,7 +195,7 @@ CORE.Lookup >STYA ZPPtr1
plx plx
tya tya
sec clc
adc ZPInputBufPtr adc ZPInputBufPtr
sta ZPInputBufPtr sta ZPInputBufPtr
bcc .8 bcc .8
@ -353,9 +224,110 @@ CORE.Lookup >STYA ZPPtr1
bne .1 bne .1
lda #E.CSYN lda #E.CSYN
CORE.Lookup.9 sec
rts
*--------------------------------------
* ArgV
*--------------------------------------
CORE.ArgV.Add jsr CORE.GetCharNB
bcs CORE.Lookup.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 CORE.Lookup.9
jsr CORE.ArgV.PutChar
.4 jsr CORE.GetNextChar
bra .1
.8 lda #0
*--------------------------------------
CORE.ArgV.PutChar
sta (ZPArgVBufPtr)
CORE.ArgV.NextChar
inc ZPArgVBufPtr
bne .8
inc ZPArgVBufPtr
.8 rts
*--------------------------------------
CORE.ArgV.Next lda (ZPArgVBufPtr)
beq .8
.1 jsr CORE.ArgV.NextChar
lda (ZPArgVBufPtr)
bne .1
jsr CORE.ArgV.NextChar
lda (ZPArgVBufPtr)
.8 rts
*--------------------------------------
* IO
*--------------------------------------
CORE.IO.JMP jmp (J.CORE.IO,x)
CORE.IO.AMP >LDA.G CORE.PSFlags
and #$ff^S.PS.F.HOLD
sta (pData),y
clc
CORE.IO.RTS rts
CORE.IO.IN lda #O.RDONLY+O.TEXT
jsr CORE.IO.Open
bcs CORE.IO.RTS
jmp IO.Set.In
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 CORE.IO.RTS
jmp IO.Set.Out
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 CORE.IO.RTS
jmp IO.Set.Err
*--------------------------------------
CORE.IO.Open pha Open Mode
jsr CORE.GetCharNB
bcs .9 no arg left....
>PUSHWI 0 Aux type
>PUSHBI S.FI.T.TXT ftype
pla
>PUSHA flags
>LDYA ZPInputBufPtr
>SYSCALL fopen
rts
.9 pla
lda #E.CSYN
sec sec
rts rts
*-------------------------------------- *--------------------------------------
* Input Buffer
*--------------------------------------
CORE.IsSpaceOrEndCmd CORE.IsSpaceOrEndCmd
cmp #C.SPACE cmp #C.SPACE
beq CORE.IsEndCmd.8 beq CORE.IsEndCmd.8
@ -408,6 +380,8 @@ CORE.GetChar lda (ZPInputBufPtr)
.9 sec .9 sec
rts rts
*-------------------------------------- *--------------------------------------
* Stack
*--------------------------------------
CORE.StkPushPtr lda ZPInputCmdPtr CORE.StkPushPtr lda ZPInputCmdPtr
jsr CORE.StkPush jsr CORE.StkPush
bcs CORE.StkPullPtr.9 bcs CORE.StkPullPtr.9

View File

@ -3,8 +3,65 @@ PREFIX
AUTO 4,1 AUTO 4,1
.LIST OFF .LIST OFF
*-------------------------------------- *--------------------------------------
EXP.EVAL ldx #1 EXP.GET >LDYA ZPArgVBufPtr
jsr CORE.GetArgX >STYA ZPPtr1
>DEBUG
jsr CORE.ArgV.Next
bne .1
>LDYA ZPPtr1 no op, return text value
clc
rts
.1 >LDYA ZPPtr1
>SYSCALL AToL
bcs .99
>PULLL.G M32.ACC
.2 >LDYA L.EXP.OP.MATH + - .... ?
jsr CORE.Lookup
bcs .9
txa
>STA.G CORE.Operator
jsr M32.ACC2ARG
jsr CORE.ArgV.Next get next argument in ACC
beq .9
>LDYA ZPArgVBufPtr
>SYSCALL AToL
bcs .9
>PULLL.G M32.ACC
jsr EXP.GET.OP
.99 bcs .9
jsr CORE.ArgV.Next another op ?
bne .2
.8 >PUSHL.G M32.ACC
>PUSHBI 4
>PUSHW L.M32.Printf
>LEA.G M32.BUF
>SYSCALL sprintf
bcs .9
>LEA.G M32.Buf
rts
.9 lda #E.BADEXP
sec
rts
EXP.GET.OP >LDA.G CORE.Operator
tax
jmp (J.EXP.OP.MATH,x)
*--------------------------------------
EXP.TEST lda (ZPArgVBufPtr)
beq .9 beq .9
>LDYA L.EXP.BEGIN >LDYA L.EXP.BEGIN
@ -23,8 +80,7 @@ EXP.EVAL ldx #1
>ORA.G CORE.Test >ORA.G CORE.Test
sta (pData),y sta (pData),y
ldx #2 jsr CORE.ArgV.Next
jsr CORE.GetArgX
beq .9 beq .9
>LDYA L.EXP.OP.UNARY -d -e -f ? >LDYA L.EXP.OP.UNARY -d -e -f ?
@ -35,21 +91,23 @@ EXP.EVAL ldx #1
txa txa
>STA.G CORE.Operator >STA.G CORE.Operator
jsr EXP.EVAL.UNARY jsr CORE.ArgV.Next
jsr EXP.TEST.UNARY
bcs .9 bcs .9
>EOR.G CORE.Test >EOR.G CORE.Test
sta (pData),y sta (pData),y
ldx #4 go check ] bra .8 go check ]
bra .8
.9 lda #E.ESYN .9 lda #E.ESYN
sec sec
.99 rts .99 rts
.1 ldx #3 .1 >LDYA ZPArgVBufPtr
jsr CORE.GetArgX >STYA ZPPtr1
jsr CORE.ArgV.Next
beq .9 beq .9
>LDYA L.EXP.OP.BINARY -eq -ne .... ? >LDYA L.EXP.OP.BINARY -eq -ne .... ?
@ -58,32 +116,26 @@ EXP.EVAL ldx #1
txa txa
>STA.G CORE.Operator >STA.G CORE.Operator
jsr EXP.EVAL.BINARY jsr EXP.TEST.BINARY
bcs .9 bcs .9
>EOR.G CORE.Test >EOR.G CORE.Test
sta (pData),y sta (pData),y
ldx #5 go check ] .8 jsr CORE.ArgV.Next
.8 jsr CORE.GetArgX
beq .9 beq .9
>STYA ZPPTR1
lda (ZPPTR1)
cmp #']' cmp #']'
bne .9 bne .9
ldy #1 ldy #1
lda (ZPPTR1),y lda (ZPArgVBufPtr),y
bne .9 bne .9
clc clc
rts rts
*-------------------------------------- *--------------------------------------
EXP.EVAL.UNARY ldx #3 EXP.TEST.UNARY jsr CORE.ArgV.Next
jsr CORE.GetArgX beq .9 we need one arg
bcs .9 we need one arg
>LDA.G CORE.Operator >LDA.G CORE.Operator
tax tax
@ -114,8 +166,7 @@ EXP.OP.UNARY.F jsr EXP.OP.UNARY.DEF.7
EXP.OP.UNARY.DEF.7 EXP.OP.UNARY.DEF.7
>PUSHEA.G StatBuf >PUSHEA.G StatBuf
ldx #3 >LDYA ZPArgVBufPtr
jsr CORE.GetArgX
>SYSCALL STAT >SYSCALL STAT
rts rts
@ -129,27 +180,19 @@ EXP.OP.UNARY.DEF.9
clc clc
rts rts
*-------------------------------------- *--------------------------------------
EXP.EVAL.BINARY ldx #2 EXP.TEST.BINARY >LDA.G CORE.Operator
jsr CORE.GetArgX
bcs .9
ldx #4
jsr CORE.GetArgX
bcs .9
>LDA.G CORE.Operator
beq .1 = beq .1 =
cmp #2 != cmp #2 !=
bne EXP.EVAL.BINARY.NUM bne EXP.TEST.BINARY.NUM
lda #$80 lda #$80
>STA.G CORE.Operator >STA.G CORE.Operator
.1 ldx #2 .1 jsr CORE.ArgV.Next
jsr CORE.GetArgX beq .9
>PUSHYA
ldx #4 >PUSHW ZPPtr1
jsr CORE.GetArgX >LDYA ZPArgVBufPtr
>SYSCALL strcmp >SYSCALL strcmp
ror CS if != ror CS if !=
and #$80 and #$80
@ -162,20 +205,17 @@ EXP.EVAL.BINARY ldx #2
sec sec
rts rts
*-------------------------------------- *--------------------------------------
EXP.EVAL.BINARY.NUM EXP.TEST.BINARY.NUM
ldx #2 jsr CORE.ArgV.Next
jsr CORE.GetArgX beq .9
bcs .9
>LDYA ZPPtr1
>SYSCALL AToL >SYSCALL AToL
bcs .9 bcs .9
>PULLL.G M32.ACC >PULLL.G M32.ACC
ldx #4 >LDYA ZPArgVBufPtr
jsr CORE.GetArgX
bcs .9
>SYSCALL AToL >SYSCALL AToL
bcs .9 bcs .9
@ -203,72 +243,6 @@ EXP.EVAL.BINARY.NUM
sec sec
rts rts
*-------------------------------------- *--------------------------------------
EXP.GET >LDA.G CORE.ArgIndex
inc
tax
jsr CORE.GetArgX
bcc .1
>LDA.G CORE.ArgIndex no op, return text value
tax
jsr CORE.GetArgX
rts
.1 >LDA.G CORE.ArgIndex
tax
jsr CORE.GetArgX
>SYSCALL AToL
bcs .99
>PULLL.G M32.ACC
jsr EXP.GetNext
.2 >LDYA L.EXP.OP.MATH + - .... ?
jsr CORE.Lookup
bcs .9
txa
>STA.G CORE.Operator
jsr M32.ACC2ARG
jsr EXP.GetNext get next argument in ACC
.99 bcs .9
>SYSCALL AToL
bcs .9
>PULLL.G M32.ACC
jsr EXP.GET.OP
bcs .9
jsr EXP.GetNext another op ?
bcc .2
.8 >PUSHL.G M32.ACC
>PUSHBI 4
>PUSHW L.M32.Printf
>LEA.G M32.BUF
>SYSCALL sprintf
bcs .9
>LEA.G M32.Buf
rts
.9 lda #E.BADEXP
rts
EXP.GET.OP >LDA.G CORE.Operator
tax
jmp (J.EXP.OP.MATH,x)
*--------------------------------------
EXP.GetNext >INC.G CORE.ArgIndex
tax
jsr CORE.GetArgX
rts
*--------------------------------------
MAN MAN
SAVE USR/SRC/BIN/SH.S.EXP SAVE USR/SRC/BIN/SH.S.EXP
LOAD USR/SRC/BIN/SH.S LOAD USR/SRC/BIN/SH.S

View File

@ -110,8 +110,8 @@ J.ESC .DA CL.BS left arrow
.DA HIS.GetNext .DA HIS.GetNext
.DA HIS.GetPrev .DA HIS.GetPrev
.DA CL.NAK right arow .DA CL.NAK right arow
L.CORE.CMD .DA CORE.CMD L.CMD .DA CMD
J.CORE.CMD .DA CMD.NOHUP J.CMD .DA CMD.NOHUP
.DA CMD.CD .DA CMD.CD
.DA CMD.DATE .DA CMD.DATE
.DA CMD.ECHO .DA CMD.ECHO
@ -138,15 +138,15 @@ J.CORE.CMD .DA CMD.NOHUP
.DA CMD.IF .DA CMD.IF
.DA CMD.ELSE .DA CMD.ELSE
.DA CMD.FI .DA CMD.FI
L.CMD.IO .DA CMD.IO L.CORE.IO .DA CORE.IO
J.CMD.IO .DA CMD.IO.AMP J.CORE.IO .DA CORE.IO.AMP
.DA CMD.IO.IN .DA CORE.IO.IN
.DA CMD.IO.OUTA .DA CORE.IO.OUTA
.DA CMD.IO.OUT .DA CORE.IO.OUT
.DA CMD.IO.1OUTA .DA CORE.IO.1OUTA
.DA CMD.IO.1OUT .DA CORE.IO.1OUT
.DA CMD.IO.2OUTA .DA CORE.IO.2OUTA
.DA CMD.IO.2OUT .DA CORE.IO.2OUT
L.EXP.BEGIN .DA EXP.BEGIN L.EXP.BEGIN .DA EXP.BEGIN
L.EXP.OP.UNARY .DA EXP.OP.UNARY L.EXP.OP.UNARY .DA EXP.OP.UNARY
J.EXP.OP.UNARY .DA EXP.OP.UNARY.D J.EXP.OP.UNARY .DA EXP.OP.UNARY.D
@ -206,6 +206,7 @@ CS.RUN jsr CL.Init
>LDYA L.MSG.GREETINGS >LDYA L.MSG.GREETINGS
>SYSCALL printf >SYSCALL printf
bcs CS.INIT.RTS bcs CS.INIT.RTS
bra CS.RUN.LOOP
>PUSHEA.G StatBuf >PUSHEA.G StatBuf
>LDYA L.HOME.PROFILE >LDYA L.HOME.PROFILE
@ -526,7 +527,7 @@ ENV.PS1 .AZ "PS1"
ENV.HOME .AZ "HOME" ENV.HOME .AZ "HOME"
HOME.PROFILE .AZ "${HOME}PROFILE" HOME.PROFILE .AZ "${HOME}PROFILE"
*-------------------------------------- *--------------------------------------
CORE.CMD .AZ "NOHUP" CMD .AZ "NOHUP"
.AZ "CD" .AZ "CD"
.AZ "DATE" .AZ "DATE"
.AZ "ECHO" .AZ "ECHO"
@ -557,7 +558,7 @@ CORE.CMD .AZ "NOHUP"
*-------------------------------------- *--------------------------------------
* https://www.tldp.org/LDP/abs/html/io-redirection.html * https://www.tldp.org/LDP/abs/html/io-redirection.html
*-------------------------------------- *--------------------------------------
CMD.IO .AZ "&" CORE.IO .AZ "&"
.AZ "<" .AZ "<"
.AZ ">>" .AZ ">>"
.AZ ">" .AZ ">"
@ -633,13 +634,11 @@ CL.hCLBuf .BS 1
CL.Ptr .BS 1 CL.Ptr .BS 1
CL.Len .BS 1 CL.Len .BS 1
CL.bReady .BS 1 CL.bReady .BS 1
CL.CmdSep .BS 1
CORE.IntCmd .BS 1 CORE.IntCmd .BS 1
CORE.hArgVBuf .BS 1 CORE.hArgVBuf .BS 1
CORE.ArgIndex .BS 1 CORE.ArgIndex .BS 1
CORE.Varname .BS 1
CORE.Test .BS 1 CORE.Test .BS 1
CORE.Operator .BS 1 CORE.Operator .BS 1
CORE.PSFlags .BS 1 CORE.PSFlags .BS 1