2180
|
1 IFNE 1
|
|
2
|
|
3 * Checksum routine - D returns as the sum of all bytes of the sector
|
|
4 * Entry: X = address of sector
|
|
5 * Exit : D = checksum value
|
|
6 DoCSum equ *
|
|
7 clr ,-s
|
|
8 clra
|
|
9 clrb
|
|
10 c2@ addb ,x+
|
|
11 adca #0
|
|
12 dec ,s
|
|
13 bne c2@
|
|
14 leas 1,s
|
|
15 * exg a,b do endian conversion to match Server's checksum
|
|
16 rts
|
|
17
|
|
18
|
|
19 * Weak but fast CRC Computation Routine
|
|
20 * Entry: X = address of sector
|
|
21 * Exit : D = crc value
|
|
22 *DoCRC equ *
|
|
23 * IFNE H6309
|
|
24 * clrd
|
|
25 * clre
|
|
26 *CRC2 eord ,x++
|
|
27 * ince
|
|
28 * bpl CRC2
|
|
29 * ELSE
|
|
30 * clr ,-s
|
|
31 * clra
|
|
32 * clrb
|
|
33 *CRC2 eora ,x+
|
|
34 * eorb ,x+
|
|
35 * inc ,s
|
|
36 * bpl CRC2
|
|
37 * leas 1,s
|
|
38 * ENDC
|
|
39 * exg a,b do endian conversion to match PC's CRC
|
|
40 * rts
|
|
41
|
|
42
|
|
43 ELSE
|
|
44
|
|
45 * CCITT CRC-16 Computation Routine
|
|
46 *
|
|
47 * Provided by Tim Lindner - 02/12/2003
|
|
48 *
|
|
49 * Entry: X = address of sector
|
|
50 * Exit : D = crc value
|
|
51 *CRC16 equ *
|
|
52 * IFNE H6309
|
|
53 * clrd
|
|
54 * clre
|
|
55 * ELSE
|
|
56 * clra
|
|
57 * clrb
|
|
58 * pshs b save as counter of 256 bytes
|
|
59 * ENDC
|
|
60 *CRCLP eora ,x+
|
|
61 * IFNE H6309
|
|
62 * lsld
|
|
63 * ELSE
|
|
64 * lslb
|
|
65 * rola
|
|
66 * ENDC
|
|
67 * bcc CRCLp0
|
|
68 * IFNE H6309
|
|
69 * eord #$1021
|
|
70 * ELSE
|
|
71 * eora #$10
|
|
72 * eorb #$21
|
|
73 * ENDC
|
|
74 *CRCLp0 equ *
|
|
75 * IFNE H6309
|
|
76 * lsld
|
|
77 * ELSE
|
|
78 * lslb
|
|
79 * rola
|
|
80 * ENDC
|
|
81 * bcc CRCLp1
|
|
82 * IFNE H6309
|
|
83 * eord #$1021
|
|
84 * ELSE
|
|
85 * eora #$10
|
|
86 * eorb #$21
|
|
87 * ENDC
|
|
88 *CRCLp1 equ *
|
|
89 * IFNE H6309
|
|
90 * lsld
|
|
91 * ELSE
|
|
92 * lslb
|
|
93 * rola
|
|
94 * ENDC
|
|
95 * bcc CRCLp2
|
|
96 * IFNE H6309
|
|
97 * eord #$1021
|
|
98 * ELSE
|
|
99 * eora #$10
|
|
100 * eorb #$21
|
|
101 * ENDC
|
|
102 *CRCLp2 equ *
|
|
103 * IFNE H6309
|
|
104 * lsld
|
|
105 * ELSE
|
|
106 * lslb
|
|
107 * rola
|
|
108 * ENDC
|
|
109 * bcc CRCLp3
|
|
110 * IFNE H6309
|
|
111 * eord #$1021
|
|
112 * ELSE
|
|
113 * eora #$10
|
|
114 * eorb #$21
|
|
115 * ENDC
|
|
116 *CRCLp3 equ *
|
|
117 * IFNE H6309
|
|
118 * lsld
|
|
119 * ELSE
|
|
120 * lslb
|
|
121 * rola
|
|
122 * ENDC
|
|
123 * bcc CRCLp4
|
|
124 ** IFNE H6309
|
|
125 ** eord #$1021
|
|
126 * ELSE
|
|
127 * eora #$10
|
|
128 * eorb #$21
|
|
129 * ENDC
|
|
130 *CRCLp4 equ *
|
|
131 * IFNE H6309
|
|
132 * lsld
|
|
133 * ELSE
|
|
134 * lslb
|
|
135 * rola
|
|
136 * ENDC
|
|
137 * bcc CRCLp5
|
|
138 * IFNE H6309
|
|
139 * eord #$1021
|
|
140 * ELSE
|
|
141 * eora #$10
|
|
142 * eorb #$21
|
|
143 * ENDC
|
|
144 *CRCLp5 equ *
|
|
145 * IFNE H6309
|
|
146 * lsld
|
|
147 * ELSE
|
|
148 * lslb
|
|
149 * rola
|
|
150 * ENDC
|
|
151 * bcc CRCLp6
|
|
152 * IFNE H6309
|
|
153 * eord #$1021
|
|
154 * ELSE
|
|
155 * eora #$10
|
|
156 * eorb #$21
|
|
157 * ENDC
|
|
158 *CRCLp6 equ *
|
|
159 * IFNE H6309
|
|
160 * lsld
|
|
161 * ELSE
|
|
162 * lslb
|
|
163 * rola
|
|
164 * ENDC
|
|
165 * bcc CRCLp7
|
|
166 * IFNE H6309
|
|
167 * eord #$1021
|
|
168 * ELSE
|
|
169 * eora #$10
|
|
170 * eorb #$21
|
|
171 * ENDC
|
|
172 *CRCLp7 equ *
|
|
173 * IFNE H6309
|
|
174 * dece
|
|
175 * ELSE
|
|
176 * dec ,s
|
|
177 * ENDC
|
|
178 * bne CRCLp
|
|
179 * IFEQ H6309
|
|
180 * leas 1,s eat counter on stack
|
|
181 * ENDC
|
|
182 * rts
|
|
183 *
|
|
184 * ENDC
|
|
185 *
|
|
186
|
|
187 * calculate CCITT CRC 16
|
|
188 * input: X - Address of block
|
|
189 * Block is assumed to be 256 bytes
|
|
190 * output: D - 16 bit CRC
|
|
191 * uses: X, D, CC, and two bytes of stack
|
|
192
|
|
193 DoCRC equ *
|
|
194 IFNE H6309
|
|
195
|
|
196 clre
|
|
197 clrd
|
|
198 nextbyte ldf #8
|
|
199 eora ,x+
|
|
200 nextbit lsld
|
|
201 bcc loop
|
|
202 eord #$1021
|
|
203 loop decf
|
|
204 bne nextbit
|
|
205 dece
|
|
206 bne nextbyte
|
|
207 rts
|
|
208
|
|
209 ELSE
|
|
210
|
|
211 clra
|
|
212 clrb
|
|
213 pshs y,b
|
|
214 nextbyte ldy #8
|
|
215 eora ,x+
|
|
216 nextbit lslb
|
|
217 rola
|
|
218 bcc loop
|
|
219 eora #$10
|
|
220 eorb #$21
|
|
221 loop leay -1,y
|
|
222 bne nextbit
|
|
223 dec ,s
|
|
224 bne nextbyte
|
|
225 leas 1,s
|
|
226 puls y,pc
|
|
227
|
|
228 ENDC
|
|
229 ENDC
|
|
230
|