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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [newlib/] [newlib/] [libc/] [machine/] [i386/] [memcmp.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 (memcmp)
14
 
15
SYM (memcmp):
16
 
17
        pushl ebp
18
        movl esp,ebp
19
        subl $16,esp
20
        pushl ebx
21
        pushl edi
22
        pushl esi
23
        movl 8(ebp),edi
24
        movl 12(ebp),esi
25
        movl 16(ebp),ecx
26
        cld
27
 
28
/* check if length is zero in which case just return 0 */
29
 
30
        xorl eax,eax
31
        testl ecx,ecx
32
        jz L4
33
 
34
#ifndef __OPTIMIZE_SIZE__
35
 
36
/* if aligned on long boundary, compare doublewords at a time first */
37
 
38
        movl edi,eax
39
        orl esi,eax
40
        testb $3,al
41
        jne BYTECMP
42
        movl ecx,ebx
43
        shrl $2,ecx             /* calculate number of long words to compare */
44
        repz
45
        cmpsl
46
        jz L5
47
        subl $4,esi
48
        subl $4,edi
49
        movl $4,ecx
50
        jmp BYTECMP
51
L5:
52
        andl $3,ebx             /* calculate number of remaining bytes */
53
        movl ebx,ecx
54
 
55
#endif /* not __OPTIMIZE_SIZE__ */
56
 
57
BYTECMP: /* compare any unaligned bytes or remainder bytes */
58
        repz
59
        cmpsb
60
 
61
/* set output to be < 0 if less than, 0 if equal, or > 0 if greater than */
62
L3:
63
        xorl edx,edx
64
        movb -1(esi),dl
65
        xorl eax,eax
66
        movb -1(edi),al
67
        subl edx,eax
68
 
69
L4:
70
        leal -28(ebp),esp
71
        popl esi
72
        popl edi
73
        popl ebx
74
        leave
75
        ret

powered by: WebSVN 2.1.0

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