2016-09-13 01:52:46 +00:00
|
|
|
!to "shasum.o", plain
|
|
|
|
* = $6000
|
2016-09-19 03:19:26 +00:00
|
|
|
jmp main
|
2016-09-13 01:52:46 +00:00
|
|
|
|
|
|
|
;; clear addresses:
|
|
|
|
;; (http://apple2.org.za/gswv/a2zine/faqs/csa2pfaq.html#017)
|
|
|
|
;; 06-09
|
|
|
|
;; EB-EF
|
|
|
|
;; FA-FD
|
2016-09-29 02:43:49 +00:00
|
|
|
|
2016-09-19 03:19:26 +00:00
|
|
|
!addr SRC = $06
|
2016-09-24 03:16:49 +00:00
|
|
|
!addr DST = $08
|
2016-09-19 03:19:26 +00:00
|
|
|
!addr INPUT = $eb
|
|
|
|
!addr LENGTH = $ee
|
2016-09-24 03:16:49 +00:00
|
|
|
!addr TMP1 = $fa
|
|
|
|
!addr TMP2 = $fb
|
2016-09-19 03:19:26 +00:00
|
|
|
|
|
|
|
!addr PRBYTE = $FDDA
|
|
|
|
!addr COUT = $FDED
|
2016-09-29 02:43:49 +00:00
|
|
|
|
2016-09-13 01:52:46 +00:00
|
|
|
h0: !32 0 ; return value (hash)
|
|
|
|
h1: !32 0
|
|
|
|
h2: !32 0
|
|
|
|
h3: !32 0
|
|
|
|
h4: !32 0
|
2016-09-29 02:43:49 +00:00
|
|
|
h5:
|
2016-09-22 01:58:40 +00:00
|
|
|
ml: !32 0, 0 ; message length
|
2016-09-13 01:52:46 +00:00
|
|
|
w: !fill 64, 0
|
|
|
|
w_next: !fill 64, 0
|
2016-09-28 02:09:04 +00:00
|
|
|
a: !32 0
|
|
|
|
b: !32 0
|
|
|
|
c: !32 0
|
|
|
|
d: !32 0
|
|
|
|
e: !32 0
|
|
|
|
f: !32 0
|
|
|
|
temp: !32 0
|
2016-09-24 03:16:49 +00:00
|
|
|
k: !32 0
|
2016-09-13 01:52:46 +00:00
|
|
|
kh0: !be32 $67452301 ; initial values for h0..h4
|
|
|
|
kh1: !be32 $EFCDAB89
|
|
|
|
kh2: !be32 $98BADCFE
|
|
|
|
kh3: !be32 $10325476
|
|
|
|
kh4: !be32 $C3D2E1F0
|
2016-10-11 00:54:50 +00:00
|
|
|
k1 = $5A827999 ; k constants
|
|
|
|
k2 = $6ED9EBA1
|
|
|
|
k3 = $8F1BBCDC
|
|
|
|
k4 = $CA62C1D6
|
2016-09-19 03:19:26 +00:00
|
|
|
|
2016-10-11 00:54:50 +00:00
|
|
|
!macro set32 .target, .value {
|
|
|
|
lda #<(.value >> 24)
|
2016-09-24 03:16:49 +00:00
|
|
|
sta .target
|
2016-10-11 00:54:50 +00:00
|
|
|
lda #<(.value >> 16)
|
2016-09-24 03:16:49 +00:00
|
|
|
sta .target+1
|
2016-10-11 00:54:50 +00:00
|
|
|
lda #<(.value >> 8)
|
2016-09-24 03:16:49 +00:00
|
|
|
sta .target+2
|
2016-10-11 00:54:50 +00:00
|
|
|
lda #<(.value)
|
2016-09-24 03:16:49 +00:00
|
|
|
sta .target+3
|
|
|
|
}
|
|
|
|
|
|
|
|
!macro setSRC .source {
|
|
|
|
lda #<.source
|
|
|
|
sta SRC
|
|
|
|
lda #>.source
|
|
|
|
sta SRC+1
|
|
|
|
}
|
|
|
|
!macro setDST .dest {
|
|
|
|
lda #<.dest
|
|
|
|
sta DST
|
|
|
|
lda #>.dest
|
|
|
|
sta DST+1
|
|
|
|
}
|
|
|
|
|
2016-09-19 03:19:26 +00:00
|
|
|
;;; Print a string of bytes, as hex.
|
|
|
|
;;; Address in SRC, count in A.
|
2016-09-24 03:16:49 +00:00
|
|
|
;;; Burns A,Y.
|
2016-09-19 03:19:26 +00:00
|
|
|
prbytes:
|
|
|
|
ldy #0
|
|
|
|
- pha
|
|
|
|
lda (SRC),y
|
|
|
|
jsr PRBYTE
|
|
|
|
iny
|
|
|
|
pla
|
|
|
|
adc #$ff
|
|
|
|
bne -
|
2016-09-13 01:52:46 +00:00
|
|
|
rts
|
2016-09-29 02:43:49 +00:00
|
|
|
|
2016-09-19 03:19:26 +00:00
|
|
|
main:
|
2016-09-29 02:43:49 +00:00
|
|
|
;; Test shasum ""
|
2016-09-19 03:19:26 +00:00
|
|
|
lda #0
|
|
|
|
sta INPUT
|
2016-10-11 00:54:50 +00:00
|
|
|
lda #$fe
|
2016-09-19 03:19:26 +00:00
|
|
|
sta INPUT+1
|
|
|
|
lda #0
|
|
|
|
sta LENGTH+1
|
2016-09-28 02:09:04 +00:00
|
|
|
lda #0 ; da39a3ee5e6b4b0d3255bfef95601890afd80709
|
2016-09-19 03:19:26 +00:00
|
|
|
sta LENGTH
|
|
|
|
jsr shasum
|
2016-09-28 02:09:04 +00:00
|
|
|
|
2016-09-29 02:43:49 +00:00
|
|
|
; lda #$8d
|
|
|
|
; jsr COUT
|
|
|
|
|
|
|
|
+setSRC h0
|
|
|
|
lda #(h5-h0)
|
|
|
|
jsr prbytes
|
|
|
|
|
2016-10-11 00:54:50 +00:00
|
|
|
;; Test shasum FE00[:0x37]
|
2016-09-29 02:43:49 +00:00
|
|
|
lda #0
|
|
|
|
sta INPUT
|
2016-10-11 00:54:50 +00:00
|
|
|
lda #$fe
|
2016-09-29 02:43:49 +00:00
|
|
|
sta INPUT+1
|
|
|
|
lda #0
|
|
|
|
sta LENGTH+1
|
2016-10-11 00:54:50 +00:00
|
|
|
lda #$37 ; 1CF73FC6156B548A949D315120B5256245EAA33E
|
2016-09-29 02:43:49 +00:00
|
|
|
sta LENGTH
|
|
|
|
jsr shasum
|
|
|
|
|
|
|
|
; lda #$8d
|
|
|
|
; jsr COUT
|
2016-09-28 02:09:04 +00:00
|
|
|
|
|
|
|
+setSRC h0
|
|
|
|
lda #(h5-h0)
|
|
|
|
jsr prbytes
|
2016-09-29 02:43:49 +00:00
|
|
|
|
2016-10-11 00:54:50 +00:00
|
|
|
;; Test shasum FE00[:0x100]
|
2016-09-29 02:43:49 +00:00
|
|
|
lda #0
|
|
|
|
sta INPUT
|
2016-10-11 00:54:50 +00:00
|
|
|
lda #$fe
|
2016-09-29 02:43:49 +00:00
|
|
|
sta INPUT+1
|
|
|
|
lda #1
|
|
|
|
sta LENGTH+1
|
2016-10-11 00:54:50 +00:00
|
|
|
lda #0 ; 7B3D05347B52210065E27054FDFD0B8B699F0965
|
|
|
|
sta LENGTH
|
|
|
|
jsr shasum
|
|
|
|
|
|
|
|
; lda #$8d
|
|
|
|
; jsr COUT
|
|
|
|
|
|
|
|
+setSRC h0
|
|
|
|
lda #(h5-h0)
|
|
|
|
jsr prbytes
|
|
|
|
|
|
|
|
;; Test shasum FE00[:0x1ff]
|
|
|
|
lda #0
|
|
|
|
sta INPUT
|
|
|
|
lda #$fe
|
|
|
|
sta INPUT+1
|
|
|
|
lda #$1
|
|
|
|
sta LENGTH+1
|
|
|
|
lda #$ff ; 269CA6B0C644DAC01D908B20C10C0D5B19C52ABF
|
|
|
|
sta LENGTH
|
|
|
|
jsr shasum
|
|
|
|
|
|
|
|
; lda #$8d
|
|
|
|
; jsr COUT
|
|
|
|
|
|
|
|
+setSRC h0
|
|
|
|
lda #(h5-h0)
|
|
|
|
jsr prbytes
|
|
|
|
|
|
|
|
;; Test shasum FE00[:0x200]
|
|
|
|
lda #0
|
|
|
|
sta INPUT
|
|
|
|
lda #$fe
|
|
|
|
sta INPUT+1
|
|
|
|
lda #2
|
|
|
|
sta LENGTH+1
|
|
|
|
lda #0 ; D5AC71D5EE76E31CC82CF5136151BF4CDA503601
|
2016-09-29 02:43:49 +00:00
|
|
|
sta LENGTH
|
|
|
|
jsr shasum
|
2016-09-28 02:09:04 +00:00
|
|
|
|
2016-09-29 02:43:49 +00:00
|
|
|
; lda #$8d
|
|
|
|
; jsr COUT
|
|
|
|
|
|
|
|
+setSRC h0
|
|
|
|
lda #(h5-h0)
|
|
|
|
jsr prbytes
|
|
|
|
|
2016-09-19 03:19:26 +00:00
|
|
|
rts
|
|
|
|
|
|
|
|
shasum:
|
|
|
|
;; Initialize h0..h4
|
2016-09-28 02:09:04 +00:00
|
|
|
ldy #(h5-h0-1)
|
2016-09-19 03:19:26 +00:00
|
|
|
- lda kh0,y
|
|
|
|
sta h0,y
|
|
|
|
dey
|
|
|
|
bpl -
|
|
|
|
;; Initialize message length (ml)
|
|
|
|
lda #0
|
2016-09-22 01:58:40 +00:00
|
|
|
ldy #4
|
|
|
|
- sta ml, y
|
|
|
|
dey
|
|
|
|
bpl -
|
2016-09-19 03:19:26 +00:00
|
|
|
lda LENGTH
|
2016-09-22 01:58:40 +00:00
|
|
|
sta ml+7
|
2016-09-19 03:19:26 +00:00
|
|
|
lda LENGTH+1
|
2016-09-22 01:58:40 +00:00
|
|
|
sta ml+6
|
2016-09-19 03:19:26 +00:00
|
|
|
|
|
|
|
;; Message length is in bits
|
|
|
|
ldy #3
|
2016-09-28 02:09:04 +00:00
|
|
|
- asl ml+7
|
2016-09-22 01:58:40 +00:00
|
|
|
rol ml+6
|
|
|
|
rol ml+5
|
2016-09-19 03:19:26 +00:00
|
|
|
dey
|
|
|
|
bne -
|
|
|
|
|
|
|
|
;; Initialize chunk counter
|
|
|
|
;; ldy #0 ; already zero
|
|
|
|
|
|
|
|
;; Invert length so we can inc instead of dec
|
|
|
|
lda LENGTH
|
|
|
|
sec
|
|
|
|
lda #0
|
|
|
|
sbc LENGTH
|
|
|
|
sta LENGTH
|
|
|
|
lda #0
|
|
|
|
sbc LENGTH+1
|
|
|
|
sta LENGTH+1
|
|
|
|
ora LENGTH
|
|
|
|
beq .msgdone
|
2016-09-29 02:43:49 +00:00
|
|
|
|
2016-09-19 03:19:26 +00:00
|
|
|
.loop lda (INPUT),y
|
|
|
|
sta w,y
|
|
|
|
iny
|
|
|
|
cpy #$40
|
|
|
|
bne +
|
|
|
|
|
|
|
|
;; Call do_chunk
|
|
|
|
jsr do_chunk
|
|
|
|
ldy #0
|
|
|
|
|
|
|
|
clc
|
|
|
|
lda INPUT
|
|
|
|
adc #$40
|
|
|
|
sta INPUT
|
|
|
|
bcc +
|
|
|
|
inc INPUT+1
|
2016-09-29 02:43:49 +00:00
|
|
|
|
2016-09-19 03:19:26 +00:00
|
|
|
+ inc LENGTH
|
|
|
|
bne .loop
|
|
|
|
inc LENGTH+1
|
|
|
|
bne .loop
|
2016-09-29 02:43:49 +00:00
|
|
|
|
2016-09-19 03:19:26 +00:00
|
|
|
.msgdone:
|
|
|
|
lda #$80
|
|
|
|
sta w,y
|
|
|
|
iny
|
|
|
|
cpy #$40
|
|
|
|
bne .zeros
|
|
|
|
jsr do_chunk
|
|
|
|
ldy #0
|
2016-09-13 01:52:46 +00:00
|
|
|
|
2016-09-19 03:19:26 +00:00
|
|
|
.zeros
|
2016-09-22 01:58:40 +00:00
|
|
|
cpy #$38
|
2016-09-19 03:19:26 +00:00
|
|
|
beq .length
|
|
|
|
lda #0
|
|
|
|
sta w,y
|
|
|
|
iny
|
|
|
|
cpy #$40
|
|
|
|
bne .zeros
|
|
|
|
jsr do_chunk
|
|
|
|
ldy #0
|
|
|
|
jmp .zeros
|
|
|
|
.length
|
2016-09-22 01:58:40 +00:00
|
|
|
ldy #7
|
2016-09-19 03:19:26 +00:00
|
|
|
- lda ml,y
|
2016-09-22 01:58:40 +00:00
|
|
|
sta w+$38,y
|
2016-09-19 03:19:26 +00:00
|
|
|
dey
|
|
|
|
bpl -
|
|
|
|
jsr do_chunk
|
|
|
|
rts
|
|
|
|
|
2016-09-28 02:09:04 +00:00
|
|
|
;;; do_chunk processes a chunk of input. It burns A,X,Y,TMP1,TMP2.
|
2016-09-19 03:19:26 +00:00
|
|
|
do_chunk:
|
2016-09-28 02:09:04 +00:00
|
|
|
;; Copy a..e from h0..h4
|
2016-09-29 02:43:49 +00:00
|
|
|
|
2016-09-28 02:09:04 +00:00
|
|
|
ldy #(f-a-1)
|
|
|
|
- lda h0,y
|
|
|
|
sta a,y
|
|
|
|
dey
|
|
|
|
bpl -
|
2016-09-29 02:43:49 +00:00
|
|
|
|
2016-09-24 03:16:49 +00:00
|
|
|
ldy #0 ; y is index into w
|
2016-09-29 02:43:49 +00:00
|
|
|
|
2016-09-24 03:16:49 +00:00
|
|
|
;; First 20: k1
|
2016-10-11 00:54:50 +00:00
|
|
|
+set32 k, k1
|
2016-09-24 03:16:49 +00:00
|
|
|
|
|
|
|
ldx #16
|
|
|
|
- jsr kind1
|
|
|
|
dex
|
|
|
|
bne -
|
|
|
|
jsr fill
|
|
|
|
ldx #4
|
|
|
|
- jsr kind1
|
|
|
|
dex
|
|
|
|
bne -
|
|
|
|
;; Second 20: k2
|
2016-10-11 00:54:50 +00:00
|
|
|
+set32 k, k2
|
2016-09-24 03:16:49 +00:00
|
|
|
|
|
|
|
ldx #12
|
|
|
|
- jsr kind2
|
|
|
|
dex
|
|
|
|
bne -
|
|
|
|
jsr fill
|
|
|
|
ldx #8
|
|
|
|
- jsr kind2
|
|
|
|
dex
|
|
|
|
bne -
|
|
|
|
|
|
|
|
;; Third 20: k3
|
2016-10-11 00:54:50 +00:00
|
|
|
+set32 k, k3
|
2016-09-24 03:16:49 +00:00
|
|
|
|
|
|
|
ldx #8
|
|
|
|
- jsr kind3
|
|
|
|
dex
|
|
|
|
bne -
|
|
|
|
jsr fill
|
|
|
|
ldx #12
|
|
|
|
- jsr kind3
|
|
|
|
dex
|
|
|
|
bne -
|
|
|
|
|
|
|
|
;; Fourth 20: k4
|
2016-10-11 00:54:50 +00:00
|
|
|
+set32 k, k4
|
2016-09-24 03:16:49 +00:00
|
|
|
|
|
|
|
ldx #4
|
2016-09-28 02:09:04 +00:00
|
|
|
- jsr kind2
|
2016-09-24 03:16:49 +00:00
|
|
|
dex
|
|
|
|
bne -
|
|
|
|
jsr fill
|
|
|
|
ldx #16
|
2016-09-28 02:09:04 +00:00
|
|
|
- jsr kind2
|
|
|
|
dex
|
|
|
|
bne -
|
|
|
|
|
|
|
|
+setSRC a
|
|
|
|
+setDST h0
|
|
|
|
ldx #5
|
|
|
|
- jsr add32
|
|
|
|
clc
|
|
|
|
lda SRC
|
|
|
|
adc #4
|
|
|
|
sta SRC
|
|
|
|
lda DST
|
|
|
|
adc #4
|
|
|
|
sta DST
|
2016-09-24 03:16:49 +00:00
|
|
|
dex
|
|
|
|
bne -
|
|
|
|
rts
|
|
|
|
|
|
|
|
kind1:
|
2016-09-28 02:09:04 +00:00
|
|
|
sty TMP1
|
|
|
|
stx TMP2
|
|
|
|
;; f = d xor (b and (c xor d))
|
|
|
|
+setDST f
|
|
|
|
+setSRC d
|
|
|
|
jsr cp32
|
|
|
|
+setSRC c
|
|
|
|
jsr xor32
|
|
|
|
+setSRC b
|
|
|
|
jsr and32
|
|
|
|
+setSRC d
|
|
|
|
jsr xor32
|
2016-09-29 02:43:49 +00:00
|
|
|
|
2016-09-28 02:09:04 +00:00
|
|
|
jmp common
|
2016-09-24 03:16:49 +00:00
|
|
|
kind2:
|
2016-09-28 02:09:04 +00:00
|
|
|
sty TMP1
|
|
|
|
stx TMP2
|
|
|
|
;; f = b xor c xor d
|
|
|
|
+setDST f
|
|
|
|
+setSRC d
|
|
|
|
jsr cp32
|
|
|
|
+setSRC c
|
|
|
|
jsr xor32
|
|
|
|
+setSRC b
|
|
|
|
jsr xor32
|
2016-09-29 02:43:49 +00:00
|
|
|
|
2016-09-28 02:09:04 +00:00
|
|
|
jmp common
|
2016-09-24 03:16:49 +00:00
|
|
|
kind3:
|
|
|
|
sty TMP1
|
2016-09-28 02:09:04 +00:00
|
|
|
stx TMP2
|
2016-09-29 02:43:49 +00:00
|
|
|
;; f = (b and c) or (d and (b or c))
|
2016-09-28 02:09:04 +00:00
|
|
|
+setSRC c
|
|
|
|
+setDST f
|
|
|
|
jsr cp32
|
|
|
|
+setDST temp
|
|
|
|
jsr cp32
|
|
|
|
+setSRC b
|
|
|
|
jsr and32
|
|
|
|
+setDST f
|
|
|
|
jsr or32
|
|
|
|
+setSRC d
|
|
|
|
jsr and32
|
|
|
|
+setSRC temp
|
|
|
|
jsr or32
|
|
|
|
; jmp common
|
|
|
|
|
|
|
|
common:
|
|
|
|
|
|
|
|
;; temp = (a leftrotate 5) + f + e + k + w[i]
|
|
|
|
+setDST temp
|
|
|
|
+setSRC a
|
|
|
|
jsr cp32
|
|
|
|
jsr rol8
|
2016-09-29 02:43:49 +00:00
|
|
|
|
2016-09-28 02:09:04 +00:00
|
|
|
jsr ror1
|
|
|
|
jsr ror1
|
|
|
|
jsr ror1
|
2016-09-29 02:43:49 +00:00
|
|
|
|
2016-09-28 02:09:04 +00:00
|
|
|
+setSRC f
|
|
|
|
jsr add32
|
|
|
|
+setSRC e
|
|
|
|
jsr add32
|
|
|
|
+setSRC k
|
|
|
|
jsr add32
|
|
|
|
|
|
|
|
;; !setSRC w[i], and call add32
|
|
|
|
ldy TMP1
|
2016-09-24 03:16:49 +00:00
|
|
|
clc
|
|
|
|
tya
|
|
|
|
adc #<w
|
2016-09-19 03:19:26 +00:00
|
|
|
sta SRC
|
2016-09-24 03:16:49 +00:00
|
|
|
lda #0
|
|
|
|
adc #>w
|
2016-09-19 03:19:26 +00:00
|
|
|
sta SRC+1
|
2016-09-28 02:09:04 +00:00
|
|
|
jsr add32
|
|
|
|
|
|
|
|
;; e = d
|
|
|
|
+setSRC d
|
|
|
|
+setDST e
|
|
|
|
jsr cp32
|
|
|
|
|
|
|
|
;; d = c
|
|
|
|
+setSRC c
|
|
|
|
+setDST d
|
|
|
|
jsr cp32
|
|
|
|
|
|
|
|
;; c = b leftrotate 30
|
|
|
|
+setSRC b
|
|
|
|
+setDST c
|
|
|
|
jsr cp32
|
|
|
|
jsr ror1
|
|
|
|
jsr ror1
|
2016-09-29 02:43:49 +00:00
|
|
|
|
2016-09-28 02:09:04 +00:00
|
|
|
;; b = a
|
|
|
|
+setSRC a
|
|
|
|
+setDST b
|
|
|
|
jsr cp32
|
2016-09-29 02:43:49 +00:00
|
|
|
|
2016-09-28 02:09:04 +00:00
|
|
|
;; a = temp
|
|
|
|
+setSRC temp
|
|
|
|
+setDST a
|
|
|
|
jsr cp32
|
2016-09-29 02:43:49 +00:00
|
|
|
|
2016-09-24 03:16:49 +00:00
|
|
|
ldy TMP1
|
2016-09-28 02:09:04 +00:00
|
|
|
ldx TMP2
|
2016-09-24 03:16:49 +00:00
|
|
|
iny
|
|
|
|
iny
|
|
|
|
iny
|
|
|
|
iny
|
|
|
|
rts
|
|
|
|
|
|
|
|
;; Replace w[i:i+16] with w[i+16:i+32]. Burns a. Sets y=0.
|
|
|
|
fill:
|
|
|
|
+setDST w_next
|
|
|
|
+setSRC w
|
|
|
|
ldx #0x10
|
|
|
|
|
|
|
|
- sec
|
|
|
|
lda DST
|
|
|
|
sbc #16*4
|
|
|
|
sta SRC
|
|
|
|
jsr cp32 ; w[i] = w[i-16]
|
|
|
|
clc
|
|
|
|
lda SRC
|
|
|
|
adc #2*4
|
|
|
|
sta SRC
|
|
|
|
jsr xor32 ; ^ w[i-14]
|
|
|
|
lda SRC
|
|
|
|
adc #6*4
|
|
|
|
sta SRC
|
|
|
|
jsr xor32 ; ^ w[i-8]
|
|
|
|
lda SRC
|
|
|
|
adc #5*4
|
|
|
|
sta SRC
|
|
|
|
jsr xor32 ; ^ w[i-3]
|
|
|
|
jsr rol1
|
|
|
|
clc
|
|
|
|
lda DST
|
|
|
|
adc #4 ; i++
|
|
|
|
sta DST
|
|
|
|
|
|
|
|
dex
|
|
|
|
bne -
|
|
|
|
|
|
|
|
ldx #w_next-w-1
|
|
|
|
- lda w_next,x
|
|
|
|
sta w,x
|
|
|
|
dex
|
|
|
|
bpl -
|
2016-09-29 02:43:49 +00:00
|
|
|
|
2016-09-24 03:16:49 +00:00
|
|
|
ldy #0
|
|
|
|
rts
|
|
|
|
|
2016-09-28 02:09:04 +00:00
|
|
|
;;; 32-bit, big-endian math routines.
|
|
|
|
;;; Result goes in DST. Second operand (if any)
|
|
|
|
;;; comes from SRC.
|
2016-09-29 02:43:49 +00:00
|
|
|
|
2016-09-24 03:16:49 +00:00
|
|
|
;; Rotate-left DST. Burns a,y.
|
|
|
|
rol1:
|
|
|
|
ldy #0
|
|
|
|
lda (DST),y
|
|
|
|
rol
|
|
|
|
ldy #3
|
|
|
|
- lda (DST),y
|
|
|
|
rol
|
|
|
|
sta (DST),y
|
|
|
|
dey
|
|
|
|
bpl -
|
|
|
|
rts
|
|
|
|
|
2016-09-28 02:09:04 +00:00
|
|
|
;; Rotate-right DST. Burns a,y.
|
|
|
|
ror1:
|
|
|
|
ldy #3
|
|
|
|
lda (DST),y
|
|
|
|
ror
|
|
|
|
ldy #0
|
2016-09-29 02:43:49 +00:00
|
|
|
php
|
2016-09-28 02:09:04 +00:00
|
|
|
- lda (DST),y
|
2016-09-29 02:43:49 +00:00
|
|
|
plp
|
2016-09-28 02:09:04 +00:00
|
|
|
ror
|
2016-09-29 02:43:49 +00:00
|
|
|
php
|
2016-09-28 02:09:04 +00:00
|
|
|
sta (DST),y
|
|
|
|
iny
|
|
|
|
cpy #4
|
|
|
|
bne -
|
2016-09-29 02:43:49 +00:00
|
|
|
plp
|
2016-09-28 02:09:04 +00:00
|
|
|
rts
|
|
|
|
|
2016-09-24 03:16:49 +00:00
|
|
|
;; Xor SRC into DST. Burns a,y.
|
|
|
|
xor32:
|
|
|
|
ldy #3
|
|
|
|
- lda (SRC),y
|
|
|
|
eor (DST),y
|
|
|
|
sta (DST),y
|
|
|
|
dey
|
|
|
|
bpl -
|
|
|
|
rts
|
|
|
|
|
|
|
|
;; Copy DST to SRC. Burns a,y.
|
|
|
|
cp32:
|
|
|
|
ldy #3
|
|
|
|
- lda (SRC),y
|
|
|
|
sta (DST),y
|
|
|
|
dey
|
|
|
|
bpl -
|
2016-09-19 03:19:26 +00:00
|
|
|
rts
|
2016-09-28 02:09:04 +00:00
|
|
|
|
|
|
|
add32:
|
|
|
|
clc
|
|
|
|
ldy #3
|
|
|
|
- lda (SRC),y
|
|
|
|
adc (DST),y
|
|
|
|
sta (DST),y
|
|
|
|
dey
|
|
|
|
bpl -
|
|
|
|
rts
|
|
|
|
|
|
|
|
and32:
|
|
|
|
clc
|
|
|
|
ldy #3
|
|
|
|
- lda (SRC),y
|
|
|
|
and (DST),y
|
|
|
|
sta (DST),y
|
|
|
|
dey
|
|
|
|
bpl -
|
|
|
|
rts
|
|
|
|
|
|
|
|
or32:
|
|
|
|
clc
|
|
|
|
ldy #3
|
|
|
|
- lda (SRC),y
|
|
|
|
ora (DST),y
|
|
|
|
sta (DST),y
|
|
|
|
dey
|
|
|
|
bpl -
|
|
|
|
rts
|
|
|
|
|
|
|
|
;; Rotate DST right by 8 bits. Burns a,x,y.
|
|
|
|
rol8:
|
|
|
|
ldy #0
|
2016-09-29 02:43:49 +00:00
|
|
|
lda (DST),y
|
2016-09-28 02:09:04 +00:00
|
|
|
tax
|
|
|
|
- iny
|
2016-09-29 02:43:49 +00:00
|
|
|
lda (DST),y
|
2016-09-28 02:09:04 +00:00
|
|
|
dey
|
2016-09-29 02:43:49 +00:00
|
|
|
sta (DST),y
|
2016-09-28 02:09:04 +00:00
|
|
|
iny
|
|
|
|
cpy #3
|
|
|
|
bne -
|
|
|
|
txa
|
2016-09-29 02:43:49 +00:00
|
|
|
sta (DST),y
|
2016-09-28 02:09:04 +00:00
|
|
|
rts
|
2016-09-29 02:43:49 +00:00
|
|
|
|
2016-09-19 03:19:26 +00:00
|
|
|
!eof
|
2016-09-13 01:52:46 +00:00
|
|
|
TODOs
|
2016-09-19 03:19:26 +00:00
|
|
|
[X] Routine to print n hex bytes (address, length (byte))
|
2016-09-19 03:26:30 +00:00
|
|
|
[X] Routine to get the next 16 values (64 bytes) of input
|
2016-09-28 02:09:04 +00:00
|
|
|
[X] Routine to get w[i] one i at a time, and rebuild next 16 values
|
2016-09-13 01:52:46 +00:00
|
|
|
|
2016-09-19 03:26:30 +00:00
|
|
|
Needed arithmetic routines for sha1sum:
|
2016-09-28 02:09:04 +00:00
|
|
|
- [X] add32
|
|
|
|
- [X] and32
|
|
|
|
- [X] or32
|
|
|
|
- [X] xor32
|
|
|
|
- [X] ROL1
|
|
|
|
- [X] ROR1
|
2016-09-29 02:43:49 +00:00
|
|
|
- [X] ROL5 --> ROL8, (ROR1,ROR1,ROR1)
|
|
|
|
- [X] ROL30 --> (ROR1,ROR1)
|