Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Optimized memset type operation for zeroing memory locations
- */
- inline void appZeroMemory(sdVoid *destPtr, int count)
- {
- __asm
- {
- mov ecx, [count] // store the repetition count for rep stosd
- mov edi, [destPtr]
- xor eax, eax // fill eax with zero, the contents of eax will go where the edi points to
- // we need two counters:
- mov edx, ecx
- shr ecx, 2 // divide [count] by 4
- and edx, 3 // store the rest of the counts to edx
- // zero on every 4 bytes, that's why we need two counters
- rep stosd // store dword from eax where the edi points to
- // if the [count] variable can't be divided by 4, then zero the rest of the bytes:
- mov ecx, edx
- rep stosb // store the lower 8bit of eax to es:di, ecx times
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement