Removed excessive traces in loadelf.c
[marionette.git] / libc / memcmp.S
blob5896685257aeb1384470120664f771b8c054e725
1 /*
2  *    Copyright (c) 2008 Joshua Phillips. All rights reserved.
3  *  
4  *  Redistribution and use in source and binary forms, with or without
5  *  modification, are permitted provided that the following conditions are
6  *  met:
7  *  
8  *    1. Redistributions of source code must retain the above copyright
9  *       notice, this list of conditions and the following disclaimer.
10  *    2. Redistributions in binary form must reproduce the above copyright
11  *       notice, this list of conditions and the following disclaimer in
12  *       the documentation and/or other materials provided with the
13  *       distribution.
14  *  
15  *  THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
16  *  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17  *  OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18  *  DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
19  *  DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20  *  DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
21  *  GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22  *  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
23  *  IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
24  *  OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
25  *  IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26  */
28 .global memcmp
30 .section .text.memcmp
32 memcmp: // (s1, s2, size)
33     pushl %ebp
34     movl %esp,%ebp
35     pushl %ebx
36     movl 8(%ebp),%eax
37     movl 12(%ebp),%edx
38     movl 16(%ebp),%ecx
39     // do it the simple way (tee hee)
41     movb (%eax),%bl
42     movb (%edx),%bh
43     cmpb %bl,%bh
44     jb 2f
45     ja 3f
46     incl %eax
47     incl %edx
48     decl %ecx
49     jnz 1b
50     xorl %eax,%eax
51     jmp 9f
53     movl $-1,%eax
54     jmp 9f
56     movl $1,%eax
58     popl %ebx
59     movl %ebp,%esp
60     popl %ebp
61     ret