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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [newlib-1.18.0/] [newlib/] [libc/] [machine/] [i386/] [memchr.S] - Blame information for rev 301

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

Line No. Rev Author Line
1 207 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 (memchr)
14
       SOTYPE_FUNCTION(memchr)
15
 
16
SYM (memchr):
17
        pushl   ebp
18
        movl    esp,ebp
19
        pushl   edi
20
        movzbl  12(ebp),eax
21
        movl    16(ebp),ecx
22
        movl    8(ebp),edi
23
 
24
        xorl    edx,edx
25
        testl   ecx,ecx
26
        jz      L20
27
 
28
#ifdef __OPTIMIZE_SIZE__
29
 
30
        cld
31
        repnz
32
        scasb
33
 
34
        setnz   dl
35
        decl    edi
36
 
37
#else /* !__OPTIMIZE_SIZE__ */
38
/* Do byte-wise checks until string is aligned.  */
39
        testl   $3,edi
40
        je      L5
41
        cmpb    (edi),al
42
        je      L15
43
        incl    edi
44
        decl    ecx
45
        je      L20
46
 
47
        testl   $3,edi
48
        je      L5
49
        cmpb    (edi),al
50
        je      L15
51
        incl    edi
52
        decl    ecx
53
        je      L20
54
 
55
        testl   $3,edi
56
        je      L5
57
        cmpb    (edi),al
58
        je      L15
59
        incl    edi
60
        decl    ecx
61
        je      L20
62
 
63
/* Create a mask, then check a word at a time.  */
64
L5:
65
        movb    al,ah
66
        movl    eax,edx
67
        sall    $16,edx
68
        orl     edx,eax
69
        pushl   ebx
70
 
71
        .p2align 4,,7
72
L8:
73
        subl    $4,ecx
74
        jc      L9
75
        movl    (edi),edx
76
        addl    $4,edi
77
        xorl    eax,edx
78
        leal    -16843009(edx),ebx
79
        notl    edx
80
        andl    edx,ebx
81
        testl   $-2139062144,ebx
82
        je      L8
83
 
84
        subl    $4,edi
85
 
86
L9:
87
        popl    ebx
88
        xorl    edx,edx
89
        addl    $4,ecx
90
        je      L20
91
 
92
/* Final byte-wise checks.  */
93
        .p2align 4,,7
94
L10:
95
        cmpb    (edi),al
96
        je      L15
97
        incl    edi
98
        decl    ecx
99
        jne     L10
100
 
101
        xorl    edi,edi
102
 
103
#endif /* !__OPTIMIZE_SIZE__ */
104
 
105
L15:
106
        decl    edx
107
        andl    edi,edx
108
L20:
109
        movl    edx,eax
110
 
111
        leal    -4(ebp),esp
112
        popl    edi
113
        leave
114
        ret

powered by: WebSVN 2.1.0

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