Kernel version 0.8 : Saved few bytes (& cycles) in MemMgr

This commit is contained in:
Rémy GIBERT 2016-11-01 22:34:29 +01:00
parent af54e1e393
commit b87ffebe14
4 changed files with 65 additions and 82 deletions

View File

@ -14,7 +14,7 @@ AUTO 6
*--------------------------------------
K.LoadEXEYA >STYA K.LoadEXEYA.Filename
>SYSCALL PStrUprYA Y,A unmodified
jsr K.GetMemByNameYA
jsr MEM.GetMemByNameYA
bcs K.LoadEXEYA.1 not already loaded
>STYA ZPQuickPtr1 Save base address

View File

@ -5,7 +5,9 @@ INC 1
AUTO 6
.LIST OFF
*--------------------------------------
DevMgr.Free .DA DevMgr.LoMem
DevMgr.Stat .DA DevMgr.LoMem Lomem
DevMgr.Free .DA DevMgr.LoMem Free
.DA DevMgr.HiMem
DevMgr.LastDevID .DA #DevMgr.Count-1
TSKMGR.SIZE .BS 1
TSKMGR.LASTID .BS 1

View File

@ -100,7 +100,7 @@ KERNEL.SYSCALL
.DA K.FreeMemA
.DA K.GetMemPtrA
.DA K.GetMemByIDA
.DA K.GetMemByNameYA
.DA 0
.DA K.LoadStockObjectYA
.DA K.GetStockObjectA
.DA K.FreeStockObject

View File

@ -114,9 +114,8 @@ K.GetMem >PULLB MemMgr.ReqFlags store requested flags
and #S.MEM.F.INIT0
beq .8
phx save hMem
jsr MemMgr.Init0
plx restore hMem
jsr MemMgr.Init0 X not madified
.8 lda #0
ldy #S.MEM.BIN
@ -226,15 +225,14 @@ MemMgr.Init0 ldy #S.MEM.PTR
eor #$ff a=not hi count
ply y=not lo count
ldx #0
.1 iny
bne .2
inc
beq .8
.2 stz $ffff,x
inx
.2 stz $ffff
inc .2+1
bne .1
inc .2+2
bne .1
@ -263,25 +261,21 @@ K.FreeMemA phy
sta (ZPMemMgrSPtr),y
bne .8 no, must be a code segment loaded several times
lda #0 mark this slot as free
sta (ZPMemMgrSPtr)
ldy #S.MEM.BIN
lda (ZPMemMgrSPtr),y Any BINPATH to discard ?
beq .1
pha save hMem
>PUSHW ZPMemMgrSPtr
pla
jsr K.GetMemByIDA X unmodified
lda (ZPMemMgrSPtr)
bpl * ***MUST BE ALLOCATED***
lda #0 mark BINPATH slot as free
sta (ZPMemMgrSPtr)
>PULLW ZPMemMgrSPtr
.1 lda #0 mark this slot as free
sta (ZPMemMgrSPtr)
.2 lda MemMgr.LastSlot
.1 lda MemMgr.LastSlot
beq .8
jsr K.GetMemByIDA X unmodified
@ -299,7 +293,7 @@ K.FreeMemA phy
sta MemMgr.Free+1
dec MemMgr.LastSlot discard last slot
bne .2 no slot left, exit
bne .1 no slot left, exit
.8 ply
clc
@ -400,13 +394,63 @@ K.GetMemByIDA sta ZPMemMgrSPtr
* sta ZPMemMgrSPtr+1
* rts
*--------------------------------------
K.LoadStockObjectYA
*--------------------------------------
K.GetStockObjectA
*--------------------------------------
K.FreeStockObject
*--------------------------------------
K.SetLoMem
clc
rts
*/--------------------------------------
* #GetMemStatYA
* ##In:
* Y,A = 24 bytes buffer
* ##Out:
* Buffer filled with memory stats
*\--------------------------------------
K.GetMemStatYA >STYA ZPMemMgrDstPtr
ldy #6
.1 lda MemMgr.Table,y
sta (ZPMemMgrDstPtr),y
dey
bpl .1
ldx #6
ldy #14
sta SETREADAUX
.2 lda MemMgr.Table,x
sta (ZPMemMgrDstPtr),y
dey
dex
bpl .2
sta CLRREADAUX
ldx #6
ldy #22
.3 lda DevMgr.Stat,x
sta (ZPMemMgrDstPtr),y
dey
dex
bpl .3
rts
*--------------------------------------
* In:
* Y,A = BINPATH (PSTR)
* Out:
* Y,A = ZPMemMgrSPtr = PTR to S.MEM
* X = hMem
*--------------------------------------
K.GetMemByNameYA
MEM.GetMemByNameYA
ldx MemMgr.LastSlot
beq .9
@ -457,69 +501,6 @@ K.GetMemByNameYA
.9 sec
rts
*--------------------------------------
K.LoadStockObjectYA
*--------------------------------------
K.GetStockObjectA
*--------------------------------------
K.FreeStockObject
*--------------------------------------
K.SetLoMem
clc
rts
*--------------------------------------
K.GetMemStatYA >STYA ZPMemMgrDstPtr
ldy #7
.1 lda MemMgr.Table,y
sta (ZPMemMgrDstPtr),y
dey
bpl .1
ldx #7
ldy #15
sta SETREADAUX
.2 lda MemMgr.Table,x
sta (ZPMemMgrDstPtr),y
dey
dex
bpl .2
sta CLRREADAUX
ldy #16
lda #DevMgr.LoMem
sta (ZPMemMgrDstPtr),y
iny
lda /DevMgr.LoMem
sta (ZPMemMgrDstPtr),y
iny
lda DevMgr.Free
sta (ZPMemMgrDstPtr),y
iny
lda DevMgr.Free+1
sta (ZPMemMgrDstPtr),y
iny
lda #DevMgr.HiMem
sta (ZPMemMgrDstPtr),y
iny
lda /DevMgr.HiMem
sta (ZPMemMgrDstPtr),y
iny
lda DevMgr.LastDevID
sta (ZPMemMgrDstPtr),y
rts
*--------------------------------------
MEM.GarbageCollector
clc
rts