blob: 79e3c675a92333ef35f0ac51340cd13af6d3ba76 [file] [log] [blame]
Wolfgang Denk7b64fef2006-10-24 14:21:16 +02001/*
2 * Copyright (C) 2004-2006 Atmel Corporation
3 *
4 * See file CREDITS for list of people who contributed to this
5 * project.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License as
9 * published by the Free Software Foundation; either version 2 of
10 * the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
20 * MA 02111-1307 USA
21 */
22
23 /*
24 * r12: void *b
25 * r11: int c
26 * r10: size_t len
27 *
28 * Returns b in r12
29 */
Haavard Skinnemoen0c16eed2008-05-02 15:24:22 +020030 .section .text.memset, "ax", @progbits
Wolfgang Denk7b64fef2006-10-24 14:21:16 +020031
32 .global memset
33 .type memset, @function
34 .align 2
35memset:
36 mov r9, r12
37 mov r8, r12
38 or r11, r11, r11 << 8
39 andl r9, 3, COH
40 brne 1f
41
422: or r11, r11, r11 << 16
43 sub r10, 4
44 brlt 5f
45
46 /* Let's do some real work */
474: st.w r8++, r11
48 sub r10, 4
49 brge 4b
50
51 /*
52 * When we get here, we've got less than 4 bytes to set. r10
53 * might be negative.
54 */
555: sub r10, -4
56 reteq r12
57
58 /* Fastpath ends here, exactly 32 bytes from memset */
59
60 /* Handle unaligned count or pointer */
61 bld r10, 1
62 brcc 6f
63 st.b r8++, r11
64 st.b r8++, r11
65 bld r10, 0
66 retcc r12
676: st.b r8++, r11
68 mov pc, lr
69
70 /* Handle unaligned pointer */
711: sub r10, 4
72 brlt 5b
73 add r10, r9
74 lsl r9, 1
75 add pc, r9
76 st.b r8++, r11
77 st.b r8++, r11
78 st.b r8++, r11
79 rjmp 2b
80
81 .size memset, . - memset