Kernel 0.93+

This commit is contained in:
Rémy GIBERT 2019-08-29 17:49:03 +02:00
parent a28d9c361f
commit d2ce5eef6b
3 changed files with 70 additions and 56 deletions

Binary file not shown.

View File

@ -91,7 +91,7 @@ CSH.STYPES >PSTR "char"
>PSTR "int" >PSTR "int"
>PSTR "long" >PSTR "long"
* .HS 00 * .HS 00
CSH.TSIZE .HS 0001020401020405 00,CHAR,INT,LONG,UCHAR,UINT,ULONG,FLOAT.... CSH.SIZEOF .HS 0001020401020405 00,CHAR,INT,LONG,UCHAR,UINT,ULONG,FLOAT....
*-------------------------------------- *--------------------------------------
* int printf ( const char * format, ... ); * int printf ( const char * format, ... );
CSH.FN >PSTR "printf" CSH.FN >PSTR "printf"

View File

@ -90,9 +90,6 @@ CSH.Run.1 cmp #'#'
bcs .6 not an internal CSH keyword.... bcs .6 not an internal CSH keyword....
txa
>STA.G CSH.CmdSave
jsr CSH.KW.JMP jsr CSH.KW.JMP
bcs .9 bcs .9
@ -109,9 +106,11 @@ CSH.Run.1 cmp #'#'
jsr CSH.GetNextChar Skip = jsr CSH.GetNextChar Skip =
bcs .99 bcs .99
lda #0 Any Type
jsr CSH.ExpEval jsr CSH.ExpEval
bcs .9 bcs .9
txa X = Exp Type
jsr CSH.SetVarValue jsr CSH.SetVarValue
bcs .9 bcs .9
@ -122,7 +121,7 @@ CSH.Run.1 cmp #'#'
bra .8 bra .8
.7 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.fCall X = function index
bcs .9 bcs .9
.8 jsr CSH.GetNextCharNB Skip ; .8 jsr CSH.GetNextCharNB Skip ;
@ -139,7 +138,9 @@ CSH.Run.1 cmp #'#'
*-------------------------------------- *--------------------------------------
* Built in Keywords * Built in Keywords
*-------------------------------------- *--------------------------------------
CSH.KW.JMP jmp (J.CSH.KW,x) CSH.KW.JMP txa
>STA.G CSH.CmdSave
jmp (J.CSH.KW,x)
CSH.WHILE CSH.WHILE
CSH.IF jsr CSH.GetCharNB CSH.IF jsr CSH.GetCharNB
@ -150,6 +151,7 @@ CSH.IF jsr CSH.GetCharNB
jsr CSH.GetNextCharNB jsr CSH.GetNextCharNB
bcs .9 bcs .9
lda #0 Any var type
jsr CSH.ExpEval jsr CSH.ExpEval
bcs .99 bcs .99
@ -163,14 +165,12 @@ CSH.IF jsr CSH.GetCharNB
cmp #'{' cmp #'{'
bne .9 bne .9
jsr CSH.IsValue0 jsr CSH.IsValue0 X = var type from ExpEval
bcc .6 Value=0, skip {{....}} bcc .6 Value=0, skip {{....}}
jsr CSH.GetNextCharNB Skip '{' jsr CSH.GetNextCharNB Skip '{'
bcs .99 bcs .99
>LDA.G CSH.CmdSave get back Token ("IF" or "WHILE")
tax
jsr CSH.Keyword.start jsr CSH.Keyword.start
bcs .99 bcs .99
@ -182,7 +182,7 @@ CSH.IF jsr CSH.GetCharNB
.6 ldx #1 expecting 1 '}' for now.... .6 ldx #1 expecting 1 '}' for now....
.7 jsr CSH.GetNextChar .7 jsr CSH.GetNextCharNB
bcs .9 bcs .9
cmp #'{' cmp #'{'
bne .71 bne .71
@ -196,7 +196,7 @@ CSH.IF jsr CSH.GetCharNB
dex dex
bne .7 bne .7
jsr CSH.GetNextChar jsr CSH.GetNextCharNB skip '}'
clc clc
rts rts
@ -204,8 +204,10 @@ CSH.IF jsr CSH.GetCharNB
.9 lda #CSH.E.SYNTAX .9 lda #CSH.E.SYNTAX
sec sec
.99 rts .99 rts
*--------------------------------------
CSH.Keyword.Start CSH.Keyword.Start
>LDA.G CSH.CmdSave get back Token ("IF" or "WHILE")
tax
jmp (J.CSH.KW.START,x) jmp (J.CSH.KW.START,x)
*-------------------------------------- *--------------------------------------
CSH.IF.START jmp CSH.Push Push "IF" Token CSH.IF.START jmp CSH.Push Push "IF" Token
@ -331,7 +333,7 @@ CSH.TYPE stx ZPVarType
jsr CSH.ExpEval jsr CSH.ExpEval
bcs .99 bcs .99
lda ZPVarType txa
jsr CSH.SetVarValue Update value to this var jsr CSH.SetVarValue Update value to this var
bcs .99 bcs .99
@ -357,19 +359,22 @@ CSH.TYPE stx ZPVarType
* CS, A = EC * CS, A = EC
* CC, A, Y,A or x bytes on Stack * CC, A, Y,A or x bytes on Stack
*-------------------------------------- *--------------------------------------
CSH.FnEval ldx ZPPtr1 CSH.fCall ldx ZPPtr1
phx phx
ldx ZPPtr1+1 ldx ZPPtr1+1
phx phx
ldx ZPPtr2 ldx ZPPtr2 local : type
phx
ldx ZPPtr2+1 local : variadic size
phx phx
sta ZPPtr2 save Type sta ZPPtr2 save Type
stz ZPPtr2+1 Reset VARIADIC byte count
>LDYA L.CSH.FN >LDYA L.CSH.FN
jsr CSH.LookupFn jsr CSH.LookupFn
phx X = function index phx X = function index
bcs .90 bcs .10
>STYA ZPPtr1 f() definition, starting at returned type >STYA ZPPtr1 f() definition, starting at returned type
@ -380,7 +385,7 @@ CSH.FnEval ldx ZPPtr1
bne .90 bne .90
jsr CSH.GetNextCharNB skip '(' jsr CSH.GetNextCharNB skip '('
bcs .90 .10 bcs .90
lda ZPPtr2 Expected type in 0, ignore lda ZPPtr2 Expected type in 0, ignore
beq .1 beq .1
@ -404,15 +409,21 @@ CSH.FnEval ldx ZPPtr1
bne .4 bne .4
inc ZPPtr1+1 inc ZPPtr1+1
.4 jsr CSH.ExpEval .4 jsr CSH.ExpEval A=0 if VARIADIC
bcs .9 X = Var Type
bcs .9
lda (ZPPtr1) no more arg in fn definition lda (ZPPtr1) no more arg in fn definition
beq .7 beq .7
eor #CSH.T.VARIADIC
bne .5
* clc
lda CSH.SIZEOF,x
adc ZPPtr2+1
sta ZPPtr2+1 Add to byte count
.5 jsr CSH.GetCharNB .5 jsr CSH.GetCharNB
bcs .9 bcs .90
cmp #',' cmp #','
bne .6 bne .6
@ -422,16 +433,18 @@ CSH.FnEval ldx ZPPtr1
lda (ZPPtr1) lda (ZPPtr1)
bne .3 Another ARG.... bne .3 Another ARG....
bra .9 extra args....error bra .90 extra args....error
.6 cmp #')' .6 cmp #')'
bne .90 bne .90
lda (ZPPtr1) lda (ZPPtr1)
eor #CSH.T.VARIADIC eor #CSH.T.VARIADIC
beq .8 bne .90 missing arg
bra .90 missing arg >PUSHB ZPPtr2+1 push VARIADIC byte count
bra .8
.7 jsr CSH.GetCharNB .7 jsr CSH.GetCharNB
bcs .90 bcs .90
@ -443,6 +456,8 @@ CSH.FnEval ldx ZPPtr1
plx restore X = function index plx restore X = function index
pla
sta ZPPtr2+1
pla pla
sta ZPPtr2 sta ZPPtr2
pla pla
@ -460,6 +475,8 @@ CSH.FnEval ldx ZPPtr1
.9 plx Discard function index .9 plx Discard function index
plx
stx ZPPtr2+1
plx plx
stx ZPPtr2 stx ZPPtr2
plx plx
@ -473,7 +490,7 @@ CSH.FnEval ldx ZPPtr1
* ZPFileBufPtr, A = Expected type * ZPFileBufPtr, A = Expected type
* Output: * Output:
* CS, A = EC * CS, A = EC
* CC, A, Y,A or x bytes on Stack * CC, X = Var Type, Value on Stack
*-------------------------------------- *--------------------------------------
CSH.ExpEval ldx ZPPtr1 CSH.ExpEval ldx ZPPtr1
phx phx
@ -504,7 +521,7 @@ CSH.ExpEval ldx ZPPtr1
bra .11 bra .11
.1 lda ZPPtr2 var type .1 lda ZPPtr2 var type
jsr CSH.FnEval X = function index jsr CSH.fCall X = function index
bcs .99 bcs .99
bra .11 bra .11
@ -581,14 +598,15 @@ CSH.ExpEval ldx ZPPtr1
.HS 90 BCC .HS 90 BCC
.80 clc .80 clc
plx ldx ZPPtr2 X = Var Type
stx ZPPtr2+1 pla
plx sta ZPPtr2+1
stx ZPPtr2 pla
plx sta ZPPtr2
stx ZPPtr1+1 pla
plx sta ZPPtr1+1
stx ZPPtr1 pla
sta ZPPtr1
rts rts
*-------------------------------------- *--------------------------------------
@ -771,7 +789,7 @@ CSH.AddVar sta ZPVarType
lda ZPVarType lda ZPVarType
and #$1f and #$1f
tax tax
ldy CSH.TSIZE,x ldy CSH.SIZEOF,x
.2 iny +1 for Type .2 iny +1 for Type
lda #0 lda #0
@ -827,7 +845,7 @@ CSH.PushValueOnStack
bne .99 bne .99
.1 ldx ZPVarData .1 ldx ZPVarData
ldy CSH.TSIZE,x ldy CSH.SIZEOF,x
.2 lda ZPVarData,y .2 lda ZPVarData,y
>PUSHA >PUSHA
@ -847,7 +865,7 @@ CSH.SetVarValue cmp ZPVarType
sta ZPVarData sta ZPVarData
tax tax
ldy CSH.TSIZE,x Byte count to transfer ldy CSH.SIZEOF,x Byte count to transfer
ldx #1 ldx #1
@ -859,7 +877,7 @@ CSH.SetVarValue cmp ZPVarType
>PUSHBI 0 >PUSHBI 0
ldx ZPVarType ldx ZPVarType
lda CSH.TSIZE,x lda CSH.SIZEOF,x
inc +1 including TYPE inc +1 including TYPE
>PUSHA >PUSHA
>PUSHWI ZPVarData >PUSHWI ZPVarData
@ -872,11 +890,13 @@ CSH.SetVarValue cmp ZPVarType
sec sec
rts rts
*-------------------------------------- *--------------------------------------
CSH.IsValue0 ldx ZPVarType * Input : Value on Stack, X = Var Type
cpx #CSH.T.FLOAT * Output : CC = true, CS = false
bne .1 char,int,long *--------------------------------------
CSH.IsValue0 cpx #CSH.T.FLOAT
bcc .1 char,int,long
ldy CSH.TSIZE,x ldy CSH.SIZEOF,x
lda ZPVarData,y lda ZPVarData,y
bne .9 bne .9
@ -885,7 +905,7 @@ CSH.IsValue0 ldx ZPVarType
rts rts
.1 tax .1 tax
lda CSH.TSIZE,x lda CSH.SIZEOF,x
tax tax
lda #0 lda #0
@ -1122,22 +1142,16 @@ CSH.IsDigit10 cmp #'0'
*-------------------------------------- *--------------------------------------
EXEC.printf >PULLYA EXEC.printf >PULLYA
>SYSCALL printf >SYSCALL printf
bcs .9 rts
.9 rts
*-------------------------------------- *--------------------------------------
EXEC.puts >PULLYA EXEC.puts >PULLYA
>SYSCALL puts >SYSCALL puts
bcs .9 rts
.9 rts
*-------------------------------------- *--------------------------------------
EXEC.cos >FPU COS EXEC.cos >FPU COS
rts rts
*-------------------------------------- *--------------------------------------
EXEC.getchar >SYSCALL getchar EXEC.getchar >SYSCALL getchar
rts rts
*-------------------------------------- *--------------------------------------
MAN MAN