Kernel version 0.8 : Merging LIBSTR into Kernel, fixed bug in DevMgr, crashing Console.DRV at Boot

This commit is contained in:
Rémy GIBERT 2016-10-12 17:46:38 +02:00
parent b6d8805622
commit 4f7c8479c0
6 changed files with 426 additions and 243 deletions

Binary file not shown.

Binary file not shown.

View File

@ -48,7 +48,7 @@ CS.INIT >LDYA L.MemStat
>SYSCALL SYS.GetMemStatYA
>LDYA L.MSG.Main
>SYSCALL SYS.PStrOutYA
>SYSCALL SYS.PrintFYA
lda MemStat+S.MEMSTAT.MF
sec
@ -63,10 +63,10 @@ CS.INIT >LDYA L.MemStat
>PUSHW MemStat+S.MEMSTAT.ML
>LDYA L.MSG.Stat
>SYSCALL SYS.PStrOutYA
>SYSCALL SYS.PrintFYA
*--------------------------------------
>LDYA L.MSG.Aux
>SYSCALL SYS.PStrOutYA
>SYSCALL SYS.PrintFYA
lda MemStat+S.MEMSTAT.XF
sec
@ -81,10 +81,10 @@ CS.INIT >LDYA L.MemStat
>PUSHW MemStat+S.MEMSTAT.XL
>LDYA L.MSG.Stat
>SYSCALL SYS.PStrOutYA
>SYSCALL SYS.PrintFYA
*--------------------------------------
>LDYA L.MSG.Kernel
>SYSCALL SYS.PStrOutYA
>SYSCALL SYS.PrintFYA
lda MemStat+S.MEMSTAT.DH
sec
@ -99,10 +99,10 @@ CS.INIT >LDYA L.MemStat
>PUSHW MemStat+S.MEMSTAT.DL
>LDYA L.MSG.Stat
>SYSCALL SYS.PStrOutYA
>SYSCALL SYS.PrintFYA
>LDYA L.MSG.End
>SYSCALL SYS.PStrOutYA
>SYSCALL SYS.PrintFYA
lda #0
sec
rts
@ -113,11 +113,11 @@ CS.QUIT clc
rts
*--------------------------------------
CS.END
MSG.Main >PSTRING "--- Main Memory ---------------\n"
MSG.Aux >PSTRING "--- Aux Memory ----------------\n"
MSG.Kernel >PSTRING "--- Kernel (Drivers) Memory ---\n"
MSG.Stat >PSTRING " Low : $%H\n Free Ptr : $%H\n High : $%H\n Available Memory : %D Bytes\n"
MSG.End >PSTRING "-------------------------------\n"
MSG.Main >CSTRING "--- Main Memory ---------------\n"
MSG.Aux >CSTRING "--- Aux Memory ----------------\n"
MSG.Kernel >CSTRING "--- Kernel (Drivers) Memory ---\n"
MSG.Stat >CSTRING " Low : $%H\n Free Ptr : $%H\n High : $%H\n Available Memory : %05D Bytes\n"
MSG.End >CSTRING "-------------------------------\n"
MemStat .BS S.MEMSTAT
*--------------------------------------
.DUMMY

View File

@ -68,10 +68,16 @@ K.LoadEXEYA.1 >PUSHWI KrnBuf256
sta BIN.Relocate.Offset+1
ldy #H.BIN.CODE.LEN get Code Len
jsr BIN.SetupCodeEndPtr2
lda (ZPQuickPtr1),y
clc
adc ZPQuickPtr1
sta ZPQuickPtr2 Make ZPQuickPtr2 = ZPQuickPtr1 + CodeLen
iny
lda (ZPQuickPtr1),y
adc ZPQuickPtr1+1
sta ZPQuickPtr2+1
jsr BIN.RelocateEXE
bcs .98
>LDYA K.LoadEXEYA.Filename get back bin path
>SYSCALL SYS.NewPStrYA make a copy of this string
@ -266,17 +272,6 @@ BIN.InstallDRV ldy #H.BIN.DRV.CODE.O
BIN.InstallDRV.DrvLen .BS 2
BIN.InstallDRV.DrvEnd .BS 2
*--------------------------------------
BIN.SetupCodeEndPtr2
lda (ZPQuickPtr1),y
clc
adc ZPQuickPtr1
sta ZPQuickPtr2 Make ZPQuickPtr2 = ZPQuickPtr1 + CodeLen
iny
lda (ZPQuickPtr1),y
adc ZPQuickPtr1+1
sta ZPQuickPtr2+1
rts
*--------------------------------------
* BIN.Relocate___ :
* In :
* ZPQuickPtr1 = Ptr to Code

View File

