kolibrios/drivers/ddk/string/_strnlen.S
Sergey Semyonov (Serge) 49cb0f914d ddk: fix strcpy
devman: scan pci root bus

git-svn-id: svn://kolibrios.org@1627 a494cfbc-eb01-0410-851d-a64ba20cac60
2010-09-26 22:57:18 +00:00

28 lines
586 B
ArmAsm

/* _strnlen() Author: Kees J. Bot */
/* 1 Jan 1994 */
/* size_t _strnlen(const char *s, size_t ecx) */
/* Return the length of a string. */
/* */
#include "asm.h"
ENTRY(_strnlen)
push %ebp
movl %esp, %ebp
push %edi
movl 8(%ebp), %edi /* edi = string */
xorb %al, %al /* Look for a zero byte */
movl %ecx, %edx /* Save maximum count */
cmpb $1, %cl /* 'Z' bit must be clear if ecx = 0 */
cld
repne scasb /* Look for zero */
jne no0
incl %ecx /* Don't count zero byte */
no0:
movl %edx, %eax
subl %ecx, %eax /* Compute bytes scanned */
pop %edi
pop %ebp
ret