A2osX/BIN/MD5.S.txt

198 lines
3.5 KiB
Plaintext
Raw Normal View History

NEW
2019-12-17 12:28:49 +00:00
AUTO 3,1
.LIST OFF
.OP 65C02
.OR $2000
2019-12-17 12:28:49 +00:00
.TF bin/md5
*--------------------------------------
2020-08-17 20:47:31 +00:00
.INB inc/macros.i
.INB inc/a2osx.i
.INB inc/mli.e.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
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
*--------------------------------------
* 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.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
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
bcs .8
2020-01-24 21:53:03 +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
beq .3
2021-06-09 22:56:38 +00:00
dey
2019-12-17 14:32:04 +00:00
bpl .2
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
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
bra .1
2019-12-17 12:28:49 +00:00
2020-01-24 21:53:03 +00:00
.4 lda Arg
bne .99
2020-01-24 21:53:03 +00:00
lda ArgIndex
sta Arg
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
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
>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-11-08 14:23:06 +00:00
CS.RUN.FILE >LDYAI FILEBUF.SIZE
2020-02-28 07:21:46 +00:00
>SYSCALL GetMem
bcs .9
2020-01-24 21:53:03 +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
>SYSCALL FOpen
bcs .9
2020-01-24 21:53:03 +00:00
sta hFile
>SYSCALL MD5Init
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
>SYSCALL FRead
bcc .2
2020-01-24 21:53:03 +00:00
2020-12-02 15:22:57 +00:00
cmp #MLI.E.EOF
beq .8
2020-01-24 21:53:03 +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
>PUSHW ZPDataBufPtr
2020-01-24 21:53:03 +00:00
>PUSHW ZPDataLen
>SYSCALL MD5Update
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
lda #0
2018-08-24 10:20:23 +00:00
* sec
* rts
*--------------------------------------
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
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
rts
*--------------------------------------
CS.END
*--------------------------------------
2021-06-09 22:56:38 +00:00
OptionList .AS "Dd"
OptionVars .DA #bText,#bText
*--------------------------------------
MSG.USAGE .AZ "Usage : MD5 [ -d input text | input file ]\r\n"
*--------------------------------------
.DUMMY
.OR 0
DS.START
MD5Buf .BS 33
DS.END .ED
*--------------------------------------
MAN
2020-08-17 20:47:31 +00:00
SAVE usr/src/bin/md5.s
ASM