Kernel 0.93+

This commit is contained in:
Rémy GIBERT 2019-09-02 08:09:28 +02:00
parent bc535424f7
commit 3bee887a66
13 changed files with 224 additions and 64 deletions

Binary file not shown.

View File

@ -1,6 +1,5 @@
NEW NEW
PREFIX AUTO 3,1
AUTO 4,1
*--------------------------------------- *---------------------------------------
DIR.Reset lda #$80 DIR.Reset lda #$80
ldy #ASM.LI.ON ldy #ASM.LI.ON

View File

@ -1,6 +1,5 @@
NEW NEW
PREFIX AUTO 3,1
AUTO 4,1
*--------------------------------------- *---------------------------------------
* EXP.Modifiers: * EXP.Modifiers:
* # : 8b,Byte 1 * # : 8b,Byte 1

View File

@ -1,6 +1,5 @@
NEW NEW
PREFIX AUTO 3,1
AUTO 4,1
*--------------------------------------- *---------------------------------------
FIO.Init >LDYA L.ASM.6502 FIO.Init >LDYA L.ASM.6502
FIO.LOAD.ASM.T >STYA ZPPtr2 FIO.LOAD.ASM.T >STYA ZPPtr2

View File

@ -1,6 +1,5 @@
NEW NEW
PREFIX AUTO 3,1
AUTO 4,1
*--------------------------------------- *---------------------------------------
MAC.Init >SYSCALL SListNew MAC.Init >SYSCALL SListNew
bcs .9 bcs .9

View File

@ -1,6 +1,5 @@
NEW NEW
PREFIX AUTO 3,1
AUTO 4,1
*--------------------------------------- *---------------------------------------
OUT.Init lda #PAGE.LEN OUT.Init lda #PAGE.LEN
>STA.G OUT.LineCnt >STA.G OUT.LineCnt

View File

@ -1,6 +1,5 @@
NEW NEW
PREFIX AUTO 3,1
AUTO 4,1
*--------------------------------------- *---------------------------------------
SRC.ParseLine jsr OUT.Reset SRC.ParseLine jsr OUT.Reset

View File

@ -1,6 +1,5 @@
NEW NEW
PREFIX AUTO 3,1
AUTO 4,1
*--------------------------------------- *---------------------------------------
* Global Symbol Record: (6+ bytes) * Global Symbol Record: (6+ bytes)
* 0 : Len * 0 : Len

View File

@ -1,5 +1,6 @@
NEW NEW
AUTO 3,1 AUTO 3,1
*---------------------------------------
.LIST OFF .LIST OFF
.OP 65C02 .OP 65C02
.OR $2000 .OR $2000

View File

@ -91,7 +91,7 @@ CSH.STYPES >PSTR "char"
>PSTR "int" >PSTR "int"
>PSTR "long" >PSTR "long"
* .HS 00 * .HS 00
CSH.SIZEOF .HS 0001020401020405 00,CHAR,INT,LONG,UCHAR,UINT,ULONG,FLOAT.... CSH.TYPESIZE .HS 0001020401020405 VOID,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

