diff options
Diffstat (limited to 'arch/blackfin/lib/strncmp.S')
-rw-r--r-- | arch/blackfin/lib/strncmp.S | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/arch/blackfin/lib/strncmp.S b/arch/blackfin/lib/strncmp.S new file mode 100644 index 000000000000..6da37c34a847 --- /dev/null +++ b/arch/blackfin/lib/strncmp.S | |||
@@ -0,0 +1,52 @@ | |||
1 | /* | ||
2 | * Copyright 2005-2010 Analog Devices Inc. | ||
3 | * | ||
4 | * Licensed under the ADI BSD license or the GPL-2 (or later) | ||
5 | */ | ||
6 | |||
7 | #include <linux/linkage.h> | ||
8 | |||
9 | /* void *strncpy(char *s1, const char *s2, size_t n); | ||
10 | * R0 = address (dest) | ||
11 | * R1 = address (src) | ||
12 | * R2 = size (n) | ||
13 | * Returns a pointer to the destination string dest | ||
14 | */ | ||
15 | |||
16 | #ifdef CONFIG_STRNCMP_L1 | ||
17 | .section .l1.text | ||
18 | #else | ||
19 | .text | ||
20 | #endif | ||
21 | |||
22 | .align 2 | ||
23 | |||
24 | ENTRY(_strncmp) | ||
25 | CC = R2 == 0; | ||
26 | if CC JUMP 5f; | ||
27 | |||
28 | P0 = R0 ; /* s1 */ | ||
29 | P1 = R1 ; /* s2 */ | ||
30 | 1: | ||
31 | R0 = B[P0++] (Z); /* get *s1 */ | ||
32 | R1 = B[P1++] (Z); /* get *s2 */ | ||
33 | CC = R0 == R1; /* compare a byte */ | ||
34 | if ! cc jump 3f; /* not equal, break out */ | ||
35 | CC = R0; /* at end of s1? */ | ||
36 | if ! cc jump 4f; /* yes, all done */ | ||
37 | R2 += -1; /* no, adjust count */ | ||
38 | CC = R2 == 0; | ||
39 | if ! cc jump 1b (bp); /* more to do, keep going */ | ||
40 | 2: | ||
41 | R0 = 0; /* strings are equal */ | ||
42 | jump.s 4f; | ||
43 | 3: | ||
44 | R0 = R0 - R1; /* *s1 - *s2 */ | ||
45 | 4: | ||
46 | RTS; | ||
47 | |||
48 | 5: | ||
49 | R0 = 0; | ||
50 | RTS; | ||
51 | |||
52 | ENDPROC(_strncmp) | ||