A2osX/SYS/KERNEL.S.BIN.txt

114 lines
2.3 KiB
Plaintext
Raw Normal View History

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-09-21 15:20:37 +00:00
* K.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-09-21 15:20:37 +00:00
K.LoadBinYA >STYA K.LoadBin.Filename
jsr K.PStrUprYA
2016-08-17 06:25:58 +00:00
2016-09-21 15:20:37 +00:00
>LDYA K.LoadBin.Filename
jsr K.GetMemByNameYA
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
2016-09-21 15:20:37 +00:00
ply X=hMem from K.GetMemByNameA
2015-03-14 21:48:35 +00:00
clc
rts
2016-09-22 06:19:49 +00:00
.3 >PUSHWI $2000 Aux type
>PUSHBI 6 S.FILEINFO.TYPE.BIN
>PUSHBI SYS.FOPEN.R
>PUSHW K.LoadBin.Filename
jsr K.LoadFile
bcs .99 Error Loading file
2015-06-03 18:30:57 +00:00
2016-09-21 15:20:37 +00:00
>STYA K.LoadBin.SegLen
stx K.LoadBin.hMem save hMem
2015-03-14 21:48:35 +00:00
txa
2016-09-21 15:20:37 +00:00
jsr K.GetMemPtrA
>STYA K.LoadBin.NewBase
2015-06-03 18:30:57 +00:00
2016-09-21 15:20:37 +00:00
>LDYA K.LoadBin.Filename
jsr K.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 ZPQuickPtr1
2015-03-14 21:48:35 +00:00
ldy #2 get AUXTYPE
lda (ZPQuickPtr1),y
2016-09-21 15:20:37 +00:00
sta K.LoadBin.OldBase
2015-03-14 21:48:35 +00:00
iny
lda (ZPQuickPtr1),y
2016-09-21 15:20:37 +00:00
sta K.LoadBin.OldBase+1
bit RRAMWRAMBNK2
bit RRAMWRAMBNK2
2016-09-21 15:20:37 +00:00
jsr K.InsBin
2015-06-03 18:30:57 +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-09-21 15:20:37 +00:00
>LDYA K.LoadBin.Filename get back bin path
jsr K.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
2016-09-21 15:20:37 +00:00
lda K.LoadBin.hMem
jsr K.GetMemByIDA
2015-03-14 21:48:35 +00:00
>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-09-21 15:20:37 +00:00
lda K.LoadBin.hMem
2015-06-03 18:30:57 +00:00
tax return hMEM to Caller...
2016-09-21 15:20:37 +00:00
jsr K.GetMemPtrA
2015-06-03 18:30:57 +00:00
clc ...and Y,A=PTR to CS
2015-03-14 21:48:35 +00:00
rts
.98 pha
2016-09-21 15:20:37 +00:00
lda K.LoadBin.hMem
jsr K.FreeMemA Discard Loaded Code
2015-03-14 21:48:35 +00:00
pla
2015-06-03 18:30:57 +00:00
sec
.99 rts
2015-03-14 21:48:35 +00:00
*--------------------------------------
2016-09-21 15:20:37 +00:00
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
2015-03-14 21:48:35 +00:00
*--------------------------------------
MAN
SAVE SYS/KERNEL.S.BIN
LOAD SYS/KERNEL.S
ASM