2018-04-17 15:25:45 +00:00
|
|
|
|
NEW
|
2019-12-17 12:28:49 +00:00
|
|
|
|
AUTO 3,1
|
2018-04-17 15:25:45 +00:00
|
|
|
|
.LIST OFF
|
|
|
|
|
.OP 65C02
|
|
|
|
|
.OR $2000
|
2019-12-17 12:28:49 +00:00
|
|
|
|
.TF bin/md5
|
2018-04-17 15:25:45 +00:00
|
|
|
|
*--------------------------------------
|
2020-08-17 20:47:31 +00:00
|
|
|
|
.INB inc/macros.i
|
|
|
|
|
.INB inc/a2osx.i
|
|
|
|
|
.INB inc/mli.e.i
|
2018-04-17 15:25:45 +00:00
|
|
|
|
*--------------------------------------
|
2018-04-18 15:18:32 +00:00
|
|
|
|
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
|
2020-01-24 21:53:03 +00:00
|
|
|
|
ZPDataLen .BS 2
|
|
|
|
|
|
|
|
|
|
ArgIndex .BS 1
|
|
|
|
|
Arg .BS 1
|
|
|
|
|
bText .BS 1
|
|
|
|
|
hFile .BS 1
|
|
|
|
|
hDataBuf .BS 1
|
|
|
|
|
hMD5Ctx .BS 1
|
|
|
|
|
|
2019-03-21 16:37:02 +00:00
|
|
|
|
ZS.END .ED
|
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
|
2019-03-21 16:37:02 +00:00
|
|
|
|
.DA #ZS.END-ZS.START ZP
|
2018-04-17 15:25:45 +00:00
|
|
|
|
.DA 0
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
* Relocation Table
|
2019-10-03 06:25:27 +00:00
|
|
|
|
*--------------------------------------
|
2018-04-17 15:25:45 +00:00
|
|
|
|
.1 .DA CS.INIT
|
|
|
|
|
.DA CS.RUN
|
|
|
|
|
.DA CS.DOEVENT
|
|
|
|
|
.DA CS.QUIT
|
|
|
|
|
L.MSG.USAGE .DA MSG.USAGE
|
|
|
|
|
.DA 0
|
|
|
|
|
*--------------------------------------
|
2020-01-24 21:53:03 +00:00
|
|
|
|
CS.INIT clc
|
|
|
|
|
rts
|
2018-11-12 11:04:59 +00:00
|
|
|
|
*--------------------------------------
|
|
|
|
|
CS.RUN ldy #S.PS.ARGC
|
2020-02-28 07:21:46 +00:00
|
|
|
|
lda (pPS),y
|
2018-04-17 15:25:45 +00:00
|
|
|
|
beq .99
|
|
|
|
|
|
2020-01-24 21:53:03 +00:00
|
|
|
|
.1 inc ArgIndex
|
|
|
|
|
lda ArgIndex
|
2018-10-16 15:48:03 +00:00
|
|
|
|
>SYSCALL ArgV
|
2018-04-18 15:18:32 +00:00
|
|
|
|
bcs .8
|
2020-01-24 21:53:03 +00:00
|
|
|
|
|
2018-04-17 15:25:45 +00:00
|
|
|
|
>STYA ZPPtr1
|
|
|
|
|
lda (ZPPtr1)
|
|
|
|
|
cmp #'-'
|
|
|
|
|
bne .4
|
|
|
|
|
ldy #1
|
|
|
|
|
lda (ZPPtr1),y
|
|
|
|
|
beq .99
|
|
|
|
|
|
2021-06-09 22:56:38 +00:00
|
|
|
|
ldy #OptionVars-OptionList-1
|
2019-12-17 12:28:49 +00:00
|
|
|
|
|
2021-06-09 22:56:38 +00:00
|
|
|
|
.2 cmp OptionList,y
|
2018-04-17 15:25:45 +00:00
|
|
|
|
beq .3
|
2021-06-09 22:56:38 +00:00
|
|
|
|
dey
|
2019-12-17 14:32:04 +00:00
|
|
|
|
bpl .2
|
2018-04-17 15:25:45 +00:00
|
|
|
|
|
2020-01-24 21:53:03 +00:00
|
|
|
|
.99 >PUSHW L.MSG.USAGE
|
|
|
|
|
>PUSHBI 0
|
2020-02-28 07:21:46 +00:00
|
|
|
|
>SYSCALL PrintF
|
2018-10-21 20:54:07 +00:00
|
|
|
|
lda #E.SYN
|
2018-04-17 15:25:45 +00:00
|
|
|
|
sec
|
|
|
|
|
rts
|
2019-12-17 12:28:49 +00:00
|
|
|
|
|
2021-06-09 22:56:38 +00:00
|
|
|
|
.3 ldx OptionVars,y
|
|
|
|
|
sec
|
|
|
|
|
ror 0,x
|
2018-04-17 15:25:45 +00:00
|
|
|
|
bra .1
|
2019-12-17 12:28:49 +00:00
|
|
|
|
|
2020-01-24 21:53:03 +00:00
|
|
|
|
.4 lda Arg
|
2018-04-17 15:25:45 +00:00
|
|
|
|
bne .99
|
2020-01-24 21:53:03 +00:00
|
|
|
|
|
|
|
|
|
lda ArgIndex
|
|
|
|
|
sta Arg
|
2018-04-18 15:18:32 +00:00
|
|
|
|
bra .1
|
2020-01-24 21:53:03 +00:00
|
|
|
|
|
|
|
|
|
.8 lda Arg
|
2018-11-12 11:04:59 +00:00
|
|
|
|
beq .99
|
2020-01-24 21:53:03 +00:00
|
|
|
|
|
|
|
|
|
lda bText
|
2018-04-18 15:18:32 +00:00
|
|
|
|
beq CS.RUN.FILE
|
|
|
|
|
*--------------------------------------
|
2020-01-24 21:53:03 +00:00
|
|
|
|
CS.RUN.TEXT lda Arg
|
2018-10-16 15:48:03 +00:00
|
|
|
|
>SYSCALL ArgV
|
2018-04-18 15:18:32 +00:00
|
|
|
|
>PUSHYA
|
2020-01-24 21:53:03 +00:00
|
|
|
|
>PUSHEA.G MD5Buf
|
|
|
|
|
>SYSCALL MD5
|
2018-08-23 15:16:20 +00:00
|
|
|
|
jmp CS.RUN.PRINT
|
2018-04-18 15:18:32 +00:00
|
|
|
|
*--------------------------------------
|
2018-11-08 14:23:06 +00:00
|
|
|
|
CS.RUN.FILE >LDYAI FILEBUF.SIZE
|
2020-02-28 07:21:46 +00:00
|
|
|
|
>SYSCALL GetMem
|
2018-04-18 15:18:32 +00:00
|
|
|
|
bcs .9
|
2020-01-24 21:53:03 +00:00
|
|
|
|
|
2018-04-18 15:18:32 +00:00
|
|
|
|
>STYA ZPDataBufPtr
|
2020-01-24 21:53:03 +00:00
|
|
|
|
stx hDataBuf
|
2020-02-18 06:55:54 +00:00
|
|
|
|
|
2020-01-24 21:53:03 +00:00
|
|
|
|
lda Arg
|
2018-11-08 14:23:06 +00:00
|
|
|
|
>SYSCALL ArgV
|
2020-02-18 06:55:54 +00:00
|
|
|
|
>PUSHYA
|
|
|
|
|
>PUSHBI O.RDONLY
|
|
|
|
|
>PUSHBI 0 ftype
|
|
|
|
|
>PUSHWZ Aux type
|
2018-04-18 15:18:32 +00:00
|
|
|
|
>SYSCALL FOpen
|
|
|
|
|
bcs .9
|
2020-01-24 21:53:03 +00:00
|
|
|
|
|
|
|
|
|
sta hFile
|
|
|
|
|
|
|
|
|
|
>SYSCALL MD5Init
|
2018-04-18 15:18:32 +00:00
|
|
|
|
bcs .9
|
2020-01-24 21:53:03 +00:00
|
|
|
|
|
|
|
|
|
sta hMD5Ctx
|
|
|
|
|
|
2020-12-02 15:22:57 +00:00
|
|
|
|
.1 >SLEEP
|
|
|
|
|
|
2021-05-14 20:58:20 +00:00
|
|
|
|
>PUSHB hFile
|
2018-07-25 15:26:14 +00:00
|
|
|
|
>PUSHW ZPDataBufPtr Dst Ptr
|
2021-05-14 20:58:20 +00:00
|
|
|
|
>PUSHWI FILEBUF.SIZE Bytes To Read
|
2018-04-18 15:18:32 +00:00
|
|
|
|
>SYSCALL FRead
|
|
|
|
|
bcc .2
|
2020-01-24 21:53:03 +00:00
|
|
|
|
|
2020-12-02 15:22:57 +00:00
|
|
|
|
cmp #MLI.E.EOF
|
2018-04-18 15:18:32 +00:00
|
|
|
|
beq .8
|
2020-01-24 21:53:03 +00:00
|
|
|
|
|
2018-04-18 15:18:32 +00:00
|
|
|
|
.9 rts
|
2020-01-24 21:53:03 +00:00
|
|
|
|
|
|
|
|
|
.2 >STYA ZPDataLen
|
|
|
|
|
|
2020-12-02 15:22:57 +00:00
|
|
|
|
>SLEEP
|
|
|
|
|
|
2020-01-24 21:53:03 +00:00
|
|
|
|
>PUSHB hMD5Ctx
|
2018-04-18 15:18:32 +00:00
|
|
|
|
>PUSHW ZPDataBufPtr
|
2020-01-24 21:53:03 +00:00
|
|
|
|
>PUSHW ZPDataLen
|
|
|
|
|
>SYSCALL MD5Update
|
2018-04-18 15:18:32 +00:00
|
|
|
|
bra .1
|
2020-01-24 21:53:03 +00:00
|
|
|
|
|
|
|
|
|
.8 >PUSHB hMD5Ctx
|
|
|
|
|
>PUSHEA.G MD5Buf
|
|
|
|
|
>SYSCALL MD5Finalize
|
|
|
|
|
|
2018-08-23 15:16:20 +00:00
|
|
|
|
CS.RUN.PRINT >LEA.G MD5Buf
|
2020-02-28 07:21:46 +00:00
|
|
|
|
>SYSCALL PutS
|
2018-04-18 15:18:32 +00:00
|
|
|
|
lda #0
|
2018-08-24 10:20:23 +00:00
|
|
|
|
* sec
|
|
|
|
|
* rts
|
2018-04-17 15:25:45 +00:00
|
|
|
|
*--------------------------------------
|
|
|
|
|
CS.DOEVENT sec
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
2020-01-24 21:53:03 +00:00
|
|
|
|
CS.QUIT lda hDataBuf
|
2018-11-08 14:23:06 +00:00
|
|
|
|
beq .2
|
2020-01-24 21:53:03 +00:00
|
|
|
|
|
2018-11-08 14:23:06 +00:00
|
|
|
|
>SYSCALL FreeMem
|
2020-01-24 21:53:03 +00:00
|
|
|
|
.2 lda hFile
|
2018-04-18 15:18:32 +00:00
|
|
|
|
beq .3
|
|
|
|
|
|
2020-02-28 07:21:46 +00:00
|
|
|
|
>SYSCALL FClose
|
2018-08-24 10:20:23 +00:00
|
|
|
|
|
2020-01-24 21:53:03 +00:00
|
|
|
|
.3 clc
|
2018-04-17 15:25:45 +00:00
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
CS.END
|
|
|
|
|
*--------------------------------------
|
2021-06-09 22:56:38 +00:00
|
|
|
|
OptionList .AS "Dd"
|
2018-04-17 15:25:45 +00:00
|
|
|
|
OptionVars .DA #bText,#bText
|
|
|
|
|
*--------------------------------------
|
2023-06-02 20:31:09 +00:00
|
|
|
|
MSG.USAGE .CZ "Usage : MD5 [ -d input text | input file ]\r\n"
|
2018-04-17 15:25:45 +00:00
|
|
|
|
*--------------------------------------
|
|
|
|
|
.DUMMY
|
|
|
|
|
.OR 0
|
|
|
|
|
DS.START
|
2018-04-18 15:18:32 +00:00
|
|
|
|
MD5Buf .BS 33
|
2018-04-17 15:25:45 +00:00
|
|
|
|
DS.END .ED
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
MAN
|
2020-08-17 20:47:31 +00:00
|
|
|
|
SAVE usr/src/bin/md5.s
|
2018-04-17 15:25:45 +00:00
|
|
|
|
ASM
|