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
17 ands r3, r0, #3 @ 1 unaligned?
18 mov ip, r0 @ preserve r0 as return value
21 * we know that the pointer in ip is aligned to a word boundary.
23 1: orr r1, r1, r1, lsl #8
24 orr r1, r1, r1, lsl #16
32 * We need 2 extra registers for this loop - use r8 and the LR
39 stmgeia ip!, {r1, r3, r8, lr} @ 64 bytes at a time.
40 stmgeia ip!, {r1, r3, r8, lr}
41 stmgeia ip!, {r1, r3, r8, lr}
42 stmgeia ip!, {r1, r3, r8, lr}
44 ldmeqfd sp!, {r8, pc} @ Now <64 bytes to go.
46 * No need to correct the count; we're only testing bits from now on
49 stmneia ip!, {r1, r3, r8, lr}
50 stmneia ip!, {r1, r3, r8, lr}
52 stmneia ip!, {r1, r3, r8, lr}
58 * This version aligns the destination pointer in order to write
59 * whole cache lines at once.
62 stmfd sp!, {r4-r8, lr}
77 movs r8, r8, lsl #(32 - 4)
78 stmcsia ip!, {r4, r5, r6, r7}
85 stmgeia ip!, {r1, r3-r8, lr}
86 stmgeia ip!, {r1, r3-r8, lr}
88 ldmeqfd sp!, {r4-r8, pc}
91 stmneia ip!, {r1, r3-r8, lr}
94 ldmfd sp!, {r4-r8, lr}
103 * When we get here, we've got less than 4 bytes to zero. We
104 * may have an unaligned pointer as well.
113 6: subs r2, r2, #4 @ 1 do we have enough
114 blt 5b @ 1 bytes to align with?
116 strltb r1, [ip], #1 @ 1
117 strleb r1, [ip], #1 @ 1
118 strb r1, [ip], #1 @ 1
119 add r2, r2, r3 @ 1 (r2 = r2 - (4 - r3))