A2osX/SYS/KERNEL.S.LIB.txt

95 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.BUILD
LOMEM $A00
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 .9+1
jsr K.LoadExeYA Y,A=filename full path
bcs .98
stx .8+1
>STYA LIB.Jump+1
txa Pass hLib to LibLoad
ldx #LIBMGR.LOAD
jsr LIB.Jump Call LIB.LOAD function
bcs .97
jsr .98 Cleanup...
.8 lda #$ff hLib
clc
rts
.97 pha
lda .8+1
jsr K.FreeMemA
pla
.98 pha
.9 lda #$ff
jsr K.FreeMemA
pla
sec
.99 rts
*--------------------------------------
K.LoadLib.Name .BS 2
*--------------------------------------
* 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 /A2OSX.SRC/SYS/KERNEL.S.LIB
LOAD /A2OSX.SRC/SYS/KERNEL.S
ASM