Kernel 0.92

This commit is contained in:
Rémy GIBERT 2018-11-26 07:57:11 +01:00
parent 8495b88a54
commit bb2e021a49
3 changed files with 218 additions and 175 deletions

View File

@ -466,7 +466,7 @@ CL.CheckCmd ldy #$ff
cmp #S.FI.T.SYS cmp #S.FI.T.SYS
beq CL.CheckCmd.SYS beq CL.CheckCmd.SYS
lda #E.SYN lda #E.BADFTYPE
sec sec
CL.CheckCmd.90 php CL.CheckCmd.90 php
@ -479,12 +479,6 @@ CL.CheckCmd.90 php
CL.CheckCmd.RTS CL.CheckCmd.RTS
rts rts
*-------------------------------------- *--------------------------------------
* TXT : add "/PATH/SHELL" "/PATH/CMD"
*--------------------------------------
*CL.CheckCmd.TXT >LDYA L.SHELL
* jsr CL.AddYAToArgV
* bcs CL.CheckCmd.90
*--------------------------------------
* BIN : add "/PATH/CMD" * BIN : add "/PATH/CMD"
*-------------------------------------- *--------------------------------------
CL.CheckCmd.BIN >LDA.G CMD.hCmdLine CL.CheckCmd.BIN >LDA.G CMD.hCmdLine
@ -580,7 +574,7 @@ CL.IO.Open pha
rts rts
.9 pla .9 pla
lda #E.SYN lda #E.SYNTAX
sec sec
rts rts
*-------------------------------------- *--------------------------------------

View File

