blob: ae6cc9189fbca81233a23e70e023454c81b8da4d [file] [log] [blame]
lh9ed821d2023-04-07 01:36:19 -07001/*
2 * Copyright (C) 2004-2007 Atmel Corporation
3 *
4 * This file is subject to the terms and conditions of the GNU Lesser General
5 * Public License. See the file "COPYING.LIB" in the main directory of this
6 * archive for more details.
7 */
8
9#include <features.h>
10
11#define s1 r12
12#define s2 r11
13#define len r10
14
15 .text
16 .global memcmp
17 .type memcmp, @function
18 .align 1
19memcmp:
20 sub len, 4
21 brlt .Lless_than_4
22
231: ld.w r8, s1++
24 ld.w r9, s2++
25 cp.w r8, r9
26 brne .Lfound_word
27 sub len, 4
28 brge 1b
29
30.Lless_than_4:
31 sub len, -4
32 reteq 0
33
341: ld.ub r8, s1++
35 ld.ub r9, s2++
36 sub r8, r9
37 retne r8
38 sub len, 1
39 brgt 1b
40
41 retal 0
42
43.Lfound_word:
44 mov len, 4
45
462: bfextu r11, r9, 24, 8
47 bfextu r12, r8, 24, 8
48 sub r12, r11
49 retne r12
50 lsl r8, 8
51 lsl r9, 8
52 sub len, 1
53 brne 2b
54 retal r12
55
56 .size memcmp, . - memcmp
57
58libc_hidden_def(memcmp)
59#ifdef __UCLIBC_SUSV3_LEGACY__
60strong_alias(memcmp,bcmp)
61#endif