OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [newlib-1.17.0/] [newlib/] [libc/] [machine/] [i386/] [strlen.S] - Blame information for rev 148

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 148 jeremybenn
/*
2
 * ====================================================
3
 * Copyright (C) 1998, 2002, 2008 by Red Hat Inc. All rights reserved.
4
 *
5
 * Permission to use, copy, modify, and distribute this
6
 * software is freely granted, provided that this notice
7
 * is preserved.
8
 * ====================================================
9
 */
10
 
11
        #include "i386mach.h"
12
 
13
        .global SYM (strlen)
14
       SOTYPE_FUNCTION(strlen)
15
 
16
SYM (strlen):
17
 
18
        pushl ebp
19
        movl esp,ebp
20
        pushl edi
21
        movl 8(ebp),edx
22
 
23
#ifdef __OPTIMIZE_SIZE__
24
        cld
25
        movl edx,edi
26
        movl $4294967295,ecx
27
        xor eax,eax
28
        repnz
29
        scasb
30
#else
31
/* Modern x86 hardware is much faster at double-word
32
   manipulation than with bytewise repnz scasb.  */
33
 
34
/* Do byte-wise checks until string is aligned.  */
35
        movl edx,edi
36
        test $3,edi
37
        je L5
38
        movb (edi),cl
39
        incl edi
40
        testb cl,cl
41
        je L15
42
 
43
        test $3,edi
44
        je L5
45
        movb (edi),cl
46
        incl edi
47
        testb cl,cl
48
        je L15
49
 
50
        test $3,edi
51
        je L5
52
        movb (edi),cl
53
        incl edi
54
        testb cl,cl
55
        je L15
56
 
57
L5:
58
        subl $4,edi
59
 
60
/* loop performing 4 byte mask checking for desired 0 byte */
61
        .p2align 4,,7
62
L10:
63
        addl $4,edi
64
        movl (edi),ecx
65
        leal -16843009(ecx),eax
66
        notl ecx
67
        andl ecx,eax
68
        testl $-2139062144,eax
69
        je L10
70
 
71
/* Find which of four bytes is 0.  */
72
        notl ecx
73
        incl edi
74
 
75
        testb cl,cl
76
        je L15
77
        incl edi
78
        shrl $8,ecx
79
 
80
        testb cl,cl
81
        je L15
82
        incl edi
83
        shrl $8,ecx
84
 
85
        testb cl,cl
86
        je L15
87
        incl edi
88
 
89
#endif
90
 
91
L15:
92
        subl edx,edi
93
        leal -1(edi),eax
94
 
95
        leal -4(ebp),esp
96
        popl edi
97
        leave
98
        ret

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.