A2osX/SYS/KERNEL.S.LIB.txt
2017-08-23 13:33:51 +02:00

87 lines
1.7 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 .9
>PUSHYA Push $LIB value
>PUSHW K.LoadLib.Name
jsr K.FileSearch.I find libname in $LIB
bcs .9
>LDYAI KrnBuf256
jsr K.LoadExeYA Y,A=filename full path
bcs .9
stx .8+1
>STYA LIB.Jump+1
txa Pass hLib to LibLoad
ldx #LIBMGR.LOAD
jsr LIB.Jump Call LIB.LOAD function
bcs .99
.8 lda #$ff hLib
clc
.9 rts
.99 pha
lda .8+1
jsr K.FreeMemA
pla
sec
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