URL
https://opencores.org/ocsvn/openrisc/openrisc/trunk
Only display areas with differences |
Details |
Blame |
View Log
Rev 207 |
Rev 345 |
/*
|
/*
|
* ====================================================
|
* ====================================================
|
* Copyright (C) 1998, 2002, 2008 by Red Hat Inc. All rights reserved.
|
* Copyright (C) 1998, 2002, 2008 by Red Hat Inc. All rights reserved.
|
*
|
*
|
* Permission to use, copy, modify, and distribute this
|
* Permission to use, copy, modify, and distribute this
|
* software is freely granted, provided that this notice
|
* software is freely granted, provided that this notice
|
* is preserved.
|
* is preserved.
|
* ====================================================
|
* ====================================================
|
*/
|
*/
|
|
|
#include "i386mach.h"
|
#include "i386mach.h"
|
|
|
.global SYM (strlen)
|
.global SYM (strlen)
|
SOTYPE_FUNCTION(strlen)
|
SOTYPE_FUNCTION(strlen)
|
|
|
SYM (strlen):
|
SYM (strlen):
|
|
|
pushl ebp
|
pushl ebp
|
movl esp,ebp
|
movl esp,ebp
|
pushl edi
|
pushl edi
|
movl 8(ebp),edx
|
movl 8(ebp),edx
|
|
|
#ifdef __OPTIMIZE_SIZE__
|
#ifdef __OPTIMIZE_SIZE__
|
cld
|
cld
|
movl edx,edi
|
movl edx,edi
|
movl $4294967295,ecx
|
movl $4294967295,ecx
|
xor eax,eax
|
xor eax,eax
|
repnz
|
repnz
|
scasb
|
scasb
|
#else
|
#else
|
/* Modern x86 hardware is much faster at double-word
|
/* Modern x86 hardware is much faster at double-word
|
manipulation than with bytewise repnz scasb. */
|
manipulation than with bytewise repnz scasb. */
|
|
|
/* Do byte-wise checks until string is aligned. */
|
/* Do byte-wise checks until string is aligned. */
|
movl edx,edi
|
movl edx,edi
|
test $3,edi
|
test $3,edi
|
je L5
|
je L5
|
movb (edi),cl
|
movb (edi),cl
|
incl edi
|
incl edi
|
testb cl,cl
|
testb cl,cl
|
je L15
|
je L15
|
|
|
test $3,edi
|
test $3,edi
|
je L5
|
je L5
|
movb (edi),cl
|
movb (edi),cl
|
incl edi
|
incl edi
|
testb cl,cl
|
testb cl,cl
|
je L15
|
je L15
|
|
|
test $3,edi
|
test $3,edi
|
je L5
|
je L5
|
movb (edi),cl
|
movb (edi),cl
|
incl edi
|
incl edi
|
testb cl,cl
|
testb cl,cl
|
je L15
|
je L15
|
|
|
L5:
|
L5:
|
subl $4,edi
|
subl $4,edi
|
|
|
/* loop performing 4 byte mask checking for desired 0 byte */
|
/* loop performing 4 byte mask checking for desired 0 byte */
|
.p2align 4,,7
|
.p2align 4,,7
|
L10:
|
L10:
|
addl $4,edi
|
addl $4,edi
|
movl (edi),ecx
|
movl (edi),ecx
|
leal -16843009(ecx),eax
|
leal -16843009(ecx),eax
|
notl ecx
|
notl ecx
|
andl ecx,eax
|
andl ecx,eax
|
testl $-2139062144,eax
|
testl $-2139062144,eax
|
je L10
|
je L10
|
|
|
/* Find which of four bytes is 0. */
|
/* Find which of four bytes is 0. */
|
notl ecx
|
notl ecx
|
incl edi
|
incl edi
|
|
|
testb cl,cl
|
testb cl,cl
|
je L15
|
je L15
|
incl edi
|
incl edi
|
shrl $8,ecx
|
shrl $8,ecx
|
|
|
testb cl,cl
|
testb cl,cl
|
je L15
|
je L15
|
incl edi
|
incl edi
|
shrl $8,ecx
|
shrl $8,ecx
|
|
|
testb cl,cl
|
testb cl,cl
|
je L15
|
je L15
|
incl edi
|
incl edi
|
|
|
#endif
|
#endif
|
|
|
L15:
|
L15:
|
subl edx,edi
|
subl edx,edi
|
leal -1(edi),eax
|
leal -1(edi),eax
|
|
|
leal -4(ebp),esp
|
leal -4(ebp),esp
|
popl edi
|
popl edi
|
leave
|
leave
|
ret
|
ret
|
|
|
© copyright 1999-2024
OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.