@ -121,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.fCall X = function index jsr CSH.fCall
bcs .9 bcs .9
.8 jsr CSH.GetNextCharNB Skip ; .8 jsr CSH.GetNextCharNB Skip ;
@ -357,7 +357,7 @@ CSH.TYPE stx ZPVarType
* 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, Result on Stack, X = Type
*-------------------------------------- *--------------------------------------
CSH.fCall ldx ZPPtr1 CSH.fCall ldx ZPPtr1
phx phx
@ -379,50 +379,55 @@ CSH.fCall ldx ZPPtr1
>STYA ZPPtr1 f() definition, starting at returned type >STYA ZPPtr1 f() definition, starting at returned type
jsr CSH.GetCharNB jsr CSH.GetCharNB
bcs .90 bcs .10
cmp #'(' cmp #'('
bne .90 bne .90
jsr CSH.GetNextCharNB skip '(' jsr CSH.GetNextCharNB skip '('
.10 bcs .90 .10 bcs .90
lda ZPPtr2 Expected type in 0, ignore lda ZPPtr2
beq .1 bne .11
cmp (ZPPtr1) Get Return value Type lda (ZPPtr1)
sta ZPPtr2
bra .1 expected type is 0, no check
.11 cmp (ZPPtr1) Get Return value Type
bne .91 bne .91
.1 inc ZPPtr1 advance to arg list type .1 inc ZPPtr1 advance to arg list type
bne .2 bne .2
inc ZPPtr1+1 inc ZPPtr1+1
.2 lda (ZPPtr1) get type of next arg .2 lda (ZPPtr1) get type of first arg
beq .7 end of list, go check ending ')' beq .7 end of list, go check ending ')'
*--------------------------------------
.3 eor #CSH.T.VARIADIC if VARIADIC, don't advance to next arg and assume type = 0 .3 eor #CSH.T.VARIADIC if VARIADIC, don't advance to next arg and assume type = 0
beq .4 beq .4
lda (ZPPtr1) get type again... eor #CSH.T.VARIADIC restore type...
inc ZPPtr1
bne .4
inc ZPPtr1+1
.4 jsr CSH.ExpEval A=0 if VARIADIC .4 jsr CSH.ExpEval A=0 if VARIADIC
bcs .9 X = Var Type bcs .9 X = Var Type
lda (ZPPtr1) no more arg in fn definition lda (ZPPtr1) get current arg type
beq .7
eor #CSH.T.VARIADIC eor #CSH.T.VARIADIC
bne .5 bne .5
jsr CSH.SIZEOF X = Var Type
* clc * clc
lda CSH.SIZEOF,x
adc ZPPtr2+1 adc ZPPtr2+1
sta ZPPtr2+1 Add to byte count sta ZPPtr2+1 Add to byte count
bra .51
.5 jsr CSH.GetCharNB .5 inc ZPPtr1
bne .51
inc ZPPtr1+1
.51 jsr CSH.GetCharNB
bcs .90 bcs .90
cmp #',' cmp #','
@ -439,6 +444,8 @@ CSH.fCall ldx ZPPtr1
bne .90 bne .90
lda (ZPPtr1) lda (ZPPtr1)
beq .8 no more arg after ')', exit
eor #CSH.T.VARIADIC eor #CSH.T.VARIADIC
bne .90 missing arg bne .90 missing arg
@ -514,15 +521,18 @@ CSH.ExpEval ldx ZPPtr1
jsr CSH.GetVar jsr CSH.GetVar
bcs .1 bcs .1
ldx ZPPtr2 var type ldx ZPPtr2 var type (could be 0=any)
jsr CSH.GetVarValue Get value on stack jsr CSH.GetVarValue Get value on stack
bcs .99 bcs .99
stx ZPPtr2 store real var type
bra .11 bra .11
.1 lda ZPPtr2 var type .1 lda ZPPtr2 var type
jsr CSH.fCall X = function index jsr CSH.fCall X = function index
bcs .99 bcs .99
stx ZPPtr2 store real var type
bra .11 bra .11
.2 jsr CSH.IsDigit10 number ? .2 jsr CSH.IsDigit10 number ?
@ -789,13 +799,13 @@ CSH.AddVar sta ZPVarType
lda ZPVarType lda ZPVarType
and #$1f and #$1f
tax tax
ldy CSH.SIZEOF,x ldy CSH.TYPESIZE,x
.2 iny +1 for Type .2 iny +1 for Type
lda #0 lda #0
>PUSHYA DataLen >PUSHYA DataLen
>PUSHW ZPVarData >PUSHWI ZPVarData
>PUSHW ZPVarID >PUSHW ZPVarID
>LDA.G CSH.hSymbols >LDA.G CSH.hSymbols
>SYSCALL SListAddData >SYSCALL SListAddData
@ -845,14 +855,14 @@ CSH.PushValueOnStack
bne .99 bne .99
.1 ldx ZPVarData .1 ldx ZPVarData
ldy CSH.SIZEOF,x ldy CSH.TYPESIZE,x
.2 lda ZPVarData,y .2 lda ZPVarData,y
>PUSHA >PUSHA
dey dey
bne .2 bne .2
clc clc X = Var Type
rts rts
.99 lda #CSH.E.TMISMATCH .99 lda #CSH.E.TMISMATCH
@ -861,11 +871,10 @@ CSH.PushValueOnStack
*-------------------------------------- *--------------------------------------
CSH.SetVarValue cmp ZPVarType CSH.SetVarValue cmp ZPVarType
bne .9 bne .9
sta ZPVarData sta ZPVarData
tax tax
ldy CSH.SIZEOF,x Byte count to transfer ldy CSH.TYPESIZE,x Byte count to transfer
ldx #1 ldx #1
@ -877,7 +886,7 @@ CSH.SetVarValue cmp ZPVarType
>PUSHBI 0 >PUSHBI 0
ldx ZPVarType ldx ZPVarType
lda CSH.SIZEOF,x lda CSH.TYPESIZE,x
inc +1 including TYPE inc +1 including TYPE
>PUSHA >PUSHA
>PUSHWI ZPVarData >PUSHWI ZPVarData
@ -896,7 +905,7 @@ CSH.SetVarValue cmp ZPVarType
CSH.IsValue0 cpx #CSH.T.FLOAT CSH.IsValue0 cpx #CSH.T.FLOAT
bcc .1 char,int,long bcc .1 char,int,long
ldy CSH.SIZEOF,x ldy CSH.TYPESIZE,x
lda ZPVarData,y lda ZPVarData,y
bne .9 bne .9
@ -905,7 +914,7 @@ CSH.IsValue0 cpx #CSH.T.FLOAT
rts rts
.1 tax .1 tax
lda CSH.SIZEOF,x lda CSH.TYPESIZE,x
tax tax
lda #0 lda #0
@ -1138,14 +1147,30 @@ CSH.IsDigit10 cmp #'0'
.9 sec .9 sec
rts rts
*-------------------------------------- *--------------------------------------
CSH.SIZEOF txa
and #CSH.Q.PPPOINTER
bne .2
txa
and #$f
tay
lda CSH.TYPESIZE,y
rts
.2 lda #2
rts
*--------------------------------------
* EXEC * EXEC
*-------------------------------------- *--------------------------------------
EXEC.printf >SYSCALL printf2 CSH.EXEC jmp (J.CSH.EXEC,x)
*--------------------------------------
EXEC.printf >DEBUG
>SYSCALL printf2
rts rts
*-------------------------------------- *--------------------------------------
EXEC.puts >PULLYA EXEC.puts >PULLYA
>SYSCALL puts >SYSCALL puts
rts rts
*-------------------------------------- *--------------------------------------
EXEC.cos >FPU COS EXEC.cos >FPU COS
rts rts

