Kernel version 0.9 : SHELL, enhancement in Batch mode....(Cont.)

This commit is contained in:
Rémy GIBERT 2017-07-17 07:59:30 +02:00
parent 417fcfe9aa
commit 7e0fb2e663
12 changed files with 257 additions and 122 deletions

View File

@ -148,6 +148,15 @@ Prints Pascal/C-Style String
+ CC : success + CC : success
+ CS : I/O error from COut + CS : I/O error from COut
# AToI
Convert String to 32 bit int
## In:
+ PUSHW PTR to target buffer DWORD
+ PUSHW Source String (PSTR)
## Out:
# GetDevByIDA # GetDevByIDA
## IN: ## IN:

Binary file not shown.

Binary file not shown.

View File

@ -1,6 +1,6 @@
PR#3 PR#3
PREFIX /A2OSX.BUILD PREFIX /A2OSX.BUILD
LOMEM $A00 LOMEM $900
INC 1 INC 1
AUTO 6 AUTO 6
.LIST OFF .LIST OFF
@ -211,7 +211,7 @@ SYS.PPrintFYA .EQ $44
SYS.CPrintFYA .EQ $46 SYS.CPrintFYA .EQ $46
* .EQ $48 * .EQ $48
* .EQ $4A * .EQ $4A
* .EQ $4C SYS.AToI .EQ $4C
* .EQ $4E * .EQ $4E
*-------------------------------------- *--------------------------------------
SYS.NewPStrYA .EQ $50 SYS.NewPStrYA .EQ $50

View File

@ -5,6 +5,60 @@ INC 1
AUTO 6 AUTO 6
.LIST OFF .LIST OFF
*-------------------------------------- *--------------------------------------
* Remove extra SPACE & comment
*--------------------------------------
Cmd.Normalize >LDYA pData
>STYA ZPPtr1
lda (pData) empty line...quit
beq .9
tax Char count
ldy #0
.1 jsr Cmd.Normalize.Next
beq .8 no more char, exit
cmp #' ' skip leading spaces
beq .1
cmp #'#' Comment ?
beq .8 ignore remaining chars
.3 iny add char to buffer
sta (pData),y
jsr Cmd.Normalize.Next
beq .8
cmp #' '
bne .3
iny add One SPACE to buffer
sta (pData),y
.5 jsr Cmd.Normalize.Next
beq .8
cmp #' '
beq .5 skip additional spaces
bne .3 no more space, add next word...
.8 tya
sta (pData)
.9 rts
Cmd.Normalize.Next
txa
beq .8
dex
inc ZPPtr1
bne .1
inc ZPPtr1+1
.1 lda (ZPPtr1)
.8 rts
*--------------------------------------
* Y,A -> Command line (formatted & not empty) * Y,A -> Command line (formatted & not empty)
*-------------------------------------- *--------------------------------------
Cmd.ExecYA stz bStartProc Cmd.ExecYA stz bStartProc
@ -536,6 +590,24 @@ Cmd.Exec.READ lda ARGS
clc clc
.99 rts .99 rts
*-------------------------------------- *--------------------------------------
Cmd.Exec.SLEEP lda ARGS
beq .9
lda #Sleep
clc
adc pData
tay
lda /Sleep
adc pData+1
>PUSHYA
>PUSHW L.ARGS
>SYSCALL AToI
bcs .9
rts
.9 jmp Cmd.Exec.ERRSYN
*--------------------------------------
Cmd.Exec.PAUSE ldy #bPause Cmd.Exec.PAUSE ldy #bPause
lda #$80 lda #$80
sta (pData),y sta (pData),y

View File

