A2osX/SYS/KERNEL.S.LIB.txt

116 lines
2.5 KiB
Plaintext
Raw Normal View History

2015-06-03 18:30:57 +00:00
PR#3
PREFIX /A2OSX.SRC
NEW
INC 1
AUTO 6
.LIST OFF
.OP 65C02
*--------------------------------------
* 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 >PUSHA push libname for S.FileSearch
>LDYAI MSG.LOADLIB
jsr S.SysScrPPSTRYA
>PUSHWI ENV.LIB push ENVNAME=LIB
ldy #S.PS.hENV
lda (pPs),y
>PUSHA
jsr S.GetEnvVarP get value for ENV=LIB
bcs .99
pha save hMem to LIB VALUE
>PUSHA Push %LIB% VALUE
jsr S.FileSearch find libname in %LIB%
bcs .98
pha save hMem to LIB full path
jsr S.SysScrPPSTRA
pla
pha
jsr S.LoadBinA A = hMem of filename full path
bcs .97
phx
>STYA pLib
ldx #LIBMGR.LOAD
jsr pLibJmp Call LIB.LOAD function
bcs .97
plx
pla discard LIB PATH
jsr S.FreeMemA
pla discard LIB VALUE
jsr S.FreeMemA
txa
clc
rts
.97 pla discard LIB PATH
jsr S.FreeMemA
.98 pla discard LIB VALUE
jsr S.FreeMemA
sec
.99 rts
*--------------------------------------
* 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
*--------------------------------------
MSG.LOADLIB >PSTRING "\nLoadLib:"
*--------------------------------------
MAN
SAVE SYS/KERNEL.S.LIB
LOAD SYS/KERNEL.S
ASM