A2osX/BIN/MD5.S.txt

183 lines
3.7 KiB
Plaintext
Raw Normal View History

NEW
2018-11-17 17:17:13 +00:00
PREFIX
AUTO 4,1
.LIST OFF
.OP 65C02
.OR $2000
2018-07-23 15:28:42 +00:00
.TF BIN/MD5
*--------------------------------------
2018-07-23 15:28:42 +00:00
.INB INC/MACROS.I
.INB INC/A2OSX.I
2018-10-02 15:52:30 +00:00
.INB INC/MLI.E.I
2018-07-23 15:28:42 +00:00
.INB INC/LIBCRYPT.I
*--------------------------------------
FILEBUF.SIZE .EQ 4096
*--------------------------------------
2019-03-21 16:37:02 +00:00
.DUMMY
.OR ZPBIN
2019-10-03 06:25:27 +00:00
ZS.START
2019-03-21 16:37:02 +00:00
ZPPtr1 .BS 2
ZPDataBufPtr .BS 2
ZS.END .ED
*--------------------------------------
* 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
2019-03-21 16:37:02 +00:00
.DA #ZS.END-ZS.START ZP
.DA 0
*--------------------------------------
* Relocation Table
2019-10-03 06:25:27 +00:00
*--------------------------------------
.1 .DA CS.INIT
.DA CS.RUN
.DA CS.DOEVENT
.DA CS.QUIT
L.LIBCRYPT .DA LIBCRYPT
L.MSG.USAGE .DA MSG.USAGE
.DA 0
*--------------------------------------
2018-11-12 11:04:59 +00:00
CS.INIT >LDYA L.LIBCRYPT
>SYSCALL LoadLib
bcs .9
sta hLIBCRYPT
.9 rts
*--------------------------------------
CS.RUN ldy #S.PS.ARGC
lda (pPs),y
beq .99
.1 >INC.G ArgIndex
2018-10-16 15:48:03 +00:00
>SYSCALL ArgV
bcs .8
>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
2018-08-23 15:16:20 +00:00
.99 >PUSHBI 0
>LDYA L.MSG.USAGE
2018-06-21 15:12:10 +00:00
>SYSCALL printf
2018-10-21 20:54:07 +00:00
lda #E.SYN
sec
rts
.3 ldy OptionVars-1,x
lda #$80
sta (pData),y
bra .1
.4 >LDA.G Arg
bne .99
>LDA.G ArgIndex
>STA.G Arg
bra .1
2018-11-12 11:04:59 +00:00
.8 >LDA.G Arg
beq .99
>LDA.G bText
beq CS.RUN.FILE
*--------------------------------------
2018-11-12 11:04:59 +00:00
CS.RUN.TEXT >PUSHEA.G MD5Buf
>LDA.G Arg
2018-10-16 15:48:03 +00:00
>SYSCALL ArgV
>PUSHYA
>LIBCALL hLIBCRYPT,LIBCRYPT.MD5
2018-08-23 15:16:20 +00:00
jmp CS.RUN.PRINT
*--------------------------------------
2018-11-08 14:23:06 +00:00
CS.RUN.FILE >LDYAI FILEBUF.SIZE
2018-07-20 11:51:08 +00:00
>SYSCALL getmem
bcs .9
>STYA ZPDataBufPtr
txa
>STA.G hDataBuf
2019-06-07 15:02:51 +00:00
>PUSHWZ Aux type
2018-11-12 11:04:59 +00:00
>PUSHBI 0 ftype
2018-10-02 15:52:30 +00:00
>PUSHBI O.RDONLY
2018-11-08 14:23:06 +00:00
>LDA.G Arg
>SYSCALL ArgV
>SYSCALL FOpen
bcs .9
>STA.G hFile
>LIBCALL hLIBCRYPT,LIBCRYPT.MD5Init
bcs .9
>STA.G hMD5Ctx
2018-07-25 15:26:14 +00:00
.1 >PUSHWI FILEBUF.SIZE Bytes To Read
>PUSHW ZPDataBufPtr Dst Ptr
2018-07-24 16:00:24 +00:00
>LDA.G hFile
>SYSCALL FRead
bcc .2
eor #MLI.E.EOF
beq .8
.9 rts
.2 >PUSHYA MD5 DataLen
>PUSHW ZPDataBufPtr
2018-11-12 11:04:59 +00:00
>LDA.G hMD5Ctx
>LIBCALL hLIBCRYPT,LIBCRYPT.MD5Update
bra .1
.8 >PUSHEA.G MD5Buf
2018-11-12 11:04:59 +00:00
>LDA.G hMD5Ctx
>LIBCALL hLIBCRYPT,LIBCRYPT.MD5Finalize
2018-08-23 15:16:20 +00:00
CS.RUN.PRINT >LEA.G MD5Buf
2018-12-05 15:12:10 +00:00
>SYSCALL strlwr
2018-08-23 15:16:20 +00:00
>SYSCALL puts
lda #0
2018-08-24 10:20:23 +00:00
* sec
* rts
*--------------------------------------
CS.DOEVENT sec
rts
*--------------------------------------
2018-11-08 14:23:06 +00:00
CS.QUIT >LDA.G hDataBuf
beq .2
>SYSCALL FreeMem
.2 >LDA.G hFile
beq .3
2018-07-20 11:51:08 +00:00
>SYSCALL fclose
2018-08-24 10:20:23 +00:00
.3 lda hLIBCRYPT
beq .4
2018-07-20 14:10:10 +00:00
>SYSCALL UnloadLib
2018-08-24 10:20:23 +00:00
.4 clc
rts
*--------------------------------------
CS.END
*--------------------------------------
OptionList >PSTR "Dd"
OptionVars .DA #bText,#bText
*--------------------------------------
MSG.USAGE .AZ "Usage : MD5 [ -d input text | input file ]\r\n"
*--------------------------------------
2019-12-10 16:06:51 +00:00
LIBCRYPT .AZ "libcrypt"
hLIBCRYPT .BS 1
*--------------------------------------
.DUMMY
.OR 0
DS.START
ArgIndex .BS 1
Arg .BS 1
bText .BS 1
hFile .BS 1
hDataBuf .BS 1
hMD5Ctx .BS 1
MD5Buf .BS 33
DS.END .ED
*--------------------------------------
MAN
2019-02-05 21:50:17 +00:00
SAVE USR/SRC/BIN/MD5.S
ASM