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
beq CL.CheckCmd.SYS
lda #E.SYN
lda #E.BADFTYPE
sec
CL.CheckCmd.90 php
@ -479,12 +479,6 @@ CL.CheckCmd.90 php
CL.CheckCmd.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"
*--------------------------------------
CL.CheckCmd.BIN >LDA.G CMD.hCmdLine
@ -580,7 +574,7 @@ CL.IO.Open pha
rts
.9 pla
lda #E.SYN
lda #E.SYNTAX
sec
rts
*--------------------------------------

View File

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

View File

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