@ -127,125 +127,199 @@ PrintFTBL2.END
PrintFTBL2.OUT .HS 1B.0D \e\n
.DA #'\' \\
.DA #'%' \%
PrintFJMP .DA PrintF.D,PrintF.DD,PrintF.U
PADLEN .BS 1
PADCHAR .BS 1
DWORDBUF .BS 4
PrintFJMP .DA PrintF.A
.DA PrintF.B,PrintF.BB
.DA PrintF.D,PrintF.DD,PrintF.U
.DA PrintF.E,PrintF.F
.DA PrintF.H,PrintF.HH
.DA PrintF.I,PrintF.II,PrintF.L
.DA PrintF.N,PrintF.NN
.DA PrintF.S,PrintF.SS
*--------------------------------------
PrintF.D >PULLA DWORDBUF
stz DWORDBUF+1
PrintF.A >PULLW HEXBUF
rts
*--------------------------------------
PrintF.BB >PULLYA
phy
jsr PrintF.B
pla
bra PrintF.B.1
*--------------------------------------
PrintF.B >PULLA
PrintF.B.1 ldx #8
.1 asl
pha
lda #'0'
adc #0 add Carry
jsr K.COutA
pla
dex
bne .1
rts
*--------------------------------------
PrintF.D >PULLB HEXBUF
stz HEXBUF+1
bra PrintF.DD.1
PrintF.DD >PULLYA DWORDBUF
PrintF.DD.1 stz DWORDBUF+2
stz DWORDBUF+3
PrintF.DD >PULLW HEXBUF
PrintF.DD.1 stz HEXBUF+2
stz HEXBUF+3
bra PrintF.U.1
PrintF.U >PULLW ZPQuickPtr2
ldy #3
.1 lda (ZPQuickPtr2),y
sta DWORDBUF,y
sta HEXBUF,y
dey
bpl .1
PrintF.U.1 rts
PrintF.U.1 stz SIGN
jsr HEX2DEC
jmp PrintDEC
*--------------------------------------
PrintF.E >PULLW ZPQuickPtr2
rts
*--------------------------------------
K.DecOutA tay
lda #0
K.DecOutYA >STYA HEX
stz BCD
stz BCD+1
stz BCD+2
ldx #16 let's roll 16 bits
sed
.2 asl HEX
rol HEX+1
php cpy will disturb carry while BCD adc
ldy #0
.3 plp
lda BCD,y
adc BCD,y
sta BCD,y
php
iny
cpy #3 Last byte of BCDBUF?
bne .3
plp
dex
bne .2
cld
stz bL0Flag
ldx #2
.4 lda BCD,x
lsr
lsr
lsr
lsr
bne .5
bit bL0Flag
bpl .6
.5 sec
ror bL0Flag
ora #$30
jsr K.COutA
bcs .9
.6 lda BCD,x
and #$0F
bne .7
bit bL0Flag
bpl .8
.7 sec
ror bL0Flag
ora #$30
jsr K.COutA
bcs .9
.8 dex
bpl .4
bit bL0Flag
bmi .9
lda #$30
jsr K.COutA
.9 rts
PrintF.F >PULLW ZPQuickPtr2
rts
*--------------------------------------
K.HexOutYA phy
jsr K.HexOutA
bcs K.COutA.RTS
PrintF.HH >PULLYA
K.HexOutYA
phy
jsr PrintF.H.1
pla
bra PrintF.H.1
*--------------------------------------
K.HexOutA pha
PrintF.H >PULLA
K.HexOutA
PrintF.H.1 pha
jsr PrintF.NN.1
pla
jmp PrintF.N.1
*--------------------------------------
PrintF.I >PULLB HEXBUF
eor #$ff if positive, it becomes neg so branch if....minus!
clc
bmi .1
sec
inc 2s complement...
sta HEXBUF
.1 stz HEXBUF+1
bra PrintF.II.1
PrintF.II >PULLW HEXBUF A=HI
eor #$ff
clc
bmi PrintF.II.1
sec
tax
lda HEXBUF
eor #$ff
inc 2s complement...
sta HEXBUF
bne .1
inx
.1 sta HEXBUF
stx HEXBUF+1
PrintF.II.1 stz HEXBUF+2
stz HEXBUF+3
bra PrintF.L.1
PrintF.L >PULLW ZPQuickPtr2
ldy #3
.1 lda (ZPQuickPtr2),y
sta HEXBUF,y
dey
bpl .1
PrintF.L.1 ror SIGN
jsr HEX2DEC
jmp PrintDEC
*--------------------------------------
PrintF.N >PULLA
PrintF.N.1 and #$0F
bra PrintF.NN.2
PrintF.NN >PULLA
PrintF.NN.1 lsr
lsr
lsr
lsr
lsr
ora #$30
PrintF.NN.2 ora #$30
cmp #$3A
bcc .1
adc #6
.1 jsr K.COutA
bcs K.COutA.RTS
pla
and #$0F
ora #$30
cmp #$3A
bcc K.COutA
adc #6
.1 jmp K.COutA
*--------------------------------------
* CStr
*--------------------------------------
PrintF.S >PULLW ZPQuickPtr2
ldy #0
.1 lda (ZPQuickPtr2),y
beq .2
jsr K.COutA
iny
lda PADLEN
beq .1
cpy PADLEN
bne .1
rts
.2 lda PADLEN
beq .8
.3 lda PADCHAR
jsr K.COutA
iny
cpy PADLEN
bne .3
.8 rts
*--------------------------------------
* PStr
*--------------------------------------
PrintF.SS >PULLW ZPQuickPtr2
ldy #0
lda (ZPQuickPtr2),y
tax
beq .8
.1 iny
lda (ZPQuickPtr2),y
jsr K.COutA
lda PADLEN
beq .2
cpy PADLEN
beq .8
.2 dex
bne .1
lda PADLEN
beq .8
.3 lda PADCHAR
jsr K.COutA
iny
cpy PADLEN
bne .3
.8 rts
*--------------------------------------
K.COutA phx
phy
@ -259,7 +333,184 @@ K.COutA phx
jsr pDevJmp
.2 ply
plx
K.COutA.RTS rts
rts
*--------------------------------------
* Convert HEXBUF to ASCBUF decimal padded with 0
*--------------------------------------
HEX2DEC ldx #4
.1 stz BCDBUF,x Clear all 5 bytes
dex
bpl .1
sed switch to BCD mode
ldx #32 let's roll 32 bits
.2 asl HEXBUF
rol HEXBUF+1
rol HEXBUF+2
rol HEXBUF+3
ldy #4
.3 lda BCDBUF,y
adc BCDBUF,y
sta BCDBUF,y
dey
bpl .3
dex
bne .2
cld
ldy #4
ldx #9
.4 lda BCDBUF,y
pha
and #$0F
ora #$30
sta ASCBUF,x
dex
pla
lsr
lsr
lsr
lsr
ora #$30
sta ASCBUF,x
dey
dex
bpl .4
rts
*--------------------------------------
PRINTDEC lda PADLEN any Len format ?
beq .1 no
lda #10
sec yes, Print only digits starting at pos 10-padlen
sbc PADLEN
.1 tax x=0 if no padlen, or x=10-padlen
.2 lda ASCBUF,x
cmp #'0' a zero?
beq .3
inc PADLEN found a non zero, Print all digits, even if 0, next time
ldy #'0'
sty PADCHAR
bra .4
.3 cpx #9 last digit ?
beq .4 Print always
ldy PADLEN no pad to fill, do not Print 0
beq .9
lda PADCHAR fill with PADCHAR
.4 bit SIGN a sign to print before digits ?
bpl .5
pha yes, save whatever we have to print....
lda #'-'
jsr K.COutA
stz SIGN reset flag for next char...
pla
.5 jsr K.COutA
.9 inx
cpx #10
bne .2
rts
*--------------------------------------
* Convert ASCBUF decimal to HEXBUF
*--------------------------------------
DEC2HEX stz HEXBUF
stz HEXBUF+1
stz HEXBUF+2
stz HEXBUF+3
ldx #0
.1 lda HEXBUF+3 save HEXBUF for 4+1
pha
lda HEXBUF+2
pha
lda HEXBUF+1
pha
lda HEXBUF
pha
asl HEXBUF HEXBUF * 2 -> HEXBUF
rol HEXBUF+1
rol HEXBUF+2
rol HEXBUF+3
bcs .9 overflow!!!
asl HEXBUF HEXBUF * 4 -> HEXBUF
rol HEXBUF+1
rol HEXBUF+2
rol HEXBUF+3
bcs .9 overflow!!!
pla HEXBUF * 4 + HEXBUF -> HEXBUF
adc HEXBUF
sta HEXBUF
pla
adc HEXBUF+1
sta HEXBUF+1
pla
adc HEXBUF+2
sta HEXBUF+2
pla
adc HEXBUF+3
sta HEXBUF+3
bcs .99 overflow!!!
asl HEXBUF HEXBUF * 10 -> HEXBUF
rol HEXBUF+1
rol HEXBUF+2
rol HEXBUF+3
bcs .99 overflow!!!
inx
lda ASCBUF,x
and #$0F
adc HEXBUF
sta HEXBUF
bcc .2
inc HEXBUF+1
bne .2
inc HEXBUF+2
bne .2
inc HEXBUF+3
.2 cpx ASCBUF
bne .1
rts
.9 pla discard saved HEXBUF
pla
pla
pla
.99 rts
*--------------------------------------
ACCESS .AS "drwxrwxrwx"
HEXBUF .BS 4 32 bits max
BCDBUF .BS 5 5, enough to handle 10 digits (32bits)
ASCBUF .BS 12 LEN + sign + 10 digits ($FFFFFFFF=4.294.967.295)
SIGN .BS 1
PADLEN .BS 1
PADCHAR .BS 1
*--------------------------------------
* SUPERSEEDED by K.PrintFYA
*--------------------------------------
* Mini printf for PSTR
* %d : byte
@ -391,134 +642,70 @@ K.PStrOutYAS >STYA ZPQuickPtr2
.9 ply
rts
*--------------------------------------
* Convert HEXBUF to ASCBUF decimal padded with 0
*--------------------------------------
HEX2DEC ldx #4
.1 stz BCDBUF,x Clear all 5 bytes
dex
bpl .1
sed switch to BCD mode
ldx #32 let's roll 32 bits
.2 asl HEXBUF
rol HEXBUF+1
rol HEXBUF+2
rol HEXBUF+3
ldy #4
.3 lda BCDBUF,y
adc BCDBUF,y
sta BCDBUF,y
dey
bpl .3
K.DecOutA tay
lda #0
K.DecOutYA >STYA HEX
stz BCD
stz BCD+1
stz BCD+2
ldx #16 let's roll 16 bits
sed
.2 asl HEX
rol HEX+1
php cpy will disturb carry while BCD adc
ldy #0
.3 plp
lda BCD,y
adc BCD,y
sta BCD,y
php
iny
cpy #3 Last byte of BCDBUF?
bne .3
plp
dex
bne .2
cld
ldy #4
ldx #9
stz bL0Flag
ldx #2
.4 lda BCDBUF,y
pha
.4 lda BCD,x
lsr
lsr
lsr
lsr
bne .5
bit bL0Flag
bpl .6
.5 sec
ror bL0Flag
ora #$30
jsr K.COutA
bcs .9
.6 lda BCD,x
and #$0F
bne .7
bit bL0Flag
bpl .8
.7 sec
ror bL0Flag
ora #$30
sta ASCBUF,x
dex
pla
lsr
lsr
lsr
lsr
ora #$30
sta ASCBUF,x
dey
dex
jsr K.COutA
bcs .9
.8 dex
bpl .4
rts
*--------------------------------------
* Convert ASCBUF decimal to HEXBUF
*--------------------------------------
DEC2HEX stz HEXBUF
stz HEXBUF+1
stz HEXBUF+2
stz HEXBUF+3
bit bL0Flag
bmi .9
lda #$30
jsr K.COutA
ldx #0
.1 lda HEXBUF+3 save HEXBUF for 4+1
pha
lda HEXBUF+2
pha
lda HEXBUF+1
pha
lda HEXBUF
pha
asl HEXBUF HEXBUF * 2 -> HEXBUF
rol HEXBUF+1
rol HEXBUF+2
rol HEXBUF+3
bcs .9 overflow!!!
asl HEXBUF HEXBUF * 4 -> HEXBUF
rol HEXBUF+1
rol HEXBUF+2
rol HEXBUF+3
bcs .9 overflow!!!
pla HEXBUF * 4 + HEXBUF -> HEXBUF
adc HEXBUF
sta HEXBUF
pla
adc HEXBUF+1
sta HEXBUF+1
pla
adc HEXBUF+2
sta HEXBUF+2
pla
adc HEXBUF+3
sta HEXBUF+3
bcs .99 overflow!!!
asl HEXBUF HEXBUF * 10 -> HEXBUF
rol HEXBUF+1
rol HEXBUF+2
rol HEXBUF+3
bcs .99 overflow!!!
inx
lda ASCBUF,x
and #$0F
adc HEXBUF
sta HEXBUF
bcc .2
inc HEXBUF+1
bne .2
inc HEXBUF+2
bne .2
inc HEXBUF+3
.2 cpx ASCBUF
bne .1
rts
.9 pla discard saved HEXBUF
pla
pla
pla
.99 rts
*--------------------------------------
HEXBUF .BS 4 32 bits max
BCDBUF .BS 5 5, enough to handle 10 digits (32bits)
ASCBUF .BS 12 LEN + sign + 10 digits ($FFFFFFFF=4.294.967.295)
.9 rts
*--------------------------------------
HEX .BS 2
BCD .BS 3

View File

@ -166,11 +166,12 @@ K.MemMgrInit >LDYAI MemMgr.MHiMem
*--------------------------------------
* K.EvtMgrInit
*--------------------------------------
K.EvtMgrInit lda #10
sta EVTMGR.10TH.CNT
K.EvtMgrInit
* lda #10
* sta EVTMGR.10TH.CNT WARNING!!!! WRONG BANK!!!
lda A2osX.HZ
sta EVTMGR.HZ.CNT
* lda A2osX.HZ
* sta EVTMGR.HZ.CNT
lda MACHID
and #MACHID.TYPE