~linaro-toolchain-dev/cortex-strings/trunk

« back to all changes in this revision

Viewing changes to src/reference/glibc/memset.S

  • Committer: Michael Hope
  • Date: 2010-08-26 22:19:29 UTC
  • Revision ID: michael.hope@linaro.org-20100826221929-ppeg01mnpx34aqrp
Pulled in the initial versions

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* Copyright (C) 1998, 2003 Free Software Foundation, Inc.
 
2
   This file is part of the GNU C Library.
 
3
   Contributed by Philip Blundell <philb@gnu.org>
 
4
 
 
5
   The GNU C Library is free software; you can redistribute it and/or
 
6
   modify it under the terms of the GNU Lesser General Public
 
7
   License as published by the Free Software Foundation; either
 
8
   version 2.1 of the License, or (at your option) any later version.
 
9
 
 
10
   The GNU C Library is distributed in the hope that it will be useful,
 
11
   but WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
13
   Lesser General Public License for more details.
 
14
 
 
15
   You should have received a copy of the GNU Lesser General Public
 
16
   License along with the GNU C Library; if not, write to the Free
 
17
   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
 
18
   02111-1307 USA.  */
 
19
 
 
20
#include <sysdep.h>
 
21
 
 
22
/* void *memset (dstpp, c, len) */
 
23
 
 
24
ENTRY(memset)
 
25
        mov     r3, r0
 
26
        cmp     r2, #8
 
27
        bcc     2f              @ less than 8 bytes to move
 
28
 
 
29
1:
 
30
        tst     r3, #3          @ aligned yet?
 
31
        strneb  r1, [r3], #1
 
32
        subne   r2, r2, #1
 
33
        bne     1b
 
34
 
 
35
        and     r1, r1, #255    @ clear any sign bits
 
36
        orr     r1, r1, r1, lsl $8
 
37
        orr     r1, r1, r1, lsl $16
 
38
        mov     ip, r1
 
39
 
 
40
1:
 
41
        subs    r2, r2, #8
 
42
        stmcsia r3!, {r1, ip}   @ store up to 32 bytes per loop iteration
 
43
        subcss  r2, r2, #8
 
44
        stmcsia r3!, {r1, ip}
 
45
        subcss  r2, r2, #8
 
46
        stmcsia r3!, {r1, ip}
 
47
        subcss  r2, r2, #8
 
48
        stmcsia r3!, {r1, ip}
 
49
        bcs     1b
 
50
 
 
51
        and     r2, r2, #7
 
52
2:
 
53
        subs    r2, r2, #1      @ store up to 4 bytes per loop iteration
 
54
        strcsb  r1, [r3], #1
 
55
        subcss  r2, r2, #1
 
56
        strcsb  r1, [r3], #1
 
57
        subcss  r2, r2, #1
 
58
        strcsb  r1, [r3], #1
 
59
        subcss  r2, r2, #1
 
60
        strcsb  r1, [r3], #1
 
61
        bcs     2b
 
62
        
 
63
        DO_RET(lr)
 
64
END(memset)
 
65
libc_hidden_builtin_def (memset)