csum_partial.S 892 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. /*
  2. * Copyright (C) 2004-2006 Atmel Corporation
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License version 2 as
  6. * published by the Free Software Foundation.
  7. */
  8. /*
  9. * unsigned int csum_partial(const unsigned char *buff,
  10. * int len, unsigned int sum)
  11. */
  12. .text
  13. .global csum_partial
  14. .type csum_partial,"function"
  15. .align 1
  16. csum_partial:
  17. /* checksum complete words, aligned or not */
  18. 3: sub r11, 4
  19. brlt 5f
  20. 4: ld.w r9, r12++
  21. add r10, r9
  22. acr r10
  23. sub r11, 4
  24. brge 4b
  25. /* return if we had a whole number of words */
  26. 5: sub r11, -4
  27. reteq r10
  28. /* checksum any remaining bytes at the end */
  29. mov r9, 0
  30. mov r8, 0
  31. cp r11, 2
  32. brlt 6f
  33. ld.uh r9, r12++
  34. sub r11, 2
  35. breq 7f
  36. lsl r9, 16
  37. 6: ld.ub r8, r12++
  38. lsl r8, 8
  39. 7: or r9, r8
  40. add r10, r9
  41. acr r10
  42. retal r10
  43. .size csum_partial, . - csum_partial