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 #0
* int puts ( const char * str );
>PSTR "printf"
>PSTR "puts"
.DA #CSH.T.INT returned value
.DA #CSH.Q.CONST+CSH.Q.POINTER1
.DA #CSH.T.CHAR
.DA 0
.DA #0
* float cos ( float x );
>PSTR "cos"
.DA #CSH.T.FLOAT returned value

View File

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

View File

@ -39,146 +39,18 @@ CORE.Quit >LDA.G CORE.hArgVBuf
* set hStdIn = hStdOut
* set hStdOut = Std
*--------------------------------------
CORE.Exec >PUSHW ZPArgVBuf
>LDYA ZPArgVBuf
>STYA ZPArgVBufPtr
>SYSCALL Args2ArgV TOKENIZE CL in ZPArgVBuf
>STZ.G CL.CmdSep
CORE.Run.CSYN lda #E.CSYN
sec
rts
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
>STYA ZPInputCmdPtr
>LDYA ZPArgVBuf
>STYA ZPArgVBufPtr
lda #0
sta (ZPArgVBuf) Reset Arg Buffer
lda #$ff
>STA.G CORE.IntCmd assume external
jsr CORE.GetCharNB
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
eor #C.CR
bne .1
rts EOL, CC,A=0
.9 rts EOL, CC,A=0
.2 cmp #'.'
.2 cmp #'|'
bne .3
jsr IO.Pipe.In
bcs CORE.Run.RTS
jsr CORE.GetNextCharNB
bcs CORE.Run.CSYN
.3 cmp #'.'
bne .4
ldy #1
lda (ZPInputBufPtr),y
cmp #C.SPACE
bne .1
bne .4
>LDA.G CORE.PSFlags yes, child process will run in same ENV
and #$ff^S.PS.F.DUPENV
@ -207,18 +88,56 @@ CORE.Run >LDYA ZPInputBufPtr Save Actual cmd for looping
jsr CORE.GetNextCharNB skip ". "
bcs CORE.Run.RTS nothing to execute...
.3 >LDYA L.CORE.CMD internal command ?
.4 >LDYA L.CMD internal command ?
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
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
>LDYA ZPArgVBuf
>SYSCALL execv
@ -247,55 +166,7 @@ CORE.ExecExtCmd >PUSHB.G CORE.PSFlags
.8 clc
.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
*
*--------------------------------------
CORE.Lookup >STYA ZPPtr1
@ -324,7 +195,7 @@ CORE.Lookup >STYA ZPPtr1
plx
tya
sec
clc
adc ZPInputBufPtr
sta ZPInputBufPtr
bcc .8
@ -353,9 +224,110 @@ CORE.Lookup >STYA ZPPtr1
bne .1
lda #E.CSYN
sec
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
rts
*--------------------------------------
* Input Buffer
*--------------------------------------
CORE.IsSpaceOrEndCmd
cmp #C.SPACE
beq CORE.IsEndCmd.8
@ -408,6 +380,8 @@ CORE.GetChar lda (ZPInputBufPtr)
.9 sec
rts
*--------------------------------------
* Stack
*--------------------------------------
CORE.StkPushPtr lda ZPInputCmdPtr
jsr CORE.StkPush
bcs CORE.StkPullPtr.9

View File

