VCPU16 removed from Relocator & LIB/LIBCRYPT.S

This commit is contained in:
Rémy GIBERT 2016-08-19 16:52:18 +02:00
parent 07813cc5d6
commit 9222922ed3
6 changed files with 164 additions and 145 deletions

Binary file not shown.

Binary file not shown.

View File

@ -16,6 +16,9 @@ ZPTmpPtr1 .EQ ZPLIB
ZPTmpPtr2 .EQ ZPLIB+2
ZPTmpPtr3 .EQ ZPLIB+4
ZPTmpPtr4 .EQ ZPLIB+6
ZPDataPtr .EQ ZPLIB+8
ZPDataLen .EQ ZPLIB+10
ZPChunkLen .EQ ZPLIB+12
*--------------------------------------
* DWORD Macros : Do NOT disturb carry with cpx, cpy...
*--------------------------------------
@ -181,29 +184,30 @@ MD5Init >PUSHWI S.MD5.SIZE
MD5Update >PULLA get MD5 Context
>SYSCALL SYS.GetMemPtrA
>STYA ZPTmpPtr1 get MD5 Context
>PULLW R.AX get DATA
>PULLW R.BX get LEN
>PULLW ZPDataPtr get DATA
>PULLW ZPDataLen get LEN
ldy #S.MD5.FINALIZED
lda (ZPTmpPtr1),y
beq .1
sec
rts
.1 lda R.BH More than 256 Bytes remaining to hash ?
.1 lda ZPDataLen+1 More than 256 Bytes remaining to hash ?
bne .3 yes
lda R.BL
lda ZPDataLen
bne .2 Len = O ?
clc All data processed
rts
.2 cmp #64 More than 64 Bytes remaining to hash ?
bcc .50 yes
.3 lda #64
.50 sta R.CL Save Chunk Len
.50 sta ZPChunkLen Save Chunk Len
jsr MD5UpdateBitCount
ldy #0
.51 lda (R.AX),y Load Buffer with data
.51 lda (ZPDataPtr),y Load Buffer with data
sta MD5.BUFFER64,y
iny
cpy R.CL
cpy ZPChunkLen
bne .51
cpy #64 Full 64 Bytes DATA ?
beq .58
@ -218,25 +222,25 @@ MD5Update >PULLA get MD5 Context
.53 ldy #S.MD5.EXTRABIT Mark MD5 Context as Appended
lda #$80
sta (ZPTmpPtr1),y
lda R.CL
lda ZPChunkLen
cmp #56 Enough room for BITCOUNT ?
bcs .58 no
jsr MD5AppendBitCount
.58 jsr MD5Transform
jsr MD5UpdateABCD0
.8 lda R.BL Substract Bytes processed from LEN
.8 lda ZPDataLen Substract Bytes processed from LEN
sec
sbc R.CL get back chunk Len
sta R.BL
sbc ZPChunkLen get back chunk Len
sta ZPDataLen
bcs .81
dec R.BH
.81 lda R.AL Add Bytes processed to DATA
dec ZPDataLen+1
.81 lda ZPDataPtr Add Bytes processed to DATA
clc
adc R.CL
sta R.AL
adc ZPChunkLen
sta ZPDataPtr
bcc .82
inc R.AH
.82 jmp .1
inc ZPDataPtr+1
.82 bra .1
*--------------------------------------
* MD5FinalizeA
* In :
@ -314,20 +318,20 @@ MD5AppendBitCount
* ZPTmpPtr1 = MD5 Context
*--------------------------------------
MD5UpdateBitCount
stz R.CH
lda R.CL
stz ZPChunkLen+1
lda ZPChunkLen
asl
rol R.CH
rol ZPChunkLen+1
asl times 8 to get bit count
rol R.CH
rol ZPChunkLen+1
asl
rol R.CH
rol ZPChunkLen+1
clc
ldy #S.MD5.BITCOUNT
adc (ZPTmpPtr1),y
sta (ZPTmpPtr1),y
iny
lda R.CH
lda ZPChunkLen+1
adc (ZPTmpPtr1),y
sta (ZPTmpPtr1),y
bcc .8

View File

