Kernel 0.93+

This commit is contained in:
Rémy GIBERT 2019-08-28 17:21:42 +02:00
parent f3a26b40a4
commit a28d9c361f
2 changed files with 83 additions and 65 deletions

Binary file not shown.

View File

@ -50,8 +50,22 @@ CSH.Quit.RTS rts
CSH.Run jsr CSH.GetCharNB CSH.Run jsr CSH.GetCharNB
bcs CSH.Quit.RTS bcs CSH.Quit.RTS
CSH.Run.1 cmp #'}' End of block ? CSH.Run.1 cmp #'#'
bne .3 comments ...
.1 jsr CSH.GetNextChar
bcs .2
cmp #C.CR
bne .1 bne .1
.2 jmp CSH.GetNextChar Skip CR and exit
.3 cmp #C.CR
beq .2
cmp #'}' End of block ?
bne .4
jsr CSH.CheckStack must be something on stack.... jsr CSH.CheckStack must be something on stack....
bcs .9 bcs .9
@ -60,26 +74,21 @@ CSH.Run.1 cmp #'}' End of block ?
tax tax
jmp (J.CSH.KW.END,x) jmp (J.CSH.KW.END,x)
.1 cmp #C.CR .4 pha
bne .2
jmp CSH.GetNextChar Skip CR and exit
.2 pha
jsr CSH.SavePtr Save Ptr, in case of while,for.... jsr CSH.SavePtr Save Ptr, in case of while,for....
pla pla
jsr CSH.IsLetter jsr CSH.IsLetter
bcc .3 bcc .5
cmp #'#'
beq .80 comments ...
bra .99 error, todo : PREOPS ++ --.....
bra .9 error, todo : PREOPS ++ --..... .5 >LDYA L.CSH.KW
.3 >LDYA L.CSH.KW
jsr CSH.LookupID jsr CSH.LookupID
bcs .4 not an internal CSH keyword.... bcs .6 not an internal CSH keyword....
txa txa
>STA.G CSH.CmdSave >STA.G CSH.CmdSave
@ -87,10 +96,10 @@ CSH.Run.1 cmp #'}' End of block ?
jsr CSH.KW.JMP jsr CSH.KW.JMP
bcs .9 bcs .9
bra .7 bra .8
.4 jsr CSH.GetVar .6 jsr CSH.GetVar
bcs .5 bcs .7
jsr CSH.GetCharNB jsr CSH.GetCharNB
bcs .9 bcs .9
@ -110,13 +119,13 @@ CSH.Run.1 cmp #'}' End of block ?
cmp #';' cmp #';'
bne .99 bne .99
bra .7 bra .8
.5 lda #0 no return value type check required .7 lda #0 no return value type check required
jsr CSH.FnEval X = function index jsr CSH.FnEval X = function index
bcs .9 bcs .9
.7 jsr CSH.GetNextCharNB Skip ; .8 jsr CSH.GetNextCharNB Skip ;
bcs .9 bcs .9
cmp #C.CR cmp #C.CR
@ -127,15 +136,6 @@ CSH.Run.1 cmp #'}' End of block ?
.99 lda #CSH.E.SYNTAX .99 lda #CSH.E.SYNTAX
sec sec
.9 rts .9 rts
.80 jsr CSH.GetNextChar
bcs .9
cmp #C.CR
bne .80
jmp CSH.GetNextChar Skip CR
*-------------------------------------- *--------------------------------------
* Built in Keywords * Built in Keywords
*-------------------------------------- *--------------------------------------
@ -329,10 +329,11 @@ CSH.TYPE stx ZPVarType
lda ZPVarType lda ZPVarType
jsr CSH.ExpEval jsr CSH.ExpEval
bcs .99 bcs .99
lda ZPVarType
jsr CSH.SetVarValue Update value to this var jsr CSH.SetVarValue Update value to this var
bcs .99
jsr CSH.GetChar jsr CSH.GetChar
bcs .9 bcs .9
@ -404,6 +405,7 @@ CSH.FnEval ldx ZPPtr1
inc ZPPtr1+1 inc ZPPtr1+1
.4 jsr CSH.ExpEval .4 jsr CSH.ExpEval
bcs .9 bcs .9
lda (ZPPtr1) no more arg in fn definition lda (ZPPtr1) no more arg in fn definition
@ -413,21 +415,31 @@ CSH.FnEval ldx ZPPtr1
bcs .9 bcs .9
cmp #',' cmp #','
bne .90 bne .6
jsr CSH.GetNextCharNB Skip , jsr CSH.GetNextCharNB Skip ,
lda (ZPPtr1) lda (ZPPtr1)
bne .3 Another ARG.... bne .3 Another ARG....
bra .9 bra .9 extra args....error
.6 cmp #')'
bne .90
lda (ZPPtr1)
eor #CSH.T.VARIADIC
beq .8
bra .90 missing arg
.7 jsr CSH.GetCharNB .7 jsr CSH.GetCharNB
bcs .90 bcs .90
cmp #')' cmp #')'
bne .90 bne .90
jsr CSH.GetNextChar Skip ) .8 jsr CSH.GetNextCharNB Skip )
plx restore X = function index plx restore X = function index
@ -446,13 +458,15 @@ CSH.FnEval ldx ZPPtr1
.91 lda #CSH.E.TMISMATCH .91 lda #CSH.E.TMISMATCH
sec sec
.9 plx .9 plx Discard function index
plx
stx ZPPtr2 stx ZPPtr2
plx plx
stx ZPPtr1+1 stx ZPPtr1+1
plx plx
stx ZPPtr1 stx ZPPtr1
plx
.99 rts .99 rts
*-------------------------------------- *--------------------------------------
* Input: * Input:
@ -465,12 +479,12 @@ CSH.ExpEval ldx ZPPtr1
phx phx
ldx ZPPtr1+1 ldx ZPPtr1+1
phx phx
ldx ZPPtr2 ldx ZPPtr2 local : VarType
phx phx
ldx ZPPtr2+1 One local : BOP1 ldx ZPPtr2+1 local : BOP1
phx phx
sta ZPPtr2 save Type sta ZPPtr2
.10 lda #$ff .10 lda #$ff
sta ZPPtr2+1 Reset BOP1 sta ZPPtr2+1 Reset BOP1
@ -481,14 +495,16 @@ CSH.ExpEval ldx ZPPtr1
.20 jsr CSH.IsLetter Fnc or Var ? .20 jsr CSH.IsLetter Fnc or Var ?
bcs .2 bcs .2
lda ZPPtr2 var type
jsr CSH.GetVar jsr CSH.GetVar
bcs .1 bcs .1
ldx ZPPtr2 var type
jsr CSH.GetVarValue Get value on stack jsr CSH.GetVarValue Get value on stack
bcs .99
bra .11 bra .11
.1 jsr CSH.FnEval X = function index .1 lda ZPPtr2 var type
jsr CSH.FnEval X = function index
bcs .99 bcs .99
bra .11 bra .11
@ -747,8 +763,8 @@ CSH.AddVar sta ZPVarType
.1 ldy #2 .1 ldy #2
lda ZPVarType lda ZPVarType
>PUSHA Push Var Type On stack... sta ZPVarData
and #CSH.Q.PPPOINTER and #CSH.Q.PPPOINTER
bne .2 Pointer, always 2 bytes bne .2 Pointer, always 2 bytes
@ -761,19 +777,17 @@ CSH.AddVar sta ZPVarType
lda #0 lda #0
>PUSHYA DataLen >PUSHYA DataLen
>PUSHW pStack >PUSHW ZPVarData
>PUSHW ZPVarID >PUSHW ZPVarID
>LDA.G CSH.hSymbols >LDA.G CSH.hSymbols
>SYSCALL SListAddData >SYSCALL SListAddData
bcs .9 bcs .9
>LDYA ZPVarType >LDYA ZPVarID
.9 rts .9 rts
*-------------------------------------- *--------------------------------------
CSH.GetVar sta ZPVarType CSH.GetVar >PUSHW ZPFileBufPtr
>DEBUG
>PUSHW ZPFileBufPtr
>LDA.G CSH.hSymbols >LDA.G CSH.hSymbols
>SYSCALL SListLookup >SYSCALL SListLookup
bcs .9 bcs .9
@ -787,37 +801,32 @@ CSH.GetVar sta ZPVarType
bcc .1 bcc .1
inc ZPFileBufPtr+1 inc ZPFileBufPtr+1
.1 ldx ZPVarType
cpx ZPVarData
bne .99
clc clc
rts .1
.99 lda #CSH.E.TMISMATCH
sec
.9 .9
CSH.GetVar.RTS rts CSH.GetVar.RTS rts
*-------------------------------------- *--------------------------------------
* Input : ZPFileBufPtr, A = Var Type * Input : ZPFileBufPtr, X = Var Type (or 0)
* Output : Value on Stack * Output : Value on Stack, X = Var Type
*-------------------------------------- *--------------------------------------
CSH.GetVarValue sta ZPVarType CSH.GetVarValue stx ZPVarType
.1 >PUSHWI 0 .1 >PUSHWI 0
>PUSHWI 6 >PUSHWI 6
>PUSHWI ZPVarData >PUSHWI ZPVarData
>PUSHWI ZPVarID >PUSHW ZPVarID
>LDA.G CSH.hSymbols >LDA.G CSH.hSymbols
>SYSCALL SListGetData >SYSCALL SListGetData
bcs CSH.GetVar.RTS bcs CSH.GetVar.RTS
CSH.PushValueOnStack CSH.PushValueOnStack
ldx ZPVarType ldx ZPVarType
beq .1
cpx ZPVarData cpx ZPVarData
bne .99 bne .99
.1 ldx ZPVarData
ldy CSH.TSIZE,x ldy CSH.TSIZE,x
.2 lda ZPVarData,y .2 lda ZPVarData,y
@ -827,14 +836,15 @@ CSH.PushValueOnStack
clc clc
rts rts
.99 lda #CSH.E.TMISMATCH .99 lda #CSH.E.TMISMATCH
sec sec
.9 rts .9 rts
*-------------------------------------- *--------------------------------------
CSH.SetVarValue cmp ZPVarType CSH.SetVarValue cmp ZPVarType
bne .9 bne .9
sta ZPVarData
tax tax
ldy CSH.TSIZE,x Byte count to transfer ldy CSH.TSIZE,x Byte count to transfer
@ -847,7 +857,15 @@ CSH.SetVarValue cmp ZPVarType
dey dey
bne .1 bne .1
clc >PUSHBI 0
ldx ZPVarType
lda CSH.TSIZE,x
inc +1 including TYPE
>PUSHA
>PUSHWI ZPVarData
>PUSHW ZPVarID
>LDA.G CSH.hSymbols
>SYSCALL SListSetData
rts rts
.9 lda #CSH.E.TMISMATCH .9 lda #CSH.E.TMISMATCH