Last change
on this file since 444 was
444,
checked in by satin@…, 6 years ago
|
add newlib,libalmos-mkh, restructure shared_syscalls.h and mini-libc
|
File size:
1.7 KB
|
Line | |
---|
1 | /* |
---|
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 | #ifdef __iamcu__ |
---|
18 | pushl edi |
---|
19 | movl eax,edi |
---|
20 | movl edx,eax |
---|
21 | xorl edx,edx |
---|
22 | testl ecx,ecx |
---|
23 | jz L20 |
---|
24 | |
---|
25 | repnz |
---|
26 | scasb |
---|
27 | |
---|
28 | setnz dl |
---|
29 | decl edi |
---|
30 | |
---|
31 | decl edx |
---|
32 | andl edi,edx |
---|
33 | L20: |
---|
34 | movl edx,eax |
---|
35 | |
---|
36 | popl edi |
---|
37 | #else |
---|
38 | pushl ebp |
---|
39 | movl esp,ebp |
---|
40 | pushl edi |
---|
41 | movzbl 12(ebp),eax |
---|
42 | movl 16(ebp),ecx |
---|
43 | movl 8(ebp),edi |
---|
44 | xorl edx,edx |
---|
45 | testl ecx,ecx |
---|
46 | jz L20 |
---|
47 | |
---|
48 | #ifdef __OPTIMIZE_SIZE__ |
---|
49 | |
---|
50 | cld |
---|
51 | repnz |
---|
52 | scasb |
---|
53 | |
---|
54 | setnz dl |
---|
55 | decl edi |
---|
56 | |
---|
57 | #else /* !__OPTIMIZE_SIZE__ */ |
---|
58 | /* Do byte-wise checks until string is aligned. */ |
---|
59 | testl $3,edi |
---|
60 | je L5 |
---|
61 | cmpb (edi),al |
---|
62 | je L15 |
---|
63 | incl edi |
---|
64 | decl ecx |
---|
65 | je L20 |
---|
66 | |
---|
67 | testl $3,edi |
---|
68 | je L5 |
---|
69 | cmpb (edi),al |
---|
70 | je L15 |
---|
71 | incl edi |
---|
72 | decl ecx |
---|
73 | je L20 |
---|
74 | |
---|
75 | testl $3,edi |
---|
76 | je L5 |
---|
77 | cmpb (edi),al |
---|
78 | je L15 |
---|
79 | incl edi |
---|
80 | decl ecx |
---|
81 | je L20 |
---|
82 | |
---|
83 | /* Create a mask, then check a word at a time. */ |
---|
84 | L5: |
---|
85 | movb al,ah |
---|
86 | movl eax,edx |
---|
87 | sall $16,edx |
---|
88 | orl edx,eax |
---|
89 | pushl ebx |
---|
90 | |
---|
91 | .p2align 4,,7 |
---|
92 | L8: |
---|
93 | subl $4,ecx |
---|
94 | jc L9 |
---|
95 | movl (edi),edx |
---|
96 | addl $4,edi |
---|
97 | xorl eax,edx |
---|
98 | leal -16843009(edx),ebx |
---|
99 | notl edx |
---|
100 | andl edx,ebx |
---|
101 | testl $-2139062144,ebx |
---|
102 | je L8 |
---|
103 | |
---|
104 | subl $4,edi |
---|
105 | |
---|
106 | L9: |
---|
107 | popl ebx |
---|
108 | xorl edx,edx |
---|
109 | addl $4,ecx |
---|
110 | je L20 |
---|
111 | |
---|
112 | /* Final byte-wise checks. */ |
---|
113 | .p2align 4,,7 |
---|
114 | L10: |
---|
115 | cmpb (edi),al |
---|
116 | je L15 |
---|
117 | incl edi |
---|
118 | decl ecx |
---|
119 | jne L10 |
---|
120 | |
---|
121 | xorl edi,edi |
---|
122 | |
---|
123 | #endif /* !__OPTIMIZE_SIZE__ */ |
---|
124 | |
---|
125 | L15: |
---|
126 | decl edx |
---|
127 | andl edi,edx |
---|
128 | L20: |
---|
129 | movl edx,eax |
---|
130 | |
---|
131 | leal -4(ebp),esp |
---|
132 | popl edi |
---|
133 | leave |
---|
134 | #endif |
---|
135 | ret |
---|
Note: See
TracBrowser
for help on using the repository browser.