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
PREFIX
AUTO 4,1
AUTO 3,1
*---------------------------------------
DIR.Reset lda #$80
ldy #ASM.LI.ON

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -91,7 +91,7 @@ CSH.STYPES >PSTR "char"
>PSTR "int"
>PSTR "long"
* .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, ... );
CSH.FN >PSTR "printf"

View File

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

View File

@ -239,10 +239,10 @@ PrintF.hFILE .BS 1
.ED
*--------------------------------------
* `int printf2 ( const char * format, ... );`
* `>PUSHBI 2` #bytecount
* `>PUSHWI format`
* `>PUSHW IntValue`
* `...`
* `>PUSHW IntValue`
* `>PUSHBI 2` #bytecount
* `>SYSCALL printf2`
*--------------------------------------
K.PrintF2 lda (pStack) Bytecount
@ -261,7 +261,8 @@ K.PrintF2 lda (pStack) Bytecount
>LDYAI K.IOBuf
>STYA pIOBuf
bra K.PrintF2.1
K.FPrintf2 lda (pStack) Bytecount
inc
tay
@ -278,7 +279,8 @@ K.FPrintf2 lda (pStack) Bytecount
>LDYAI K.IOBuf
>STYA pIOBuf
bra K.PrintF2.1
K.SPrintf2 lda (pStack) Bytecount
inc
tay
@ -298,19 +300,144 @@ K.SPrintf2 lda (pStack) Bytecount
lda (pStack),y str HI
sta pIOBuf+1
*--------------------------------------
K.PrintF.GetFormat
lda (pStack)
sta ZPPtr2
ldy #1
lda (pStack),y
sta ZPPtr2+1
K.PrintF2.1 stz PrintF.Cnt
stz PrintF.Cnt+1
lda pStack
inc
inc
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
*--------------------------------------
K.SPrintF stz PrintF.hFILE
@ -722,6 +849,20 @@ PrintF.COut phy
.9 lda #E.BUF
sec
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)
* 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.STDIO
.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
A2osX.D2 .PH $D000
.DA #RRAMWRAMBNK2
@ -72,6 +69,9 @@ A2osX.E0 .PH $E000
********* TMP ***** go to A2osX.D1
.INB USR/SRC/SYS/KERNEL.S.IO
.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
*--------------------------------------
PWD.bDirty .BS 1