@ -30,23 +30,24 @@ CMD.Quit ldy #CMD.hArgVBuf
>SYSCALL FreeMem >SYSCALL FreeMem
.9 rts .9 rts
*-------------------------------------- *--------------------------------------
* Input : ZPArgVBuf * Input : CMD.IntCmd,ZPArgVBuf
*-------------------------------------- *--------------------------------------
Cmd.Exec >LDA.G CMD.IntCmd Cmd.Exec jsr CMD.StkGet IF,WHILE,FOR ?
bmi .2 External bcs .3 no particular context, exec...
tax tax
cpx #C.ELSE always execute ELSE,FI and #$3F
bcs .1 cmp #C.FOR
bcs .3 FOR...FI : always execute
jsr CMD.StkGet IF,WHILE,FOR ?
bcs .1 no particular context
txa
bpl .8 context is FALSE, skip line bpl .8 context is FALSE, skip line
asl
bpl .8 parent context is FALSE, skip line
.1 jmp (J.CMD.INT,x) .3 >LDA.G CMD.IntCmd
bpl .80 Internal
.2 >PUSHB.G CMD.PSFlags >PUSHB.G CMD.PSFlags
>LDYA ZPArgVBuf >LDYA ZPArgVBuf
>SYSCALL execv >SYSCALL execv
bcs .9 bcs .9
@ -75,6 +76,9 @@ Cmd.Exec >LDA.G CMD.IntCmd
.99 sec .99 sec
rts rts
.80 tax
jmp (J.CMD.INT,x)
*-------------------------------------- *--------------------------------------
* STARTPROC : intcmd = 0 * STARTPROC : intcmd = 0
*-------------------------------------- *--------------------------------------
@ -168,7 +172,7 @@ Cmd.INT.CD.1 >STYA ZPPtr1
plp plp
.9 rts .9 rts
*-------------------------------------- *--------------------------------------
Cmd.Exec.ERRSYN lda #E.SYN Cmd.Exec.ERRSYN lda #E.SYNTAX
sec sec
rts rts
*-------------------------------------- *--------------------------------------
@ -302,9 +306,11 @@ Cmd.INT.SET.GET
tax tax
jsr Cmd.GetArgX jsr Cmd.GetArgX
>SYSCALL GetEnv >SYSCALL GetEnv
bcc .1
clc
rts rts
>PUSHYA push value .1 >PUSHYA push value
>LDA.G CMD.Varname >LDA.G CMD.Varname
tax tax
jsr Cmd.GetArgX jsr Cmd.GetArgX
@ -498,19 +504,121 @@ Cmd.INT.RD ldx #1
>SYSCALL Remove >SYSCALL Remove
.99 rts .99 rts
.9 jmp Cmd.Exec.ERRSYN
*--------------------------------------
Cmd.INT.PUSHD
.9 jmp Cmd.Exec.ERRSYN
*--------------------------------------
Cmd.INT.POPD
.9 jmp Cmd.Exec.ERRSYN
*--------------------------------------
Cmd.INT.BREAK
.9 jmp Cmd.Exec.ERRSYN
*--------------------------------------
Cmd.INT.CONTINUE
.9 jmp Cmd.Exec.ERRSYN .9 jmp Cmd.Exec.ERRSYN
*-------------------------------------- *--------------------------------------
Cmd.INT.FOR Cmd.INT.FOR
.9 jmp Cmd.Exec.ERRSYN
*--------------------------------------
Cmd.INT.NEXT
.9 jmp Cmd.Exec.ERRSYN .9 jmp Cmd.Exec.ERRSYN
*-------------------------------------- *--------------------------------------
Cmd.INT.WHILE Cmd.INT.WHILE
Cmd.INT.IF ldx #1 Cmd.INT.IF jsr CMD.StkGet
bcs .1 no context...
and #$40 parent is true ?
bra .2
.1 lda #$40
.2 >STA.G CMD.Test
>DEBUG
jsr Cmd.Eval
bcs .9
tax
>LDA.G CMD.IntCmd
cmp #C.WHILE
bne .8
jsr CMD.StkPushPtr
bcs .9
.8 txa
>ORA.G CMD.Test
jmp CMD.StkPush
clc
.9 rts
*--------------------------------------
Cmd.INT.ELSE jsr CMD.StkGet
bcs .9
>DEBUG
bit #$40 parent is true ?
beq .8 yes, skip
tax
and #$3F
cmp #C.IF
bne .9
txa
eor #$80 toggle and store at stack ptr
sta (pData),y
.8 clc
rts
.9 lda #E.NOIF
sec
rts
*--------------------------------------
Cmd.INT.FI jsr CMD.StkPull
bcs .9
and #$3F
cmp #C.IF
bne .9
clc
rts
.9 lda #E.NOIF
sec
rts
*--------------------------------------
Cmd.INT.LOOP jsr CMD.StkPull
bcs .9
tax
and #$3F
cmp #C.WHILE
bne .9
txa
bpl .1
jmp CMD.StkPullPtr
.1 jsr CMD.StkPull
bcs .99
jmp CMD.StkPull
.9 lda #E.NOWHILE
sec
.99 rts
*--------------------------------------
Cmd.Eval lda #$40 Parent = true
>STA.G CMD.Test
ldx #1
jsr Cmd.GetArgX jsr Cmd.GetArgX
beq .9 beq .9
>PUSHYA >PUSHYA
>LDYA L.CMD.IF.TOKEN1 >LDYA L.CMD.Eval.TOKEN1
jsr Lookup jsr Lookup
bcs .9 bcs .9
@ -530,7 +638,7 @@ Cmd.INT.IF ldx #1
beq .9 beq .9
>PUSHYA >PUSHYA
>LDYA L.CMD.IF.TOKEN2 -d -e -f ? >LDYA L.CMD.Eval.TOKEN2 -d -e -f ?
jsr Lookup jsr Lookup
bcs .1 bcs .1
@ -538,7 +646,7 @@ Cmd.INT.IF ldx #1
txa txa
>STA.G CMD.Operator >STA.G CMD.Operator
jsr CMD.IF.UNARY jsr CMD.Eval.UNARY
bcs .9 bcs .9
>EOR.G CMD.Test >EOR.G CMD.Test
@ -556,13 +664,13 @@ Cmd.INT.IF ldx #1
beq .9 beq .9
>PUSHYA >PUSHYA
>LDYA L.CMD.IF.TOKEN3 -eq -ne .... ? >LDYA L.CMD.Eval.TOKEN3 -eq -ne .... ?
jsr Lookup jsr Lookup
bcs .9 bcs .9
txa txa
>STA.G CMD.Operator >STA.G CMD.Operator
jsr CMD.IF.BINARY jsr CMD.Eval.BINARY
bcs .9 bcs .9
>EOR.G CMD.Test >EOR.G CMD.Test
@ -582,66 +690,55 @@ Cmd.INT.IF ldx #1
ldy #1 ldy #1
lda (ZPPTR1),y lda (ZPPTR1),y
bne .9 bne .9
clc
>LDA.G CMD.IntCmd rts
cmp #C.WHILE
bne .81
tax
jsr CMD.StkPushPtr
bcs .99
txa
.81 >ORA.G CMD.Test
jmp CMD.StkPush
*-------------------------------------- *--------------------------------------
CMD.IF.UNARY ldx #3 CMD.Eval.UNARY ldx #3
jsr Cmd.GetArgX jsr Cmd.GetArgX
bcs .9 we need one arg bcs .9 we need one arg
>LDA.G CMD.Operator >LDA.G CMD.Operator
tax tax
jmp (J.CMD.IF.TOKEN2,x) jmp (J.CMD.Eval.TOKEN2,x)
.9 lda #E.SYNTAX .9 lda #E.SYNTAX
sec sec
rts rts
CMD.IF.D jsr CMD.IF.DEF.7 CMD.Eval.D jsr CMD.Eval.DEF.7
bcs CMD.IF.DEF.9 bcs CMD.Eval.DEF.9
>LDA.G CMD.Stat+S.STAT.P.TYPE >LDA.G CMD.Stat+S.STAT.P.TYPE
cmp #S.FI.T.DIR cmp #S.FI.T.DIR
bne CMD.IF.DEF.9 bne CMD.Eval.DEF.9
bra CMD.IF.DEF.8 bra CMD.Eval.DEF.8
CMD.IF.E jsr CMD.IF.DEF.7 CMD.Eval.E jsr CMD.Eval.DEF.7
bcs CMD.IF.DEF.9 bcs CMD.Eval.DEF.9
bra CMD.IF.DEF.8 DIR or FILE exist bra CMD.Eval.DEF.8 DIR or FILE exist
CMD.IF.F jsr CMD.IF.DEF.7 CMD.Eval.F jsr CMD.Eval.DEF.7
bcs CMD.IF.DEF.9 bcs CMD.Eval.DEF.9
>LDA.G CMD.Stat+S.STAT.P.TYPE >LDA.G CMD.Stat+S.STAT.P.TYPE
cmp #S.FI.T.DIR cmp #S.FI.T.DIR
beq CMD.IF.DEF.9 beq CMD.Eval.DEF.9
bra CMD.IF.DEF.8 bra CMD.Eval.DEF.8
CMD.IF.DEF.7 >PUSHEA.G CMD.Stat CMD.Eval.DEF.7 >PUSHEA.G CMD.Stat
ldx #3 ldx #3
jsr Cmd.GetArgX jsr Cmd.GetArgX
>SYSCALL STAT >SYSCALL STAT
rts rts
CMD.IF.DEF.8 lda #$80 true CMD.Eval.DEF.8 lda #$80 true
clc clc
rts rts
CMD.IF.DEF.9 lda #0 false CMD.Eval.DEF.9 lda #0 false
clc clc
rts rts
*-------------------------------------- *--------------------------------------
CMD.IF.BINARY ldx #2 CMD.Eval.BINARY ldx #2
jsr Cmd.GetArgX jsr Cmd.GetArgX
bcs .9 bcs .9
@ -653,7 +750,7 @@ CMD.IF.BINARY ldx #2
beq .1 = beq .1 =
cmp #2 != cmp #2 !=
bne CMD.IF.BINARY.NUM bne CMD.Eval.BINARY.NUM
lda #$80 lda #$80
>STA.G CMD.Operator >STA.G CMD.Operator
@ -669,11 +766,11 @@ CMD.IF.BINARY ldx #2
clc clc
rts rts
.9 lda #E.SYN .9 lda #E.SYNTAX
sec sec
rts rts
*-------------------------------------- *--------------------------------------
CMD.IF.BINARY.NUM CMD.Eval.BINARY.NUM
ldx #2 ldx #2
jsr Cmd.GetArgX jsr Cmd.GetArgX
bcs .9 bcs .9
@ -699,7 +796,7 @@ CMD.IF.BINARY.NUM
lsr lsr
tax tax
pla pla
eor CMD.IF.TOKEN3.BITS,x eor CMD.Eval.TOKEN3.BITS,x
bne .80 bne .80
lda #$80 true lda #$80 true
@ -714,66 +811,6 @@ CMD.IF.BINARY.NUM
sec sec
rts rts
*-------------------------------------- *--------------------------------------
Cmd.INT.ELSE jsr CMD.StkGet
bcs .9
pha
and #$7F
cmp #C.IF
bne .9
pla
eor #$80
sta (pData),y
clc
rts
.9 pla
lda #E.SYNTAX
sec
rts
*--------------------------------------
Cmd.INT.FI jsr CMD.StkPull
bcs .9
and #$7F
cmp #C.IF
bne .9
clc
rts
.9 lda #E.SYNTAX
sec
rts
*--------------------------------------
Cmd.INT.NEXT
.9 jmp Cmd.Exec.ERRSYN
*--------------------------------------
Cmd.INT.BREAK
.9 jmp Cmd.Exec.ERRSYN
*--------------------------------------
Cmd.INT.LOOP jsr CMD.StkPull
bcs .9
tax
and #$7F
cmp #C.WHILE
bne .9
txa
bpl .1
jmp CMD.StkPullPtr
.1 jsr CMD.StkPull
bcs .99
jmp CMD.StkPull
.9 lda #E.NOWHILE
sec
.99 rts
*--------------------------------------
Cmd.GetEXP >LDA.G CMD.ArgIndex Cmd.GetEXP >LDA.G CMD.ArgIndex
inc inc
tax tax
@ -796,7 +833,7 @@ Cmd.GetEXP >LDA.G CMD.ArgIndex
jsr Cmd.GetEXP.GetNext jsr Cmd.GetEXP.GetNext
.2 >PUSHYA .2 >PUSHYA
>LDYA L.CMD.IF.TOKEN4 + - .... ? >LDYA L.CMD.Eval.TOKEN4 + - .... ?
jsr Lookup jsr Lookup
bcs .9 bcs .9
@ -834,7 +871,7 @@ Cmd.GetEXP >LDA.G CMD.ArgIndex
Cmd.GetEXP.Op >LDA.G CMD.Operator Cmd.GetEXP.Op >LDA.G CMD.Operator
tax tax
jmp (J.CMD.IF.TOKEN4,x) jmp (J.CMD.Eval.TOKEN4,x)
*-------------------------------------- *--------------------------------------
Cmd.GetEXP.GetNext Cmd.GetEXP.GetNext
>INC.G CMD.ArgIndex >INC.G CMD.ArgIndex

