blob: ac2d38860e77c76b554f6c6bcfea8a4669d766e7 [file] [log] [blame]
Wolfgang Denk7b64fef2006-10-24 14:21:16 +02001/*
2 * Copyright (C) 2004-2006 Atmel Corporation
3 *
Wolfgang Denk1a459662013-07-08 09:37:19 +02004 * SPDX-License-Identifier: GPL-2.0+
Wolfgang Denk7b64fef2006-10-24 14:21:16 +02005 */
6
7 /*
8 * r12: void *b
9 * r11: int c
10 * r10: size_t len
11 *
12 * Returns b in r12
13 */
Haavard Skinnemoen0c16eed2008-05-02 15:24:22 +020014 .section .text.memset, "ax", @progbits
Wolfgang Denk7b64fef2006-10-24 14:21:16 +020015
16 .global memset
17 .type memset, @function
18 .align 2
19memset:
20 mov r9, r12
21 mov r8, r12
22 or r11, r11, r11 << 8
23 andl r9, 3, COH
24 brne 1f
25
262: or r11, r11, r11 << 16
27 sub r10, 4
28 brlt 5f
29
30 /* Let's do some real work */
314: st.w r8++, r11
32 sub r10, 4
33 brge 4b
34
35 /*
36 * When we get here, we've got less than 4 bytes to set. r10
37 * might be negative.
38 */
395: sub r10, -4
40 reteq r12
41
42 /* Fastpath ends here, exactly 32 bytes from memset */
43
44 /* Handle unaligned count or pointer */
45 bld r10, 1
46 brcc 6f
47 st.b r8++, r11
48 st.b r8++, r11
49 bld r10, 0
50 retcc r12
516: st.b r8++, r11
52 mov pc, lr
53
54 /* Handle unaligned pointer */
551: sub r10, 4
56 brlt 5b
57 add r10, r9
58 lsl r9, 1
59 add pc, r9
60 st.b r8++, r11
61 st.b r8++, r11
62 st.b r8++, r11
63 rjmp 2b
64
65 .size memset, . - memset