aboutsummaryrefslogtreecommitdiffstats
path: root/arch/avr32/lib/memset.S
diff options
context:
space:
mode:
Diffstat (limited to 'arch/avr32/lib/memset.S')
-rw-r--r--arch/avr32/lib/memset.S72
1 files changed, 72 insertions, 0 deletions
diff --git a/arch/avr32/lib/memset.S b/arch/avr32/lib/memset.S
new file mode 100644
index 000000000000..40da32c0480c
--- /dev/null
+++ b/arch/avr32/lib/memset.S
@@ -0,0 +1,72 @@
1/*
2 * Copyright (C) 2004-2006 Atmel Corporation
3 *
4 * Based on linux/arch/arm/lib/memset.S
5 * Copyright (C) 1995-2000 Russell King
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 *
11 * ASM optimised string functions
12 */
13#include <asm/asm.h>
14
15 /*
16 * r12: void *b
17 * r11: int c
18 * r10: size_t len
19 *
20 * Returns b in r12
21 */
22 .text
23 .global memset
24 .type memset, @function
25 .align 5
26memset:
27 mov r9, r12
28 mov r8, r12
29 or r11, r11, r11 << 8
30 andl r9, 3, COH
31 brne 1f
32
332: or r11, r11, r11 << 16
34 sub r10, 4
35 brlt 5f
36
37 /* Let's do some real work */
384: st.w r8++, r11
39 sub r10, 4
40 brge 4b
41
42 /*
43 * When we get here, we've got less than 4 bytes to set. r10
44 * might be negative.
45 */
465: sub r10, -4
47 reteq r12
48
49 /* Fastpath ends here, exactly 32 bytes from memset */
50
51 /* Handle unaligned count or pointer */
52 bld r10, 1
53 brcc 6f
54 st.b r8++, r11
55 st.b r8++, r11
56 bld r10, 0
57 retcc r12
586: st.b r8++, r11
59 retal r12
60
61 /* Handle unaligned pointer */
621: sub r10, 4
63 brlt 5b
64 add r10, r9
65 lsl r9, 1
66 add pc, r9
67 st.b r8++, r11
68 st.b r8++, r11
69 st.b r8++, r11
70 rjmp 2b
71
72 .size memset, . - memset