Welcome to mirror list, hosted at ThFree Co, Russian Federation.

memcmp.c « xscale « machine « libc « newlib - cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 15ca9b1d10ec94815a6f78709ca26fab6cbdb618 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
#if defined __thumb__

#include "../../string/memcmp.c"

#else

#include <string.h>
#include "xscale.h"

int
memcmp (const void *s1, const void *s2, size_t len)
{
  int result;
  asm (
#ifndef __OPTIMIZE_SIZE__ 
"		
	cmp	%2, #0x3
	bls	6f
	and	r2, %0, #0x3
	and	r3, %1, #0x3
	cmp	r2, r3
	bne	6f
	mov	lr, %0
	mov	r4, %1
	cmp	r2, #0x0
	beq	3f
	b	1f
0:
	ldrb	r2, [lr], #1	@ zero_extendqisi2
"	PRELOADSTR("lr") "
	ldrb	r3, [r4], #1	@ zero_extendqisi2
"	PRELOADSTR("r4") "
	cmp	r2, r3
	bne	5f
	tst	lr, #0x3
	beq	3f
1:
	sub	%2, %2, #1
	cmn	%2, #0x1
	bne	0b
	b	4f

0:
	cmp	%2, #0x7
	bls	3f
	ldmia	lr,{r2, r3}
	ldmia	r4,{r5, r6}
	sub	%2, %2, #0x4
	cmp	r2, r5
	bne	1f
	sub	%2, %2, #0x4
	add	lr, lr, #0x4
	add	r4, r4, #0x4
	cmp	r3, r6
	beq	0b
1:
	add	%2, %2, #0x4
	sub	%0, lr, #0x4
	sub	%1, r4, #0x4
	b	6f
3:
	cmp	%2, #0x3
	bls	1f
	ldr	r2, [lr], #4
	ldr	r3, [r4], #4
	sub	%2, %2, #4
	cmp	r2, r3
	bne	1f
0:
	cmp	%2, #0x3
	bls	1f
	ldr	r2, [lr], #4
"	PRELOADSTR("lr") "
	ldr	r3, [r4], #4
"	PRELOADSTR("r4") "
	sub	%2, %2, #4
	cmp	r2, r3
	beq	0b
1:
	sub	%0, lr, #0x4
	sub	%1, r4, #0x4
	add	%2, %2, #4
"
#endif /* !__OPTIMIZE_SIZE__ */
"
6:				
	sub	%2, %2, #1
	cmn	%2, #0x1
	beq	4f
0:
	ldrb	r2, [%0], #1	@ zero_extendqisi2
"	PRELOADSTR("%0") "
	ldrb	r3, [%1], #1	@ zero_extendqisi2
"	PRELOADSTR("%1") "
	cmp	r2, r3
	bne	5f
	sub	%2, %2, #1
	cmn	%2, #0x1
	bne	0b
4:		
	mov	r3, r2
5:		
	rsb	%0, r3, r2"
       : "=r" (result), "=&r" (s2), "=&r" (len)
       : "0" (s1), "1" (s2), "2" (len)
       : "r2", "r3", "r4", "r5", "r6", "cc", "lr");
  return result;
}
#endif