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 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 (memcmp) |
---|
14 | SOTYPE_FUNCTION(memcmp) |
---|
15 | |
---|
16 | SYM (memcmp): |
---|
17 | |
---|
18 | #ifdef __iamcu__ |
---|
19 | pushl edi |
---|
20 | pushl esi |
---|
21 | movl eax,edi |
---|
22 | movl edx,esi |
---|
23 | cld |
---|
24 | |
---|
25 | /* check if length is zero in which case just return 0 */ |
---|
26 | |
---|
27 | xorl eax,eax |
---|
28 | testl ecx,ecx |
---|
29 | jz L4 |
---|
30 | |
---|
31 | /* compare any unaligned bytes or remainder bytes */ |
---|
32 | repz |
---|
33 | cmpsb |
---|
34 | |
---|
35 | /* set output to be < 0 if less than, 0 if equal, or > 0 if greater than */ |
---|
36 | xorl edx,edx |
---|
37 | movb -1(esi),dl |
---|
38 | movb -1(edi),al |
---|
39 | subl edx,eax |
---|
40 | |
---|
41 | L4: |
---|
42 | popl esi |
---|
43 | popl edi |
---|
44 | #else |
---|
45 | pushl ebp |
---|
46 | movl esp,ebp |
---|
47 | subl $16,esp |
---|
48 | pushl ebx |
---|
49 | pushl edi |
---|
50 | pushl esi |
---|
51 | movl 8(ebp),edi |
---|
52 | movl 12(ebp),esi |
---|
53 | movl 16(ebp),ecx |
---|
54 | cld |
---|
55 | |
---|
56 | /* check if length is zero in which case just return 0 */ |
---|
57 | |
---|
58 | xorl eax,eax |
---|
59 | testl ecx,ecx |
---|
60 | jz L4 |
---|
61 | |
---|
62 | #ifndef __OPTIMIZE_SIZE__ |
---|
63 | |
---|
64 | /* if aligned on long boundary, compare doublewords at a time first */ |
---|
65 | |
---|
66 | movl edi,eax |
---|
67 | orl esi,eax |
---|
68 | testb $3,al |
---|
69 | jne BYTECMP |
---|
70 | movl ecx,ebx |
---|
71 | shrl $2,ecx /* calculate number of long words to compare */ |
---|
72 | repz |
---|
73 | cmpsl |
---|
74 | jz L5 |
---|
75 | subl $4,esi |
---|
76 | subl $4,edi |
---|
77 | movl $4,ecx |
---|
78 | jmp BYTECMP |
---|
79 | L5: |
---|
80 | andl $3,ebx /* calculate number of remaining bytes */ |
---|
81 | movl ebx,ecx |
---|
82 | |
---|
83 | #endif /* not __OPTIMIZE_SIZE__ */ |
---|
84 | |
---|
85 | BYTECMP: /* compare any unaligned bytes or remainder bytes */ |
---|
86 | repz |
---|
87 | cmpsb |
---|
88 | |
---|
89 | /* set output to be < 0 if less than, 0 if equal, or > 0 if greater than */ |
---|
90 | L3: |
---|
91 | xorl edx,edx |
---|
92 | movb -1(esi),dl |
---|
93 | xorl eax,eax |
---|
94 | movb -1(edi),al |
---|
95 | subl edx,eax |
---|
96 | |
---|
97 | L4: |
---|
98 | leal -28(ebp),esp |
---|
99 | popl esi |
---|
100 | popl edi |
---|
101 | popl ebx |
---|
102 | leave |
---|
103 | #endif |
---|
104 | ret |
---|
Note: See
TracBrowser
for help on using the repository browser.