Guest User

Untitled

a guest
Feb 3rd, 2016
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. // void memclr_sse2(const void * const m_start (ebx), const size_t m_count (edx)) (Requires SSE2)
  2. .global memclr_sse2
  3. //TODO: Make the code easier to read and optimize it more!
  4. memclr_sse2:
  5. or %edx, %edx
  6. jeq .return
  7. pxor %xmm0, %xmm0
  8. push %edi
  9. mov %ebx, %edi
  10. xor %eax, %eax
  11. xor %ecx, %ecx
  12. test $0xF, %ebx // Check if start address is aligned
  13. jeq .aligned
  14. mov %ebx, %ecx
  15. and $0xF, %ecx
  16. sub $0xF, %ecx
  17. neg %ecx
  18. .unaligned:
  19. stosb
  20. dec %edx
  21. inc %ebx
  22. loop .unaligned
  23. or %edx, %edx
  24. jeq .return
  25. .aligned:
  26. cmp $0x10, %edx
  27. jbl .fin
  28. movdqa %xmm0, 0(%ebx, %ecx)
  29. sub $0x10, %edx
  30. add $0x10, %ecx
  31. jmp .aligned
  32. .fin:
  33. add %ecx, %ebx
  34. mov %ebx, %edi
  35. mov %edx, %ecx
  36. rep stosb
  37. .return:
  38. pop %edi
  39. ret
Advertisement
Add Comment
Please, Sign In to add comment