39 #define BUF ((uip_tcpip_hdr *)&uip_buf[UIP_LLH_LEN])
40 #define IP_PROTO_TCP 6
41 #define IP_PROTO_UDP 17
44 #pragma optimize(push, off)
57 asm(
"sta _uip_acc32+3");
62 asm(
"sta _uip_acc32+2");
66 asm(
"sta _uip_acc32+1");
70 asm(
"sta _uip_acc32+0");
74 static u16_t chksum_ptr, chksum_len, chksum_tmp;
75 static u8_t chksum_protocol;
76 static u16_t chksum(
void);
78 #pragma optimize(push, off)
85 asm(
"lda _chksum_ptr");
87 asm(
"lda _chksum_ptr+1");
91 asm(
"lda _chksum_len+1");
92 asm(
"beq chksumlast");
98 asm(
"chksumloop_256:");
107 asm(
"bne chksumloop_256");
109 asm(
"dec _chksum_len+1");
110 asm(
"bne chksumloop_256");
112 asm(
"chksum_endloop_256:");
119 asm(
"bcs chksum_endloop_256");
122 asm(
"lda _chksum_len");
124 asm(
"bcc chksum_noodd");
125 asm(
"ldy _chksum_len");
136 asm(
"dec _chksum_len");
138 asm(
"chksum_noodd:");
141 asm(
"ldy _chksum_len");
142 asm(
"chksum_loop1:");
144 asm(
"beq chksum_loop1_end");
157 asm(
"jmp chksum_loop1");
158 asm(
"chksum_loop1_end:");
161 asm(
"chksum_endloop:");
168 asm(
"bcs chksum_endloop");
173 #pragma optimize(pop)
202 chksum_ptr = (
u16_t)buf;
210 chksum_len = UIP_IPH_LEN;
214 #pragma optimize(push, off)
216 transport_chksum(u8_t protocol)
218 chksum_protocol = protocol;
220 chksum_len = UIP_TCPH_LEN;
221 chksum_tmp = chksum();
226 asm(
"sbc #%b", UIP_IPTCPH_LEN);
227 asm(
"sta _chksum_len");
230 asm(
"sta _chksum_len+1");
232 asm(
"jsr %v", chksum);
235 asm(
"adc _chksum_tmp");
236 asm(
"sta _chksum_tmp");
238 asm(
"adc _chksum_tmp+1");
239 asm(
"sta _chksum_tmp+1");
246 asm(
"tcpchksum_loop1:");
247 asm(
"lda _chksum_tmp");
249 asm(
"sta _chksum_tmp");
250 asm(
"lda _chksum_tmp+1");
252 asm(
"sta _chksum_tmp+1");
253 asm(
"bcs tcpchksum_loop1");
258 asm(
"sbc #%b", UIP_IPH_LEN);
259 asm(
"sta _chksum_len");
262 asm(
"sta _chksum_len+1");
268 asm(
"tcpchksum_loop2:");
271 asm(
"adc _chksum_tmp");
272 asm(
"sta _chksum_tmp");
275 asm(
"adc _chksum_tmp+1");
276 asm(
"sta _chksum_tmp+1");
280 asm(
"bne tcpchksum_loop2");
284 asm(
"lda _chksum_tmp");
286 asm(
"sta _chksum_tmp");
287 asm(
"lda _chksum_tmp+1");
288 asm(
"adc %v", chksum_protocol);
289 asm(
"sta _chksum_tmp+1");
292 asm(
"lda _chksum_tmp");
293 asm(
"adc _chksum_len+1");
294 asm(
"sta _chksum_tmp");
295 asm(
"lda _chksum_tmp+1");
296 asm(
"adc _chksum_len");
297 asm(
"sta _chksum_tmp+1");
301 asm(
"tcpchksum_loop3:");
302 asm(
"lda _chksum_tmp");
304 asm(
"sta _chksum_tmp");
305 asm(
"lda _chksum_tmp+1");
307 asm(
"sta _chksum_tmp+1");
308 asm(
"bcs tcpchksum_loop3");
313 #pragma optimize(pop)
319 return transport_chksum(IP_PROTO_TCP);
322 chksum_len = UIP_TCPH_LEN;
323 chksum_tmp = chksum();
328 asm(
"sbc #%b", UIP_IPTCPH_LEN);
329 asm(
"sta _chksum_len");
332 asm(
"sta _chksum_len+1");
334 asm(
"jsr %v", chksum);
337 asm(
"adc _chksum_tmp");
338 asm(
"sta _chksum_tmp");
340 asm(
"adc _chksum_tmp+1");
341 asm(
"sta _chksum_tmp+1");
348 asm(
"tcpchksum_loop1:");
349 asm(
"lda _chksum_tmp");
351 asm(
"sta _chksum_tmp");
352 asm(
"lda _chksum_tmp+1");
354 asm(
"sta _chksum_tmp+1");
355 asm(
"bcs tcpchksum_loop1");
360 asm(
"sbc #%b", UIP_IPH_LEN);
361 asm(
"sta _chksum_len");
364 asm(
"sta _chksum_len+1");
370 asm(
"tcpchksum_loop2:");
373 asm(
"adc _chksum_tmp");
374 asm(
"sta _chksum_tmp");
377 asm(
"adc _chksum_tmp+1");
378 asm(
"sta _chksum_tmp+1");
382 asm(
"bne tcpchksum_loop2");
386 asm(
"lda _chksum_tmp");
388 asm(
"sta _chksum_tmp");
389 asm(
"lda _chksum_tmp+1");
391 asm(
"sta _chksum_tmp+1");
394 asm(
"lda _chksum_tmp");
395 asm(
"adc _chksum_len+1");
396 asm(
"sta _chksum_tmp");
397 asm(
"lda _chksum_tmp+1");
398 asm(
"adc _chksum_len");
399 asm(
"sta _chksum_tmp+1");
403 asm(
"tcpchksum_loop3:");
404 asm(
"lda _chksum_tmp");
406 asm(
"sta _chksum_tmp");
407 asm(
"lda _chksum_tmp+1");
409 asm(
"sta _chksum_tmp+1");
410 asm(
"bcs tcpchksum_loop3");
418 #if UIP_UDP_CHECKSUMS
422 return transport_chksum(IP_PROTO_UDP);
426 chksum_tmp = chksum();
432 asm(
"sta _chksum_len");
435 asm(
"sta _chksum_len+1");
437 asm(
"jsr %v", chksum);
440 asm(
"adc _chksum_tmp");
441 asm(
"sta _chksum_tmp");
443 asm(
"adc _chksum_tmp+1");
444 asm(
"sta _chksum_tmp+1");
451 asm(
"tcpchksum_loop1:");
452 asm(
"lda _chksum_tmp");
454 asm(
"sta _chksum_tmp");
455 asm(
"lda _chksum_tmp+1");
457 asm(
"sta _chksum_tmp+1");
458 asm(
"bcs tcpchksum_loop1");
464 asm(
"sta _chksum_len");
467 asm(
"sta _chksum_len+1");
473 asm(
"tcpchksum_loop2:");
476 asm(
"adc _chksum_tmp");
477 asm(
"sta _chksum_tmp");
480 asm(
"adc _chksum_tmp+1");
481 asm(
"sta _chksum_tmp+1");
485 asm(
"bne tcpchksum_loop2");
489 asm(
"lda _chksum_tmp");
491 asm(
"sta _chksum_tmp");
492 asm(
"lda _chksum_tmp+1");
494 asm(
"sta _chksum_tmp+1");
497 asm(
"lda _chksum_tmp");
498 asm(
"adc _chksum_len+1");
499 asm(
"sta _chksum_tmp");
500 asm(
"lda _chksum_tmp+1");
501 asm(
"adc _chksum_len");
502 asm(
"sta _chksum_tmp+1");
506 asm(
"tcpchksum_loop3:");
507 asm(
"lda _chksum_tmp");
509 asm(
"sta _chksum_tmp");
510 asm(
"lda _chksum_tmp+1");
512 asm(
"sta _chksum_tmp+1");
513 asm(
"bcs tcpchksum_loop3");