A2osX/SYS/KERNEL.S.LIB.txt
Rémy GIBERT bae3f91aab 0.9
2017-01-12 18:43:45 +01:00

96 lines
1.8 KiB
Plaintext
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

PR#3
PREFIX /A2OSX.SRC
NEW
INC 1
AUTO 6
.LIST OFF
*--------------------------------------
* K.LoadLibYA
* in :
* Y,A = PTR To Lib Name
* out :
* A = hMem To loaded LIB
*--------------------------------------
K.LoadLibYA >STYA K.LoadLib.Name save libname for K.FileSearch
>LDYAI ENV.LIB push ENVNAME=LIB
>SYSCALL GetEnvYA get value for ENV=LIB
bcs .99
>PUSHYA Push $LIB value
>PUSHW K.LoadLib.Name
jsr K.FileSearch find libname in $LIB
bcs .99
stx K.LoadLib.hFullName
jsr K.LoadExeYA Y,A=filename full path
bcs .98
stx K.LoadLib.hMem
>STYA pLib
ldx #LIBMGR.LOAD
jsr pLibJmp Call LIB.LOAD function
bcs .97
jsr .98 Cleanup...
lda K.LoadLib.hMem
clc
rts
.97 pha
lda K.LoadLib.hMem
jsr K.FreeMemA
pla
.98 pha
lda K.LoadLib.hFullName
jsr K.FreeMemA
pla
sec
.99 rts
*--------------------------------------
K.LoadLib.Name .BS 2
K.LoadLib.hFullName .BS 1
K.LoadLib.hMem .BS 1
*--------------------------------------
* K.UnloadLibA
* in :
* A = hMem To Lib
* out :
*--------------------------------------
K.UnloadLibA pha
jsr K.GetMemByIDA
>STYA ZPPtr1
ldy #S.MEM.REFCNT
lda (ZPPtr1),y Get count of those referencing this lib
dec only one left ?
beq .1
sta (ZPPtr1),y
pla
clc
rts
.1 ldy #S.MEM.PTR
lda (ZPPtr1),y
sta pLib
iny
lda (ZPPtr1),y
sta pLib+1
ldx #LIBMGR.UNLOAD
jsr pLibJmp Call LIB.UNLOAD function
pla
jmp K.FreeMemA
*--------------------------------------
MAN
SAVE SYS/KERNEL.S.LIB
LOAD SYS/KERNEL.S
ASM