Kernel 0.92+

This commit is contained in:
Rémy GIBERT 2019-02-06 16:20:51 +00:00
parent f1d2dcf41d
commit e9bfd87013
8 changed files with 83 additions and 42 deletions

Binary file not shown.

View File

@ -122,7 +122,12 @@ CSH.Run jsr CSH.GetCharNB
.80 clc
.80 jsr CSH.GetNextChar
bcs .9
cmp #C.CR
bne .80
clc
rts
*--------------------------------------
CSH.WHILE

View File

@ -8,6 +8,7 @@ AUTO 4,1 Enable MASM3 auto line num
*--------------------------------------
.INB INC/MACROS.I
.INB INC/A2OSX.I
.INB INC/MLI.I
.INB INC/MLI.E.I
*--------------------------------------
.INB USR/SRC/BIN/CSH.E
@ -47,6 +48,7 @@ CS.START cld
.DA CS.RUN
.DA CS.DOEVENT
.DA CS.QUIT
L.MSG.GREETINGS .DA MSG.GREETINGS
.INB USR/SRC/BIN/CSH.R
.DA 0
*--------------------------------------
@ -59,19 +61,41 @@ CS.INIT clc
* Called until exit with CS
* if RUN exits with CC, RN entered again
*--------------------------------------
CS.RUN
CS.RUN >PUSHWI K.VER
>PUSHBI 2
>LDYA L.MSG.GREETINGS
>SYSCALL printf
bcs .99
* Put your code here
* >LDYA L.MSG.Test Load EFFECTIVE address
* >SYSCALL puts Call API to print a string
jsr CSH.Init
bcs .99
ldy #S.PS.ARGC
lda (pPS),y
beq .90 no arg, usage
>PUSHWI 0 Aux type
>PUSHBI S.FI.T.TXT
>PUSHBI O.RDONLY
lda #1
>SYSCALL ArgV
>SYSCALL LoadTxtFile
bcs .99
txa
>STA.G hFileBuf
>SYSCALL GetMemPtr
>STYA ZPFileBufPtr
.1 >SLEEP
jsr CSH.Run
bcc .1
.8 lda #0 Exit Code = Succes
sec QUIT Process
rts
.9 lda #E.SYN Exit Code = Succes
.90 lda #E.SYN Exit Code = Succes
sec QUIT Process
rts
.99 rts
*--------------------------------------
* Called if option S.PS.F.EVENT enabled in Header
* Timer Event : every 10th seconds
@ -82,7 +106,8 @@ CS.DOEVENT sec
* Called once, when RUN exited with CS
* Put code for unloading LIB here
*--------------------------------------
CS.QUIT clc
CS.QUIT jsr CSH.Quit
clc
rts
*--------------------------------------
.INB USR/SRC/BIN/CSH.S.CORE
@ -91,6 +116,7 @@ CS.END
*--------------------------------------
* Initialized DATA
*--------------------------------------
MSG.Greetings .AZ "\r\nCSH-Shell %d.%d\r\n\r\n"
.INB USR/SRC/BIN/CSH.I
*--------------------------------------
.DUMMY

View File

@ -7,7 +7,6 @@ CL.Init >LDYAI 256
>SYSCALL GetMem
bcs .9
>STYA ZPCLBuf
txa
>STA.G CL.hCLBuf
@ -85,7 +84,7 @@ CL.CHARIN.CTRL cpx #C.CR
>SYSCALL printf
lda #$ff
>STA.G CL.bExec
>STA.G CL.bReady
clc
rts
@ -111,10 +110,8 @@ CL.CHARIN.CTRL cpx #C.CR
rts
*--------------------------------------
CL.Insert >LDA.G CL.Len
cmp #CL.MAX
beq .9 Buffer full, discard...
inc
beq .9 Buffer full, discard...
sta (pData),y
pha
@ -178,7 +175,7 @@ CL.CLR lda (ZPCLBuf)
*--------------------------------------
CL.RESET lda #0
sta (ZPCLBuf)
CL.RESET.1 >STA.G CL.bExec
CL.RESET.1 >STA.G CL.bReady
>STA.G CL.Ptr
>STA.G CL.Len
rts

View File

@ -464,7 +464,8 @@ CMD.READ lda #1
bcs .99
bra .7
.4 >SYSCALL strdup
.4 >STYA ZPVarNamePtr
>SYSCALL strdup
txa
>STA.G hVarName

View File

@ -20,8 +20,8 @@ CORE.Quit >LDA.G CORE.hArgVBuf
* Input : ZPCLBuf/ZPFileBuf
* Get Line from buf until ;, CR, \0 (EOL / EOF) -> ZPArgVBuf
*--------------------------------------
CORE.GetCmd >LDYA ZPInputBufPtr
>STYA ZPInputLinePtr
CORE.GetCmd >LDYA ZPInputBufPtr Save Actual cmd for looping
>STYA ZPInputCmdPtr
lda (ZPInputBufPtr)
beq .9
@ -308,10 +308,10 @@ CORE.GetArgX >LDYA ZPArgVBuf
.9 sec
rts
*--------------------------------------
CORE.StkPushPtr lda ZPInputLinePtr
CORE.StkPushPtr lda ZPInputCmdPtr
jsr CORE.StkPush
bcs CORE.StkPullPtr.9
lda ZPInputLinePtr+1
lda ZPInputCmdPtr+1
bra CORE.StkPush
.9 rts
*--------------------------------------

View File