View File

@ -239,10 +239,10 @@ PrintF.hFILE .BS 1
.ED .ED
*-------------------------------------- *--------------------------------------
* `int printf2 ( const char * format, ... );` * `int printf2 ( const char * format, ... );`
* `>PUSHBI 2` #bytecount
* `>PUSHWI format` * `>PUSHWI format`
* `>PUSHW IntValue`
* `...` * `...`
* `>PUSHW IntValue`
* `>PUSHBI 2` #bytecount
* `>SYSCALL printf2` * `>SYSCALL printf2`
*-------------------------------------- *--------------------------------------
K.PrintF2 lda (pStack) Bytecount K.PrintF2 lda (pStack) Bytecount
@ -261,7 +261,8 @@ K.PrintF2 lda (pStack) Bytecount
>LDYAI K.IOBuf >LDYAI K.IOBuf
>STYA pIOBuf >STYA pIOBuf
bra K.PrintF2.1
K.FPrintf2 lda (pStack) Bytecount K.FPrintf2 lda (pStack) Bytecount
inc inc
tay tay
@ -278,7 +279,8 @@ K.FPrintf2 lda (pStack) Bytecount
>LDYAI K.IOBuf >LDYAI K.IOBuf
>STYA pIOBuf >STYA pIOBuf
bra K.PrintF2.1
K.SPrintf2 lda (pStack) Bytecount K.SPrintf2 lda (pStack) Bytecount
inc inc
tay tay
@ -298,19 +300,144 @@ K.SPrintf2 lda (pStack) Bytecount
lda (pStack),y str HI lda (pStack),y str HI
sta pIOBuf+1 sta pIOBuf+1
*-------------------------------------- K.PrintF2.1 stz PrintF.Cnt
K.PrintF.GetFormat stz PrintF.Cnt+1
lda (pStack)
sta ZPPtr2
ldy #1
lda (pStack),y
sta ZPPtr2+1
lda pStack lda pStack
inc
inc
sta pLocal sta pLocal
stz PrintF.LocalGetByte+1
.1 jsr SHARED.GetCharPtr2
bne .22
jmp .8 end of format..
.22 cmp #'%'
bne .10
stz K.PrintF.PadL
stz K.PrintF.PadC
lda (ZPPtr2)
beq .7 end of format... print % and exit
jsr ZP.IsDigit
bcs .6 no digit....go check specifier
cmp #'0' ...a 0...mmm... padding char?
bne .4
sta K.PrintF.PadC
jsr SHARED.NextCharPtr2 skip 0 ...
lda (ZPPtr2)
beq .7
jsr ZP.IsDigit
bcs .6 %0x ??????
.4 jsr MATH.Dec2ACC32
bcs .99
lda ACC32
sta K.PrintF.PadL
lda K.PrintF.PadC
bne .5
lda #C.SPACE
sta K.PrintF.PadC
.5 jsr SHARED.AddYToPtr2 skip all processed chars
lda (ZPPtr2)
beq .7
.6 ldx #PrintFTBL1.Cnt-1 do we have a %x command?
.61 cmp PrintFTBL1,x
beq .62
dex
bpl .61
bra .20 unknown ...
.62 jsr SHARED.NextCharPtr2
txa yes, jmp to it!
asl
tax
jsr PrintF.ESC
.11 bcc .1
bra .99
.7 lda #'%'
bra .20
*--------------------------------------
.10 cmp #'\'
bne .20
jsr SHARED.GetCharPtr2
beq .99
ldx #PrintFTBL2.Cnt-1
.12 cmp PrintFTBL2,x
beq .19
dex
bpl .12
cmp #'x' \xHH
bne .1
jsr MATH.Hex2ACC32
bcs .99
jsr SHARED.AddYToPtr2
.14 lda ACC32
bra .20
.19 lda PrintFTBL2.OUT,x
.20 jsr PrintF.COut
bcc .11
*--------------------------------------
.99 bra PrintF2.LocalCleanUp
*--------------------------------------
.8 ldx PrintF.hFILE
beq .80 Writing to buffer, append \0
>PUSHW PrintF.Cnt Writing to File/dev...
>PUSHWI K.IOBuf
txa
jsr K.FWrite
bcc .81
tay
bne .99
>RET 4 0=BLOCKING
.80 ldy PrintF.Cnt A=0, Writing to buffer, append \0
sta (pIOBuf),y
.81 >LDYA PrintF.Cnt
* clc
*--------------------------------------
PrintF2.LocalCleanUp
php
pha
lda pLocal
sec ByteCnt byte
adc (pLocal) ... ByteCnt
sta pStack CC
pla
plp
PrintF2.LocalCleanUp.RTS
rts rts
*-------------------------------------- *--------------------------------------
K.SPrintF stz PrintF.hFILE K.SPrintF stz PrintF.hFILE
@ -722,6 +849,20 @@ PrintF.COut phy
.9 lda #E.BUF .9 lda #E.BUF
sec sec
PrintF.COut.RTS rts PrintF.COut.RTS rts
*--------------------------------------
K.PrintF.GetFormat
lda (pStack)
sta ZPPtr2
ldy #1
lda (pStack),y
sta ZPPtr2+1
lda pStack
inc
inc
sta pLocal
rts
*/-------------------------------------- */--------------------------------------
* # fgets (BLOCKING) * # fgets (BLOCKING)
* read bytes from stream into the array * read bytes from stream into the array

