2017-01-06 02:47:49 +00:00
|
|
|
;;; SHA-1 implementation in 6502 assembly.
|
|
|
|
;;; A straightforward implementation of:
|
|
|
|
;;; https://en.wikipedia.org/wiki/SHA-1#SHA-1_pseudocode
|
|
|
|
;;; Copyright © 2016 Zellyn Hunter <zellyn@gmail.com>
|
|
|
|
|
|
|
|
!zone shasum {
|
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
|
2017-01-06 02:47:49 +00:00
|
|
|
!addr SHAINPUT = $eb
|
|
|
|
!addr SHALENGTH = $ee
|
|
|
|
!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
|
|
|
|
2017-01-06 02:47:49 +00:00
|
|
|
!macro .set32 .target, .value {
|
2016-10-11 00:54:50 +00:00
|
|
|
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
|
|
|
|
}
|
|
|
|
|
2017-01-06 02:47:49 +00:00
|
|
|
!macro .setSRC .source {
|
2016-09-24 03:16:49 +00:00
|
|
|
lda #<.source
|
|
|
|
sta SRC
|
|
|
|
lda #>.source
|
|
|
|
sta SRC+1
|
|
|
|
}
|
2017-01-06 02:47:49 +00:00
|
|
|
!macro .setDST .dest {
|
2016-09-24 03:16:49 +00:00
|
|
|
lda #<.dest
|
|
|
|
sta DST
|
|
|
|
lda #>.dest
|
|
|
|
sta DST+1
|
|
|
|
}
|
|
|
|
|
2016-09-29 02:43:49 +00:00
|
|
|
|
2017-01-06 02:47:49 +00:00
|
|
|
!align 255, 0 ; align data area to page boundary
|
|
|
|
SHA:
|
|
|
|
SHALEN = 20
|
|
|
|
.h0: !32 0 ; return value (hash)
|
|
|
|
.h1: !32 0
|
|
|
|
.h2: !32 0
|
|
|
|
.h3: !32 0
|
|
|
|
.h4: !32 0
|
|
|
|
.h5:
|
|
|
|
.ml: !32 0, 0 ; message length
|
|
|
|
.w: !fill 64, 0
|
|
|
|
.w_next: !fill 64, 0
|
|
|
|
.a: !32 0
|
|
|
|
.b: !32 0
|
|
|
|
.c: !32 0
|
|
|
|
.d: !32 0
|
|
|
|
.e: !32 0
|
|
|
|
.f: !32 0
|
|
|
|
.temp: !32 0
|
|
|
|
.k: !32 0
|
|
|
|
.kh0: !be32 $67452301 ; initial values for h0..h4
|
|
|
|
.kh1: !be32 $EFCDAB89
|
|
|
|
.kh2: !be32 $98BADCFE
|
|
|
|
.kh3: !be32 $10325476
|
|
|
|
.kh4: !be32 $C3D2E1F0
|
|
|
|
.k1 = $5A827999 ; k constants
|
|
|
|
.k2 = $6ED9EBA1
|
|
|
|
.k3 = $8F1BBCDC
|
|
|
|
.k4 = $CA62C1D6
|
|
|
|
|
|
|
|
SHASUM:
|
2016-09-19 03:19:26 +00:00
|
|
|
;; Initialize h0..h4
|
2017-01-06 02:47:49 +00:00
|
|
|
ldy #(.h5-.h0-1)
|
|
|
|
- lda .kh0,y
|
|
|
|
sta .h0,y
|
2016-09-19 03:19:26 +00:00
|
|
|
dey
|
|
|
|
bpl -
|
2017-01-06 02:47:49 +00:00
|
|
|
;; Initialize message length (.ml)
|
2016-09-19 03:19:26 +00:00
|
|
|
lda #0
|
2016-09-22 01:58:40 +00:00
|
|
|
ldy #4
|
2017-01-06 02:47:49 +00:00
|
|
|
- sta .ml, y
|
2016-09-22 01:58:40 +00:00
|
|
|
dey
|
|
|
|
bpl -
|
2017-01-06 02:47:49 +00:00
|
|
|
lda SHALENGTH
|
|
|
|
sta .ml+7
|
|
|
|
lda SHALENGTH+1
|
|
|
|
sta .ml+6
|
2016-09-19 03:19:26 +00:00
|
|
|
|
|
|
|
;; Message length is in bits
|
|
|
|
ldy #3
|
2017-01-06 02:47:49 +00:00
|
|
|
- asl .ml+7
|
|
|
|
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
|
2017-01-06 02:47:49 +00:00
|
|
|
lda SHALENGTH
|
2016-09-19 03:19:26 +00:00
|
|
|
sec
|
|
|
|
lda #0
|
2017-01-06 02:47:49 +00:00
|
|
|
sbc SHALENGTH
|
|
|
|
sta SHALENGTH
|
2016-09-19 03:19:26 +00:00
|
|
|
lda #0
|
2017-01-06 02:47:49 +00:00
|
|
|
sbc SHALENGTH+1
|
|
|
|
sta SHALENGTH+1
|
|
|
|
ora SHALENGTH
|
2016-09-19 03:19:26 +00:00
|
|
|
beq .msgdone
|
2016-09-29 02:43:49 +00:00
|
|
|
|
2017-01-06 02:47:49 +00:00
|
|
|
.loop lda (SHAINPUT),y
|
|
|
|
sta .w,y
|
2016-09-19 03:19:26 +00:00
|
|
|
iny
|
|
|
|
cpy #$40
|
|
|
|
bne +
|
|
|
|
|
|
|
|
;; Call do_chunk
|
|
|
|
jsr do_chunk
|
|
|
|
ldy #0
|
|
|
|
|
|
|
|
clc
|
2017-01-06 02:47:49 +00:00
|
|
|
lda SHAINPUT
|
2016-09-19 03:19:26 +00:00
|
|
|
adc #$40
|
2017-01-06 02:47:49 +00:00
|
|
|
sta SHAINPUT
|
2016-09-19 03:19:26 +00:00
|
|
|
bcc +
|
2017-01-06 02:47:49 +00:00
|
|
|
inc SHAINPUT+1
|
2016-09-29 02:43:49 +00:00
|
|
|
|
2017-01-06 02:47:49 +00:00
|
|
|
+ inc SHALENGTH
|
2016-09-19 03:19:26 +00:00
|
|
|
bne .loop
|
2017-01-06 02:47:49 +00:00
|
|
|
inc SHALENGTH+1
|
2016-09-19 03:19:26 +00:00
|
|
|
bne .loop
|
2016-09-29 02:43:49 +00:00
|
|
|
|
2016-09-19 03:19:26 +00:00
|
|
|
.msgdone:
|
|
|
|
lda #$80
|
2017-01-06 02:47:49 +00:00
|
|
|
sta .w,y
|
2016-09-19 03:19:26 +00:00
|
|
|
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
|
2017-01-06 02:47:49 +00:00
|
|
|
sta .w,y
|
2016-09-19 03:19:26 +00:00
|
|
|
iny
|
|
|
|
cpy #$40
|
|
|
|
bne .zeros
|
|
|
|
jsr do_chunk
|
|
|
|
ldy #0
|
|
|
|
jmp .zeros
|
|
|
|
.length
|
2016-09-22 01:58:40 +00:00
|
|
|
ldy #7
|
2017-01-06 02:47:49 +00:00
|
|
|
- lda .ml,y
|
|
|
|
sta .w+$38,y
|
2016-09-19 03:19:26 +00:00
|
|
|
dey
|
|
|
|
bpl -
|
|
|
|
jsr do_chunk
|
|
|
|
rts
|
|
|
|
|
2017-01-06 02:47:49 +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
|
|
|
|
2017-01-06 02:47:49 +00:00
|
|
|
ldy #(.f-.a-1)
|
|
|
|
- lda .h0,y
|
|
|
|
sta .a,y
|
2016-09-28 02:09:04 +00:00
|
|
|
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
|
2017-01-06 02:47:49 +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
|
2017-01-06 02:47:49 +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
|
2017-01-06 02:47:49 +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
|
2017-01-06 02:47:49 +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 -
|
|
|
|
|
2017-01-06 02:47:49 +00:00
|
|
|
+.setSRC .a
|
|
|
|
+.setDST .h0
|
2016-09-28 02:09:04 +00:00
|
|
|
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:
|
2017-01-06 02:47:49 +00:00
|
|
|
sty .tmp1
|
|
|
|
stx .tmp2
|
2016-09-28 02:09:04 +00:00
|
|
|
;; f = d xor (b and (c xor d))
|
2017-01-06 02:47:49 +00:00
|
|
|
+.setDST .f
|
|
|
|
+.setSRC .d
|
2016-09-28 02:09:04 +00:00
|
|
|
jsr cp32
|
2017-01-06 02:47:49 +00:00
|
|
|
+.setSRC .c
|
2016-09-28 02:09:04 +00:00
|
|
|
jsr xor32
|
2017-01-06 02:47:49 +00:00
|
|
|
+.setSRC .b
|
2016-09-28 02:09:04 +00:00
|
|
|
jsr and32
|
2017-01-06 02:47:49 +00:00
|
|
|
+.setSRC .d
|
2016-09-28 02:09:04 +00:00
|
|
|
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:
|
2017-01-06 02:47:49 +00:00
|
|
|
sty .tmp1
|
|
|
|
stx .tmp2
|
2016-09-28 02:09:04 +00:00
|
|
|
;; f = b xor c xor d
|
2017-01-06 02:47:49 +00:00
|
|
|
+.setDST .f
|
|
|
|
+.setSRC .d
|
2016-09-28 02:09:04 +00:00
|
|
|
jsr cp32
|
2017-01-06 02:47:49 +00:00
|
|
|
+.setSRC .c
|
2016-09-28 02:09:04 +00:00
|
|
|
jsr xor32
|
2017-01-06 02:47:49 +00:00
|
|
|
+.setSRC .b
|
2016-09-28 02:09:04 +00:00
|
|
|
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:
|
2017-01-06 02:47:49 +00:00
|
|
|
sty .tmp1
|
|
|
|
stx .tmp2
|
2016-09-29 02:43:49 +00:00
|
|
|
;; f = (b and c) or (d and (b or c))
|
2017-01-06 02:47:49 +00:00
|
|
|
+.setSRC .c
|
|
|
|
+.setDST .f
|
2016-09-28 02:09:04 +00:00
|
|
|
jsr cp32
|
2017-01-06 02:47:49 +00:00
|
|
|
+.setDST .temp
|
2016-09-28 02:09:04 +00:00
|
|
|
jsr cp32
|
2017-01-06 02:47:49 +00:00
|
|
|
+.setSRC .b
|
2016-09-28 02:09:04 +00:00
|
|
|
jsr and32
|
2017-01-06 02:47:49 +00:00
|
|
|
+.setDST .f
|
2016-09-28 02:09:04 +00:00
|
|
|
jsr or32
|
2017-01-06 02:47:49 +00:00
|
|
|
+.setSRC .d
|
2016-09-28 02:09:04 +00:00
|
|
|
jsr and32
|
2017-01-06 02:47:49 +00:00
|
|
|
+.setSRC .temp
|
2016-09-28 02:09:04 +00:00
|
|
|
jsr or32
|
|
|
|
; jmp common
|
|
|
|
|
|
|
|
common:
|
|
|
|
|
|
|
|
;; temp = (a leftrotate 5) + f + e + k + w[i]
|
2017-01-06 02:47:49 +00:00
|
|
|
+.setDST .temp
|
|
|
|
+.setSRC .a
|
2016-09-28 02:09:04 +00:00
|
|
|
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
|
|
|
|
2017-01-06 02:47:49 +00:00
|
|
|
+.setSRC .f
|
2016-09-28 02:09:04 +00:00
|
|
|
jsr add32
|
2017-01-06 02:47:49 +00:00
|
|
|
+.setSRC .e
|
2016-09-28 02:09:04 +00:00
|
|
|
jsr add32
|
2017-01-06 02:47:49 +00:00
|
|
|
+.setSRC .k
|
2016-09-28 02:09:04 +00:00
|
|
|
jsr add32
|
|
|
|
|
2017-01-06 02:47:49 +00:00
|
|
|
;; !.setSRC w[i], and call add32
|
|
|
|
ldy .tmp1
|
2016-09-24 03:16:49 +00:00
|
|
|
clc
|
|
|
|
tya
|
2017-01-06 02:47:49 +00:00
|
|
|
adc #<.w
|
2016-09-19 03:19:26 +00:00
|
|
|
sta SRC
|
2016-09-24 03:16:49 +00:00
|
|
|
lda #0
|
2017-01-06 02:47:49 +00:00
|
|
|
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
|
2017-01-06 02:47:49 +00:00
|
|
|
+.setSRC .d
|
|
|
|
+.setDST .e
|
2016-09-28 02:09:04 +00:00
|
|
|
jsr cp32
|
|
|
|
|
|
|
|
;; d = c
|
2017-01-06 02:47:49 +00:00
|
|
|
+.setSRC .c
|
|
|
|
+.setDST .d
|
2016-09-28 02:09:04 +00:00
|
|
|
jsr cp32
|
|
|
|
|
|
|
|
;; c = b leftrotate 30
|
2017-01-06 02:47:49 +00:00
|
|
|
+.setSRC .b
|
|
|
|
+.setDST .c
|
2016-09-28 02:09:04 +00:00
|
|
|
jsr cp32
|
|
|
|
jsr ror1
|
|
|
|
jsr ror1
|
2016-09-29 02:43:49 +00:00
|
|
|
|
2016-09-28 02:09:04 +00:00
|
|
|
;; b = a
|
2017-01-06 02:47:49 +00:00
|
|
|
+.setSRC .a
|
|
|
|
+.setDST .b
|
2016-09-28 02:09:04 +00:00
|
|
|
jsr cp32
|
2016-09-29 02:43:49 +00:00
|
|
|
|
2016-09-28 02:09:04 +00:00
|
|
|
;; a = temp
|
2017-01-06 02:47:49 +00:00
|
|
|
+.setSRC .temp
|
|
|
|
+.setDST .a
|
2016-09-28 02:09:04 +00:00
|
|
|
jsr cp32
|
2016-09-29 02:43:49 +00:00
|
|
|
|
2017-01-06 02:47:49 +00:00
|
|
|
ldy .tmp1
|
|
|
|
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:
|
2017-01-06 02:47:49 +00:00
|
|
|
+.setDST .w_next
|
|
|
|
+.setSRC .w
|
2016-09-24 03:16:49 +00:00
|
|
|
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 -
|
|
|
|
|
2017-01-06 02:47:49 +00:00
|
|
|
ldx #.w_next-.w-1
|
|
|
|
- lda .w_next,x
|
|
|
|
sta .w,x
|
2016-09-24 03:16:49 +00:00
|
|
|
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
|
2017-01-06 02:47:49 +00:00
|
|
|
} ;shasum
|