blob: f73bd43e77543c38dbd4be70fee53caf4ff69fd3 [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 strcmp
17 .type strcmp, @function
18 .align 1
19strcmp:
20 mov r8, 3
21 tst s1, r8
22 brne .Lunaligned_s1
23 tst s2, r8
24 brne .Lunaligned_s2
25
261: ld.w r8, s1++
27 ld.w r9, s2++
28 cp.w r8, r9
29 brne 2f
30 tnbz r8
31 brne 1b
32 retal 0
33
342: bfextu r12, r8, 24, 8
35 bfextu r11, r9, 24, 8
36 sub r12, r11
37 retne r12
38 cp.w r11, 0
39 reteq 0
40 bfextu r12, r8, 16, 8
41 bfextu r11, r9, 16, 8
42 sub r12, r11
43 retne r12
44 cp.w r11, 0
45 reteq 0
46 bfextu r12, r8, 8, 8
47 bfextu r11, r9, 8, 8
48 sub r12, r11
49 retne r12
50 cp.w r11, 0
51 reteq 0
52 bfextu r12, r8, 0, 8
53 bfextu r11, r9, 0, 8
54 sub r12, r11
55 retal r12
56
57.Lunaligned_s1:
583: tst s1, r8
59 breq 4f
60 ld.ub r10, s1++
61 ld.ub r9, s2++
62 sub r10, r9
63 retne r10
64 cp.w r9, 0
65 brne 3b
66 retal r10
67
684: tst s2, r8
69 breq 1b
70
71.Lunaligned_s2:
72 /*
73 * s1 and s2 can't both be aligned, and unaligned word loads
74 * can trigger spurious exceptions if we cross a page boundary.
75 * Do it the slow way...
76 */
771: ld.ub r8, s1++
78 ld.ub r9, s2++
79 sub r8, r9
80 retne r8
81 cp.w r9, 0
82 brne 1b
83 retal 0
84
85 .size strcmp, . - strcmp
86
87libc_hidden_def(strcmp)
88#ifndef __UCLIBC_HAS_LOCALE__
89strong_alias(strcmp, strcoll)
90libc_hidden_def(strcoll)
91#endif