@ -36,55 +36,31 @@ S.LoadBinYA >STYA S.LoadBin.Filename
.3 >LDYA S.LoadBin.Filename
jsr S.LoadFileYA
bcc .4
rts Error Loading file
bcs .99 Error Loading file
.4 >STYA S.LoadBin.FileLen
>STYA S.LoadBin.SegLen
stx S.LoadBin.hMem save hMem
txa
jsr S.GetMemPtrA
>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
>STYA S.LoadBin.NewBase
>LDYA S.LoadBin.Filename
jsr S.MLIGetFileInfoYA Get File Info for AUXTYPE
bcs .98
>STYA ZPQuickPtr2
>STYA ZPQuickPtr1
ldy #2 get AUXTYPE
lda (ZPQuickPtr2),y
sta R.BL Make BX=Range Start=AUXTYPE
sta S.LoadBin.AuxType
clc
adc S.LoadBin.FileLen
sta R.CL Make CX=Range End=AUXTYPE+FILELEN
lda (ZPQuickPtr1),y
sta S.LoadBin.OldBase
iny
lda (ZPQuickPtr2),y
sta R.BH
sta S.LoadBin.AuxType+1
adc S.LoadBin.FileLen+1
sta R.CH
lda ZPQuickPtr1 Compute relocation offset in DX
sec
sbc S.LoadBin.AuxType
sta R.DL DX=Offset=ZPQuickPtr1-AUXTYPE
lda ZPQuickPtr1+1
sbc S.LoadBin.AuxType+1
sta R.DH
>LDYA ZPQuickPtr1
lda (ZPQuickPtr1),y
sta S.LoadBin.OldBase+1
bit RRAMWRAMBNK2
bit RRAMWRAMBNK2
jsr S.BinRelocateYA
jsr S.InsBin
bit RRAMWRAMBNK1
bit RRAMWRAMBNK1
@ -120,12 +96,13 @@ S.LoadBinYA >STYA S.LoadBin.Filename
pla
sec
rts
.99 rts
*--------------------------------------
S.LoadBin.Filename .BS 2
S.LoadBin.hMem .BS 1
S.LoadBin.AuxType .BS 2
S.LoadBin.FileLen .BS 2
S.LoadBin.OldBase .BS 2
S.LoadBin.NewBase .BS 2
S.LoadBin.SegLen .BS 2
*--------------------------------------
MAN
SAVE SYS/KERNEL.S.BIN

View File

@ -239,7 +239,7 @@ S.ListDirInitYA >STYA R.BX Store path
>PUSHBI S.MEM.F.INIT0 reset all bytes
jsr S.GetMem
bcs .99
stx R.AH
stx S.ListDirInitYA.hDir
>STYA R.CX Store LISTDIR Struct
>LDYA R.BX
@ -275,21 +275,23 @@ S.ListDirInitYA >STYA R.BX Store path
bne .6
jsr S.ListDirInitAV
bcs .98
lda R.AH
lda S.ListDirInitYA.hDir
rts
.6 jsr S.ListDirInitAD
bcs .98
lda R.AH
lda S.ListDirInitYA.hDir
rts
.98 pha
lda R.AH Discard S.LISTDIR
lda S.ListDirInitYA.hDir Discard S.LISTDIR
jsr S.ListDirCloseA
pla
.99 sec
rts
*--------------------------------------
S.ListDirInitYA.hDir .BS 1
*--------------------------------------
S.ListDirInitAV >PUSHWI 256
>PUSHBI 0
jsr S.GetMem
@ -430,7 +432,7 @@ S.ListDirNextAV jsr S.GetMemPtrA
.9 sec
rts
*--------------------------------------
S.ListDirNextAD stz R.DL Reset Return Record hMem
S.ListDirNextAD stz S.ListDirNext.hRec Reset Return Record hMem
ldy #S.LISTDIR.FI File Index = File count ?
lda (R.CX),y
ldy #S.LISTDIR.FC
@ -505,7 +507,7 @@ S.ListDirNextAD stz R.DL Reset Return Record hMem
jsr S.GetMem
bcs .99
>STYA R.BX R.BX = DEST RECORD
stx R.DL
stx S.ListDirNext.hRec
ldy #S.LISTDIR.EL
lda (R.CX),y
@ -547,7 +549,7 @@ S.ListDirNextAD stz R.DL Reset Return Record hMem
inc
sta (R.CX),y
.6 lda R.DL
.6 lda S.ListDirNext.hRec
bne .8
jmp S.ListDirNextAD Nothing to return, start over for next file entry
@ -557,6 +559,37 @@ S.ListDirNextAD stz R.DL Reset Return Record hMem
.99 sec
rts
*--------------------------------------
* S.ListDirReadBlock
* In :
* CX = LISTDIR
* Out :
* Y,A = READ BUFFER
*--------------------------------------
S.ListDirReadBlock
ldy #S.LISTDIR.REFNUM
lda (R.CX),y get ref_num
sta MLICALL.PARAMS+1
ldy #S.LISTDIR.hREADBUF
lda (R.CX),y get READ BUFFER
jsr S.GetMemPtrA
>STYA MLICALL.PARAMS+2
>LDYAI 512
>STYA MLICALL.PARAMS+4
>MLICALL MLIREAD
bcs .9
ldy #S.LISTDIR.BLKPTR set BLKPTR to $0004
lda #4
sta (R.CX),y
iny
lda #0
sta (R.CX),y
ldy #S.LISTDIR.EIB set EIB to 0
sta (R.CX),y
>LDYA MLICALL.PARAMS+2
.9 rts
*--------------------------------------
S.ListDirNext.hRec .BS 1
*--------------------------------------
* S.DirListCloseA
* in :
* A = hS.LISTDIR
@ -600,37 +633,6 @@ S.ListDirCloseA pha
clc
rts
*--------------------------------------
* PRIVATE
*--------------------------------------
* S.ListDirReadBlock
* In :
* CX = LISTDIR
* Out :
* Y,A = READ BUFFER
*--------------------------------------
S.ListDirReadBlock
ldy #S.LISTDIR.REFNUM
lda (R.CX),y get ref_num
sta MLICALL.PARAMS+1
ldy #S.LISTDIR.hREADBUF
lda (R.CX),y get READ BUFFER
jsr S.GetMemPtrA
>STYA MLICALL.PARAMS+2
>LDYAI 512
>STYA MLICALL.PARAMS+4
>MLICALL MLIREAD
bcs .9
ldy #S.LISTDIR.BLKPTR set BLKPTR to $0004
lda #4
sta (R.CX),y
iny
lda #0
sta (R.CX),y
ldy #S.LISTDIR.EIB set EIB to 0
sta (R.CX),y
>LDYA MLICALL.PARAMS+2
.9 rts
*--------------------------------------
TmpFileName .BS 16
*--------------------------------------
MAN