@ -97,7 +97,7 @@ IO.Reset.Err >LDA.G IO.hErr
.8 rts
*--------------------------------------
IO.PrintBatchErrMsg
>LDA.G hFileBuf
>LDA.G hInputBuf
>SYSCALL GetMemPtr
>STYA ZPPtr1

View File

@ -6,7 +6,6 @@ AUTO 4,1
.OR $2000
.TF BIN/SHELL
*--------------------------------------
CL.MAX .EQ 159
History.MAX .EQ 256
CORE.STACK.MAX .EQ 64
PUSHD.STACK.MAX .EQ 8
@ -62,11 +61,12 @@ ZPPtr1 .BS 2
ZPPtr2 .BS 2
ZPPtr3 .BS 2
ZPCLBuf .BS 2
ZPFileBuf .BS 2
ZPInputBuf .BS 2
ZPInputBufPtr .BS 2
ZPInputLinePtr .BS 2
ZPInputCmdPtr .BS 2
ZPArgVBuf .BS 2
ZPArgVBufPtr .BS 2
ZPVarNamePtr .BS 2
ZS.END .ED
*--------------------------------------
* File Header (16 Bytes)
@ -184,14 +184,17 @@ CS.RUN jsr CL.Init
bcs CS.INIT.RTS
txa
>STA.G hFileBuf
>STA.G hInputBuf
>SYSCALL GetMemPtr
>STYA ZPFileBuf
>STYA ZPInputBuf
>STYA ZPInputBufPtr
lda #0
jsr CMD.SHIFTA Remove $0=/bin/shell
lda #$ff
>STA.G bBatchMode
bra CS.RUN.LOOP
*--------------------------------------
.1 jsr CMD.CD.HOME
@ -226,7 +229,7 @@ CS.RUN.LOOP jsr IO.Reset
cmp #3 Ctrl-C
bne .1
>LDA.G hFileBuf batch mode ?
>LDA.G bBatchMode batch mode ?
beq .1
>LDA.G bSET.C
@ -250,7 +253,7 @@ CS.RUN.LOOP jsr IO.Reset
.5 cmp #3 Ctrl-C
bne .60
>LDA.G hFileBuf batch mode ?
>LDA.G bBatchMode batch mode ?
beq .61
>LDA.G bSET.C
@ -266,7 +269,7 @@ CS.RUN.LOOP jsr IO.Reset
.6 >LDA.G hVarName read mode ?
bne .7
.62 >LDA.G hFileBuf batch mode ?
.62 >LDA.G bBatchMode batch mode ?
beq CS.RUN.INTERACTIVE
jmp CS.RUN.BATCH
.7 jmp CS.RUN.READ
@ -294,7 +297,7 @@ CS.RUN.INTERACTIVE
jsr CL.CHARIN
>LDA.G CL.bExec Something to execute ?
>LDA.G CL.bReady Something to execute ?
bpl .1
lda (ZPCLBuf)
@ -303,7 +306,12 @@ CS.RUN.INTERACTIVE
jsr HIS.Add
>LDYA ZPCLBuf
>SYSCALL strdup
bcs .8
>STYA ZPInputBuf
>STYA ZPInputBufPtr
txa
>STA.G hInputBuf
.7 jsr CORE.GetCmd
bcs .8
@ -316,14 +324,15 @@ CS.RUN.INTERACTIVE
.8 jmp CS.RUN.LOOP.END
*--------------------------------------
CS.RUN.READ
CS.RUN.READ jsr CL.RESET
.1 >SLEEP
>SYSCALL GetChar
bcs .1 no char
jsr CL.CHARIN
>LDA.G CL.bExec
>LDA.G CL.bReady
bpl .1
lda (ZPCLBuf)
@ -342,9 +351,10 @@ CS.RUN.READ
.7 php
pha
>LDA.G hVarName
>SYSCALL freemem
>STZ.G hVarName
>STA.G bREAD.S
@ -400,7 +410,7 @@ CS.RUN.LOOP.END ldy #S.PS.RC
bcc CS.RUN.LOOP.8
tay
beq CS.RUN.LOOP.8
>LDA.G hFileBuf batch mode ?
>LDA.G bBatchMode batch mode ?
beq .1
jsr IO.PrintBatchErrMsg
@ -411,6 +421,10 @@ CS.RUN.LOOP.END ldy #S.PS.RC
jsr IO.PrintErrMsg
bcs CS.RUN.LOOP.RTS
>LDA.G hInputBuf
beq CS.RUN.LOOP.8
>SYSCALL FreeMem
CS.RUN.LOOP.8 >LDA.G bExit
beq CS.RUN.LOOP.80
@ -445,11 +459,7 @@ CS.DOEVENT lda (pEvent)
.9 sec
rts
*--------------------------------------
CS.QUIT >LDA.G hFileBuf
beq .1
>SYSCALL FreeMem
.1 jsr HIS.Quit
CS.QUIT jsr HIS.Quit
jsr CL.Quit
jsr CORE.Quit
clc
@ -652,9 +662,11 @@ DS.START
CORE.STACK .BS CORE.STACK.MAX+1 pData (0 = Stack Ptr)
PUSHD.STACK .BS PUSHD.STACK.MAX+1
hFileBuf .BS 1 batch mode
hInputBuf .BS 1 batch mode
hVarName .BS 1 read mode
bBatchMode .BS 1
bEscMode .BS 1
bPause .BS 1
bExit .BS 1
@ -670,7 +682,7 @@ TimeBuf .BS S.TIME
CL.hCLBuf .BS 1
CL.Ptr .BS 1
CL.Len .BS 1
CL.bExec .BS 1
CL.bReady .BS 1
CL.CmdSep .BS 1
CORE.IntCmd .BS 1