1
0
kolibrios/drivers/ddk/string/strrchr.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

36 lines
749 B
ArmAsm

/* strrchr() Author: Kees J. Bot */
/* 2 Jan 1994 */
/* char *strrchr(const char *s, int c) */
/* Look for the last occurrence a character in a string. */
/* */
#include "asm.h"
ENTRY(strrchr)
push %ebp
movl %esp, %ebp
push %edi
movl 8(%ebp), %edi /* edi = string */
movl $-1, %ecx
xorb %al, %al
cld
repne scasb /* Look for the end of the string */
notl %ecx /* -1 - ecx = Length of the string + null */
decl %edi /* Put edi back on the zero byte */
movb 12(%ebp), %al /* The character to look for */
std /* Downwards search */
repne scasb
cld /* Direction bit back to default */
jne failure
leal 1(%edi), %eax /* Found it */
pop %edi
pop %ebp
ret
failure:
xorl %eax, %eax /* Not there */
pop %edi
pop %ebp
ret