2 * linux/arch/arm/lib/memset.S
4 * Copyright (C) 1995-2000 Russell King
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
10 * ASM optimised string functions
12 #include <linux/linkage.h>
13 #include <asm/assembler.h>
19 ands r3, r0, #3 @ 1 unaligned?
20 mov ip, r0 @ preserve r0 as return value
23 * we know that the pointer in ip is aligned to a word boundary.
25 1: orr r1, r1, r1, lsl #8
26 orr r1, r1, r1, lsl #16
34 * We need 2 extra registers for this loop - use r8 and the LR
41 stmgeia ip!, {r1, r3, r8, lr} @ 64 bytes at a time.
42 stmgeia ip!, {r1, r3, r8, lr}
43 stmgeia ip!, {r1, r3, r8, lr}
44 stmgeia ip!, {r1, r3, r8, lr}
46 ldmeqfd sp!, {r8, pc} @ Now <64 bytes to go.
48 * No need to correct the count; we're only testing bits from now on
51 stmneia ip!, {r1, r3, r8, lr}
52 stmneia ip!, {r1, r3, r8, lr}
54 stmneia ip!, {r1, r3, r8, lr}
60 * This version aligns the destination pointer in order to write
61 * whole cache lines at once.
64 stmfd sp!, {r4-r8, lr}
79 movs r8, r8, lsl #(32 - 4)
80 stmcsia ip!, {r4, r5, r6, r7}
87 stmgeia ip!, {r1, r3-r8, lr}
88 stmgeia ip!, {r1, r3-r8, lr}
90 ldmeqfd sp!, {r4-r8, pc}
93 stmneia ip!, {r1, r3-r8, lr}
96 ldmfd sp!, {r4-r8, lr}
101 stmneia ip!, {r1, r3}
105 * When we get here, we've got less than 4 bytes to zero. We
106 * may have an unaligned pointer as well.
115 6: subs r2, r2, #4 @ 1 do we have enough
116 blt 5b @ 1 bytes to align with?
118 strltb r1, [ip], #1 @ 1
119 strleb r1, [ip], #1 @ 1
120 strb r1, [ip], #1 @ 1
121 add r2, r2, r3 @ 1 (r2 = r2 - (4 - r3))