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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [newlib/] [newlib/] [libc/] [machine/] [i386/] [strchr.S] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 56 joel
/*
2
 * ====================================================
3
 * Copyright (C) 1998 by Cygnus Solutions. 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 (strchr)
14
 
15
SYM (strchr):
16
 
17
        pushl ebp
18
        movl esp,ebp
19
        pushl edi
20
        pushl ebx
21
        xorl ebx,ebx
22
        movl 8(ebp),edi
23
        movb 12(ebp),bl
24
 
25
#ifndef __OPTIMIZE_SIZE__
26
/* check if string is aligned, if not do check one byte at a time */
27
        test $3,edi
28
        jne L9
29
 
30
/* create 4 byte mask which is just the desired byte repeated 4 times */
31
        movl ebx,ecx
32
        sall $8,ebx
33
        subl $4,edi
34
        orl ecx,ebx
35
        movl ebx,edx
36
        sall $16,ebx
37
        orl edx,ebx
38
 
39
/* loop performing 4 byte mask checking for 0 byte or desired byte */
40
        .p2align 4,,7
41
L10:
42
        addl $4,edi
43
        movl (edi),ecx
44
        leal -16843009(ecx),edx
45
        movl ecx,eax
46
        notl eax
47
        andl eax,edx
48
        testl $-2139062144,edx
49
        jne L9
50
 
51
        movl ebx,eax
52
        xorl ecx,eax
53
        leal -16843009(eax),edx
54
        notl eax
55
        andl eax,edx
56
        testl $-2139062144,edx
57
        je L10
58
#endif /* not __OPTIMIZE_SIZE__ */
59
 
60
/* loop while (*s && *s++ != c) */
61
L9:
62
        leal -1(edi),eax
63
        .p2align 4,,7
64
L15:
65
        incl eax
66
        movb (eax),dl
67
        testb dl,dl
68
        je L14
69
        cmpb bl,dl
70
        jne L15
71
 
72
L14:
73
/*  if (*s == c) return address otherwise return NULL */
74
        cmpb bl,(eax)
75
        je L19
76
        xorl eax,eax
77
 
78
L19:
79
        leal -8(ebp),esp
80
        popl ebx
81
        popl edi
82
        leave
83
        ret
84
 

powered by: WebSVN 2.1.0

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