@ -3,8 +3,65 @@ PREFIX
AUTO 4,1
.LIST OFF
*--------------------------------------
EXP.EVAL ldx #1
jsr CORE.GetArgX
EXP.GET >LDYA ZPArgVBufPtr
>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
>LDYA L.EXP.BEGIN
@ -23,8 +80,7 @@ EXP.EVAL ldx #1
>ORA.G CORE.Test
sta (pData),y
ldx #2
jsr CORE.GetArgX
jsr CORE.ArgV.Next
beq .9
>LDYA L.EXP.OP.UNARY -d -e -f ?
@ -35,21 +91,23 @@ EXP.EVAL ldx #1
txa
>STA.G CORE.Operator
jsr EXP.EVAL.UNARY
jsr CORE.ArgV.Next
jsr EXP.TEST.UNARY
bcs .9
>EOR.G CORE.Test
sta (pData),y
ldx #4 go check ]
bra .8
bra .8 go check ]
.9 lda #E.ESYN
sec
.99 rts
.1 ldx #3
jsr CORE.GetArgX
.1 >LDYA ZPArgVBufPtr
>STYA ZPPtr1
jsr CORE.ArgV.Next
beq .9
>LDYA L.EXP.OP.BINARY -eq -ne .... ?
@ -58,32 +116,26 @@ EXP.EVAL ldx #1
txa
>STA.G CORE.Operator
jsr EXP.EVAL.BINARY
jsr EXP.TEST.BINARY
bcs .9
>EOR.G CORE.Test
sta (pData),y
ldx #5 go check ]
.8 jsr CORE.GetArgX
.8 jsr CORE.ArgV.Next
beq .9
>STYA ZPPTR1
lda (ZPPTR1)
cmp #']'
bne .9
ldy #1
lda (ZPPTR1),y
lda (ZPArgVBufPtr),y
bne .9
clc
rts
*--------------------------------------
EXP.EVAL.UNARY ldx #3
jsr CORE.GetArgX
bcs .9 we need one arg
EXP.TEST.UNARY jsr CORE.ArgV.Next
beq .9 we need one arg
>LDA.G CORE.Operator
tax
@ -114,8 +166,7 @@ EXP.OP.UNARY.F jsr EXP.OP.UNARY.DEF.7
EXP.OP.UNARY.DEF.7
>PUSHEA.G StatBuf
ldx #3
jsr CORE.GetArgX
>LDYA ZPArgVBufPtr
>SYSCALL STAT
rts
@ -129,27 +180,19 @@ EXP.OP.UNARY.DEF.9
clc
rts
*--------------------------------------
EXP.EVAL.BINARY ldx #2
jsr CORE.GetArgX
bcs .9
ldx #4
jsr CORE.GetArgX
bcs .9
>LDA.G CORE.Operator
EXP.TEST.BINARY >LDA.G CORE.Operator
beq .1 =
cmp #2 !=
bne EXP.EVAL.BINARY.NUM
bne EXP.TEST.BINARY.NUM
lda #$80
>STA.G CORE.Operator
.1 ldx #2
jsr CORE.GetArgX
>PUSHYA
ldx #4
jsr CORE.GetArgX
.1 jsr CORE.ArgV.Next
beq .9
>PUSHW ZPPtr1
>LDYA ZPArgVBufPtr
>SYSCALL strcmp
ror CS if !=
and #$80
@ -162,20 +205,17 @@ EXP.EVAL.BINARY ldx #2
sec
rts
*--------------------------------------
EXP.EVAL.BINARY.NUM
ldx #2
jsr CORE.GetArgX
bcs .9
EXP.TEST.BINARY.NUM
jsr CORE.ArgV.Next
beq .9
>LDYA ZPPtr1
>SYSCALL AToL
bcs .9
>PULLL.G M32.ACC
ldx #4
jsr CORE.GetArgX
bcs .9
>LDYA ZPArgVBufPtr
>SYSCALL AToL
bcs .9
@ -203,72 +243,6 @@ EXP.EVAL.BINARY.NUM
sec
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
SAVE USR/SRC/BIN/SH.S.EXP
LOAD USR/SRC/BIN/SH.S

View File

@ -110,8 +110,8 @@ J.ESC .DA CL.BS left arrow
.DA HIS.GetNext
.DA HIS.GetPrev
.DA CL.NAK right arow
L.CORE.CMD .DA CORE.CMD
J.CORE.CMD .DA CMD.NOHUP
L.CMD .DA CMD
J.CMD .DA CMD.NOHUP
.DA CMD.CD
.DA CMD.DATE
.DA CMD.ECHO
@ -138,15 +138,15 @@ J.CORE.CMD .DA CMD.NOHUP
.DA CMD.IF
.DA CMD.ELSE
.DA CMD.FI
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.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.EXP.BEGIN .DA EXP.BEGIN
L.EXP.OP.UNARY .DA EXP.OP.UNARY
J.EXP.OP.UNARY .DA EXP.OP.UNARY.D
@ -174,7 +174,7 @@ CS.RUN jsr CL.Init
ldy #S.PS.ARGC
lda (pPS),y
beq .1 no arg, continue starting interactive
>PUSHWI 0 Aux type
>PUSHBI S.FI.T.TXT
>PUSHBI O.RDONLY
@ -206,6 +206,7 @@ CS.RUN jsr CL.Init
>LDYA L.MSG.GREETINGS
>SYSCALL printf
bcs CS.INIT.RTS
bra CS.RUN.LOOP
>PUSHEA.G StatBuf
>LDYA L.HOME.PROFILE
@ -526,7 +527,7 @@ ENV.PS1 .AZ "PS1"
ENV.HOME .AZ "HOME"
HOME.PROFILE .AZ "${HOME}PROFILE"
*--------------------------------------
CORE.CMD .AZ "NOHUP"
CMD .AZ "NOHUP"
.AZ "CD"
.AZ "DATE"
.AZ "ECHO"
@ -557,7 +558,7 @@ CORE.CMD .AZ "NOHUP"
*--------------------------------------
* https://www.tldp.org/LDP/abs/html/io-redirection.html
*--------------------------------------
CMD.IO .AZ "&"
CORE.IO .AZ "&"
.AZ "<"
.AZ ">>"
.AZ ">"
@ -633,13 +634,11 @@ CL.hCLBuf .BS 1
CL.Ptr .BS 1
CL.Len .BS 1
CL.bReady .BS 1
CL.CmdSep .BS 1
CORE.IntCmd .BS 1
CORE.hArgVBuf .BS 1
CORE.ArgIndex .BS 1
CORE.Varname .BS 1
CORE.Test .BS 1
CORE.Operator .BS 1
CORE.PSFlags .BS 1