.data
.set ZERO , 0b00000000000000000000000000000000
strlen:
#asm_strlen(const char *data)
__asm_strlen:
pushl %ebp
movl %esp , %ebp
movl 8(%ebp) , %edi
movl $-1 , %ecx
movl $0 , %eax
cld
repne scasb
orl $ZERO , %ecx
notl %ecx
decl %ecx
movl %ebp , %esp
popl %ebp
movl %ecx , %eax
ret
strncpy:
#asm_strncpy(char *dest , char *source , int len)
.global __asm_strncpy
__asm_strncpy:
pushl %ebp
movl %esp , %ebp
movl 16(%ebp) , %ecx
movl 12(%ebp) , %esi
movl 8(%ebp) , %edi
movl %ecx , %ebx
1:
lodsb
stosb
decl %ecx
jne 1b
movl %ebp , %esp
popl %ebp
orl %ecx , %ecx
jne 2
ret
2:
subl %ecx , %ebx
movl %ebx , %eax
ret
strchr:
#asm_strchr( char *__s, int __c )
.global __asm_strchr
__asm_strchr:
pushl %ebp
movl %esp , %ebp
movl 12(%ebp) , %eax
movl 8(%ebp) , %edi
movl %edi , %ebx
movl $-1 , %ecx
cld
repne scasb
orl $ZERO , %ecx
notl %ecx
decl %ecx
movl %ebp , %esp
popl %ebp
addl %ecx , %ebx
#movl (%ebx) , %eax #return current char
movl %ebx , %eax # return string
ret