@ -271,6 +271,64 @@ CSH.CONTINUE
sec sec
rts rts
*-------------------------------------- *--------------------------------------
CSH.ExpEval stz CSH.ACC
stz CSH.ACC+1
stz CSH.ACC+2
stz CSH.ACC+3
ldy #0
jsr CSH.GetCharNB
>DEBUG
bcs .9
cmp #')'
beq .8
jsr CSH.IsLetter Fnc or Var ?
bcs .1
bra .9
.1 jsr CSH.IsDigit number ?
bcs .9
jsr CSH.GetNumInACC
bcs .9
.8 clc
rts
.9 lda #CSHERR.SYNTAX
sec
.99 rts
*--------------------------------------
CSH.GetNumInACC ldy #0
.1 iny
cpy #10
beq .9
sta (pData),y
jsr CSH.GetNextChar
bcs .8
jsr CSH.IsDigit
bcc .1
.8 tya
sta (pData)
>PUSHW pData
>PUSHW L.CSH.ACC
>SYSCALL AToI
bcs .9
rts
.9 lda #CSHERR.SYNTAX
sec
rts
*--------------------------------------
CSH.Push pha CSH.Push pha
ldy #CSH.StackPtr ldy #CSH.StackPtr
lda (pData),y lda (pData),y
@ -325,33 +383,6 @@ CSH.CheckStack pha
sec sec
rts rts
*-------------------------------------- *--------------------------------------
CSH.ExpEval stz CSH.ACC
stz CSH.ACC+1
stz CSH.ACC+2
stz CSH.ACC+3
jsr CSH.GetCharNB
bcs .9
cmp #')'
beq .8
jsr CSH.IsLetter Fnc or Var ?
bne .1
.1
.8 clc
rts
.9 lda #CSHERR.SYNTAX
sec
rts
*---------------------------------------
CSH.IsLetterOrDigit
jsr CSH.IsDigit
bcc CSH.IsLetterRTS
*--------------------------------------
CSH.GetCharNB jsr CSH.GetChar CSH.GetCharNB jsr CSH.GetChar
bcs CSH.GetNextCharNB.RTS bcs CSH.GetNextCharNB.RTS
jsr CSH.CheckCharNB jsr CSH.CheckCharNB
@ -410,6 +441,10 @@ CSH.GetChar lda ZPBufPtr
clc clc
rts rts
*--------------------------------------- *---------------------------------------
CSH.IsLetterOrDigit
jsr CSH.IsDigit
bcc CSH.IsLetterRTS
*---------------------------------------
CSH.IsLetter cmp #'A' CSH.IsLetter cmp #'A'
bcc .9 bcc .9

View File

