A2osX/SYS/KERNEL.S.BIN.txt
2016-08-19 16:52:18 +02:00

111 lines
2.2 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.LoadBinYA
* in :
* A = hMem of FilePath (PSTRING)
* out :
* Y,A = MEMPTR
* X = hMem of Code Segment
*--------------------------------------
S.LoadBinYA >STYA S.LoadBin.Filename
jsr S.PStrUprYA
>LDYA S.LoadBin.Filename
jsr S.GetMemByNameYA
bcs .3 not already loaded
>STYA ZPQuickPtr1 Save base address
ldy #S.MEM.REFCNT
lda (ZPQuickPtr1),y
inc
sta (ZPQuickPtr1),y
ldy #S.MEM.PTR
lda (ZPQuickPtr1),y
pha Y,A = MEM PTR...
iny
lda (ZPQuickPtr1),y
ply X=hMem from S.GetMemByNameA
clc
rts
.3 >LDYA S.LoadBin.Filename
jsr S.LoadFileYA
bcs .99 Error Loading file
>STYA S.LoadBin.SegLen
stx S.LoadBin.hMem save hMem
txa
jsr S.GetMemPtrA
>STYA S.LoadBin.NewBase
>LDYA S.LoadBin.Filename
jsr S.MLIGetFileInfoYA Get File Info for AUXTYPE
bcs .98
>STYA ZPQuickPtr1
ldy #2 get AUXTYPE
lda (ZPQuickPtr1),y
sta S.LoadBin.OldBase
iny
lda (ZPQuickPtr1),y
sta S.LoadBin.OldBase+1
bit RRAMWRAMBNK2
bit RRAMWRAMBNK2
jsr S.InsBin
bit RRAMWRAMBNK1
bit RRAMWRAMBNK1
bcs .98 relocation error, dicard Code segment
>LDYA S.LoadBin.Filename get back bin path
jsr S.NewPStrYA make a copy of this string
bcs .98
phx save copy
lda S.LoadBin.hMem
jsr S.GetMemByIDA
>STYA ZPQuickPtr1
lda (ZPQuickPtr1)
ora #S.MEM.F.CODE This is a code segment
sta (ZPQuickPtr1)
pla
ldy #S.MEM.BIN
sta (ZPQuickPtr1),y
lda S.LoadBin.hMem
tax return hMEM to Caller...
jsr S.GetMemPtrA
clc ...and Y,A=PTR to CS
rts
.98 pha
lda S.LoadBin.hMem
jsr S.FreeMemA Discard Loaded Code
pla
sec
.99 rts
*--------------------------------------
S.LoadBin.Filename .BS 2
S.LoadBin.hMem .BS 1
S.LoadBin.OldBase .BS 2
S.LoadBin.NewBase .BS 2
S.LoadBin.SegLen .BS 2
*--------------------------------------
MAN
SAVE SYS/KERNEL.S.BIN
LOAD SYS/KERNEL.S
ASM