View File

@ -49,9 +49,6 @@ A2osX.D1 .PH $D000
.INB USR/SRC/SYS/KERNEL.S.UNISTD .INB USR/SRC/SYS/KERNEL.S.UNISTD
.INB USR/SRC/SYS/KERNEL.S.STDIO .INB USR/SRC/SYS/KERNEL.S.STDIO
.INB USR/SRC/SYS/KERNEL.S.STDLIB .INB USR/SRC/SYS/KERNEL.S.STDLIB
.INB USR/SRC/SYS/KERNEL.S.DEV
.INB USR/SRC/SYS/KERNEL.S.FIO
.INB USR/SRC/SYS/KERNEL.S.PFT
.EP .EP
A2osX.D2 .PH $D000 A2osX.D2 .PH $D000
.DA #RRAMWRAMBNK2 .DA #RRAMWRAMBNK2
@ -72,6 +69,9 @@ A2osX.E0 .PH $E000
********* TMP ***** go to A2osX.D1 ********* TMP ***** go to A2osX.D1
.INB USR/SRC/SYS/KERNEL.S.IO .INB USR/SRC/SYS/KERNEL.S.IO
.INB USR/SRC/SYS/KERNEL.S.PIPE .INB USR/SRC/SYS/KERNEL.S.PIPE
.INB USR/SRC/SYS/KERNEL.S.DEV
.INB USR/SRC/SYS/KERNEL.S.FIO
.INB USR/SRC/SYS/KERNEL.S.PFT
********* TMP ***** go to A2osX.D2 ********* TMP ***** go to A2osX.D2
*-------------------------------------- *--------------------------------------
PWD.bDirty .BS 1 PWD.bDirty .BS 1