@ -70,6 +70,7 @@ J.INTCMDS .DA Cmd.Exec.CD
.DA Cmd.Exec.PWD .DA Cmd.Exec.PWD
.DA Cmd.Exec.READ .DA Cmd.Exec.READ
.DA Cmd.Exec.SET .DA Cmd.Exec.SET
.DA Cmd.Exec.SLEEP
.DA Cmd.Exec.STARTPROC .DA Cmd.Exec.STARTPROC
.DA Cmd.Exec.TIME .DA Cmd.Exec.TIME
L.CSHCMDS .DA CSHCMDS L.CSHCMDS .DA CSHCMDS
@ -79,15 +80,16 @@ J.CSHCMDS .DA CSH.IF
.DA CSH.CONTINUE .DA CSH.CONTINUE
J.CSHCMDS.END .DA CSH.IF.END J.CSHCMDS.END .DA CSH.IF.END
.DA CSH.WHILE.END .DA CSH.WHILE.END
L.CSH.ACC .DA CSH.ACC
L.ERR.Codes .DA ERR.Codes L.ERR.Codes .DA ERR.Codes
L.ERR.Messages .DA ERR.Messages L.ERR.Messages .DA ERR.Messages
.DA 0 .DA 0
*-------------------------------------- *--------------------------------------
CS.INIT jsr SetPWD CS.INIT jsr SetPWD
* lda (pPs) lda (pPs)
* ora #S.PS.F.EVENT Now accept events ora #S.PS.F.EVENT Now accept events
* sta (pPs) sta (pPs)
>SYSCALL GetArgC >SYSCALL GetArgC
cmp #1 cmp #1
@ -130,11 +132,7 @@ CS.INIT jsr SetPWD
* clc * clc
.9 rts .9 rts
*-------------------------------------- *--------------------------------------
CS.RUN ldy #bPause CS.RUN ldy #VarBuffer READ Command ?
lda (pData),y
bmi .8
ldy #VarBuffer READ Command ?
lda (pData),y lda (pData),y
bne CS.RUN.READ bne CS.RUN.READ
@ -145,7 +143,17 @@ CS.RUN ldy #bPause
jsr ERR.Print jsr ERR.Print
bcs CS.RUN.EXIT.RTS bcs CS.RUN.EXIT.RTS
.11 ldy #CSH.hBuf batch mode ? .11 ldy #bPause
lda (pData),y
bpl .13
>SYSCALL GetC
bcs .8
.13 jsr CheckSleep
bne .8
ldy #CSH.hBuf batch mode ?
lda (pData),y lda (pData),y
beq .10 beq .10
@ -172,7 +180,7 @@ CS.RUN ldy #bPause
and #$7F and #$7F
sta (pData) sta (pData)
jsr CmdBuffer.Normalize jsr Cmd.Normalize
lda (pData) lda (pData)
beq .12 Empty line beq .12 Empty line
@ -184,11 +192,11 @@ CS.RUN ldy #bPause
ldy #S.PS.RC ldy #S.PS.RC
sta (pPs),y sta (pPs),y
.8 ldy #bEXIT ldy #bEXIT
lda (pData),y lda (pData),y
bne CS.RUN.EXIT bne CS.RUN.EXIT
clc .8 clc
rts rts
CS.RUN.EXIT lda #0 CS.RUN.EXIT lda #0
@ -234,7 +242,7 @@ CS.RUN.READ lda #0
CS.RUN.BATCH jsr CSH.Exec CS.RUN.BATCH jsr CSH.Exec
bcs .9 bcs .9
jsr CmdBuffer.Normalize jsr Cmd.Normalize
lda (pData) lda (pData)
beq .8 Empty line....nothing to do.... beq .8 Empty line....nothing to do....
@ -286,7 +294,25 @@ CS.RUN.BATCH jsr CSH.Exec
pla pla
rts rts
*-------------------------------------- *--------------------------------------
CS.DOEVENT sec CS.DOEVENT lda (pEvent)
bpl .9
jsr CheckSleep
beq .9
* ldy #Sleep already set by CheckSleep
clc
ldx #4
.1 lda (pData),y
sbc #0
sta (pData),y
iny
dex
bne .1
.9 sec
rts rts
*-------------------------------------- *--------------------------------------
CS.CHARIN tax CS.CHARIN tax
@ -442,7 +468,15 @@ CS.QUIT jsr HIS.Quit
.8 clc .8 clc
rts rts
*-------------------------------------- *--------------------------------------
* PRIVATE CheckSleep ldy #Sleep+3
lda (pData),y
dey
ora (pData),y
dey
ora (pData),y
dey
ora (pData),y
rts
*-------------------------------------- *--------------------------------------
SetPWD ldy #S.PS.hPREFIX SetPWD ldy #S.PS.hPREFIX
lda (pPs),y lda (pPs),y
@ -468,61 +502,6 @@ PrintPrompt >LDYA L.ENV.PS1
plp plp
.9 rts .9 rts
*-------------------------------------- *--------------------------------------
* Remove extra SPACE & comment
*--------------------------------------
CmdBuffer.Normalize
>LDYA pData
>STYA ZPPtr1
lda (pData) empty line...quit
beq .9
tax Char count
ldy #0
.1 jsr CmdBuffer.Normalize.Next
beq .8 no more char, exit
cmp #' ' skip leading spaces
beq .1
cmp #'#' Comment ?
beq .8 ignore remaining chars
.3 iny add char to buffer
sta (pData),y
jsr CmdBuffer.Normalize.Next
beq .8
cmp #' '
bne .3
iny add One SPACE to buffer
sta (pData),y
.5 jsr CmdBuffer.Normalize.Next
beq .8
cmp #' '
beq .5 skip additional spaces
bne .3 no more space, add next word...
.8 tya
sta (pData)
.9 rts
CmdBuffer.Normalize.Next
txa
beq .8
dex
inc ZPPtr1
bne .1
inc ZPPtr1+1
.1 lda (ZPPtr1)
.8 rts
*--------------------------------------
CmdBuffer.CLR jsr CmdBuffer.DEL CmdBuffer.CLR jsr CmdBuffer.DEL
bne CmdBuffer.CLR bne CmdBuffer.CLR
rts rts
@ -554,6 +533,7 @@ INTCMDS >PSTR "CD"
>PSTR "PWD" >PSTR "PWD"
>PSTR "READ" >PSTR "READ"
>PSTR "SET" >PSTR "SET"
>PSTR "SLEEP"
>PSTR "STARTPROC" >PSTR "STARTPROC"
>PSTR "TIME" >PSTR "TIME"
.HS 00 .HS 00
@ -598,6 +578,7 @@ bExitOnEOF .BS 1
hCmdHistory .BS 1 hCmdHistory .BS 1
CmdHistory.IDX .BS 1 CmdHistory.IDX .BS 1
CmdHistory.END .BS 1 CmdHistory.END .BS 1
Sleep .BS 4
CSH.hBuf .BS 1 CSH.hBuf .BS 1
CSH.BufPtr .BS 2 CSH.BufPtr .BS 2
CSH.BufLen .BS 2 CSH.BufLen .BS 2

View File

