A2osX/SYS/KERNEL.S.LIB.txt
2017-03-27 17:32:30 +02: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
*--------------------------------------
* 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 LIB.Jump+1
ldx #LIBMGR.LOAD
jsr LIB.Jump 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 LIB.Jump+1
iny
lda (ZPPtr1),y
sta LIB.Jump+2
ldx #LIBMGR.UNLOAD
jsr LIB.Jump Call LIB.UNLOAD function
pla
jmp K.FreeMemA
LIB.Jump jmp $ffff Self Modiied
*--------------------------------------
MAN
SAVE SYS/KERNEL.S.LIB
LOAD SYS/KERNEL.S
ASM