2 * linux/arch/arm/lib/memmove.S
4 * Author: Nicolas Pitre
5 * Created: Sep 28, 2005
6 * Copyright: (C) MontaVista Software Inc.
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
13 #include <linux/linkage.h>
14 #include <asm/assembler.h>
19 * Prototype: void *memmove(void *dest, const void *src, size_t n);
23 * If the memory regions don't overlap, we simply branch to memcpy which is
24 * normally a bit faster. Otherwise the copy is done going downwards. This
25 * is a transposition of the code from copy_template.S but with the copy
26 * occurring in the opposite direction.
35 stmfd sp!, {r0, r4, lr}
50 CALGN( ands ip, r0, #31 )
51 CALGN( sbcnes r4, ip, r2 ) @ C is always set here
54 CALGN( subs r2, r2, ip ) @ C is set here
55 CALGN( rsb ip, ip, #32 )
56 CALGN( add pc, r4, ip )
59 2: PLD( subs r2, r2, #96 )
65 3: PLD( pld [r1, #-128] )
66 4: ldmdb r1!, {r3, r4, r5, r6, r7, r8, ip, lr}
68 stmdb r0!, {r3, r4, r5, r6, r7, r8, ip, lr}
75 addne pc, pc, ip @ C is always clear here
99 7: ldmfd sp!, {r5 - r8}
101 8: movs r2, r2, lsl #31
102 ldrneb r3, [r1, #-1]!
103 ldrcsb r4, [r1, #-1]!
105 strneb r3, [r0, #-1]!
106 strcsb r4, [r0, #-1]!
108 ldmfd sp!, {r0, r4, pc}
111 ldrgtb r3, [r1, #-1]!
112 ldrgeb r4, [r1, #-1]!
114 strgtb r3, [r0, #-1]!
115 strgeb r4, [r0, #-1]!
129 .macro backward_copy_shift push pull
134 CALGN( ands ip, r0, #31 )
135 CALGN( sbcnes r4, ip, r2 ) @ C is always set here
136 CALGN( subcc r2, r2, ip )
139 11: stmfd sp!, {r5 - r9}
142 PLD( subs r2, r2, #96 )
143 PLD( pld [r1, #-32] )
145 PLD( pld [r1, #-64] )
146 PLD( pld [r1, #-96] )
148 12: PLD( pld [r1, #-128] )
149 13: ldmdb r1!, {r7, r8, r9, ip}
150 mov lr, r3, lspush #\push
152 ldmdb r1!, {r3, r4, r5, r6}
153 orr lr, lr, ip, lspull #\pull
154 mov ip, ip, lspush #\push
155 orr ip, ip, r9, lspull #\pull
156 mov r9, r9, lspush #\push
157 orr r9, r9, r8, lspull #\pull
158 mov r8, r8, lspush #\push
159 orr r8, r8, r7, lspull #\pull
160 mov r7, r7, lspush #\push
161 orr r7, r7, r6, lspull #\pull
162 mov r6, r6, lspush #\push
163 orr r6, r6, r5, lspull #\pull
164 mov r5, r5, lspush #\push
165 orr r5, r5, r4, lspull #\pull
166 mov r4, r4, lspush #\push
167 orr r4, r4, r3, lspull #\pull
168 stmdb r0!, {r4 - r9, ip, lr}
178 15: mov lr, r3, lspush #\push
181 orr lr, lr, r3, lspull #\pull
187 16: add r1, r1, #(\pull / 8)
193 backward_copy_shift push=8 pull=24
195 17: backward_copy_shift push=16 pull=16
197 18: backward_copy_shift push=24 pull=8