@ -494,7 +494,7 @@ CIO.GetCharAtPtr1Y
beq .9 beq .9
iny advance to next char... iny advance to next char...
bne .9 bne .9
inc ZPPtr1+1 Allow >256 CStrings inc ZPPtr1+1 Allow >256 CStrings
rts rts
@ -506,6 +506,52 @@ CIO.GetCharAtPtr1Y
.9 clc no error, but end of string .9 clc no error, but end of string
rts rts
*/--------------------------------------
* # AToI
* Convert String to 32 bit int
* ## In:
* PUSHW PTR to target buffer DWORD
* PUSHW Source String (PSTR)
* ## Out:
*\--------------------------------------
K.AToI jsr PullPtr1Ptr2 PSTR in Ptr1,buffer in Ptr2
stz ASCBUF
lda (ZPPtr1)
beq .2
ldx #0
ldy #0
.1 iny
lda (ZPPtr1),y
cmp #'0'
bcc .2
cmp #'9'+1
bcs .2
inx
sta ASCBUF,x
cpx #10
beq .2
tya
cmp (ZPPtr1)
bne .1
.2 stx ASCBUF
jsr DEC2HEX
ldy #3
.3 lda HEXBUF,y
sta (ZPPtr2),y
dey
bpl .3
clc
rts
*-------------------------------------- *--------------------------------------
TYPES .AS "-dbclssp" TYPES .AS "-dbclssp"
ACCESS .AS "rwxrwxrwx" ACCESS .AS "rwxrwxrwx"

View File

@ -60,6 +60,9 @@ DEC2HEX stz HEXBUF
stz HEXBUF+2 stz HEXBUF+2
stz HEXBUF+3 stz HEXBUF+3
lda ASCBUF
beq .8
ldx #0 ldx #0
.1 lda HEXBUF+3 save HEXBUF for 4+1 .1 lda HEXBUF+3 save HEXBUF for 4+1
@ -109,7 +112,8 @@ DEC2HEX stz HEXBUF
.2 cpx ASCBUF .2 cpx ASCBUF
bne .1 bne .1
rts
.8 rts
*.9 pla discard saved HEXBUF *.9 pla discard saved HEXBUF
* pla * pla

View File

@ -13,7 +13,7 @@ Kernel.Init2 sei
>STYA ZPPtr1 >STYA ZPPtr1
>LDYAI A2osX.SYSCALL >LDYAI A2osX.SYSCALL
>STYA ZPPtr2 >STYA ZPPtr2
>LDYAI A2osX.GP.S^$FFFF >LDYAI A2osX.D1-A2osX.GP^$FFFF
>STYA ZPPtr3 >STYA ZPPtr3
jsr Kernel.Move jsr Kernel.Move
@ -30,7 +30,7 @@ Kernel.Init2 sei
>STYA ZPPtr1 >STYA ZPPtr1
>LDYAI $D000 >LDYAI $D000
>STYA ZPPtr2 >STYA ZPPtr2
>LDYAI A2osX.D2.S^$FFFF >LDYAI A2osX.E0-A2osX.D2^$FFFF
>STYA ZPPtr3 >STYA ZPPtr3
jsr Kernel.Move jsr Kernel.Move
@ -47,7 +47,7 @@ Kernel.Init2 sei
>STYA ZPPtr1 >STYA ZPPtr1
>LDYAI $D000 >LDYAI $D000
>STYA ZPPtr2 >STYA ZPPtr2
>LDYAI A2osX.D1.S^$FFFF >LDYAI A2osX.D2-A2osX.D1^$FFFF
>STYA ZPPtr3 >STYA ZPPtr3
jsr Kernel.Move jsr Kernel.Move
@ -64,7 +64,7 @@ Kernel.Init2 sei
>STYA ZPPtr1 >STYA ZPPtr1
>LDYAI $E000 >LDYAI $E000
>STYA ZPPtr2 >STYA ZPPtr2
>LDYAI A2osX.E0.S^$FFFF >LDYAI A2osX.E0.E-A2osX.E0^$FFFF
>STYA ZPPtr3 >STYA ZPPtr3
jsr Kernel.Move jsr Kernel.Move

View File

@ -52,7 +52,7 @@ K.SYSCALL.JMP .DA K.FileSearch $00
.DA K.CPrintFYA .DA K.CPrintFYA
.DA 0 .DA 0
.DA 0 .DA 0
.DA 0 .DA K.AToI
.DA 0 .DA 0
*-------------------------------------- *--------------------------------------
.DA K.NewPStrYA $50 .DA K.NewPStrYA $50

View File

