Blackfin: move string functions to normal lib/ assembly
[pandora-kernel.git] / arch / blackfin / lib / strncpy.S
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 *dest, const char *src, size_t n);
10  * R0 = address (dest)
11  * R1 = address (src)
12  * R2 = size
13  * Returns a pointer to the destination string dest
14  */
15
16 #ifdef CONFIG_STRNCPY_L1
17 .section .l1.text
18 #else
19 .text
20 #endif
21
22 .align 2
23
24 ENTRY(_strncpy)
25         CC = R2 == 0;
26         if CC JUMP 4f;
27         P0 = R0 ;       /* dst*/
28         P1 = R1 ;       /* src*/
29
30 1:
31         R1 = B [P1++] (Z);
32         B [P0++] = R1;
33         CC = R1;
34         if ! cc jump 2f;
35         R2 += -1;
36         CC = R2 == 0;
37         if ! cc jump 1b (bp);
38         jump 4f;
39 2:
40         /* if src is shorter than n, we need to null pad bytes in dest */
41         R1 = 0;
42 3:
43         R2 += -1;
44         CC = R2 == 0;
45         if cc jump 4f;
46         B [P0++] = R1;
47         jump 3b;
48
49 4:
50         RTS;
51
52 ENDPROC(_strncpy)