A2osX/SYS/KERNEL.S.LIB.txt
2016-06-07 08:10:18 +02:00

118 lines
2.5 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
*--------------------------------------
* S.LoadLibYA
* in :
* Y,A = PTR To Lib Name
* out :
* A = hMem To loaded LIB
*--------------------------------------
S.LoadLibYA jsr S.NewPStrYA
bcs .99
sta S.LoadLibYA.hLibName save LibName hMem for discard
jsr S.LoadLibA
php save error status
pha save error code/hMem
lda S.LoadLibYA.hLibName
jsr S.FreeMemA discard STR hMem
pla get back error code/hMem
plp ..and error status
.99 rts
*--------------------------------------
S.LoadLibYA.hLibName .BS 1
*--------------------------------------
* S.LoadLibA
* in :
* A = hMem To Lib Name
* out :
* A = hMem of Loaded Lib
*--------------------------------------
S.LoadLibA sta S.LoadLibA.hName save libname for S.FileSearch
>LDYAI ENV.LIB push ENVNAME=LIB
jsr S.GetEnvVarYA get value for ENV=LIB
bcs .99
sta S.LoadLibA.hSrch save hMem to LIB VALUE
>PUSHB S.LoadLibA.hName
>PUSHB S.LoadLibA.hSrch
jsr S.FileSearch find libname in $LIB
bcs .98
sta S.LoadLibA.hPath
jsr S.LoadBinA A = hMem of filename full path
bcs .97
stx S.LoadLibA.hMem
>STYA pLib
ldx #LIBMGR.LOAD
jsr pLibJmp Call LIB.LOAD function
bcs .97
jsr .97
lda S.LoadLibA.hMem
clc
rts
.97 pha
lda S.LoadLibA.hPath discard LIB PATH
jsr S.FreeMemA
pla
.98 pha
lda S.LoadLibA.hSrch discard LIB VALUE
jsr S.FreeMemA
pla
sec
.99 rts
*--------------------------------------
S.LoadLibA.hName .BS 1
S.LoadLibA.hSrch .BS 1
S.LoadLibA.hPath .BS 1
S.LoadLibA.hMem .BS 1
*--------------------------------------
* S.UnloadLibA
* in :
* A = hMem To Lib
* out :
*--------------------------------------
S.UnloadLibA pha
jsr S.GetMemByIDA
>STYA ZPQuickPtr1
ldy #S.MEM.REFCNT
lda (ZPQuickPtr1),y Get count of those referencing this lib
dec only one left ?
beq .1
sta (ZPQuickPtr1),y
pla
clc
rts
.1 ldy #S.MEM.PTR
lda (ZPQuickPtr1),y
pha
iny
lda (ZPQuickPtr1),y
ply
>STYA pLib
ldx #LIBMGR.UNLOAD
jsr pLibJmp Call LIB.UNLOAD function
pla
jmp S.FreeMemA
*--------------------------------------
ENV.LIB >PSTRING "LIB"
MAN
SAVE SYS/KERNEL.S.LIB
LOAD SYS/KERNEL.S
ASM