@ -34,15 +34,13 @@ ZPPtr4 .EQ ZPKERNEL+6
>DEBUGOA >DEBUGOA
jmp Kernel.Init3 jmp Kernel.Init3
.INB /A2OSX.SRC/X.PRINTF.S
.INB /A2OSX.SRC/SYS/KERNEL.S.INIT2 .INB /A2OSX.SRC/SYS/KERNEL.S.INIT2
.INB /A2OSX.SRC/SYS/KERNEL.S.INIT3 .INB /A2OSX.SRC/SYS/KERNEL.S.INIT3
.INB /A2OSX.SRC/X.PRINTF.S
A2osX.GP .PH $BD00 A2osX.GP .PH $BD00
.INB /A2OSX.SRC/SYS/KERNEL.S.GP .INB /A2OSX.SRC/SYS/KERNEL.S.GP
.EP .EP
A2osX.GP.E .EQ *
A2osX.D1 .PH $D000 A2osX.D1 .PH $D000
.DA #RRAMWRAMBNK1 .DA #RRAMWRAMBNK1
.INB /A2OSX.SRC/SYS/KERNEL.S.FIO .INB /A2OSX.SRC/SYS/KERNEL.S.FIO
@ -51,12 +49,9 @@ A2osX.D1 .PH $D000
.INB /A2OSX.SRC/SYS/KERNEL.S.TIME .INB /A2OSX.SRC/SYS/KERNEL.S.TIME
.INB /A2OSX.SRC/SYS/KERNEL.S.FILE .INB /A2OSX.SRC/SYS/KERNEL.S.FILE
.INB /A2OSX.SRC/SYS/KERNEL.S.DIR .INB /A2OSX.SRC/SYS/KERNEL.S.DIR
.INB /A2OSX.SRC/SYS/KERNEL.S.PFT .INB /A2OSX.SRC/SYS/KERNEL.S.PFT
.INB /A2OSX.SRC/SYS/KERNEL.S.BIN .INB /A2OSX.SRC/SYS/KERNEL.S.BIN
.EP .EP
A2osX.D1.E .EQ *
A2osX.D2 .PH $D000 A2osX.D2 .PH $D000
.DA #RRAMWRAMBNK2 .DA #RRAMWRAMBNK2
.INB /A2OSX.SRC/SYS/KERNEL.S.CIO .INB /A2OSX.SRC/SYS/KERNEL.S.CIO
@ -65,14 +60,11 @@ A2osX.D2 .PH $D000
.INB /A2OSX.SRC/SYS/KERNEL.S.PS .INB /A2OSX.SRC/SYS/KERNEL.S.PS
.INB /A2OSX.SRC/SYS/KERNEL.S.ARG .INB /A2OSX.SRC/SYS/KERNEL.S.ARG
.INB /A2OSX.SRC/SYS/KERNEL.S.ENV .INB /A2OSX.SRC/SYS/KERNEL.S.ENV
.INB /A2OSX.SRC/SYS/KERNEL.S.CNV .INB /A2OSX.SRC/SYS/KERNEL.S.CNV
.INB /A2OSX.SRC/SYS/KERNEL.S.RUN .INB /A2OSX.SRC/SYS/KERNEL.S.RUN
.INB /A2OSX.SRC/SYS/KERNEL.S.EVT .INB /A2OSX.SRC/SYS/KERNEL.S.EVT
.INB /A2OSX.SRC/SYS/KERNEL.S.TSK .INB /A2OSX.SRC/SYS/KERNEL.S.TSK
.EP .EP
A2osX.D2.E .EQ *
A2osX.E0 .PH $E000 A2osX.E0 .PH $E000
.INB /A2OSX.SRC/SYS/KERNEL.S.JMP .INB /A2OSX.SRC/SYS/KERNEL.S.JMP
.INB /A2OSX.SRC/SYS/KERNEL.S.DAT .INB /A2OSX.SRC/SYS/KERNEL.S.DAT
@ -84,17 +76,13 @@ A2osX.E0 .PH $E000
A2osX.E0.E .EQ * A2osX.E0.E .EQ *
* CONTROL SECTION : * CONTROL SECTION :
.LIST ON .LIST ON
A2osX.GP.S .EQ A2osX.GP.E-A2osX.GP .DO A2osX.D1-A2osX.GP>$200
A2osX.D1.S .EQ A2osX.D1.E-A2osX.D1
A2osX.D2.S .EQ A2osX.D2.E-A2osX.D2
A2osX.E0.S .EQ A2osX.E0.E-A2osX.E0
.DO A2osX.GP.S>$200
* ERROR:GP too big * ERROR:GP too big
.FIN .FIN
.DO A2osX.D1.S>$1000 .DO A2osX.D2-A2osX.D1>$1000
* ERROR:BNK1 too big * ERROR:BNK1 too big
.FIN .FIN
.DO A2osX.D2.S>$1000 .DO A2osX.E0-A2osX.D2>$1000
* ERROR:BNK2 too big * ERROR:BNK2 too big
.FIN .FIN
.LIST OFF .LIST OFF