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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [newlib-1.17.0/] [newlib/] [libc/] [machine/] [i386/] [memcmp.S] - Blame information for rev 438

Go to most recent revision | Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

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