This is highly optimized code that in the normal case loads 4 bytes at
a time, checks if any of the 4 is z a null (0) and handles accordingly.
 If the string doesn't start on a 4-byte boundary, the str_misaligned
counts 1, 2, or 3 characters until a null or alignment boundary is
found.  The tricky computation in main_loop is

 (~ax ^ (ax + 0x7efefeff) ) & 0x81010100 == 0

This test is true if and only if none of the four bytes in ax is
initially 0 (null).  If the test fails (i.e. the terminating null is
found), there are four cases to deal with computing the length by
subtracting pointers.  (The lea instruction is a cheap way of
subtracting a constant from one register and placing the result into
another.)


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/algogeeks
-~----------~----~----~----~------~----~------~--~---

Reply via email to