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

Subversion Repositories or1k

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

Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

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