mirror of
https://github.com/A2osX/A2osX.git
synced 2025-04-05 10:39:33 +00:00
Kernel 0.93
This commit is contained in:
parent
cdd1d64001
commit
4dbd36cb7b
@ -61,6 +61,7 @@ where [ exp ] and [ condition ] allow to detail operators....
|
||||
| \<op\> | Working | \+ signed int32 add <br> \- signed int32 sub <br> \* <br> / <br> mod |
|
||||
| \<condition\> | Working |[ -D direxists ] <br> [ -E fileordirexists ] <br> [ -F fileexists ]<br> [ -N $VAR variable is not empty ] <br> [ -Z $VAR variable is empty ] <br> [ string1 = string2 ] <br> [ string1 != string2 ] <br> [ string1 .< string2 ] <br> [ string1 <= string2 ] <br> [ string1 .> string2 ] <br> [ string1 >= string2 ] <br> [ int32 -eq int32 ] <br> [ int32 -ne int32 ] <br> [ int32 -lt int32 ] <br> [ int32 -le int32 ] <br> [ int32 -gt int32 ] <br> [ int32 -ge int32 ] |
|
||||
| BREAK | Working | Exit CASE of SWITCH |
|
||||
| CALL | Working | CALL function <arg> ... |
|
||||
| CASE | Working | CASE <expression> |
|
||||
| CD | Working | CD path or relative path |
|
||||
| DATE | Working | |
|
||||
@ -80,7 +81,7 @@ where [ exp ] and [ condition ] allow to detail operators....
|
||||
| PUSHD | Working | Save actual working directory <br> PUSHD \<dir\> do also a CD to \<dir\> |
|
||||
| PWD | Working | Print Working Directory |
|
||||
| RD | Working | Delete an empty directory |
|
||||
| READ | Working | -S : no echo (password) <br> -P : "prompt message" |
|
||||
| READ | Working | -F : Undefine all functions <br> -S : no echo (password) <br> -P : "prompt message" |
|
||||
| REN | Working | Rename a file, directory or volume |
|
||||
| RETURN | In Progress | Exit function with return code |
|
||||
| SET | Working | -X : toggle debug mode <br> -C : toggle Control-C break mode |
|
||||
|
Binary file not shown.
@ -228,17 +228,25 @@ CMD.SET.1
|
||||
cmp #'C'
|
||||
bne .2
|
||||
|
||||
>LDA.G bSET.C
|
||||
ldy #bSET.C
|
||||
bra .5
|
||||
|
||||
.2 cmp #'X'
|
||||
bne .3
|
||||
|
||||
ldy #bSET.X
|
||||
bra .5
|
||||
|
||||
.3 cmp #'F'
|
||||
bne .99
|
||||
|
||||
>LDA.G bSET.X
|
||||
jsr CORE.FUNCRESET
|
||||
bra .50
|
||||
|
||||
.5 eor #$ff
|
||||
.5 lda (pData),y
|
||||
eor #$ff
|
||||
sta (pData),y
|
||||
jsr CORE.ArgV.Next
|
||||
.50 jsr CORE.ArgV.Next
|
||||
bne .1
|
||||
clc
|
||||
rts
|
||||
@ -564,18 +572,31 @@ CMD.FUNC lda (ZPArgVBufPtr)
|
||||
lda #$ff
|
||||
>STA.G bFuncMode
|
||||
clc
|
||||
rts
|
||||
.99 rts
|
||||
|
||||
.9 jmp CMD.Exec.CSYN
|
||||
.99 rts
|
||||
*--------------------------------------
|
||||
CMD.RETURN
|
||||
.9 jmp CMD.Exec.CSYN
|
||||
CMD.RETURN lda (ZPArgVBufPtr)
|
||||
beq .8 no arg, exit 0
|
||||
|
||||
>LDYA ZPArgVBufPtr
|
||||
>SYSCALL AToL
|
||||
bcs .9
|
||||
|
||||
>PULLL M32.ACC
|
||||
lda M32.ACC
|
||||
|
||||
.8 pha
|
||||
lda #$FF
|
||||
>STA.G bExit
|
||||
pla
|
||||
clc
|
||||
.9 rts
|
||||
*--------------------------------------
|
||||
CMD.CALL >LDA.G hFuncList
|
||||
beq .9
|
||||
|
||||
>PUSHW ZPInputBufPtr
|
||||
|
||||
>PUSHW ZPArgVBufPtr
|
||||
>LDA.G hFuncList
|
||||
>SYSCALL SListLookup
|
||||
bcs .9
|
||||
@ -589,13 +610,7 @@ CMD.CALL >LDA.G hFuncList
|
||||
>LDA.G hFuncList
|
||||
>SYSCALL SListGetData
|
||||
bcs .99
|
||||
txa
|
||||
pha
|
||||
>SYSCALL GetMemPtr
|
||||
pla
|
||||
>SYSCALL freemem
|
||||
rts
|
||||
|
||||
jmp CORE.CALL
|
||||
|
||||
.9 lda #E.FUNDEF
|
||||
sec
|
||||
|
@ -12,16 +12,17 @@ CORE.Init >LDYAI 256
|
||||
|
||||
.9 rts
|
||||
*--------------------------------------
|
||||
CORE.Quit >LDA.G hFuncList
|
||||
beq .1
|
||||
|
||||
>SYSCALL SListFree
|
||||
|
||||
.1 >LDA.G CORE.hArgVBuf
|
||||
beq .9
|
||||
CORE.Quit >LDA.G CORE.hArgVBuf
|
||||
beq CORE.FUNCRESET
|
||||
>SYSCALL FreeMem
|
||||
|
||||
.9 rts
|
||||
CORE.FUNCRESET >LDA.G hFuncList
|
||||
beq CORE.Quit.9
|
||||
|
||||
>SYSCALL SListFree
|
||||
>STZ.G hFuncList
|
||||
|
||||
CORE.Quit.9 rts
|
||||
*--------------------------------------
|
||||
* http://heirloom.sourceforge.net/sh/sh.1.html
|
||||
*--------------------------------------
|
||||
@ -71,6 +72,9 @@ CORE.Run >LDYA ZPInputBufPtr Save Actual cmd for looping
|
||||
|
||||
jsr CORE.GetCharNB
|
||||
bcc .11
|
||||
|
||||
jsr CORE.RETURN
|
||||
bcs .9
|
||||
|
||||
jsr IO.Reset
|
||||
lda #0
|
||||
@ -227,11 +231,7 @@ CORE.ExecExtCmd >LDA.G CORE.CmdFile
|
||||
bpl .1
|
||||
|
||||
>LDYA ZPArgVBufPtr
|
||||
>SYSCALL puts
|
||||
>DEBUG
|
||||
|
||||
>LDYA ZPArgVBufPtr
|
||||
jsr IO.FILECALL.NOQUIT
|
||||
jsr CORE.FCALL.NOQUIT
|
||||
bra CORE.ExecExtCmd.Exit
|
||||
|
||||
.1 >PUSHB.G CORE.PSFlags
|
||||
@ -565,6 +565,85 @@ CORE.IO.Open pha Open Mode
|
||||
lda #E.SYN
|
||||
sec
|
||||
rts
|
||||
*--------------------------------------
|
||||
CORE.FCALL.QUIT sec
|
||||
.HS 90 BCC
|
||||
CORE.FCALL.NOQUIT
|
||||
clc
|
||||
|
||||
>STYA ZPPtr1 Filename
|
||||
|
||||
lda #0
|
||||
ror
|
||||
>STA.G bExitOnEOF
|
||||
|
||||
>PUSHWI 0 Aux type
|
||||
>PUSHBI S.FI.T.TXT
|
||||
>PUSHBI O.RDONLY
|
||||
|
||||
>LDYA ZPPtr1
|
||||
>SYSCALL LoadTxtFile
|
||||
bcs CORE.CALL.9
|
||||
|
||||
CORE.CALL lda ZPInputBuf X=hBuf
|
||||
jsr CORE.StkPush
|
||||
bcs CORE.CALL.9
|
||||
|
||||
lda ZPInputBuf+1
|
||||
jsr CORE.StkPush
|
||||
bcs CORE.CALL.9
|
||||
|
||||
lda ZPInputBufPtr
|
||||
jsr CORE.StkPush
|
||||
bcs CORE.CALL.9
|
||||
|
||||
lda ZPInputBufPtr+1
|
||||
jsr CORE.StkPush
|
||||
bcs CORE.CALL.9
|
||||
|
||||
txa
|
||||
jsr CORE.StkPush
|
||||
bcs CORE.CALL.9
|
||||
|
||||
txa
|
||||
>SYSCALL GetMemPtr
|
||||
>STYA ZPInputBuf
|
||||
>STYA ZPInputBufPtr
|
||||
|
||||
lda #$C0
|
||||
jmp CORE.StkPush
|
||||
|
||||
CORE.CALL.90 lda #E.STKOVERFLOW
|
||||
sec
|
||||
CORE.CALL.9 rts
|
||||
*--------------------------------------
|
||||
CORE.RETURN jsr CORE.StkPull
|
||||
bcs .90
|
||||
|
||||
cmp #$C0
|
||||
bne .90
|
||||
|
||||
jsr CORE.StkPull
|
||||
>SYSCALL freemem
|
||||
|
||||
jsr CORE.StkPull
|
||||
sta ZPInputBufPtr+1
|
||||
|
||||
jsr CORE.StkPull
|
||||
sta ZPInputBufPtr
|
||||
|
||||
jsr CORE.StkPull
|
||||
sta ZPInputBuf+1
|
||||
|
||||
jsr CORE.StkPull
|
||||
sta ZPInputBuf
|
||||
|
||||
* clc
|
||||
rts
|
||||
|
||||
.90 lda #E.STACKERROR
|
||||
sec
|
||||
rts
|
||||
*--------------------------------------
|
||||
* Input Buffer
|
||||
*--------------------------------------
|
||||
@ -640,7 +719,7 @@ CORE.StkPushPtr bcs .1
|
||||
.2 jsr CORE.StkPush
|
||||
bcs CORE.StkPullPtr.9
|
||||
txa
|
||||
bra CORE.StkPush
|
||||
bra CORE.StkPush
|
||||
*--------------------------------------
|
||||
CORE.StkPullPtr jsr CORE.StkPull
|
||||
bcs CORE.StkPullPtr.9
|
||||
@ -691,6 +770,8 @@ CORE.StkPush pha
|
||||
CORE.StkGetCtx jsr CORE.StkGet
|
||||
tax
|
||||
bcs .1 no context...
|
||||
cmp #$C0 in a call...
|
||||
beq .1 CS
|
||||
|
||||
and #$80 get current..
|
||||
lsr becomes parent
|
||||
@ -699,6 +780,7 @@ CORE.StkGetCtx jsr CORE.StkGet
|
||||
.1 lda #$40 ...set Parent = true
|
||||
|
||||
.2 >STA.G CORE.Test
|
||||
|
||||
txa
|
||||
rts
|
||||
*--------------------------------------
|
||||
|
@ -62,7 +62,11 @@ EXP.GET.OP >LDA.G CORE.Operator
|
||||
EXP.TEST lda (ZPArgVBufPtr)
|
||||
beq .9
|
||||
|
||||
>LDYA L.EXP.BEGIN
|
||||
lda #$ff
|
||||
>STA.G CORE.TestArg True
|
||||
>STA.G CORE.TestOp no op
|
||||
|
||||
.10 >LDYA L.EXP.BEGIN
|
||||
jsr CORE.LookupArgVBuf
|
||||
|
||||
bcs .9
|
||||
@ -125,7 +129,36 @@ EXP.TEST lda (ZPArgVBufPtr)
|
||||
ldy #1
|
||||
lda (ZPArgVBufPtr),y
|
||||
bne .9
|
||||
clc
|
||||
|
||||
jsr CORE.ArgV.Next
|
||||
beq .82
|
||||
|
||||
>LDYA L.EXP.OP.LOGIC
|
||||
jsr CORE.LookupArgVBuf
|
||||
bcs .9
|
||||
|
||||
txa
|
||||
>STA.G CORE.TestOp
|
||||
>LDA.G CORE.Test
|
||||
>STA.G CORE.TestArg
|
||||
txa
|
||||
bne .81 OR...
|
||||
tay AND : stop if already false
|
||||
bpl .88
|
||||
|
||||
.81 jsr CORE.ArgV.Next
|
||||
beq .9
|
||||
|
||||
jmp .10
|
||||
|
||||
.82 >LDA.G CORE.TestOp
|
||||
bmi .88
|
||||
|
||||
>LDA.G CORE.Test
|
||||
>ORA.G CORE.TestArg
|
||||
>STA.G CORE.Test
|
||||
|
||||
.88 clc
|
||||
rts
|
||||
*--------------------------------------
|
||||
EXP.TEST.UNARY jsr CORE.ArgV.Next
|
||||
@ -265,11 +298,6 @@ EXP.TEST.BINARY.END
|
||||
clc
|
||||
rts
|
||||
*--------------------------------------
|
||||
EXP.OP.AND
|
||||
EXP.OP.OR
|
||||
clc
|
||||
rts
|
||||
*--------------------------------------
|
||||
MAN
|
||||
SAVE USR/SRC/BIN/SH.S.EXP
|
||||
LOAD USR/SRC/BIN/SH.S
|
||||
|
@ -3,97 +3,11 @@ PREFIX
|
||||
AUTO 4,1
|
||||
.LIST OFF
|
||||
*--------------------------------------
|
||||
IO.Init lda #FILECALL.STACK
|
||||
>STA.G FILECALL.STACK
|
||||
rts
|
||||
*--------------------------------------
|
||||
IO.Reset jsr IO.Reset.In
|
||||
jsr IO.Reset.Out
|
||||
jsr IO.Reset.Err
|
||||
IO.Reset.9 rts
|
||||
*--------------------------------------
|
||||
IO.FILECALL.QUIT sec
|
||||
.HS 90 BCC
|
||||
IO.FILECALL.NOQUIT clc
|
||||
|
||||
>STYA ZPPtr1 Filename
|
||||
|
||||
lda #0
|
||||
ror
|
||||
>STA.G bExitOnEOF
|
||||
|
||||
>LDA.G FILECALL.STACK
|
||||
cmp #FILECALL.STACK+FILECALL.STACK.MAX*3
|
||||
beq .90
|
||||
|
||||
>PUSHWI 0 Aux type
|
||||
>PUSHBI S.FI.T.TXT
|
||||
>PUSHBI O.RDONLY
|
||||
|
||||
>LDYA ZPPtr1
|
||||
>SYSCALL LoadTxtFile
|
||||
bcs .9
|
||||
|
||||
>LDA.G FILECALL.STACK
|
||||
tay
|
||||
|
||||
iny
|
||||
lda ZPInputBufPtr+1
|
||||
sta (pData),y
|
||||
iny
|
||||
lda ZPInputBufPtr
|
||||
sta (pData),y
|
||||
iny
|
||||
txa
|
||||
sta (pData),y
|
||||
|
||||
tya
|
||||
>STA.G FILECALL.STACK
|
||||
|
||||
txa
|
||||
>SYSCALL GetMemPtr
|
||||
>STYA ZPInputBuf
|
||||
>STYA ZPInputBufPtr
|
||||
|
||||
lda #$ff
|
||||
>STA.G bBatchMode
|
||||
*
|
||||
* clc
|
||||
rts
|
||||
|
||||
.90 lda #E.STKOVERFLOW
|
||||
sec
|
||||
.9 rts
|
||||
*--------------------------------------
|
||||
IO.FEXIT >LDA.G FILECALL.STACK
|
||||
cmp #FILECALL.STACK
|
||||
beq .90
|
||||
|
||||
tay
|
||||
dey
|
||||
lda (pData),y
|
||||
tax hBuf
|
||||
|
||||
dey
|
||||
lda (pData),y
|
||||
sta ZPInputBufPtr
|
||||
|
||||
dey
|
||||
lda (pData),y
|
||||
sta ZPInputBufPtr+1
|
||||
|
||||
tya
|
||||
>STA.G FILECALL.STACK
|
||||
txa
|
||||
>SYSCALL GetMemPtr
|
||||
>STYA ZPInputBuf
|
||||
* clc
|
||||
rts
|
||||
|
||||
.90 lda #E.STACKERROR
|
||||
sec
|
||||
rts
|
||||
*--------------------------------------
|
||||
IO.Pipe.In >LDA.G IO.hOut
|
||||
ldy #S.PS.hStdOut
|
||||
sta (pPS),y
|
||||
|
80
BIN/SH.S.txt
80
BIN/SH.S.txt
@ -7,9 +7,8 @@ AUTO 4,1
|
||||
.TF BIN/SH
|
||||
*--------------------------------------
|
||||
HISTORY.MAX .EQ 256
|
||||
CORE.STACK.MAX .EQ 64
|
||||
CORE.STACK.MAX .EQ 128
|
||||
PUSHD.STACK.MAX .EQ 8
|
||||
FILECALL.STACK.MAX .EQ 8
|
||||
*--------------------------------------
|
||||
C.NOHUP .EQ 0
|
||||
C.CD .EQ 1
|
||||
@ -188,8 +187,6 @@ J.EXP.OP.MATH .DA M32.Add
|
||||
.DA M32.Div
|
||||
.DA M32.Mod
|
||||
L.EXP.OP.LOGIC .DA EXP.OP.LOGIC
|
||||
J.EXP.OP.LOGIC .DA EXP.OP.AND
|
||||
.DA EXP.OP.OR
|
||||
L.HOME.PROFILE .DA HOME.PROFILE
|
||||
L.M32.Printf .DA M32.Printf
|
||||
L.ERR.Codes .DA ERR.Codes
|
||||
@ -202,7 +199,6 @@ CS.INIT.RTS rts
|
||||
*--------------------------------------
|
||||
CS.RUN jsr CL.Init
|
||||
jsr CORE.Init
|
||||
jsr IO.Init
|
||||
|
||||
ldy #S.PS.ARGC
|
||||
lda (pPS),y
|
||||
@ -211,12 +207,15 @@ CS.RUN jsr CL.Init
|
||||
lda #1
|
||||
>SYSCALL ArgV
|
||||
|
||||
jsr IO.FILECALL.QUIT Exec file an exit
|
||||
jsr CORE.FCALL.QUIT Exec file an exit
|
||||
bcs CS.INIT.RTS
|
||||
|
||||
lda #0
|
||||
jsr CMD.SHIFTA Remove $0=/bin/sh
|
||||
|
||||
lda #$ff
|
||||
>STA.G bBatchMode
|
||||
|
||||
bra CS.RUN.LOOP
|
||||
*--------------------------------------
|
||||
.1 jsr CMD.CD.HOME
|
||||
@ -235,7 +234,7 @@ CS.RUN jsr CL.Init
|
||||
bcs CS.RUN.LOOP no profile...
|
||||
|
||||
>LDYA L.HOME.PROFILE
|
||||
jsr IO.FILECALL.NOQUIT exec profile and continue
|
||||
jsr CORE.FCALL.NOQUIT exec profile and continue
|
||||
|
||||
* bcs CS.RUN.LOOP
|
||||
*--------------------------------------
|
||||
@ -300,15 +299,8 @@ CS.RUN.LOOP >SLEEP
|
||||
.9 rts
|
||||
*--------------------------------------
|
||||
CS.RUN.INTERACTIVE
|
||||
>LDA.G hInputBuf some commmands left in buffer
|
||||
beq .10
|
||||
|
||||
lda (ZPInputBufPtr)
|
||||
lda (pData) some commmands left in buffer
|
||||
bne .6
|
||||
|
||||
>LDA.G hInputBuf
|
||||
>SYSCALL freemem
|
||||
>STZ.G hInputBuf
|
||||
|
||||
.10 jsr IO.Reset
|
||||
jsr CL.Reset
|
||||
@ -339,10 +331,8 @@ CS.RUN.INTERACTIVE
|
||||
>LDYA ZPCLBuf
|
||||
>SYSCALL strdup
|
||||
bcs .8
|
||||
>STYA ZPInputBuf
|
||||
>STYA ZPInputBufPtr
|
||||
txa
|
||||
>STA.G hInputBuf
|
||||
|
||||
jsr CORE.CALL
|
||||
|
||||
.6 jsr CORE.Run
|
||||
|
||||
@ -385,30 +375,30 @@ CS.RUN.READ jsr CL.RESET
|
||||
CS.RUN.READ.9 rts
|
||||
*--------------------------------------
|
||||
CS.RUN.BATCH
|
||||
* ldy #S.PS.hStdIn
|
||||
* lda (pPS),y
|
||||
* >SYSCALL feof
|
||||
* bcs .2 unsupported
|
||||
ldy #S.PS.hStdIn
|
||||
lda (pPS),y
|
||||
>SYSCALL feof
|
||||
bcs .2 unsupported
|
||||
|
||||
* tay
|
||||
* beq .2
|
||||
tay
|
||||
beq .2
|
||||
|
||||
* >SYSCALL GetChar
|
||||
* bcs CS.RUN.READ.9
|
||||
>SYSCALL GetChar
|
||||
bcs CS.RUN.READ.9
|
||||
|
||||
* cmp #3 test Ctrl-c
|
||||
* bne .1
|
||||
cmp #3 test Ctrl-c
|
||||
bne .1
|
||||
|
||||
* sec
|
||||
* rts
|
||||
sec
|
||||
rts
|
||||
|
||||
*.1 cmp #19 test Ctrl-s
|
||||
* bne .2
|
||||
.1 cmp #19 test Ctrl-s
|
||||
bne .2
|
||||
|
||||
* lda #$80
|
||||
* >STA.G bPause
|
||||
* clc
|
||||
* jmp CS.RUN.LOOP.END
|
||||
lda #$80
|
||||
>STA.G bPause
|
||||
clc
|
||||
jmp CS.RUN.LOOP.END
|
||||
|
||||
.2 >LDA.G bSET.X
|
||||
beq .5
|
||||
@ -436,7 +426,7 @@ CS.RUN.BATCH
|
||||
bne CS.RUN.LOOP.END
|
||||
|
||||
pha
|
||||
jsr IO.FEXIT
|
||||
jsr CORE.RETURN
|
||||
|
||||
>LDA.G bExitOnEOF
|
||||
>STA.G bExit
|
||||
@ -494,12 +484,7 @@ CS.DOEVENT lda (pEvent)
|
||||
.9 sec
|
||||
rts
|
||||
*--------------------------------------
|
||||
CS.QUIT >LDA.G hInputBuf
|
||||
beq .1
|
||||
|
||||
>SYSCALL FreeMem
|
||||
|
||||
.1 jsr HIS.Quit
|
||||
CS.QUIT jsr HIS.Quit
|
||||
jsr CL.Quit
|
||||
jsr CORE.Quit
|
||||
clc
|
||||
@ -693,12 +678,9 @@ M32.Printf .AZ "%L"
|
||||
DS.START
|
||||
CORE.STACK .BS CORE.STACK.MAX+1 pData (0 = Stack Ptr)
|
||||
PUSHD.STACK .BS PUSHD.STACK.MAX+1
|
||||
FILECALL.STACK .BS FILECALL.STACK.MAX*3+1
|
||||
|
||||
hFuncList .BS 1
|
||||
|
||||
hInputBuf .BS 1
|
||||
|
||||
bReadMode .BS 1
|
||||
bBatchMode .BS 1
|
||||
bFuncMode .BS 1
|
||||
@ -726,10 +708,12 @@ CORE.IntCmd .BS 1
|
||||
CORE.CmdFile .BS 1
|
||||
CORE.hArgVBuf .BS 1
|
||||
|
||||
CORE.PSFlags .BS 1
|
||||
CORE.ArgIndex .BS 1
|
||||
CORE.Test .BS 1
|
||||
CORE.TestOp .BS 1
|
||||
CORE.TestArg .BS 1
|
||||
CORE.Operator .BS 1
|
||||
CORE.PSFlags .BS 1
|
||||
|
||||
HIS.hBuf .BS 1
|
||||
HIS.Count .BS 1
|
||||
|
@ -41,6 +41,7 @@ ERR.Codes .DA #MLI.E.IO
|
||||
.DA #E.NOFOR
|
||||
.DA #E.NOIF
|
||||
.DA #E.BADFTYPE
|
||||
.DA #E.FUNDEF
|
||||
*--------------------------------------
|
||||
ERR.Count .EQ *-ERR.Codes
|
||||
*--------------------------------------
|
||||
@ -82,6 +83,7 @@ ERR.Messages >PSTR "I/O Error"
|
||||
>PSTR "NEXT Without FOR"
|
||||
>PSTR "FI/ELSE Without IF"
|
||||
>PSTR "Bad File Type"
|
||||
>PSTR "Undefined Function"
|
||||
*--------------------------------------
|
||||
>PSTR "Unknown Error"
|
||||
*--------------------------------------
|
||||
|
Loading…
x
Reference in New Issue
Block a user