A2osX/SYS/KERNEL.S.BIN.txt
2016-09-26 18:00:52 +02:00

103 lines
2.1 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
*--------------------------------------
* K.LoadBinYA
* in :
* A = hMem of FilePath (PSTRING)
* out :
* Y,A = MEMPTR
* X = hMem of Code Segment
*--------------------------------------
K.LoadBinYA >STYA K.LoadBin.Filename
jsr K.PStrUprYA
>LDYA K.LoadBin.Filename
jsr K.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 K.GetMemByNameA
clc
rts
.3 >PUSHWI KrnBuf256
>PUSHW K.LoadBin.Filename
jsr K.STAT Look for AUXTYPE
bcs .99
>LDYA KrnBuf256+S.STAT.AUXTYPE
>STYA K.LoadBin.OldBase
>PUSHYA
>PUSHBI 6 S.FILEINFO.TYPE.BIN
>PUSHBI SYS.FOPEN.R
>PUSHW K.LoadBin.Filename
jsr K.LoadFile
bcs .99 Error Loading file
>STYA K.LoadBin.SegLen
stx K.LoadBin.hMem save hMem
txa
jsr K.GetMemPtrA
>STYA K.LoadBin.NewBase
jsr K.InsBin
bcs .98 relocation error, dicard Code segment
>LDYA K.LoadBin.Filename get back bin path
jsr K.NewPStrYA make a copy of this string
bcs .98
phx save copy
lda K.LoadBin.hMem
jsr K.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 K.LoadBin.hMem
tax return hMEM to Caller...
jsr K.GetMemPtrA
clc ...and Y,A=PTR to CS
rts
.98 pha
lda K.LoadBin.hMem
jsr K.FreeMemA Discard Loaded Code
pla
sec
.99 rts
*--------------------------------------
K.LoadBin.Filename .BS 2
K.LoadBin.hMem .BS 1
K.LoadBin.OldBase .BS 2
K.LoadBin.NewBase .BS 2
K.LoadBin.SegLen .BS 2
*--------------------------------------
MAN
SAVE SYS/KERNEL.S.BIN
LOAD SYS/KERNEL.S
ASM