00001 .globl strlen 00002 strlen: 00003 pushl %edi 00004 movl 8(%esp),%edi /* string address */ 00005 cld /* set search forward */ 00006 xorl %eax,%eax /* set search for null terminator */ 00007 movl $-1,%ecx /* set search for lots of characters */ 00008 repne /* search! */ 00009 scasb 00010 notl %ecx /* get length by taking complement */ 00011 leal -1(%ecx),%eax /* and subtracting one */ 00012 popl %edi 00013 ret