blob: 8a16f39d4b05d6360d383e20d57230d7b5647c89 [file] [log] [blame]
yuezonghe824eb0c2024-06-27 02:32:26 -07001/* strncpy implementation for SUPERH
2 *
3 * Copyright (C) 2009 STMicroelectronics Ltd.
4 *
5 * Author: Giuseppe Cavallaro <peppe.cavallaro@st.com>
6 *
7 * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
8 */
9
10/*
11 char *strncpy(char *dest, const char *src, size_t n);
12 */
13
14#include <sysdep.h>
15
16ENTRY(strncpy)
17 mov #0,r0
18 bra 2f
19 mov r4,r2
201:
21 mov.b r1,@(r0,r2)
22 add #1,r0
232:
24 cmp/hs r6,r0
25 bt 5f
26 mov.b @(r0,r5),r1
27 tst r1,r1
28 bf/s 1b
29 cmp/hs r6,r0
30 bra 4f
31 nop
323:
33 mov.b r1,@(r0,r2)
34 add #1,r0
35 cmp/hs r6,r0
364:
37 bf/s 3b
38 mov #0,r1
395:
40 rts
41 mov r2,r0
42END(strncpy)
43libc_hidden_def(strncpy)