2015-03-14 21:48:35 +00:00
|
|
|
|
PR#3
|
2017-03-29 15:48:15 +00:00
|
|
|
|
PREFIX /A2OSX.BUILD
|
2017-03-15 16:44:15 +00:00
|
|
|
|
LOMEM $A00
|
2015-03-14 21:48:35 +00:00
|
|
|
|
INC 1
|
|
|
|
|
AUTO 6
|
|
|
|
|
*--------------------------------------
|
2017-08-24 12:46:48 +00:00
|
|
|
|
* K.LoadLib.YA
|
|
|
|
|
* in :
|
2017-08-25 15:02:16 +00:00
|
|
|
|
* Y,A = PTR To "LibName.o" C-String
|
2017-08-24 12:46:48 +00:00
|
|
|
|
* out :
|
|
|
|
|
* A = hMem To loaded LIB
|
|
|
|
|
*--------------------------------------
|
2017-08-25 15:02:16 +00:00
|
|
|
|
K.LoadLib.YA jsr BIN.FindLIB
|
2017-08-24 12:46:48 +00:00
|
|
|
|
bcs .9
|
|
|
|
|
|
2017-08-25 15:02:16 +00:00
|
|
|
|
jsr BIN.Load.YA Y,A=filename full path
|
2017-08-24 12:46:48 +00:00
|
|
|
|
bcs .9
|
|
|
|
|
|
|
|
|
|
stx .8+1
|
2017-08-25 15:02:16 +00:00
|
|
|
|
>STYA .1+1
|
2017-08-24 12:46:48 +00:00
|
|
|
|
|
|
|
|
|
txa Pass hLib to LibLoad
|
|
|
|
|
ldx #LIBMGR.LOAD
|
2017-08-25 15:02:16 +00:00
|
|
|
|
.1 jsr $ffff Self Modified, Call LIB.LOAD function
|
2017-08-24 12:46:48 +00:00
|
|
|
|
|
|
|
|
|
bcs .99
|
|
|
|
|
|
|
|
|
|
.8 lda #$ff hLib
|
|
|
|
|
clc
|
|
|
|
|
.9 rts
|
|
|
|
|
|
|
|
|
|
.99 pha
|
|
|
|
|
lda .8+1
|
2017-08-25 06:37:21 +00:00
|
|
|
|
jsr K.FreeMem.A
|
2017-08-24 12:46:48 +00:00
|
|
|
|
pla
|
|
|
|
|
|
|
|
|
|
sec
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
* K.UnloadLib.A
|
|
|
|
|
* in :
|
|
|
|
|
* A = hMem To Lib
|
|
|
|
|
* out :
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
K.UnloadLib.A pha
|
2017-08-25 06:37:21 +00:00
|
|
|
|
jsr K.GetMemByID.A
|
2017-08-24 12:46:48 +00:00
|
|
|
|
>STYA ZPPtr1
|
|
|
|
|
ldy #S.MEM.REFCNT
|
2017-08-25 15:02:16 +00:00
|
|
|
|
lda (ZPPtr1),y Get count of those referencing this lib
|
2017-08-24 12:46:48 +00:00
|
|
|
|
dec only one left ?
|
|
|
|
|
beq .1
|
|
|
|
|
sta (ZPPtr1),y
|
|
|
|
|
pla
|
|
|
|
|
clc
|
|
|
|
|
rts
|
|
|
|
|
|
|
|
|
|
.1 ldy #S.MEM.PTR
|
|
|
|
|
lda (ZPPtr1),y
|
2017-08-25 15:02:16 +00:00
|
|
|
|
sta .2+1
|
2017-08-24 12:46:48 +00:00
|
|
|
|
|
|
|
|
|
iny
|
|
|
|
|
lda (ZPPtr1),y
|
2017-08-25 15:02:16 +00:00
|
|
|
|
sta .2+2
|
2017-08-24 12:46:48 +00:00
|
|
|
|
|
|
|
|
|
ldx #LIBMGR.UNLOAD
|
2017-08-25 15:02:16 +00:00
|
|
|
|
.2 jsr $ffff Self Modified, Call LIB.UNLOAD function
|
2017-08-24 12:46:48 +00:00
|
|
|
|
pla
|
2017-08-25 06:37:21 +00:00
|
|
|
|
jmp K.FreeMem.A
|
2017-08-24 12:46:48 +00:00
|
|
|
|
*--------------------------------------
|
2017-08-25 15:02:16 +00:00
|
|
|
|
* K.LoadDrv.YA
|
|
|
|
|
* in :
|
|
|
|
|
* Y,A = PTR to "NAME.DRV [PARAM]" C-String
|
|
|
|
|
* out :
|
|
|
|
|
* none
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
K.LoadDrv.YA jsr BIN.FindDRV
|
|
|
|
|
bcs .9
|
|
|
|
|
|
|
|
|
|
jsr BIN.Load.YA Y,A =filename full path
|
|
|
|
|
bcs .9
|
|
|
|
|
|
|
|
|
|
>STYA pDrv
|
|
|
|
|
stx .97+1
|
|
|
|
|
|
|
|
|
|
>LDYA BIN.CmdLine
|
|
|
|
|
>STYA ZPPtr1
|
|
|
|
|
|
|
|
|
|
.1 lda (ZPPtr1) Advance to ARG[1]
|
|
|
|
|
pha
|
|
|
|
|
inc ZPPtr1
|
|
|
|
|
bne .2
|
|
|
|
|
inc ZPPtr1+1
|
|
|
|
|
|
|
|
|
|
.2 pla
|
|
|
|
|
bne .1
|
|
|
|
|
|
|
|
|
|
>LDYA ZPPtr1
|
|
|
|
|
|
|
|
|
|
jsr pDrvJmp call Dev.Detect
|
|
|
|
|
bcs .96
|
|
|
|
|
|
|
|
|
|
jsr BIN.InstallDRV
|
|
|
|
|
bcs .96
|
|
|
|
|
|
|
|
|
|
jsr .96 Cleanup...
|
|
|
|
|
|
|
|
|
|
lda #0 Make sure RC = 0 if success
|
|
|
|
|
clc
|
|
|
|
|
.9 rts
|
|
|
|
|
|
|
|
|
|
.96 pha
|
|
|
|
|
.97 lda #$ff
|
|
|
|
|
jsr K.FreeMem.A
|
|
|
|
|
pla
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
BIN.FindLIB clc
|
|
|
|
|
.HS B0 bcs
|
|
|
|
|
BIN.FindDRV sec
|
|
|
|
|
>STYA BIN.CmdLine
|
|
|
|
|
|
|
|
|
|
>LDYAI BIN.Find.ENV.LIB
|
|
|
|
|
bcc .1
|
|
|
|
|
>LDYAI BIN.Find.ENV.DRV
|
|
|
|
|
|
|
|
|
|
.1 >SYSCALL GetEnv.YA get value for Search Path
|
|
|
|
|
bcs .9
|
|
|
|
|
|
|
|
|
|
>PUSHYA Push Search path
|
|
|
|
|
|
|
|
|
|
>LDYA BIN.CmdLine
|
|
|
|
|
|
|
|
|
|
jsr K.FileSearch.I find libname in Search
|
|
|
|
|
bcs .9
|
|
|
|
|
>LDYAI K.Buf256
|
|
|
|
|
|
|
|
|
|
.9 rts
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
BIN.Find.ENV.DRV >CSTR "DRV"
|
|
|
|
|
BIN.Find.ENV.LIB >CSTR "LIB"
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
* BIN.Load.YA
|
2015-03-14 21:48:35 +00:00
|
|
|
|
* in :
|
2016-10-29 19:58:21 +00:00
|
|
|
|
* A = hMem of FilePath (PSTR)
|
2015-03-14 21:48:35 +00:00
|
|
|
|
* out :
|
|
|
|
|
* Y,A = MEMPTR
|
|
|
|
|
* X = hMem of Code Segment
|
|
|
|
|
*--------------------------------------
|
2017-08-25 15:02:16 +00:00
|
|
|
|
BIN.Load.YA >STYA BIN.CmdLine
|
2017-08-24 12:46:48 +00:00
|
|
|
|
|
2016-11-01 21:34:29 +00:00
|
|
|
|
jsr MEM.GetMemByNameYA
|
2017-08-25 15:02:16 +00:00
|
|
|
|
bcs BIN.Load.YA.1 not already loaded
|
2015-09-13 20:35:07 +00:00
|
|
|
|
|
2017-08-24 06:47:31 +00:00
|
|
|
|
>STYA ZPPtr1 Save base address
|
2015-03-14 21:48:35 +00:00
|
|
|
|
ldy #S.MEM.REFCNT
|
2017-01-12 17:43:45 +00:00
|
|
|
|
lda (ZPPtr1),y
|
2015-03-14 21:48:35 +00:00
|
|
|
|
inc
|
2017-01-12 17:43:45 +00:00
|
|
|
|
sta (ZPPtr1),y
|
2015-06-03 18:30:57 +00:00
|
|
|
|
|
2016-09-28 15:34:15 +00:00
|
|
|
|
txa
|
2017-08-25 06:37:21 +00:00
|
|
|
|
jmp K.GetMemPtr.A X=hMem from K.GetMemByNameA
|
2016-09-28 15:34:15 +00:00
|
|
|
|
*--------------------------------------
|
2017-08-25 15:02:16 +00:00
|
|
|
|
BIN.Load.YA.1 >PUSHWI K.S.STAT
|
|
|
|
|
>PUSHW BIN.CmdLine
|
2017-08-30 15:26:34 +00:00
|
|
|
|
>SYSCALL STAT BANK1!!! Look for AUXTYPE
|
2016-09-28 15:34:15 +00:00
|
|
|
|
bcs .9
|
2016-09-26 16:00:52 +00:00
|
|
|
|
|
2017-03-28 15:46:12 +00:00
|
|
|
|
>LDYA K.S.STAT+S.STAT.P.AUXTYPE
|
2016-09-28 15:34:15 +00:00
|
|
|
|
>STYA BIN.Relocate.Start
|
2016-09-26 16:00:52 +00:00
|
|
|
|
|
2016-09-28 15:34:15 +00:00
|
|
|
|
>PUSHYA Push AUXTYPE
|
2016-09-22 06:19:49 +00:00
|
|
|
|
>PUSHBI 6 S.FILEINFO.TYPE.BIN
|
2017-01-12 17:43:45 +00:00
|
|
|
|
>PUSHBI SYS.FOpen.R
|
2017-08-25 15:02:16 +00:00
|
|
|
|
>PUSHW BIN.CmdLine
|
2016-10-03 06:18:46 +00:00
|
|
|
|
|
2017-08-30 15:26:34 +00:00
|
|
|
|
>SYSCALL LoadFile BANK1!!!
|
2016-09-28 15:34:15 +00:00
|
|
|
|
.9 bcs .99 Error Loading file
|
2016-09-30 15:04:55 +00:00
|
|
|
|
|
2017-08-25 15:02:16 +00:00
|
|
|
|
stx BIN.hMem save hMem
|
2016-09-28 15:34:15 +00:00
|
|
|
|
|
2017-08-24 06:47:31 +00:00
|
|
|
|
pha YA=CODE+DATA size
|
2016-09-30 15:04:55 +00:00
|
|
|
|
tya
|
|
|
|
|
* clc CC from bcs .99
|
2016-09-28 15:34:15 +00:00
|
|
|
|
|
2016-09-30 15:04:55 +00:00
|
|
|
|
adc BIN.Relocate.Start Get AUXTYPE for actual Base Address
|
|
|
|
|
sta BIN.Relocate.End compute Range End=AUXTYPE+FILELEN
|
|
|
|
|
pla
|
|
|
|
|
adc BIN.Relocate.Start+1
|
2016-09-28 15:34:15 +00:00
|
|
|
|
sta BIN.Relocate.End+1
|
2016-09-30 15:04:55 +00:00
|
|
|
|
|
|
|
|
|
txa
|
2017-08-25 06:37:21 +00:00
|
|
|
|
jsr K.GetMemPtr.A
|
2017-01-12 17:43:45 +00:00
|
|
|
|
>STYA ZPPtr1 set ZPPtr1 -> Code start
|
2016-09-30 15:04:55 +00:00
|
|
|
|
|
|
|
|
|
pha YA = actual load address
|
|
|
|
|
tya
|
2016-09-28 15:34:15 +00:00
|
|
|
|
sec
|
|
|
|
|
sbc BIN.Relocate.Start
|
2017-01-12 17:43:45 +00:00
|
|
|
|
sta BIN.Relocate.Offset Offset=ZPPtr1-AUXTYPE
|
2016-09-30 15:04:55 +00:00
|
|
|
|
pla
|
2016-09-28 15:34:15 +00:00
|
|
|
|
sbc BIN.Relocate.Start+1
|
|
|
|
|
sta BIN.Relocate.Offset+1
|
|
|
|
|
|
2016-09-30 15:04:55 +00:00
|
|
|
|
ldy #H.BIN.CODE.LEN get Code Len
|
2017-01-12 17:43:45 +00:00
|
|
|
|
lda (ZPPtr1),y
|
2016-10-12 15:46:38 +00:00
|
|
|
|
clc
|
2017-01-12 17:43:45 +00:00
|
|
|
|
adc ZPPtr1
|
|
|
|
|
sta ZPPtr2 Make ZPPtr2 = ZPPtr1 + CodeLen
|
2016-10-12 15:46:38 +00:00
|
|
|
|
iny
|
2017-01-12 17:43:45 +00:00
|
|
|
|
lda (ZPPtr1),y
|
|
|
|
|
adc ZPPtr1+1
|
|
|
|
|
sta ZPPtr2+1
|
2016-09-30 15:04:55 +00:00
|
|
|
|
|
|
|
|
|
jsr BIN.RelocateEXE
|
2015-06-03 18:30:57 +00:00
|
|
|
|
|
2017-08-25 15:02:16 +00:00
|
|
|
|
>LDYA BIN.CmdLine get back bin path
|
2017-09-08 14:49:23 +00:00
|
|
|
|
jsr K.NewStr.YA make a copy of this string
|
2015-03-14 21:48:35 +00:00
|
|
|
|
bcs .98
|
2015-09-13 20:35:07 +00:00
|
|
|
|
|
2017-08-25 15:02:16 +00:00
|
|
|
|
lda BIN.hMem Keep X=hMem
|
2017-08-25 06:37:21 +00:00
|
|
|
|
jsr K.GetMemByID.A X unmodified
|
2017-01-12 17:43:45 +00:00
|
|
|
|
>STYA ZPPtr1
|
2015-06-03 18:30:57 +00:00
|
|
|
|
|
2017-01-12 17:43:45 +00:00
|
|
|
|
lda (ZPPtr1)
|
2015-03-14 21:48:35 +00:00
|
|
|
|
ora #S.MEM.F.CODE This is a code segment
|
2017-01-12 17:43:45 +00:00
|
|
|
|
sta (ZPPtr1)
|
2016-03-13 21:47:19 +00:00
|
|
|
|
|
2016-09-30 15:04:55 +00:00
|
|
|
|
txa Get Back hMem
|
2015-03-14 21:48:35 +00:00
|
|
|
|
ldy #S.MEM.BIN
|
2017-01-12 17:43:45 +00:00
|
|
|
|
sta (ZPPtr1),y
|
2015-06-03 18:30:57 +00:00
|
|
|
|
|
2017-08-25 15:02:16 +00:00
|
|
|
|
lda BIN.hMem
|
2015-06-03 18:30:57 +00:00
|
|
|
|
tax return hMEM to Caller...
|
2017-08-25 06:37:21 +00:00
|
|
|
|
jsr K.GetMemPtr.A
|
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
|
2017-08-25 15:02:16 +00:00
|
|
|
|
lda BIN.hMem
|
2017-08-25 06:37:21 +00:00
|
|
|
|
jsr K.FreeMem.A Discard Loaded Code
|
2015-03-14 21:48:35 +00:00
|
|
|
|
pla
|
|
|
|
|
|
2015-06-03 18:30:57 +00:00
|
|
|
|
sec
|
2016-08-19 14:52:18 +00:00
|
|
|
|
.99 rts
|
2015-03-14 21:48:35 +00:00
|
|
|
|
*--------------------------------------
|
2017-08-25 15:02:16 +00:00
|
|
|
|
BIN.CmdLine .BS 2
|
|
|
|
|
BIN.hMem .BS 1
|
2016-09-27 15:51:59 +00:00
|
|
|
|
*--------------------------------------
|
2016-09-28 15:34:15 +00:00
|
|
|
|
* BIN.InstallDRV
|
2016-10-04 16:01:07 +00:00
|
|
|
|
* In:
|
|
|
|
|
* pDrv = .DRV File Loaded Address
|
|
|
|
|
* Note:
|
2017-08-25 15:02:16 +00:00
|
|
|
|
* BIN.Load.YA called from K.LoadDrvYA
|
2016-10-04 16:01:07 +00:00
|
|
|
|
* Already setup correctly pDrv,
|
|
|
|
|
* BIN.Relocate.Start,End
|
2016-09-27 15:51:59 +00:00
|
|
|
|
*--------------------------------------
|
2016-10-05 15:57:43 +00:00
|
|
|
|
BIN.InstallDRV ldy #H.BIN.DRV.CODE.O
|
2016-09-27 15:51:59 +00:00
|
|
|
|
lda (pDrv),y
|
|
|
|
|
clc
|
2016-10-05 15:57:43 +00:00
|
|
|
|
adc BIN.Relocate.Start Advance start From AUXTYPE to AUXTYPE+DRV code offset
|
2016-09-28 15:34:15 +00:00
|
|
|
|
sta BIN.Relocate.Start
|
2016-10-04 16:01:07 +00:00
|
|
|
|
|
2016-09-27 15:51:59 +00:00
|
|
|
|
iny
|
|
|
|
|
lda (pDrv),y
|
2016-09-28 15:34:15 +00:00
|
|
|
|
adc BIN.Relocate.Start+1
|
|
|
|
|
sta BIN.Relocate.Start+1
|
2016-09-27 15:51:59 +00:00
|
|
|
|
|
2016-10-05 15:57:43 +00:00
|
|
|
|
lda DevMgr.Free Offset = Target DRV address-(AUXTYPE+DRV OFFSET)
|
|
|
|
|
sec
|
|
|
|
|
sbc BIN.Relocate.Start
|
|
|
|
|
sta BIN.Relocate.Offset
|
|
|
|
|
|
|
|
|
|
lda DevMgr.Free+1
|
|
|
|
|
sbc BIN.Relocate.Start+1
|
|
|
|
|
sta BIN.Relocate.Offset+1
|
|
|
|
|
|
2016-09-30 15:04:55 +00:00
|
|
|
|
lda BIN.Relocate.End Compute DRVLen=End-start
|
2016-09-27 15:51:59 +00:00
|
|
|
|
sec
|
2016-09-30 15:04:55 +00:00
|
|
|
|
sbc BIN.Relocate.Start
|
2016-09-29 15:30:15 +00:00
|
|
|
|
sta BIN.InstallDRV.DRVLen
|
2016-09-30 15:04:55 +00:00
|
|
|
|
|
|
|
|
|
lda BIN.Relocate.End+1
|
|
|
|
|
sbc BIN.Relocate.Start+1
|
|
|
|
|
sta BIN.InstallDRV.DRVLen+1
|
2016-09-27 15:51:59 +00:00
|
|
|
|
|
|
|
|
|
lda DevMgr.Free
|
|
|
|
|
clc
|
2016-09-29 15:30:15 +00:00
|
|
|
|
adc BIN.InstallDRV.DRVLen
|
|
|
|
|
sta BIN.InstallDRV.DRVEnd
|
2016-09-30 15:04:55 +00:00
|
|
|
|
tay Save DRVEnd LO
|
2016-09-27 15:51:59 +00:00
|
|
|
|
lda DevMgr.Free+1
|
2016-09-30 15:04:55 +00:00
|
|
|
|
adc BIN.InstallDRV.DRVLen+1 A = DRVEnd HI
|
2016-09-29 15:30:15 +00:00
|
|
|
|
sta BIN.InstallDRV.DRVEnd+1
|
2016-09-30 15:04:55 +00:00
|
|
|
|
|
2016-10-04 16:01:07 +00:00
|
|
|
|
bcs .9 we crossed $FFFF, out of mem
|
2016-09-27 15:51:59 +00:00
|
|
|
|
|
2016-09-30 15:04:55 +00:00
|
|
|
|
cpy #DevMgr.HiMem
|
2016-09-27 15:51:59 +00:00
|
|
|
|
sbc /DevMgr.HiMem
|
2016-10-04 16:01:07 +00:00
|
|
|
|
bcs .9 No More Room to load Driver....
|
2016-09-27 15:51:59 +00:00
|
|
|
|
|
2017-01-12 17:43:45 +00:00
|
|
|
|
lda DevMgr.Count
|
2016-09-27 15:51:59 +00:00
|
|
|
|
cmp #K.DEV.MAX
|
2016-10-04 16:01:07 +00:00
|
|
|
|
bne .10 No Device Handle Left
|
2016-09-27 15:51:59 +00:00
|
|
|
|
|
2016-10-04 16:01:07 +00:00
|
|
|
|
lda #DEVMGR.ERROOH
|
2016-09-27 15:51:59 +00:00
|
|
|
|
sec
|
2016-10-04 16:01:07 +00:00
|
|
|
|
rts
|
|
|
|
|
|
|
|
|
|
.9 lda #DEVMGR.ERROOM
|
2016-09-27 15:51:59 +00:00
|
|
|
|
sec
|
|
|
|
|
rts
|
|
|
|
|
|
2017-01-12 17:43:45 +00:00
|
|
|
|
.10 inc DevMgr.Count
|
2017-03-15 16:44:15 +00:00
|
|
|
|
|
2017-08-25 06:37:21 +00:00
|
|
|
|
>SYSCALL GetDevByID.A
|
2017-01-12 17:43:45 +00:00
|
|
|
|
>STYA ZPPtr2 setup Ptr2 to dest HEADER
|
2016-10-04 16:01:07 +00:00
|
|
|
|
|
|
|
|
|
ldy #H.BIN.DRV.HEADER.O
|
2016-09-27 15:51:59 +00:00
|
|
|
|
lda (pDrv),y
|
|
|
|
|
clc
|
|
|
|
|
adc pDrv
|
2017-01-12 17:43:45 +00:00
|
|
|
|
sta ZPPtr1
|
2016-09-27 15:51:59 +00:00
|
|
|
|
iny
|
|
|
|
|
lda (pDrv),y
|
|
|
|
|
adc pDrv+1
|
2017-01-12 17:43:45 +00:00
|
|
|
|
sta ZPPtr1+1 set Ptr1 to Src HEADER
|
2016-09-27 15:51:59 +00:00
|
|
|
|
|
2016-10-04 16:01:07 +00:00
|
|
|
|
ldy #S.DEV-1
|
2016-09-27 15:51:59 +00:00
|
|
|
|
|
2017-01-12 17:43:45 +00:00
|
|
|
|
.1 lda (ZPPtr1),y copy header to DevMgr.Table
|
|
|
|
|
sta (ZPPtr2),y
|
2016-09-27 15:51:59 +00:00
|
|
|
|
dey
|
|
|
|
|
bpl .1
|
2016-10-04 16:01:07 +00:00
|
|
|
|
|
2017-03-15 16:44:15 +00:00
|
|
|
|
ldy #S.DEV.DRV.JMP+1 Setup Main JMP
|
2016-10-04 16:01:07 +00:00
|
|
|
|
lda DevMgr.Free+1
|
2017-01-12 17:43:45 +00:00
|
|
|
|
sta (ZPPtr2),y
|
2016-10-06 15:50:20 +00:00
|
|
|
|
tax
|
|
|
|
|
|
2017-03-15 16:44:15 +00:00
|
|
|
|
dey
|
2016-10-06 15:50:20 +00:00
|
|
|
|
lda DevMgr.Free
|
2017-01-12 17:43:45 +00:00
|
|
|
|
sta (ZPPtr2),y
|
2016-09-27 15:51:59 +00:00
|
|
|
|
|
2017-01-12 17:43:45 +00:00
|
|
|
|
sta ZPPtr2 set Ptr2 to Dest CODE
|
|
|
|
|
stx ZPPtr2+1
|
2016-09-27 15:51:59 +00:00
|
|
|
|
|
2016-10-04 16:01:07 +00:00
|
|
|
|
ldy #H.BIN.DRV.CODE.O
|
2016-09-27 15:51:59 +00:00
|
|
|
|
lda (pDrv),y
|
|
|
|
|
clc
|
|
|
|
|
adc pDrv
|
2017-01-12 17:43:45 +00:00
|
|
|
|
sta ZPPtr1
|
2016-10-04 16:01:07 +00:00
|
|
|
|
iny
|
2016-09-27 15:51:59 +00:00
|
|
|
|
lda (pDrv),y
|
|
|
|
|
adc pDrv+1
|
2017-01-12 17:43:45 +00:00
|
|
|
|
sta ZPPtr1+1 set Ptr1 to Src CODE
|
2016-10-04 16:01:07 +00:00
|
|
|
|
|
2016-09-29 15:30:15 +00:00
|
|
|
|
lda BIN.InstallDRV.DrvLen+1
|
2016-09-28 15:34:15 +00:00
|
|
|
|
eor #$ff
|
|
|
|
|
pha
|
2016-09-29 15:30:15 +00:00
|
|
|
|
lda BIN.InstallDRV.DrvLen
|
2016-09-28 15:34:15 +00:00
|
|
|
|
eor #$ff
|
|
|
|
|
tax
|
2016-09-27 15:51:59 +00:00
|
|
|
|
|
2016-09-28 15:34:15 +00:00
|
|
|
|
ldy #0
|
2016-09-27 15:51:59 +00:00
|
|
|
|
|
2016-10-04 16:01:07 +00:00
|
|
|
|
.2 inx Move CODE in LC
|
2016-09-27 15:51:59 +00:00
|
|
|
|
bne .3
|
2016-09-28 15:34:15 +00:00
|
|
|
|
pla
|
2016-10-04 16:01:07 +00:00
|
|
|
|
inc
|
|
|
|
|
beq .4
|
2016-09-28 15:34:15 +00:00
|
|
|
|
pha
|
2016-09-27 15:51:59 +00:00
|
|
|
|
|
2017-01-12 17:43:45 +00:00
|
|
|
|
.3 lda (ZPPtr1),y
|
|
|
|
|
sta (ZPPtr2),y
|
2016-09-28 15:34:15 +00:00
|
|
|
|
iny
|
|
|
|
|
bne .2
|
2017-01-12 17:43:45 +00:00
|
|
|
|
inc ZPPtr1+1
|
|
|
|
|
inc ZPPtr2+1
|
2016-10-04 16:01:07 +00:00
|
|
|
|
bra .2
|
|
|
|
|
|
|
|
|
|
.4 ldy #H.BIN.DRV.CODE.LEN
|
|
|
|
|
lda DevMgr.Free Make Ptr1 = code start
|
2017-01-12 17:43:45 +00:00
|
|
|
|
sta ZPPtr1
|
2016-10-04 16:01:07 +00:00
|
|
|
|
clc
|
|
|
|
|
adc (pDrv),y
|
2017-01-12 17:43:45 +00:00
|
|
|
|
sta ZPPtr2
|
2016-09-27 15:51:59 +00:00
|
|
|
|
|
2016-10-04 16:01:07 +00:00
|
|
|
|
iny
|
|
|
|
|
lda DevMgr.Free+1
|
2017-01-12 17:43:45 +00:00
|
|
|
|
sta ZPPtr1+1
|
2016-10-04 16:01:07 +00:00
|
|
|
|
adc (pDrv),y
|
2017-01-12 17:43:45 +00:00
|
|
|
|
sta ZPPtr2+1 Make ZPPtr2 = ZPPtr1 + CodeLen
|
2016-10-04 16:01:07 +00:00
|
|
|
|
|
|
|
|
|
jsr BIN.RelocateDRV
|
|
|
|
|
|
|
|
|
|
>LDYA BIN.InstallDRV.DrvEnd
|
|
|
|
|
>STYA DevMgr.Free
|
2017-01-12 17:43:45 +00:00
|
|
|
|
|
2016-10-04 16:01:07 +00:00
|
|
|
|
clc
|
|
|
|
|
rts
|
2016-09-27 15:51:59 +00:00
|
|
|
|
*--------------------------------------
|
2016-09-29 15:30:15 +00:00
|
|
|
|
BIN.InstallDRV.DrvLen .BS 2
|
|
|
|
|
BIN.InstallDRV.DrvEnd .BS 2
|
2016-09-27 15:51:59 +00:00
|
|
|
|
*--------------------------------------
|
|
|
|
|
* BIN.Relocate___ :
|
2016-09-28 15:34:15 +00:00
|
|
|
|
* In :
|
2017-01-12 17:43:45 +00:00
|
|
|
|
* ZPPtr1 = Ptr to Code
|
|
|
|
|
* ZPPtr2 = End Of Code
|
2016-09-28 15:34:15 +00:00
|
|
|
|
*--------------------------------------
|
|
|
|
|
BIN.Relocate.Start .BS 2
|
|
|
|
|
BIN.Relocate.End .BS 2
|
|
|
|
|
BIN.Relocate.Offset .BS 2
|
2016-09-27 15:51:59 +00:00
|
|
|
|
*--------------------------------------
|
2016-09-30 15:04:55 +00:00
|
|
|
|
BIN.RelocateEXE ldy #H.BIN.HEADER+1
|
2017-01-12 17:43:45 +00:00
|
|
|
|
lda (ZPPtr1),y
|
2016-09-30 15:04:55 +00:00
|
|
|
|
cmp /H.BIN.HEADER.BIN65
|
2016-10-04 16:01:07 +00:00
|
|
|
|
beq .1
|
|
|
|
|
cmp /H.BIN.HEADER.DRV65
|
|
|
|
|
beq .1
|
|
|
|
|
|
|
|
|
|
lda #SYSMGR.ERRIBIN
|
|
|
|
|
sec
|
|
|
|
|
rts
|
2016-10-03 06:18:46 +00:00
|
|
|
|
|
2016-10-04 16:01:07 +00:00
|
|
|
|
.1 ldy #H.BIN.JMP relocate Main JMP
|
2017-01-12 17:43:45 +00:00
|
|
|
|
lda (ZPPtr1),y
|
2016-09-27 15:51:59 +00:00
|
|
|
|
clc
|
2016-09-28 15:34:15 +00:00
|
|
|
|
adc BIN.Relocate.Offset
|
2017-01-12 17:43:45 +00:00
|
|
|
|
sta (ZPPtr1),y
|
2016-09-27 15:51:59 +00:00
|
|
|
|
|
|
|
|
|
iny
|
2017-01-12 17:43:45 +00:00
|
|
|
|
lda (ZPPtr1),y
|
2016-09-28 15:34:15 +00:00
|
|
|
|
adc BIN.Relocate.Offset+1
|
2017-01-12 17:43:45 +00:00
|
|
|
|
sta (ZPPtr1),y
|
2016-09-27 15:51:59 +00:00
|
|
|
|
|
2016-09-30 15:04:55 +00:00
|
|
|
|
ldy #H.BIN.EXE.REL.TABLE skip Header, CS.SIZE & DS.SIZE... (16 bytes)
|
|
|
|
|
|
2016-09-27 15:51:59 +00:00
|
|
|
|
.HS 2C bit abs
|
2016-09-28 15:34:15 +00:00
|
|
|
|
*--------------------------------------
|
2016-09-30 15:04:55 +00:00
|
|
|
|
BIN.RelocateDRV ldy #H.BIN.DRV.REL.TABLE
|
2016-09-27 15:51:59 +00:00
|
|
|
|
|
2017-01-12 17:43:45 +00:00
|
|
|
|
.1 lda (ZPPtr1),y Start Relocate JMP table
|
2016-09-28 15:34:15 +00:00
|
|
|
|
tax LO in X
|
2016-09-27 15:51:59 +00:00
|
|
|
|
iny
|
2017-01-12 17:43:45 +00:00
|
|
|
|
ora (ZPPtr1),y ORA with HI
|
2016-09-27 15:51:59 +00:00
|
|
|
|
beq .2 $0000 = end of table
|
|
|
|
|
|
|
|
|
|
dey
|
2016-09-28 15:34:15 +00:00
|
|
|
|
txa get back LO
|
2016-09-27 15:51:59 +00:00
|
|
|
|
clc
|
2016-09-28 15:34:15 +00:00
|
|
|
|
adc BIN.Relocate.Offset
|
2017-01-12 17:43:45 +00:00
|
|
|
|
sta (ZPPtr1),y
|
2016-09-27 15:51:59 +00:00
|
|
|
|
|
|
|
|
|
iny
|
2017-01-12 17:43:45 +00:00
|
|
|
|
lda (ZPPtr1),y
|
2016-09-28 15:34:15 +00:00
|
|
|
|
adc BIN.Relocate.Offset+1
|
2017-01-12 17:43:45 +00:00
|
|
|
|
sta (ZPPtr1),y
|
2016-09-27 15:51:59 +00:00
|
|
|
|
|
|
|
|
|
iny
|
|
|
|
|
|
|
|
|
|
bra .1
|
2016-09-28 15:34:15 +00:00
|
|
|
|
*--------------------------------------
|
|
|
|
|
.2 tya add current offset in Y to Ptr
|
|
|
|
|
|
|
|
|
|
sec + 1 to skip last 00 from beq .2
|
2016-09-27 15:51:59 +00:00
|
|
|
|
|
2017-01-12 17:43:45 +00:00
|
|
|
|
adc ZPPtr1
|
|
|
|
|
sta ZPPtr1
|
2016-09-28 15:34:15 +00:00
|
|
|
|
bcc .3
|
2017-08-24 15:29:22 +00:00
|
|
|
|
inc ZPPtr1+1 ZPPtr1=Current Code PTR
|
2016-09-27 15:51:59 +00:00
|
|
|
|
|
2017-08-24 15:29:22 +00:00
|
|
|
|
.3 lda (ZPPtr1) get OPCODE
|
2016-09-28 15:34:15 +00:00
|
|
|
|
lsr /2
|
2016-09-27 15:51:59 +00:00
|
|
|
|
tax
|
|
|
|
|
lda BIN.OPCODES,x get OPCODE definition
|
2016-09-30 15:04:55 +00:00
|
|
|
|
bcs .4 go get LO nibble
|
2016-09-28 15:34:15 +00:00
|
|
|
|
lsr
|
|
|
|
|
lsr move HI -> LO
|
|
|
|
|
lsr
|
|
|
|
|
lsr
|
2016-09-30 15:04:55 +00:00
|
|
|
|
.4 and #$0f
|
2016-09-28 15:34:15 +00:00
|
|
|
|
|
|
|
|
|
bit #$8 abs addressing?
|
2016-09-30 15:04:55 +00:00
|
|
|
|
beq .6 no....
|
2016-09-27 15:51:59 +00:00
|
|
|
|
|
2016-09-28 15:34:15 +00:00
|
|
|
|
and #7 save Opcode length...
|
2016-09-27 15:51:59 +00:00
|
|
|
|
pha
|
|
|
|
|
|
|
|
|
|
ldy #1
|
2017-01-12 17:43:45 +00:00
|
|
|
|
lda (ZPPtr1),y Get LO
|
2016-09-28 15:34:15 +00:00
|
|
|
|
tax save LO in X
|
|
|
|
|
|
|
|
|
|
iny make Y point to HI
|
|
|
|
|
|
|
|
|
|
cpx BIN.Relocate.Start
|
2017-01-12 17:43:45 +00:00
|
|
|
|
lda (ZPPtr1),y Get HI
|
2016-09-28 15:34:15 +00:00
|
|
|
|
sbc BIN.Relocate.Start+1
|
2016-09-30 15:04:55 +00:00
|
|
|
|
bcc .5 addr < BIN.Relocate.Start, out of range
|
2016-09-27 15:51:59 +00:00
|
|
|
|
|
2016-09-28 15:34:15 +00:00
|
|
|
|
txa Get back LO
|
|
|
|
|
cpx BIN.Relocate.End
|
2017-01-12 17:43:45 +00:00
|
|
|
|
lda (ZPPtr1),y Get HI
|
2016-09-28 15:34:15 +00:00
|
|
|
|
sbc BIN.Relocate.End+1
|
2016-09-30 15:04:55 +00:00
|
|
|
|
bcs .5 addr > BIN.Relocate.End, out of range
|
2016-09-27 15:51:59 +00:00
|
|
|
|
|
2016-09-28 15:34:15 +00:00
|
|
|
|
txa Get back LO
|
|
|
|
|
* clc CC from bcs .6
|
|
|
|
|
adc BIN.Relocate.Offset add Offset to abs address
|
2016-09-27 15:51:59 +00:00
|
|
|
|
dey
|
2017-01-12 17:43:45 +00:00
|
|
|
|
sta (ZPPtr1),y store relocated addr LO
|
2016-09-27 15:51:59 +00:00
|
|
|
|
iny
|
2017-01-12 17:43:45 +00:00
|
|
|
|
lda (ZPPtr1),y Get HI
|
2016-09-28 15:34:15 +00:00
|
|
|
|
adc BIN.Relocate.Offset+1
|
2017-01-12 17:43:45 +00:00
|
|
|
|
sta (ZPPtr1),y store relocated addr HI
|
2016-09-27 15:51:59 +00:00
|
|
|
|
|
2016-09-30 15:04:55 +00:00
|
|
|
|
.5 pla get back Opcode length...
|
2016-09-27 15:51:59 +00:00
|
|
|
|
|
2016-09-30 15:04:55 +00:00
|
|
|
|
.6 clc A = OPCODE length
|
2017-01-12 17:43:45 +00:00
|
|
|
|
adc ZPPtr1
|
|
|
|
|
sta ZPPtr1
|
2016-09-30 15:04:55 +00:00
|
|
|
|
bcc .7
|
2017-01-12 17:43:45 +00:00
|
|
|
|
inc ZPPtr1+1
|
2016-09-30 15:04:55 +00:00
|
|
|
|
|
2017-01-12 17:43:45 +00:00
|
|
|
|
.7 eor ZPPtr2 A = ZPPtr1
|
2016-09-30 15:04:55 +00:00
|
|
|
|
bne .3
|
2017-01-12 17:43:45 +00:00
|
|
|
|
lda ZPPtr1+1
|
|
|
|
|
eor ZPPtr2+1
|
2016-09-30 15:04:55 +00:00
|
|
|
|
bne .3 next opcode....
|
2016-09-27 15:51:59 +00:00
|
|
|
|
|
2016-09-30 06:24:52 +00:00
|
|
|
|
.8 rts
|
2016-09-27 15:51:59 +00:00
|
|
|
|
*--------------------------------------
|
|
|
|
|
* 65C02 OPCODES
|
2016-09-28 15:34:15 +00:00
|
|
|
|
* Bit 3 : 1 = absolute addressing
|
|
|
|
|
* Bit 2-1-0 : opcode + @ length
|
2016-09-27 15:51:59 +00:00
|
|
|
|
*--------------------------------------
|
2016-09-28 15:34:15 +00:00
|
|
|
|
* 0.1.2.3.4.5.6.7.8.9.A.B.C.D.E.F
|
|
|
|
|
BIN.OPCODES .HS 1.2.2.1.2.2.2.2.1.2.1.1.B.B.B.3
|
|
|
|
|
.HS 2.2.2.1.2.2.2.2.1.B.1.1.B.B.B.3
|
|
|
|
|
.HS B.2.2.1.2.2.2.2.1.2.1.1.B.B.B.3
|
|
|
|
|
.HS 2.2.2.1.2.2.2.2.1.B.1.1.B.B.B.3
|
|
|
|
|
.HS 1.2.2.1.2.2.2.2.1.2.1.1.B.B.B.3
|
|
|
|
|
.HS 2.2.2.1.2.2.2.2.1.B.1.1.1.B.B.3
|
|
|
|
|
.HS 1.2.2.1.2.2.2.2.1.2.1.1.B.B.B.3
|
|
|
|
|
.HS 2.2.2.1.2.2.2.2.1.B.1.1.B.B.B.3
|
|
|
|
|
.HS 2.2.2.1.2.2.2.2.1.2.1.1.B.B.B.3
|
|
|
|
|
.HS 2.2.2.1.2.2.2.2.1.B.1.1.B.B.B.3
|
|
|
|
|
.HS 2.2.2.1.2.2.2.2.1.2.1.1.B.B.B.3
|
|
|
|
|
.HS 2.2.2.1.2.2.2.2.1.B.1.1.B.B.B.3
|
|
|
|
|
.HS 2.2.2.1.2.2.2.2.1.2.1.1.B.B.B.3
|
|
|
|
|
.HS 2.2.2.1.2.2.2.2.1.B.1.1.1.B.B.3
|
|
|
|
|
.HS 2.2.2.1.2.2.2.2.1.2.1.1.B.B.B.3
|
|
|
|
|
.HS 2.2.2.1.2.2.2.2.1.B.1.1.1.B.B.3
|
2015-03-14 21:48:35 +00:00
|
|
|
|
*--------------------------------------
|
|
|
|
|
MAN
|
2017-03-29 15:48:15 +00:00
|
|
|
|
SAVE /A2OSX.SRC/SYS/KERNEL.S.BIN
|
|
|
|
|
LOAD /A2OSX.SRC/SYS/KERNEL.S
|
2015-03-14 21:48:35 +00:00
|
|
|
|
ASM
|