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
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
* S.LoadBinA
|
|
|
|
|
* in :
|
|
|
|
|
* A = hMem of FilePath (PSTRING)
|
|
|
|
|
* out :
|
|
|
|
|
* Y,A = MEMPTR
|
|
|
|
|
* X = hMem of Code Segment
|
|
|
|
|
*--------------------------------------
|
2015-06-03 18:30:57 +00:00
|
|
|
|
S.LoadBinA sta S.LoadBinA.hFilename save file path
|
2015-11-22 22:30:06 +00:00
|
|
|
|
|
2015-09-13 20:35:07 +00:00
|
|
|
|
jsr S.GetMemPtrA
|
|
|
|
|
>STYA ZPQuickPtr1
|
|
|
|
|
|
|
|
|
|
lda (ZPQuickPtr1)
|
|
|
|
|
tay
|
|
|
|
|
|
|
|
|
|
.1 lda (ZPQuickPtr1),y convert to UPPERCASE
|
2015-11-22 22:30:06 +00:00
|
|
|
|
cmp #'a'
|
2015-09-13 20:35:07 +00:00
|
|
|
|
bmi .2
|
2015-11-22 22:30:06 +00:00
|
|
|
|
cmp #'z'+1
|
2015-09-13 20:35:07 +00:00
|
|
|
|
bpl .2
|
2015-11-22 22:30:06 +00:00
|
|
|
|
eor #$20
|
2015-09-13 20:35:07 +00:00
|
|
|
|
sta (ZPQuickPtr1),y
|
|
|
|
|
.2 dey
|
|
|
|
|
bne .1
|
2015-06-03 18:30:57 +00:00
|
|
|
|
|
2016-06-07 06:10:18 +00:00
|
|
|
|
>LDYA ZPQuickPtr1
|
|
|
|
|
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-06-07 06:10:18 +00:00
|
|
|
|
.3 >LDYA ZPQuickPtr1
|
|
|
|
|
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
|
|
|
|
|
|
2015-09-13 20:35:07 +00:00
|
|
|
|
.4 >STYA S.LoadBinA.FileLen
|
2015-06-03 18:30:57 +00:00
|
|
|
|
stx S.LoadBinA.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
|
|
|
|
|
|
|
|
|
|
lda S.LoadBinA.hFilename
|
2016-06-07 06:10:18 +00:00
|
|
|
|
jsr S.GetMemPtrA
|
|
|
|
|
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
|
|
|
|
|
sta S.LoadBinA.AuxType
|
|
|
|
|
clc
|
|
|
|
|
adc S.LoadBinA.FileLen
|
|
|
|
|
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
|
|
|
|
|
sta S.LoadBinA.AuxType+1
|
|
|
|
|
adc S.LoadBinA.FileLen+1
|
|
|
|
|
sta R.CH
|
|
|
|
|
|
|
|
|
|
lda ZPQuickPtr1 Compute relocation offset in DX
|
2015-03-14 21:48:35 +00:00
|
|
|
|
sec
|
2015-06-03 18:30:57 +00:00
|
|
|
|
sbc S.LoadBinA.AuxType
|
|
|
|
|
sta R.DL DX=Offset=ZPQuickPtr1-AUXTYPE
|
|
|
|
|
lda ZPQuickPtr1+1
|
|
|
|
|
sbc S.LoadBinA.AuxType+1
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
lda S.LoadBinA.hFilename get back bin path
|
2015-03-14 21:48:35 +00:00
|
|
|
|
jsr S.PStrCpyA
|
|
|
|
|
bcs .98
|
2016-03-13 21:47:19 +00:00
|
|
|
|
pha
|
2015-09-13 20:35:07 +00:00
|
|
|
|
|
2015-06-03 18:30:57 +00:00
|
|
|
|
lda S.LoadBinA.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
|
|
|
|
|
|
|
|
|
lda S.LoadBinA.hMem
|
|
|
|
|
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
|
2015-06-03 18:30:57 +00:00
|
|
|
|
lda S.LoadBinA.hMem
|
|
|
|
|
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
|
|
|
|
|
*--------------------------------------
|
2015-06-03 18:30:57 +00:00
|
|
|
|
S.LoadBinA.hFilename .BS 1
|
|
|
|
|
S.LoadBinA.hMem .BS 1
|
|
|
|
|
S.LoadBinA.AuxType .BS 2
|
|
|
|
|
S.LoadBinA.FileLen .BS 2
|
2015-03-14 21:48:35 +00:00
|
|
|
|
*--------------------------------------
|
|
|
|
|
MAN
|
|
|
|
|
SAVE SYS/KERNEL.S.BIN
|
|
|
|
|
LOAD SYS/KERNEL.S
|
|
|
|
|
ASM
|