summaryrefslogtreecommitdiff
path: root/qdos/crc68.s
blob: cf74e47d48d0fdd6765448f934e3a57d550db969 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
;===========================================================================
; Copyright (c) 1990-1999 Info-ZIP.  All rights reserved.
;
; See the accompanying file LICENSE, version 1999-Oct-05 or later
; (the contents of which are also included in zip.h) for terms of use.
; If, for some reason, both of these files are missing, the Info-ZIP license
; also may be found at:  ftp://ftp.cdrom.com/pub/infozip/license.html
;===========================================================================
.text

.globl  _crc32          ; (ulg val, uch *buf, extent bufsize)
.globl  _get_crc_table  ; ulg *get_crc_table(void)

_crc32:
        move.l  8(sp),d0
        bne    valid
        moveq  #0,d0
        rts
valid:  movem.l d2/d3,-(sp)
        jsr     _get_crc_table
        move.l  d0,a0
        move.l  12(sp),d0
        move.l  16(sp),a1
        move.l  20(sp),d1
        not.l   d0

        move.l  d1,d2
        lsr.l   #3,d1
        bra     decr8
loop8:  moveq  #0,d3
        move.b (a1)+,d3
        eor.b  d0,d3
        lsl.w  #2,d3
        move.l 0(a0,d3.w),d3
        lsr.l  #8,d0
        eor.l  d3,d0
        moveq  #0,d3
        move.b (a1)+,d3
        eor.b  d0,d3
        lsl.w  #2,d3
        move.l 0(a0,d3.w),d3
        lsr.l  #8,d0
        eor.l  d3,d0
        moveq  #0,d3
        move.b (a1)+,d3
        eor.b  d0,d3
        lsl.w  #2,d3
        move.l 0(a0,d3.w),d3
        lsr.l  #8,d0
        eor.l  d3,d0
        moveq  #0,d3
        move.b (a1)+,d3
        eor.b  d0,d3
        lsl.w  #2,d3
        move.l 0(a0,d3.w),d3
        lsr.l  #8,d0
        eor.l  d3,d0
        moveq  #0,d3
        move.b (a1)+,d3
        eor.b  d0,d3
        lsl.w  #2,d3
        move.l 0(a0,d3.w),d3
        lsr.l  #8,d0
        eor.l  d3,d0
        moveq  #0,d3
        move.b (a1)+,d3
        eor.b  d0,d3
        lsl.w  #2,d3
        move.l 0(a0,d3.w),d3
        lsr.l  #8,d0
        eor.l  d3,d0
        moveq  #0,d3
        move.b (a1)+,d3
        eor.b  d0,d3
        lsl.w  #2,d3
        move.l 0(a0,d3.w),d3
        lsr.l  #8,d0
        eor.l  d3,d0
        moveq  #0,d3
        move.b (a1)+,d3
        eor.b  d0,d3
        lsl.w  #2,d3
        move.l 0(a0,d3.w),d3
        lsr.l  #8,d0
        eor.l  d3,d0
decr8:  dbra   d1,loop8
        and.w   #7,d2
        bra     decr1
loop1:  moveq  #0,d3
        move.b (a1)+,d3
        eor.b  d0,d3
        lsl.w  #2,d3
        move.l 0(a0,d3.w),d3
        lsr.l  #8,d0
        eor.l  d3,d0
decr1:  dbra   d2,loop1
done:   movem.l (sp)+,d2/d3
        not.l   d0
        rts