2015-03-14 21:48:35 +00:00
|
|
|
|
PR#3
|
2015-06-03 18:30:57 +00:00
|
|
|
|
PREFIX /A2OSX.SRC
|
2015-03-14 21:48:35 +00:00
|
|
|
|
NEW
|
|
|
|
|
INC 1
|
|
|
|
|
AUTO 6
|
|
|
|
|
.LIST OFF
|
|
|
|
|
*--------------------------------------
|
2016-08-17 06:25:58 +00:00
|
|
|
|
* S.LoadBinYA
|
2015-03-14 21:48:35 +00:00
|
|
|
|
* in :
|
|
|
|
|
* A = hMem of FilePath (PSTRING)
|
|
|
|
|
* out :
|
|
|
|
|
* Y,A = MEMPTR
|
|
|
|
|
* X = hMem of Code Segment
|
|
|
|
|
*--------------------------------------
|
2016-08-17 06:25:58 +00:00
|
|
|
|
S.LoadBinYA >STYA S.LoadBin.Filename
|
|
|
|
|
jsr S.PStrUprYA
|
|
|
|
|
|
|
|
|
|
>LDYA S.LoadBin.Filename
|
2016-06-07 06:10:18 +00:00
|
|
|
|
jsr S.GetMemByNameYA
|
2015-09-13 20:35:07 +00:00
|
|
|
|
bcs .3 not already loaded
|
|
|
|
|
|
2015-06-03 18:30:57 +00:00
|
|
|
|
>STYA ZPQuickPtr1 Save base address
|
2015-03-14 21:48:35 +00:00
|
|
|
|
ldy #S.MEM.REFCNT
|
2015-06-03 18:30:57 +00:00
|
|
|
|
lda (ZPQuickPtr1),y
|
2015-03-14 21:48:35 +00:00
|
|
|
|
inc
|
2015-06-03 18:30:57 +00:00
|
|
|
|
sta (ZPQuickPtr1),y
|
|
|
|
|
|
2015-03-14 21:48:35 +00:00
|
|
|
|
ldy #S.MEM.PTR
|
2015-06-03 18:30:57 +00:00
|
|
|
|
lda (ZPQuickPtr1),y
|
2015-03-14 21:48:35 +00:00
|
|
|
|
pha Y,A = MEM PTR...
|
|
|
|
|
iny
|
2015-06-03 18:30:57 +00:00
|
|
|
|
lda (ZPQuickPtr1),y
|
2015-03-14 21:48:35 +00:00
|
|
|
|
ply X=hMem from S.GetMemByNameA
|
|
|
|
|
clc
|
|
|
|
|
rts
|
|
|
|
|
|
2016-08-17 06:25:58 +00:00
|
|
|
|
.3 >LDYA S.LoadBin.Filename
|
2016-06-07 06:10:18 +00:00
|
|
|
|
jsr S.LoadFileYA
|
2015-09-13 20:35:07 +00:00
|
|
|
|
bcc .4
|
2015-06-03 18:30:57 +00:00
|
|
|
|
rts Error Loading file
|
|
|
|
|
|
2016-08-17 06:25:58 +00:00
|
|
|
|
.4 >STYA S.LoadBin.FileLen
|
|
|
|
|
stx S.LoadBin.hMem save hMem
|
2015-03-14 21:48:35 +00:00
|
|
|
|
txa
|
|
|
|
|
jsr S.GetMemPtrA
|
2015-06-03 18:30:57 +00:00
|
|
|
|
>STYA ZPQuickPtr1 save base address for relocation
|
|
|
|
|
|
|
|
|
|
ldy #H.BIN.CODE.LEN make AX = Code Len
|
|
|
|
|
lda (ZPQuickPtr1),y
|
|
|
|
|
sta R.AL
|
|
|
|
|
iny
|
|
|
|
|
lda (ZPQuickPtr1),y
|
|
|
|
|
sta R.AH
|
|
|
|
|
|
2016-08-17 06:25:58 +00:00
|
|
|
|
>LDYA S.LoadBin.Filename
|
2016-06-07 06:10:18 +00:00
|
|
|
|
jsr S.MLIGetFileInfoYA Get File Info for AUXTYPE
|
2015-03-14 21:48:35 +00:00
|
|
|
|
bcs .98
|
2015-06-03 18:30:57 +00:00
|
|
|
|
|
|
|
|
|
>STYA ZPQuickPtr2
|
2015-03-14 21:48:35 +00:00
|
|
|
|
ldy #2 get AUXTYPE
|
2015-06-03 18:30:57 +00:00
|
|
|
|
lda (ZPQuickPtr2),y
|
|
|
|
|
sta R.BL Make BX=Range Start=AUXTYPE
|
2016-08-17 06:25:58 +00:00
|
|
|
|
sta S.LoadBin.AuxType
|
2015-06-03 18:30:57 +00:00
|
|
|
|
clc
|
2016-08-17 06:25:58 +00:00
|
|
|
|
adc S.LoadBin.FileLen
|
2015-06-03 18:30:57 +00:00
|
|
|
|
sta R.CL Make CX=Range End=AUXTYPE+FILELEN
|
2015-03-14 21:48:35 +00:00
|
|
|
|
iny
|
2015-06-03 18:30:57 +00:00
|
|
|
|
lda (ZPQuickPtr2),y
|
|
|
|
|
sta R.BH
|
2016-08-17 06:25:58 +00:00
|
|
|
|
sta S.LoadBin.AuxType+1
|
|
|
|
|
adc S.LoadBin.FileLen+1
|
2015-06-03 18:30:57 +00:00
|
|
|
|
sta R.CH
|
|
|
|
|
|
|
|
|
|
lda ZPQuickPtr1 Compute relocation offset in DX
|
2015-03-14 21:48:35 +00:00
|
|
|
|
sec
|
2016-08-17 06:25:58 +00:00
|
|
|
|
sbc S.LoadBin.AuxType
|
2015-06-03 18:30:57 +00:00
|
|
|
|
sta R.DL DX=Offset=ZPQuickPtr1-AUXTYPE
|
|
|
|
|
lda ZPQuickPtr1+1
|
2016-08-17 06:25:58 +00:00
|
|
|
|
sbc S.LoadBin.AuxType+1
|
2015-06-03 18:30:57 +00:00
|
|
|
|
sta R.DH
|
|
|
|
|
|
|
|
|
|
>LDYA ZPQuickPtr1
|
2016-06-23 15:56:13 +00:00
|
|
|
|
|
|
|
|
|
bit RRAMWRAMBNK2
|
|
|
|
|
bit RRAMWRAMBNK2
|
|
|
|
|
|
2015-06-03 18:30:57 +00:00
|
|
|
|
jsr S.BinRelocateYA
|
|
|
|
|
|
2016-06-23 15:56:13 +00:00
|
|
|
|
bit RRAMWRAMBNK1
|
|
|
|
|
bit RRAMWRAMBNK1
|
|
|
|
|
|
2015-03-14 21:48:35 +00:00
|
|
|
|
bcs .98 relocation error, dicard Code segment
|
2015-06-03 18:30:57 +00:00
|
|
|
|
|
2016-08-17 06:25:58 +00:00
|
|
|
|
>LDYA S.LoadBin.Filename get back bin path
|
|
|
|
|
jsr S.NewPStrYA make a copy of this string
|
2015-03-14 21:48:35 +00:00
|
|
|
|
bcs .98
|
2016-08-17 06:25:58 +00:00
|
|
|
|
phx save copy
|
2015-09-13 20:35:07 +00:00
|
|
|
|
|
2016-08-17 06:25:58 +00:00
|
|
|
|
lda S.LoadBin.hMem
|
2015-03-14 21:48:35 +00:00
|
|
|
|
jsr S.GetMemByIDA
|
|
|
|
|
>STYA ZPQuickPtr1
|
2015-06-03 18:30:57 +00:00
|
|
|
|
|
2015-03-14 21:48:35 +00:00
|
|
|
|
lda (ZPQuickPtr1)
|
|
|
|
|
ora #S.MEM.F.CODE This is a code segment
|
|
|
|
|
sta (ZPQuickPtr1)
|
2016-03-13 21:47:19 +00:00
|
|
|
|
|
|
|
|
|
pla
|
2015-03-14 21:48:35 +00:00
|
|
|
|
ldy #S.MEM.BIN
|
|
|
|
|
sta (ZPQuickPtr1),y
|
2015-06-03 18:30:57 +00:00
|
|
|
|
|
2016-08-17 06:25:58 +00:00
|
|
|
|
lda S.LoadBin.hMem
|
2015-06-03 18:30:57 +00:00
|
|
|
|
tax return hMEM to Caller...
|
|
|
|
|
jsr S.GetMemPtrA
|
|
|
|
|
clc ...and Y,A=PTR to CS
|
2015-03-14 21:48:35 +00:00
|
|
|
|
rts
|
|
|
|
|
|
|
|
|
|
.98 pha
|
2016-08-17 06:25:58 +00:00
|
|
|
|
lda S.LoadBin.hMem
|
2015-06-03 18:30:57 +00:00
|
|
|
|
jsr S.FreeMemA Discard Loaded Code
|
2015-03-14 21:48:35 +00:00
|
|
|
|
pla
|
|
|
|
|
|
2015-06-03 18:30:57 +00:00
|
|
|
|
sec
|
2015-03-14 21:48:35 +00:00
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
2016-08-17 06:25:58 +00:00
|
|
|
|
S.LoadBin.Filename .BS 2
|
|
|
|
|
S.LoadBin.hMem .BS 1
|
|
|
|
|
S.LoadBin.AuxType .BS 2
|
|
|
|
|
S.LoadBin.FileLen .BS 2
|
2015-03-14 21:48:35 +00:00
|
|
|
|
*--------------------------------------
|
|
|
|
|
MAN
|
|
|
|
|
SAVE SYS/KERNEL.S.BIN
|
|
|
|
|
LOAD SYS/KERNEL.S
|
|
|
|
|
ASM
|