Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // void memclr_sse2(const void * const m_start (ebx), const size_t m_count (edx)) (Requires SSE2)
- .global memclr_sse2
- //TODO: Make the code easier to read and optimize it more!
- memclr_sse2:
- or %edx, %edx
- jeq .return
- pxor %xmm0, %xmm0
- push %edi
- mov %ebx, %edi
- xor %eax, %eax
- xor %ecx, %ecx
- test $0xF, %ebx // Check if start address is aligned
- jeq .aligned
- mov %ebx, %ecx
- and $0xF, %ecx
- sub $0xF, %ecx
- neg %ecx
- .unaligned:
- stosb
- dec %edx
- inc %ebx
- loop .unaligned
- or %edx, %edx
- jeq .return
- .aligned:
- cmp $0x10, %edx
- jbl .fin
- movdqa %xmm0, 0(%ebx, %ecx)
- sub $0x10, %edx
- add $0x10, %ecx
- jmp .aligned
- .fin:
- add %ecx, %ebx
- mov %ebx, %edi
- mov %edx, %ecx
- rep stosb
- .return:
- pop %edi
- ret
Advertisement
Add Comment
Please, Sign In to add comment