View File

@ -5,41 +5,74 @@ INC 1
AUTO 6
.LIST OFF
*--------------------------------------
* S.InsBin
*--------------------------------------
S.InsBin >LDYA S.LoadBin.NewBase
>STYA ZPQuickPtr1
ldy #H.BIN.CODE.LEN make AX = Code Len
lda (ZPQuickPtr1),y
sta Rel.CodeLen
iny
lda (ZPQuickPtr1),y
sta Rel.CodeLen+1
lda S.LoadBin.OldBase
sta Rel.Start Make BX=Range Start=AUXTYPE
clc
adc S.LoadBin.SegLen
sta Rel.End Make CX=Range End=AUXTYPE+FILELEN
lda S.LoadBin.OldBase+1
sta Rel.Start+1
adc S.LoadBin.SegLen+1
sta Rel.End+1
lda ZPQuickPtr1 Compute relocation offset in DX
sec
sbc S.LoadBin.OldBase
sta Rel.Offset DX=Offset=ZPQuickPtr1-AUXTYPE
lda ZPQuickPtr1+1
sbc S.LoadBin.OldBase+1
sta Rel.Offset+1
jmp S.BinRelocate
*--------------------------------------
* S.InsDrv
* pDrv = .DRV File Loaded Address
*--------------------------------------
S.InsDrv ldy #H.BIN.DRV.CODE.LEN
lda (pDrv),y
sta R.AL
sta Rel.CodeLen
iny
lda (pDrv),y
sta R.AH
sta Rel.CodeLen+1
ldy #H.BIN.DRV.CODE.O
lda (pDrv),y
clc
adc S.LoadBin.AuxType
sta R.BL
adc S.LoadBin.OldBase
sta Rel.Start
iny
lda (pDrv),y
adc S.LoadBin.AuxType+1
sta R.BH set BX=End Of Code
adc S.LoadBin.OldBase+1
sta Rel.Start+1 set BX=End Of Code
lda S.LoadBin.AuxType
lda S.LoadBin.OldBase
clc
adc S.LoadBin.FileLen
sta R.CL
lda S.LoadBin.AuxType+1
adc S.LoadBin.FileLen+1
sta R.CH set CX=End Of Range
adc S.LoadBin.SegLen
sta Rel.End
lda S.LoadBin.OldBase+1
adc S.LoadBin.SegLen+1
sta Rel.End+1 set CX=End Of Range
ldy #H.BIN.DRV.CODE.O
lda S.LoadBin.FileLen
lda S.LoadBin.SegLen
sec
sbc (pDrv),y
sta S.InsDrv.DRVLen
iny
lda S.LoadBin.FileLen+1
lda S.LoadBin.SegLen+1
sbc (pDrv),y
sta S.InsDrv.DRVLen+1 Compute DRV Len
@ -82,23 +115,24 @@ S.InsDrv ldy #H.BIN.DRV.CODE.LEN
lda DevMgr.Free
sec
sbc (ZPQuickPtr1),y
sta R.DL
sta Rel.Offset
lda DevMgr.Free+1
iny
sbc (ZPQuickPtr1),y
sta R.DH set DX=Offset
sta Rel.Offset+1 set DX=Offset
ldy #H.BIN.DRV.CODE.O
lda (pDrv),y
clc
adc pDrv
pha
sta ZPQuickPtr1
iny
lda (pDrv),y
adc pDrv+1
ply
sta ZPQuickPtr1+1
jsr S.DrvRelocateYA
jsr S.DrvRelocate
jsr S.InsDrv.Move
@ -128,11 +162,11 @@ S.InsDrv.Move ldy #H.BIN.DEV.HEADER.O
ldy #S.DEV.JMP Relocate Main JMP
lda (ZPQuickPtr1),y
clc
adc R.DL
adc Rel.Offset
sta (ZPQuickPtr1),y
iny
lda (ZPQuickPtr1),y
adc R.DH
adc Rel.Offset+1
sta (ZPQuickPtr1),y
lda DevMgr.LastDevID
@ -195,60 +229,57 @@ S.InsDrv.Move ldy #H.BIN.DEV.HEADER.O
S.InsDrv.DrvLen .BS 2
S.InsDrv.DrvEnd .BS 2
*--------------------------------------
* S.BinRelocateYA :
* YA = Ptr to Code
* S.BinRelocate :
* ZPQuickPtr1 = Ptr to Code
* R.AX = Code Length
* R.BX = Range Start address to relocate
* R.CX = Range End address to relocate
* R.DX = offset to apply to all abs addresses between R.BX and R.CX
*--------------------------------------
S.BinRelocateYA >STYA ZPQuickPtr1
ldy #H.BIN.JMP relocate Main JMP
S.BinRelocate ldy #H.BIN.JMP relocate Main JMP
lda (ZPQuickPtr1),y
clc
adc R.DL
adc Rel.Offset
sta (ZPQuickPtr1),y
iny
lda (ZPQuickPtr1),y
adc R.DH
adc Rel.Offset+1
sta (ZPQuickPtr1),y
ldy #H.BIN.RELOC.TABLE skip Header, CS.SIZE & DS.SIZE... (16 bytes)
bra S.JmpRelocate
S.DrvRelocateYA >STYA ZPQuickPtr1
ldy #0
.HS 2C bit abs
S.JmpRelocate lda (ZPQuickPtr1),y Start Relocate JMP table
S.DrvRelocate ldy #0
.1 lda (ZPQuickPtr1),y Start Relocate JMP table
tax
iny
ora (ZPQuickPtr1),y
beq S.CodeRelocate $0000 = end of table
beq .2 $0000 = end of table
dey
txa
clc
adc R.DL
adc Rel.Offset
sta (ZPQuickPtr1),y
iny
lda (ZPQuickPtr1),y
adc R.DH
adc Rel.Offset+1
sta (ZPQuickPtr1),y
iny
bra S.JmpRelocate
bra .1
S.CodeRelocate lda ZPQuickPtr1
.2 lda ZPQuickPtr1
clc
adc R.AL Make ZPQuickPtr2=End of code
adc Rel.CodeLen Make ZPQuickPtr2=End of code
sta ZPQuickPtr2 =ZPQuickPtr1+AX (code len)
lda ZPQuickPtr1+1
adc R.AH
adc Rel.CodeLen+1
sta ZPQuickPtr2+1
iny
@ -271,29 +302,29 @@ S.CodeRelocate lda ZPQuickPtr1
ldy #1
lda (ZPQuickPtr1),y Get LO
sec
sbc R.BL
sbc Rel.Start
iny
lda (ZPQuickPtr1),y Get HI
sbc R.BH
sbc Rel.Start+1
bcc .6 addr < AX, out of range
dey
lda (ZPQuickPtr1),y Get LO
sec
sbc R.CL
sbc Rel.End
iny
lda (ZPQuickPtr1),y Get HI
sbc R.CH
sbc Rel.End+1
bcs .6 addr > CX, out of range
dey
lda (ZPQuickPtr1),y Get LO
clc
adc R.DL add DX to abs address
adc Rel.Offset add DX to abs address
sta (ZPQuickPtr1),y store relocated addr LO
iny
lda (ZPQuickPtr1),y Get HI
adc R.DH
adc Rel.Offset+1
sta (ZPQuickPtr1),y store relocated addr HI
.6 pla
@ -336,6 +367,11 @@ OPCODES .HS 01.02.02.01.02.02.02.02.01.02.01.01.83.83.83.03
.HS 02.02.02.01.02.02.02.02.01.02.01.01.83.83.83.03
.HS 02.02.02.01.02.02.02.02.01.83.01.01.01.83.83.03
*--------------------------------------
Rel.CodeLen .BS 2
Rel.Start .BS 2
Rel.End .BS 2
Rel.Offset .BS 2
*--------------------------------------
MAN
SAVE SYS/KERNEL.S.REL
LOAD SYS/KERNEL.S