2018-04-17 15:25:45 +00:00
|
|
|
|
NEW
|
|
|
|
|
PREFIX /A2OSX.BUILD
|
|
|
|
|
AUTO 4,1
|
|
|
|
|
.LIST OFF
|
|
|
|
|
.OP 65C02
|
|
|
|
|
.OR $2000
|
|
|
|
|
.TF /A2OSX.BUILD/BIN/MD5
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
.INB /A2OSX.BUILD/INC/MACROS.I
|
|
|
|
|
.INB /A2OSX.BUILD/INC/A2OSX.I
|
2018-04-18 15:18:32 +00:00
|
|
|
|
.INB /A2OSX.BUILD/INC/MLI.ERR.I
|
2018-04-17 15:25:45 +00:00
|
|
|
|
.INB /A2OSX.BUILD/INC/LIBCRYPT.I
|
|
|
|
|
*--------------------------------------
|
2018-04-18 15:18:32 +00:00
|
|
|
|
FILEBUF.SIZE .EQ 4096
|
|
|
|
|
*--------------------------------------
|
2018-04-17 15:25:45 +00:00
|
|
|
|
ZPPtr1 .EQ ZPBIN
|
2018-04-18 15:18:32 +00:00
|
|
|
|
ZPDataBufPtr .EQ ZPBIN+2
|
2018-04-17 15:25:45 +00:00
|
|
|
|
*--------------------------------------
|
|
|
|
|
* File Header (16 Bytes)
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
CS.START cld
|
|
|
|
|
jmp (.1,x)
|
|
|
|
|
.DA #$61 6502,Level 1 (65c02)
|
|
|
|
|
.DA #1 BIN Layout Version 1
|
|
|
|
|
.DA 0
|
|
|
|
|
.DA CS.END-CS.START CS
|
|
|
|
|
.DA DS.END-DS.START DS
|
|
|
|
|
.DA #16 SS
|
|
|
|
|
.DA #4 ZP
|
|
|
|
|
.DA 0
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
* Relocation Table
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
.1 .DA CS.INIT
|
|
|
|
|
.DA CS.RUN
|
|
|
|
|
.DA CS.DOEVENT
|
|
|
|
|
.DA CS.QUIT
|
|
|
|
|
L.LIBCRYPT .DA LIBCRYPT
|
|
|
|
|
L.MSG.USAGE .DA MSG.USAGE
|
|
|
|
|
L.MSG.INIT .DA MSG.INIT
|
|
|
|
|
L.MSG.OK .DA MSG.OK
|
|
|
|
|
L.MSG.ERR .DA MSG.ERR
|
|
|
|
|
.DA 0
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
CS.INIT ldy #S.PS.ARGC
|
|
|
|
|
lda (pPs),y
|
|
|
|
|
beq .99
|
|
|
|
|
|
|
|
|
|
.1 >INC.G ArgIndex
|
|
|
|
|
|
|
|
|
|
>SYSCALL GetArg.A
|
2018-04-18 15:18:32 +00:00
|
|
|
|
bcs .8
|
2018-04-17 15:25:45 +00:00
|
|
|
|
|
|
|
|
|
>STYA ZPPtr1
|
|
|
|
|
|
|
|
|
|
lda (ZPPtr1)
|
|
|
|
|
cmp #'-'
|
|
|
|
|
bne .4
|
|
|
|
|
|
|
|
|
|
ldy #1
|
|
|
|
|
lda (ZPPtr1),y
|
|
|
|
|
beq .99
|
|
|
|
|
|
|
|
|
|
ldx OptionList
|
|
|
|
|
|
|
|
|
|
.2 cmp OptionList,x
|
|
|
|
|
beq .3
|
|
|
|
|
dex
|
|
|
|
|
bne .2
|
|
|
|
|
|
|
|
|
|
.99 >LDYA L.MSG.USAGE
|
2018-06-21 15:12:10 +00:00
|
|
|
|
>SYSCALL printf
|
2018-04-17 15:25:45 +00:00
|
|
|
|
lda #K.E.SYN
|
|
|
|
|
sec
|
|
|
|
|
rts
|
|
|
|
|
|
|
|
|
|
.3 ldy OptionVars-1,x
|
|
|
|
|
lda #$80
|
|
|
|
|
sta (pData),y
|
|
|
|
|
bra .1
|
|
|
|
|
|
2018-04-18 15:18:32 +00:00
|
|
|
|
.4 >LDA.G Arg
|
2018-04-17 15:25:45 +00:00
|
|
|
|
bne .99
|
2018-04-18 15:18:32 +00:00
|
|
|
|
|
|
|
|
|
>LDA.G ArgIndex
|
|
|
|
|
>STA.G Arg
|
|
|
|
|
bra .1
|
|
|
|
|
|
2018-04-17 15:25:45 +00:00
|
|
|
|
.8 >LDYA L.LIBCRYPT
|
|
|
|
|
>SYSCALL LoadLib.YA
|
2018-04-18 15:18:32 +00:00
|
|
|
|
bcs .9
|
|
|
|
|
|
2018-04-17 15:25:45 +00:00
|
|
|
|
sta hLIBCRYPT
|
|
|
|
|
|
|
|
|
|
* lda (pPs)
|
|
|
|
|
* ora #S.PS.F.EVENT Now accept events
|
|
|
|
|
* sta (pPs)
|
|
|
|
|
|
|
|
|
|
clc
|
2018-04-18 15:18:32 +00:00
|
|
|
|
.9 rts
|
2018-04-17 15:25:45 +00:00
|
|
|
|
*--------------------------------------
|
2018-04-18 15:18:32 +00:00
|
|
|
|
CS.RUN >LDA.G bText
|
|
|
|
|
beq CS.RUN.FILE
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
CS.RUN.TEXT >LDA.G Arg
|
|
|
|
|
>SYSCALL GetArg.A
|
|
|
|
|
>PUSHYA
|
|
|
|
|
>PUSHEA.G MD5Buf
|
2018-04-17 15:25:45 +00:00
|
|
|
|
|
2018-04-18 15:18:32 +00:00
|
|
|
|
>LIBCALL hLIBCRYPT,LIBCRYPT.MD5
|
|
|
|
|
bcs .9
|
|
|
|
|
|
|
|
|
|
>LEA.G MD5Buf
|
2018-06-21 15:12:10 +00:00
|
|
|
|
>SYSCALL printf
|
2018-04-18 15:18:32 +00:00
|
|
|
|
|
|
|
|
|
lda #13
|
|
|
|
|
>SYSCALL PutChar.A
|
|
|
|
|
lda #10
|
|
|
|
|
>SYSCALL PutChar.A
|
|
|
|
|
|
2018-04-17 15:25:45 +00:00
|
|
|
|
lda #0
|
|
|
|
|
sec
|
2018-04-18 15:18:32 +00:00
|
|
|
|
.9 rts
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
CS.RUN.FILE >LDA.G Arg
|
|
|
|
|
>SYSCALL GetArg.A
|
|
|
|
|
>SYSCALL RealPath.YA
|
|
|
|
|
bcc .10
|
2018-04-17 15:25:45 +00:00
|
|
|
|
rts
|
|
|
|
|
|
2018-04-18 15:18:32 +00:00
|
|
|
|
.10 txa
|
|
|
|
|
>STA.G hFullPath
|
|
|
|
|
|
|
|
|
|
>LDYAI FILEBUF.SIZE
|
|
|
|
|
>SYSCALL GetMem.YA
|
|
|
|
|
bcs .9
|
|
|
|
|
>STYA ZPDataBufPtr
|
|
|
|
|
txa
|
|
|
|
|
>STA.G hDataBuf
|
|
|
|
|
|
|
|
|
|
>PUSHWI 0 Aux type
|
|
|
|
|
>PUSHBI 0
|
|
|
|
|
>PUSHBI SYS.FOpen.R
|
|
|
|
|
|
|
|
|
|
>LDA.G hFullPath
|
|
|
|
|
>SYSCALL GetMemPtr.A
|
|
|
|
|
|
|
|
|
|
>PUSHYA
|
|
|
|
|
|
|
|
|
|
>SYSCALL FOpen
|
|
|
|
|
bcs .9
|
|
|
|
|
>STA.G hFile
|
|
|
|
|
|
|
|
|
|
>LIBCALL hLIBCRYPT,LIBCRYPT.MD5Init
|
|
|
|
|
bcs .9
|
|
|
|
|
|
|
|
|
|
>STA.G hMD5Ctx
|
|
|
|
|
|
|
|
|
|
.1 >PUSHW ZPDataBufPtr Dst Ptr
|
|
|
|
|
>PUSHWI FILEBUF.SIZE Bytes To Read
|
|
|
|
|
>PUSHB.G hFile
|
|
|
|
|
>SYSCALL FRead
|
|
|
|
|
|
|
|
|
|
bcc .2
|
|
|
|
|
eor #MLI.E.EOF
|
|
|
|
|
beq .8
|
|
|
|
|
.9 rts
|
|
|
|
|
|
|
|
|
|
.2 >PUSHYA MD5 DataLen
|
|
|
|
|
>PUSHW ZPDataBufPtr
|
|
|
|
|
>PUSHB.G hMD5Ctx
|
|
|
|
|
>LIBCALL hLIBCRYPT,LIBCRYPT.MD5Update
|
|
|
|
|
bra .1
|
|
|
|
|
|
|
|
|
|
.8 >PUSHEA.G MD5Buf
|
|
|
|
|
>PUSHB.G hMD5Ctx
|
|
|
|
|
>LIBCALL hLIBCRYPT,LIBCRYPT.MD5Finalize
|
|
|
|
|
|
|
|
|
|
>LEA.G MD5Buf
|
2018-06-21 15:12:10 +00:00
|
|
|
|
>SYSCALL printf
|
2018-04-18 15:18:32 +00:00
|
|
|
|
|
|
|
|
|
lda #13
|
|
|
|
|
>SYSCALL PutChar.A
|
|
|
|
|
lda #10
|
|
|
|
|
>SYSCALL PutChar.A
|
|
|
|
|
|
|
|
|
|
lda #0
|
2018-04-17 15:25:45 +00:00
|
|
|
|
sec
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
CS.DOEVENT sec
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
2018-04-18 15:18:32 +00:00
|
|
|
|
CS.QUIT >LDA.G hFullPath
|
2018-04-17 15:25:45 +00:00
|
|
|
|
beq .1
|
2018-04-18 15:18:32 +00:00
|
|
|
|
|
2018-04-17 15:25:45 +00:00
|
|
|
|
>SYSCALL FreeMem.A
|
2018-04-18 15:18:32 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
.1 >LDA.G hDataBuf
|
|
|
|
|
beq .2
|
|
|
|
|
>SYSCALL FreeMem.A
|
|
|
|
|
|
|
|
|
|
.2 >LDA.G hFile
|
|
|
|
|
beq .3
|
|
|
|
|
|
|
|
|
|
>SYSCALL FClose.A
|
|
|
|
|
.3
|
2018-04-17 15:25:45 +00:00
|
|
|
|
|
2018-04-18 15:18:32 +00:00
|
|
|
|
.7 lda hLIBCRYPT
|
2018-04-17 15:25:45 +00:00
|
|
|
|
beq .8
|
|
|
|
|
|
|
|
|
|
>SYSCALL UnloadLib.A
|
|
|
|
|
|
|
|
|
|
.8 clc
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
A2CharAX pha
|
|
|
|
|
lsr
|
|
|
|
|
lsr
|
|
|
|
|
lsr
|
|
|
|
|
lsr
|
|
|
|
|
and #$0F
|
|
|
|
|
cmp #'9'+1
|
|
|
|
|
bcc .1
|
|
|
|
|
adc #6
|
|
|
|
|
.1 tax
|
|
|
|
|
pla
|
|
|
|
|
and #$0F
|
|
|
|
|
ora #$30
|
|
|
|
|
cmp #'9'+1
|
|
|
|
|
bcc .8
|
|
|
|
|
adc #6
|
|
|
|
|
.8 rts
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
CS.END
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
OptionList >PSTR "Dd"
|
|
|
|
|
OptionVars .DA #bText,#bText
|
|
|
|
|
*--------------------------------------
|
2018-04-18 15:18:32 +00:00
|
|
|
|
MSG.USAGE .AZ "Usage : MD5 [ -d input text | input file ]\r\n"
|
2018-04-17 15:25:45 +00:00
|
|
|
|
MSG.OK .AZ "[OK]\r\n"
|
|
|
|
|
MSG.ERR .AZ "[%h]\r\n"
|
|
|
|
|
MSG.INIT .AZ "Computing %s ..."
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
LIBCRYPT .AZ "libcrypt.o"
|
|
|
|
|
hLIBCRYPT .BS 1
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
.DUMMY
|
|
|
|
|
.OR 0
|
|
|
|
|
DS.START
|
|
|
|
|
ArgIndex .BS 1
|
2018-04-18 15:18:32 +00:00
|
|
|
|
Arg .BS 1
|
2018-04-17 15:25:45 +00:00
|
|
|
|
bText .BS 1
|
|
|
|
|
hFullPath .BS 1
|
2018-04-18 15:18:32 +00:00
|
|
|
|
hFile .BS 1
|
2018-04-17 15:25:45 +00:00
|
|
|
|
hDataBuf .BS 1
|
2018-04-18 15:18:32 +00:00
|
|
|
|
hMD5Ctx .BS 1
|
|
|
|
|
MD5Buf .BS 33
|
2018-04-17 15:25:45 +00:00
|
|
|
|
DS.END .ED
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
MAN
|
|
|
|
|
SAVE /A2OSX.SRC/BIN/MD5.S
|
|
|
|
|
ASM
|