2018-01-19 07:14:38 +00:00
|
|
|
|
NEW
|
2017-03-29 15:48:15 +00:00
|
|
|
|
PREFIX /A2OSX.BUILD
|
2018-01-19 07:14:38 +00:00
|
|
|
|
AUTO 4,1
|
2015-03-14 21:48:35 +00:00
|
|
|
|
*--------------------------------------
|
2018-07-20 05:43:11 +00:00
|
|
|
|
* LoadLib
|
2017-08-24 12:46:48 +00:00
|
|
|
|
* 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
|
|
|
|
|
*--------------------------------------
|
2018-06-21 15:12:10 +00:00
|
|
|
|
K.LoadLib jsr BIN.FindLIB
|
2017-08-24 12:46:48 +00:00
|
|
|
|
bcs .9
|
|
|
|
|
|
2018-06-22 06:24:35 +00:00
|
|
|
|
jsr BIN.Load Y,A = "/PATH/BIN"
|
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
|
2018-06-22 06:24:35 +00:00
|
|
|
|
jsr K.FreeMem
|
2017-08-24 12:46:48 +00:00
|
|
|
|
pla
|
|
|
|
|
|
|
|
|
|
sec
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
2018-07-20 05:43:11 +00:00
|
|
|
|
* UnloadLib
|
2017-08-24 12:46:48 +00:00
|
|
|
|
* in :
|
|
|
|
|
* A = hMem To Lib
|
|
|
|
|
* out :
|
|
|
|
|
*--------------------------------------
|
2018-06-18 06:22:50 +00:00
|
|
|
|
K.UnloadLib pha
|
2018-06-21 15:12:10 +00:00
|
|
|
|
jsr K.GetMemByID
|
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
|
2018-06-22 06:24:35 +00:00
|
|
|
|
jmp K.FreeMem
|
2018-06-21 15:12:10 +00:00
|
|
|
|
*/--------------------------------------
|
|
|
|
|
* # LoadDrv
|
2018-07-20 05:43:11 +00:00
|
|
|
|
* ## ASM
|
2018-06-21 15:12:10 +00:00
|
|
|
|
* **In:**
|
|
|
|
|
* Y,A = PTR to "NAME.DRV [PARAM]" C-String
|
|
|
|
|
* **Out:**
|
|
|
|
|
* none
|
|
|
|
|
*\--------------------------------------
|
2018-06-18 06:22:50 +00:00
|
|
|
|
K.LoadDrv >STYA .2+1 Save "BIN\0ARGS\0\0"
|
2018-01-19 07:14:38 +00:00
|
|
|
|
|
2018-06-21 15:12:10 +00:00
|
|
|
|
jsr BIN.FindDRV
|
2017-08-25 15:02:16 +00:00
|
|
|
|
bcs .9
|
|
|
|
|
|
2018-06-22 06:24:35 +00:00
|
|
|
|
jsr BIN.Load Y,A = "/PATH/BIN"
|
2017-08-25 15:02:16 +00:00
|
|
|
|
bcs .9
|
|
|
|
|
|
2018-07-05 15:39:36 +00:00
|
|
|
|
>STYA .3+1
|
2017-08-25 15:02:16 +00:00
|
|
|
|
stx .97+1
|
|
|
|
|
|
2018-01-19 07:14:38 +00:00
|
|
|
|
ldx #$ff
|
|
|
|
|
|
|
|
|
|
.1 inx Skip "BIN"
|
|
|
|
|
.2 lda $ffff,x
|
2017-08-25 15:02:16 +00:00
|
|
|
|
bne .1
|
|
|
|
|
|
2018-01-19 07:14:38 +00:00
|
|
|
|
txa
|
|
|
|
|
sec
|
|
|
|
|
adc .2+1
|
|
|
|
|
tay
|
|
|
|
|
lda #0
|
2018-06-28 15:26:34 +00:00
|
|
|
|
adc .2+2 Y,A = ARGS
|
2018-01-19 07:14:38 +00:00
|
|
|
|
|
2018-07-05 15:39:36 +00:00
|
|
|
|
.3 jsr $ffff SELF MODIFIED, call Dev.Detect
|
2017-08-25 15:02:16 +00:00
|
|
|
|
bcs .96
|
|
|
|
|
|
|
|
|
|
jsr .96 Cleanup...
|
|
|
|
|
|
|
|
|
|
lda #0 Make sure RC = 0 if success
|
|
|
|
|
clc
|
|
|
|
|
.9 rts
|
|
|
|
|
|
2018-01-18 06:49:41 +00:00
|
|
|
|
.96 pha
|
|
|
|
|
|
2017-08-25 15:02:16 +00:00
|
|
|
|
.97 lda #$ff
|
2018-06-22 06:24:35 +00:00
|
|
|
|
jsr K.FreeMem
|
2017-08-25 15:02:16 +00:00
|
|
|
|
pla
|
2018-01-18 06:49:41 +00:00
|
|
|
|
sec
|
2018-07-05 15:39:36 +00:00
|
|
|
|
rts
|
2018-01-18 06:49:41 +00:00
|
|
|
|
*--------------------------------------
|
2018-06-18 06:22:50 +00:00
|
|
|
|
BIN.FindLIB clc
|
2018-01-18 06:49:41 +00:00
|
|
|
|
.HS B0 bcs
|
2018-06-18 06:22:50 +00:00
|
|
|
|
BIN.FindDRV sec
|
2018-01-19 07:14:38 +00:00
|
|
|
|
|
2018-01-18 06:49:41 +00:00
|
|
|
|
>STYA BIN.CmdLine
|
|
|
|
|
|
|
|
|
|
>LDYAI BIN.Find.ENV.LIB
|
|
|
|
|
bcc .1
|
|
|
|
|
>LDYAI BIN.Find.ENV.DRV
|
|
|
|
|
|
2018-06-18 06:22:50 +00:00
|
|
|
|
.1 jsr K.GetEnv get value for Search Path
|
2018-01-18 06:49:41 +00:00
|
|
|
|
bcs .9
|
2018-01-19 07:14:38 +00:00
|
|
|
|
|
2018-06-28 15:26:34 +00:00
|
|
|
|
>STYA K.FileSearch.SearchPath
|
|
|
|
|
|
|
|
|
|
>LDYA BIN.CmdLine
|
|
|
|
|
|
|
|
|
|
jsr K.FileSearch.YA find LIB/DRV in Search
|
2018-01-18 06:49:41 +00:00
|
|
|
|
bcs .9
|
2018-01-19 07:14:38 +00:00
|
|
|
|
|
2018-01-18 06:49:41 +00:00
|
|
|
|
>LDYAI K.Buf256
|
2018-01-19 07:14:38 +00:00
|
|
|
|
clc
|
2018-01-18 06:49:41 +00:00
|
|
|
|
.9 rts
|
2017-08-25 15:02:16 +00:00
|
|
|
|
*--------------------------------------
|
2018-04-10 15:03:29 +00:00
|
|
|
|
BIN.Find.ENV.DRV .AZ "DRV"
|
|
|
|
|
BIN.Find.ENV.LIB .AZ "LIB"
|
2017-08-25 15:02:16 +00:00
|
|
|
|
*--------------------------------------
|
2018-06-28 15:26:34 +00:00
|
|
|
|
* BIN.Load
|
2015-03-14 21:48:35 +00:00
|
|
|
|
* in :
|
2018-01-19 07:14:38 +00:00
|
|
|
|
* Y,A = /BIN/PATH (CSTR)
|
2015-03-14 21:48:35 +00:00
|
|
|
|
* out :
|
|
|
|
|
* Y,A = MEMPTR
|
|
|
|
|
* X = hMem of Code Segment
|
|
|
|
|
*--------------------------------------
|
2018-06-22 06:24:35 +00:00
|
|
|
|
BIN.Load >STYA BIN.CmdLine
|
2017-11-22 16:27:50 +00:00
|
|
|
|
>STYA .2+1
|
|
|
|
|
|
|
|
|
|
>LDYAI Mem.Table
|
|
|
|
|
>STYA ZPPtr1
|
2015-09-13 20:35:07 +00:00
|
|
|
|
|
2018-08-20 15:15:37 +00:00
|
|
|
|
ldx #0 we will skip Slot 0...
|
|
|
|
|
|
|
|
|
|
.1 cpx Mem.LastSlot
|
|
|
|
|
beq BIN.Load.1
|
|
|
|
|
|
|
|
|
|
inx
|
|
|
|
|
|
|
|
|
|
lda ZPPtr1
|
|
|
|
|
clc
|
|
|
|
|
adc #S.MEM
|
|
|
|
|
sta ZPPtr1
|
|
|
|
|
bcc .11
|
|
|
|
|
inc ZPPtr1+1
|
2017-11-22 16:27:50 +00:00
|
|
|
|
|
2018-08-20 15:15:37 +00:00
|
|
|
|
.11 lda (ZPPtr1)
|
|
|
|
|
bpl .1 In Use?
|
2017-11-22 16:27:50 +00:00
|
|
|
|
|
|
|
|
|
ldy #S.MEM.BIN any BIN PATH in this slot?
|
|
|
|
|
lda (ZPPtr1),y
|
2018-08-20 15:15:37 +00:00
|
|
|
|
beq .1
|
2017-11-22 16:27:50 +00:00
|
|
|
|
|
2018-08-20 15:15:37 +00:00
|
|
|
|
jsr K.GetMemPtr X unmodified, get pathname
|
2017-11-22 16:27:50 +00:00
|
|
|
|
>STYA .3+1
|
|
|
|
|
|
|
|
|
|
ldy #0
|
|
|
|
|
|
|
|
|
|
.2 lda $ffff,y SELF MODIFIED
|
|
|
|
|
.3 cmp $ffff,y SELF MODIFIED
|
2018-08-20 15:15:37 +00:00
|
|
|
|
bne .1
|
2017-11-22 16:27:50 +00:00
|
|
|
|
iny
|
|
|
|
|
ora #0
|
|
|
|
|
bne .2
|
|
|
|
|
|
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-11-22 16:27:50 +00:00
|
|
|
|
sta (ZPPtr1),y
|
|
|
|
|
|
2018-08-20 15:15:37 +00:00
|
|
|
|
ldy #S.MEM.PTR
|
|
|
|
|
lda (ZPPtr1),y
|
|
|
|
|
pha
|
|
|
|
|
iny
|
|
|
|
|
lda (ZPPtr1),y
|
|
|
|
|
ply
|
|
|
|
|
|
2017-11-22 16:27:50 +00:00
|
|
|
|
clc
|
2018-08-20 15:15:37 +00:00
|
|
|
|
rts X=hMem, Y,A=Ptr
|
2016-09-28 15:34:15 +00:00
|
|
|
|
*--------------------------------------
|
2018-06-22 06:24:35 +00:00
|
|
|
|
BIN.Load.1 >PUSHWI K.S.STAT
|
2018-07-20 11:51:08 +00:00
|
|
|
|
>LDYA 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
|
2018-06-29 14:16:40 +00:00
|
|
|
|
>STYA BIN.R.CS.Start
|
2016-09-26 16:00:52 +00:00
|
|
|
|
|
2016-09-28 15:34:15 +00:00
|
|
|
|
>PUSHYA Push AUXTYPE
|
2018-06-29 14:16:40 +00:00
|
|
|
|
>PUSHBI S.FI.T.BIN
|
2017-01-12 17:43:45 +00:00
|
|
|
|
>PUSHBI SYS.FOpen.R
|
2018-07-25 15:26:14 +00:00
|
|
|
|
>LDYA 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
|
|
|
|
|
2018-01-18 06:49:41 +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
|
|
|
|
|
2018-07-13 14:38:24 +00:00
|
|
|
|
adc BIN.R.CS.Start Get AUXTYPE for actual Base Address
|
2017-10-27 14:56:46 +00:00
|
|
|
|
sta BIN.R.End compute Range End=AUXTYPE+FILELEN
|
2016-09-30 15:04:55 +00:00
|
|
|
|
pla
|
2018-06-29 14:16:40 +00:00
|
|
|
|
adc BIN.R.CS.Start+1
|
2017-10-27 14:56:46 +00:00
|
|
|
|
sta BIN.R.End+1
|
2016-09-30 15:04:55 +00:00
|
|
|
|
|
|
|
|
|
txa
|
2018-06-21 15:12:10 +00:00
|
|
|
|
jsr K.GetMemPtr
|
|
|
|
|
>STYA ZPPtr1 set ZPPtr1 -> Code start
|
2016-09-30 15:04:55 +00:00
|
|
|
|
|
2018-06-21 15:12:10 +00:00
|
|
|
|
pha YA = actual load address
|
2016-09-30 15:04:55 +00:00
|
|
|
|
tya
|
2016-09-28 15:34:15 +00:00
|
|
|
|
sec
|
2018-06-29 14:16:40 +00:00
|
|
|
|
sbc BIN.R.CS.Start
|
2018-06-21 15:12:10 +00:00
|
|
|
|
sta BIN.R.Offset Offset=ZPPtr1-AUXTYPE
|
2016-09-30 15:04:55 +00:00
|
|
|
|
pla
|
2018-06-29 14:16:40 +00:00
|
|
|
|
sbc BIN.R.CS.Start+1
|
2017-10-27 14:56:46 +00:00
|
|
|
|
sta BIN.R.Offset+1
|
2016-09-28 15:34:15 +00:00
|
|
|
|
|
2018-09-11 13:32:56 +00:00
|
|
|
|
ldy #H.BIN.CS.SIZE get Code Len
|
2017-01-12 17:43:45 +00:00
|
|
|
|
lda (ZPPtr1),y
|
2016-10-12 15:46:38 +00:00
|
|
|
|
clc
|
2018-07-19 15:33:55 +00:00
|
|
|
|
adc BIN.R.CS.Start
|
2018-07-13 14:38:24 +00:00
|
|
|
|
sta BIN.R.CS.End ZPPtr1 + CodeLen
|
2016-10-12 15:46:38 +00:00
|
|
|
|
iny
|
2017-01-12 17:43:45 +00:00
|
|
|
|
lda (ZPPtr1),y
|
2018-07-19 15:33:55 +00:00
|
|
|
|
adc BIN.R.CS.Start+1
|
2018-07-13 14:38:24 +00:00
|
|
|
|
sta BIN.R.CS.End+1
|
2016-09-30 15:04:55 +00:00
|
|
|
|
|
2017-10-27 14:56:46 +00:00
|
|
|
|
jsr BIN.RelExe
|
2015-06-03 18:30:57 +00:00
|
|
|
|
|
2018-06-21 15:12:10 +00:00
|
|
|
|
>LDYA BIN.CmdLine get back bin path
|
|
|
|
|
jsr K.NewStr make a copy of this string
|
2015-03-14 21:48:35 +00:00
|
|
|
|
bcs .98
|
2015-09-13 20:35:07 +00:00
|
|
|
|
|
2018-06-21 15:12:10 +00:00
|
|
|
|
lda BIN.hMem Keep X=hMem
|
|
|
|
|
jsr K.GetMemByID 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...
|
2018-06-21 15:12:10 +00:00
|
|
|
|
jmp K.GetMemPtr ...and Y,A=PTR to CS
|
2015-03-14 21:48:35 +00:00
|
|
|
|
|
|
|
|
|
.98 pha
|
2017-08-25 15:02:16 +00:00
|
|
|
|
lda BIN.hMem
|
2018-06-21 15:12:10 +00:00
|
|
|
|
jsr K.FreeMem 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
|
2018-06-28 15:26:34 +00:00
|
|
|
|
*/--------------------------------------
|
2018-07-20 05:43:11 +00:00
|
|
|
|
* # InsDrv
|
|
|
|
|
* ## C
|
2018-07-17 15:45:59 +00:00
|
|
|
|
* `void * insdrv (void * src, void * crvcsstart, void * drvcsend, void * drvend);`
|
2018-07-20 05:43:11 +00:00
|
|
|
|
* ## ASM
|
2018-06-28 15:26:34 +00:00
|
|
|
|
* **In:**
|
2018-07-19 15:33:55 +00:00
|
|
|
|
* `>PUSHW DRV.END`
|
|
|
|
|
* `>PUSHW DRV.CS.END`
|
|
|
|
|
* `>PUSHW DRV.CS.START`
|
|
|
|
|
* `>LDYA L.SRC`
|
|
|
|
|
* `SYSCALL insdrv`
|
2018-07-17 15:45:59 +00:00
|
|
|
|
* **Out:**
|
|
|
|
|
* Y,A = Ptr to installed driver
|
2018-06-28 15:26:34 +00:00
|
|
|
|
*\--------------------------------------
|
2018-07-17 15:45:59 +00:00
|
|
|
|
K.InsDrv >STYA ZPPtr1
|
|
|
|
|
|
|
|
|
|
>PULLW BIN.R.CS.Start
|
2018-06-29 14:16:40 +00:00
|
|
|
|
>PULLW BIN.R.CS.End
|
|
|
|
|
>PULLW BIN.R.End
|
2018-07-17 15:45:59 +00:00
|
|
|
|
|
2017-10-27 14:56:46 +00:00
|
|
|
|
lda BIN.R.End Compute DRVLen=End-start
|
2016-09-27 15:51:59 +00:00
|
|
|
|
sec
|
2018-06-29 14:16:40 +00:00
|
|
|
|
sbc BIN.R.CS.Start
|
2018-07-17 15:45:59 +00:00
|
|
|
|
sta BIN.Move.Len
|
2016-09-30 15:04:55 +00:00
|
|
|
|
|
2017-10-27 14:56:46 +00:00
|
|
|
|
lda BIN.R.End+1
|
2018-06-29 14:16:40 +00:00
|
|
|
|
sbc BIN.R.CS.Start+1
|
2018-07-17 15:45:59 +00:00
|
|
|
|
sta BIN.Move.Len+1
|
2016-09-27 15:51:59 +00:00
|
|
|
|
|
2018-06-29 14:16:40 +00:00
|
|
|
|
lda DevMgr.Free Compute new DevMgr.Free
|
2016-09-27 15:51:59 +00:00
|
|
|
|
clc
|
2018-07-17 15:45:59 +00:00
|
|
|
|
adc BIN.Move.Len
|
2018-06-21 15:12:10 +00:00
|
|
|
|
tay Save DRVEnd LO
|
2016-09-27 15:51:59 +00:00
|
|
|
|
lda DevMgr.Free+1
|
2018-07-17 15:45:59 +00:00
|
|
|
|
adc BIN.Move.Len+1 A = DRVEnd HI
|
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
|
|
|
|
|
2018-07-17 15:45:59 +00:00
|
|
|
|
>LDYA DevMgr.Free
|
|
|
|
|
jsr BIN.MoveToYA
|
2016-09-27 15:51:59 +00:00
|
|
|
|
|
2018-07-17 15:45:59 +00:00
|
|
|
|
lda DevMgr.Free
|
|
|
|
|
sta ZPPtr1
|
2018-06-29 14:16:40 +00:00
|
|
|
|
sec
|
|
|
|
|
sbc BIN.R.CS.Start
|
|
|
|
|
sta BIN.R.Offset
|
2016-09-27 15:51:59 +00:00
|
|
|
|
|
2016-10-04 16:01:07 +00:00
|
|
|
|
lda DevMgr.Free+1
|
2018-07-17 15:45:59 +00:00
|
|
|
|
sta ZPPtr1+1
|
2018-06-29 14:16:40 +00:00
|
|
|
|
sbc BIN.R.CS.Start+1
|
|
|
|
|
sta BIN.R.Offset+1
|
2018-07-17 15:45:59 +00:00
|
|
|
|
|
2018-06-29 14:16:40 +00:00
|
|
|
|
jsr BIN.RelDrv
|
2016-10-06 15:50:20 +00:00
|
|
|
|
|
|
|
|
|
lda DevMgr.Free
|
2018-07-17 15:45:59 +00:00
|
|
|
|
tay
|
|
|
|
|
clc
|
|
|
|
|
adc BIN.Move.Len
|
|
|
|
|
sta DevMgr.Free
|
2018-06-29 14:16:40 +00:00
|
|
|
|
lda DevMgr.Free+1
|
2018-07-17 15:45:59 +00:00
|
|
|
|
pha
|
|
|
|
|
adc BIN.Move.Len+1
|
|
|
|
|
sta DevMgr.Free+1
|
|
|
|
|
pla
|
2016-09-27 15:51:59 +00:00
|
|
|
|
|
|
|
|
|
clc
|
2018-06-29 14:16:40 +00:00
|
|
|
|
rts
|
2018-07-17 15:45:59 +00:00
|
|
|
|
|
|
|
|
|
.9 lda #K.E.OOM
|
|
|
|
|
sec
|
|
|
|
|
rts
|
2018-06-29 14:16:40 +00:00
|
|
|
|
*--------------------------------------
|
2018-07-17 15:45:59 +00:00
|
|
|
|
BIN.Move.Len .BS 2
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
BIN.MoveToYA >STYA ZPPtr2
|
2016-10-04 16:01:07 +00:00
|
|
|
|
|
2018-07-17 15:45:59 +00:00
|
|
|
|
lda BIN.Move.Len+1
|
2016-09-28 15:34:15 +00:00
|
|
|
|
eor #$ff
|
|
|
|
|
pha
|
2018-07-17 15:45:59 +00:00
|
|
|
|
lda BIN.Move.Len
|
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
|
|
|
|
|
2018-06-29 14:16:40 +00:00
|
|
|
|
.1 inx
|
|
|
|
|
bne .2
|
2016-09-28 15:34:15 +00:00
|
|
|
|
pla
|
2016-10-04 16:01:07 +00:00
|
|
|
|
inc
|
2018-06-29 14:16:40 +00:00
|
|
|
|
beq .3
|
2016-09-28 15:34:15 +00:00
|
|
|
|
pha
|
2016-09-27 15:51:59 +00:00
|
|
|
|
|
2018-06-29 14:16:40 +00:00
|
|
|
|
.2 lda (ZPPtr1),y
|
2017-01-12 17:43:45 +00:00
|
|
|
|
sta (ZPPtr2),y
|
2016-09-28 15:34:15 +00:00
|
|
|
|
iny
|
2018-06-29 14:16:40 +00:00
|
|
|
|
bne .1
|
|
|
|
|
|
2017-01-12 17:43:45 +00:00
|
|
|
|
inc ZPPtr1+1
|
|
|
|
|
inc ZPPtr2+1
|
2018-06-29 14:16:40 +00:00
|
|
|
|
bra .1
|
2016-10-04 16:01:07 +00:00
|
|
|
|
|
2018-07-17 15:45:59 +00:00
|
|
|
|
.3 rts
|
2016-09-27 15:51:59 +00:00
|
|
|
|
*--------------------------------------
|
2017-10-27 14:56:46 +00:00
|
|
|
|
* BIN.Rel___ :
|
2016-09-28 15:34:15 +00:00
|
|
|
|
*--------------------------------------
|
2018-06-29 14:16:40 +00:00
|
|
|
|
BIN.R.CS.Start .BS 2
|
|
|
|
|
BIN.R.CS.End .BS 2
|
2017-10-27 14:56:46 +00:00
|
|
|
|
BIN.R.End .BS 2
|
|
|
|
|
BIN.R.Offset .BS 2
|
2016-09-27 15:51:59 +00:00
|
|
|
|
*--------------------------------------
|
2017-10-27 14:56:46 +00:00
|
|
|
|
BIN.RelExe ldy #H.BIN.T+1
|
2017-01-12 17:43:45 +00:00
|
|
|
|
lda (ZPPtr1),y
|
2017-10-17 15:40:21 +00:00
|
|
|
|
cmp /H.BIN.T.BIN65
|
2016-10-04 16:01:07 +00:00
|
|
|
|
beq .1
|
2017-10-17 15:40:21 +00:00
|
|
|
|
cmp /H.BIN.T.DRV65
|
2016-10-04 16:01:07 +00:00
|
|
|
|
beq .1
|
|
|
|
|
|
2017-10-26 16:01:54 +00:00
|
|
|
|
lda #K.E.IBIN
|
2016-10-04 16:01:07 +00:00
|
|
|
|
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
|
2017-10-27 14:56:46 +00:00
|
|
|
|
adc BIN.R.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
|
2017-10-27 14:56:46 +00:00
|
|
|
|
adc BIN.R.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
|
|
|
|
*--------------------------------------
|
2017-10-27 14:56:46 +00:00
|
|
|
|
BIN.RelDrv ldy #H.BIN.DRV.REL.TABLE
|
2018-07-17 15:45:59 +00:00
|
|
|
|
|
2018-07-16 15:29:18 +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
|
2018-09-09 08:11:42 +00:00
|
|
|
|
lda (ZPPtr1),y HI in A
|
|
|
|
|
beq .2 $00xx = end of table
|
2016-09-27 15:51:59 +00:00
|
|
|
|
|
2018-09-09 08:11:42 +00:00
|
|
|
|
cpx BIN.R.CS.Start
|
|
|
|
|
sbc BIN.R.CS.Start+1
|
|
|
|
|
bcc .11 addr < BIN.R.CS.Start, out of range
|
|
|
|
|
|
|
|
|
|
txa Get back LO
|
|
|
|
|
cpx BIN.R.End
|
|
|
|
|
lda (ZPPtr1),y Get HI
|
|
|
|
|
sbc BIN.R.End+1
|
|
|
|
|
bcs .11 addr > BIN.R.End, out of range
|
|
|
|
|
|
2016-09-27 15:51:59 +00:00
|
|
|
|
dey
|
2016-09-28 15:34:15 +00:00
|
|
|
|
txa get back LO
|
2016-09-27 15:51:59 +00:00
|
|
|
|
clc
|
2017-10-27 14:56:46 +00:00
|
|
|
|
adc BIN.R.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
|
2017-10-27 14:56:46 +00:00
|
|
|
|
adc BIN.R.Offset+1
|
2017-01-12 17:43:45 +00:00
|
|
|
|
sta (ZPPtr1),y
|
2016-09-27 15:51:59 +00:00
|
|
|
|
|
2018-09-09 08:11:42 +00:00
|
|
|
|
.11 iny
|
2016-09-27 15:51:59 +00:00
|
|
|
|
|
|
|
|
|
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
|
2018-07-20 05:43:11 +00:00
|
|
|
|
|
|
|
|
|
.3 lda BIN.R.CS.End compute new CS.END to stop relocating
|
2018-07-19 15:33:55 +00:00
|
|
|
|
clc
|
|
|
|
|
adc BIN.R.Offset
|
|
|
|
|
sta .7+1
|
|
|
|
|
|
|
|
|
|
lda BIN.R.CS.End+1
|
|
|
|
|
adc BIN.R.Offset+1
|
|
|
|
|
sta .71+1
|
|
|
|
|
|
2018-07-20 05:43:11 +00:00
|
|
|
|
lda (ZPPtr1) get OPCODE
|
2016-09-28 15:34:15 +00:00
|
|
|
|
lsr /2
|
2016-09-27 15:51:59 +00:00
|
|
|
|
tax
|
2018-06-29 14:16:40 +00:00
|
|
|
|
lda BIN.65816,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
|
2018-07-17 15:45:59 +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
|
2018-07-17 15:45:59 +00:00
|
|
|
|
lda (ZPPtr1),y Get HI
|
2016-09-28 15:34:15 +00:00
|
|
|
|
|
2018-06-29 14:16:40 +00:00
|
|
|
|
cpx BIN.R.CS.Start
|
|
|
|
|
sbc BIN.R.CS.Start+1
|
|
|
|
|
bcc .5 addr < BIN.R.CS.Start, out of range
|
2016-09-27 15:51:59 +00:00
|
|
|
|
|
2016-09-28 15:34:15 +00:00
|
|
|
|
txa Get back LO
|
2017-10-27 14:56:46 +00:00
|
|
|
|
cpx BIN.R.End
|
2018-07-17 15:45:59 +00:00
|
|
|
|
lda (ZPPtr1),y Get HI
|
2017-10-27 14:56:46 +00:00
|
|
|
|
sbc BIN.R.End+1
|
|
|
|
|
bcs .5 addr > BIN.R.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
|
2018-07-17 15:45:59 +00:00
|
|
|
|
adc BIN.R.Offset add Offset to abs address
|
2016-09-27 15:51:59 +00:00
|
|
|
|
dey
|
2018-07-17 15:45:59 +00:00
|
|
|
|
sta (ZPPtr1),y store relocated addr LO
|
2016-09-27 15:51:59 +00:00
|
|
|
|
iny
|
2018-07-17 15:45:59 +00:00
|
|
|
|
lda (ZPPtr1),y Get HI
|
2017-10-27 14:56:46 +00:00
|
|
|
|
adc BIN.R.Offset+1
|
2018-07-17 15:45:59 +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
|
|
|
|
|
2018-07-19 15:33:55 +00:00
|
|
|
|
.7 eor #$ff SELF MODIFIED A = ZPPtr1
|
2016-09-30 15:04:55 +00:00
|
|
|
|
bne .3
|
2017-01-12 17:43:45 +00:00
|
|
|
|
lda ZPPtr1+1
|
2018-07-19 15:33:55 +00:00
|
|
|
|
.71 eor #$ff SELF MODIFIED
|
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
|
|
|
|
*--------------------------------------
|
2018-06-29 14:16:40 +00:00
|
|
|
|
* 6502/65C02/65816 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
|
2018-07-05 15:39:36 +00:00
|
|
|
|
BIN.65816
|
|
|
|
|
* TO DO : Make 2 different tables
|
|
|
|
|
* http://axis.llx.com/~nparker/a2/opcodes.html
|
2018-06-29 14:16:40 +00:00
|
|
|
|
*--------------------------------------
|
|
|
|
|
* 65R02 OPCODES
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
* 0.1.2.3.4.5.6.7.8.9.A.B.C.D.E.F
|
|
|
|
|
BIN.65R02 .HS 1.2.2.1.2.2.2.2.1.2.1.1.B.B.B.3
|
2016-09-28 15:34:15 +00:00
|
|
|
|
.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
|