| lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 1 | /* | 
 | 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 | 
 | 19 | memcmp: | 
 | 20 | 	sub	len, 4 | 
 | 21 | 	brlt	.Lless_than_4 | 
 | 22 |  | 
 | 23 | 1:	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 |  | 
 | 34 | 1:	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 |  | 
 | 46 | 2:	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 |  | 
 | 58 | libc_hidden_def(memcmp) | 
 | 59 | #ifdef __UCLIBC_SUSV3_LEGACY__ | 
 | 60 | strong_alias(memcmp,bcmp) | 
 | 61 | #endif |