View File

@ -11,31 +11,35 @@ CSH .EQ 0
CL.MAX .EQ 127 CL.MAX .EQ 127
History.MAX .EQ 256 History.MAX .EQ 256
CMD.STACK.MAX .EQ 64 CMD.STACK.MAX .EQ 64
PUSHD.STACK.MAX .EQ 8
*-------------------------------------- *--------------------------------------
C.STARTPROC .EQ 0 C.STARTPROC .EQ 0
C.BREAK .EQ 2 C.CD .EQ 2
C.CD .EQ 4 C.DATE .EQ 4
C.DATE .EQ 6 C.ECHO .EQ 6
C.ECHO .EQ 8 C.EXIT .EQ 8
C.EXIT .EQ 10 C.MD .EQ 10
C.FOR .EQ 12 C.PAUSE .EQ 12
C.IF .EQ 14 C.PWD .EQ 14
C.MD .EQ 16 C.RD .EQ 16
C.PAUSE .EQ 18 C.READ .EQ 18
C.PWD .EQ 20 C.REN .EQ 20
C.RD .EQ 22 C.SET .EQ 22
C.READ .EQ 24 C.SLEEP .EQ 24
C.REN .EQ 26 C.SHIFT .EQ 26
C.SET .EQ 28 C.TIME .EQ 28
C.SLEEP .EQ 30 C.PUSHD .EQ 30
C.SHIFT .EQ 32 C.POPD .EQ 32
C.TIME .EQ 34 C.BREAK .EQ 34
C.WHILE .EQ 36 C.CONTINUE .EQ 36
C.NEXT .EQ 38
C.LOOP .EQ 40
*-------------------------------------- *--------------------------------------
C.ELSE .EQ 42 C.FOR .EQ 38
C.FI .EQ 44 C.NEXT .EQ 40
C.WHILE .EQ 42
C.LOOP .EQ 44
C.IF .EQ 46
C.ELSE .EQ 48
C.FI .EQ 50
*-------------------------------------- *--------------------------------------
E.SYNTAX .EQ $C0 E.SYNTAX .EQ $C0
E.STKOVERFLOW .EQ $C1 E.STKOVERFLOW .EQ $C1
@ -43,6 +47,7 @@ E.NOWHILE .EQ $C2
E.NOFOR .EQ $C3 E.NOFOR .EQ $C3
E.NOIF .EQ $C4 E.NOIF .EQ $C4
E.BADEXP .EQ $C5 E.BADEXP .EQ $C5
E.BADFTYPE .EQ $C6
*-------------------------------------- *--------------------------------------
.INB INC/MACROS.I .INB INC/MACROS.I
.INB INC/A2OSX.I .INB INC/A2OSX.I
@ -119,13 +124,10 @@ J.CL.IO .DA CL.IO.AMP
.DA CL.IO.2OUT .DA CL.IO.2OUT
L.CMD.INT .DA CMD.INT L.CMD.INT .DA CMD.INT
J.CMD.INT .DA Cmd.INT.STARTPROC J.CMD.INT .DA Cmd.INT.STARTPROC
.DA Cmd.INT.BREAK
.DA Cmd.INT.CD .DA Cmd.INT.CD
.DA Cmd.INT.DATE .DA Cmd.INT.DATE
.DA Cmd.INT.ECHO .DA Cmd.INT.ECHO
.DA Cmd.INT.EXIT .DA Cmd.INT.EXIT
.DA Cmd.INT.FOR
.DA Cmd.INT.IF
.DA Cmd.INT.MD .DA Cmd.INT.MD
.DA Cmd.INT.PAUSE .DA Cmd.INT.PAUSE
.DA Cmd.INT.PWD .DA Cmd.INT.PWD
@ -136,19 +138,25 @@ J.CMD.INT .DA Cmd.INT.STARTPROC
.DA Cmd.INT.SLEEP .DA Cmd.INT.SLEEP
.DA Cmd.INT.SHIFT .DA Cmd.INT.SHIFT
.DA Cmd.INT.TIME .DA Cmd.INT.TIME
.DA Cmd.INT.WHILE .DA Cmd.INT.PUSHD
.DA Cmd.INT.POPD
.DA Cmd.INT.BREAK
.DA Cmd.INT.CONTINUE
.DA Cmd.INT.FOR
.DA Cmd.INT.NEXT .DA Cmd.INT.NEXT
.DA Cmd.INT.WHILE
.DA Cmd.INT.LOOP .DA Cmd.INT.LOOP
.DA Cmd.INT.IF
.DA Cmd.INT.ELSE .DA Cmd.INT.ELSE
.DA Cmd.INT.FI .DA Cmd.INT.FI
L.CMD.IF.TOKEN1 .DA CMD.IF.TOKEN1 L.CMD.Eval.TOKEN1 .DA CMD.Eval.TOKEN1
L.CMD.IF.TOKEN2 .DA CMD.IF.TOKEN2 L.CMD.Eval.TOKEN2 .DA CMD.Eval.TOKEN2
J.CMD.IF.TOKEN2 .DA CMD.IF.D J.CMD.Eval.TOKEN2 .DA CMD.Eval.D
.DA CMD.IF.E .DA CMD.Eval.E
.DA CMD.IF.F .DA CMD.Eval.F
L.CMD.IF.TOKEN3 .DA CMD.IF.TOKEN3 L.CMD.Eval.TOKEN3 .DA CMD.Eval.TOKEN3
L.CMD.IF.TOKEN4 .DA CMD.IF.TOKEN4 L.CMD.Eval.TOKEN4 .DA CMD.Eval.TOKEN4
J.CMD.IF.TOKEN4 .DA M32.Add J.CMD.Eval.TOKEN4 .DA M32.Add
.DA M32.Sub .DA M32.Sub
.DA M32.Mul .DA M32.Mul
.DA M32.Div .DA M32.Div
@ -578,13 +586,10 @@ CL.IO .AZ "&"
.HS 00 .HS 00
*-------------------------------------- *--------------------------------------
CMD.INT .AZ "STARTPROC" CMD.INT .AZ "STARTPROC"
.AZ "BREAK"
.AZ "CD" .AZ "CD"
.AZ "DATE" .AZ "DATE"
.AZ "ECHO" .AZ "ECHO"
.AZ "EXIT" .AZ "EXIT"
.AZ "FOR"
.AZ "IF"
.AZ "MD" .AZ "MD"
.AZ "PAUSE" .AZ "PAUSE"
.AZ "PWD" .AZ "PWD"
@ -595,21 +600,27 @@ CMD.INT .AZ "STARTPROC"
.AZ "SLEEP" .AZ "SLEEP"
.AZ "SHIFT" .AZ "SHIFT"
.AZ "TIME" .AZ "TIME"
.AZ "WHILE" .AZ "PUSHD"
.AZ "POPD"
.AZ "BREAK"
.AZ "CONTINUE"
.AZ "FOR"
.AZ "NEXT" .AZ "NEXT"
.AZ "WHILE"
.AZ "LOOP" .AZ "LOOP"
.AZ "IF"
.AZ "ELSE" .AZ "ELSE"
.AZ "FI" .AZ "FI"
.HS 00 .HS 00
*-------------------------------------- *--------------------------------------
CMD.IF.TOKEN1 .AZ "![" CMD.Eval.TOKEN1 .AZ "!["
.AZ "[" .AZ "["
.HS 00 .HS 00
CMD.IF.TOKEN2 .AZ "-d" CMD.Eval.TOKEN2 .AZ "-d"
.AZ "-e" .AZ "-e"
.AZ "-f" .AZ "-f"
.HS 00 .HS 00
CMD.IF.TOKEN3 .AZ "=" CMD.Eval.TOKEN3 .AZ "="
.AZ "!=" .AZ "!="
.AZ "-eq" .AZ "-eq"
.AZ "-ne" .AZ "-ne"
@ -618,13 +629,7 @@ CMD.IF.TOKEN3 .AZ "="
.AZ "-gt" .AZ "-gt"
.AZ "-ge" .AZ "-ge"
.HS 00 .HS 00
CMD.IF.TOKEN4 .AZ "+" CMD.Eval.TOKEN3.BITS
.AZ "-"
.AZ "*"
.AZ "div"
.AZ "mod"
.HS 00
CMD.IF.TOKEN3.BITS
.DA #%000 .DA #%000
.DA #%000 .DA #%000
.DA #%001 .DA #%001
@ -633,6 +638,12 @@ CMD.IF.TOKEN3.BITS
.DA #%101 .DA #%101
.DA #%010 .DA #%010
.DA #%011 .DA #%011
CMD.Eval.TOKEN4 .AZ "+"
.AZ "-"
.AZ "*"
.AZ "div"
.AZ "mod"
.HS 00
*-------------------------------------- *--------------------------------------
.DO CSH=1 .DO CSH=1
.INB USR/SRC/BIN/SHELL.C.CSH .INB USR/SRC/BIN/SHELL.C.CSH
@ -647,7 +658,8 @@ M32.Printf .AZ "%L"
.DUMMY .DUMMY
.OR 0 .OR 0
DS.START DS.START
CMD.STACK .BS CMD.STACK.MAX pData (0 = Stack Ptr) CMD.STACK .BS CMD.STACK.MAX+1 pData (0 = Stack Ptr)
PUSHD.STACK .BS PUSHD.STACK.MAX+1
hFileBuf .BS 1 batch mode hFileBuf .BS 1 batch mode
hVarName .BS 1 read mode hVarName .BS 1 read mode