1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 2006 Free Software Foundation, Inc.
11 * This file was originally part of the GNU C Library
12 * Contributed to glibc by MontaVista Software, Inc. (written by Nicolas Pitre)
13 * Adapted for Rockbox by Daniel Ankers
15 * This program is free software; you can redistribute it and/or
16 * modify it under the terms of the GNU General Public License
17 * as published by the Free Software Foundation; either version 2
18 * of the License, or (at your option) any later version.
20 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
21 * KIND, either express or implied.
23 ****************************************************************************/
28 * Endian independent macros for shifting bytes within registers.
41 * Prototype: void *memmove(void *dest, const void *src, size_t n);
45 * If the memory regions don't overlap, we simply branch to memcpy which is
46 * normally a bit faster. Otherwise the copy is done going downwards.
49 .section .icode,"ax",%progbits
53 .type memmove,%function
61 stmfd sp!, {r0, r4, lr}
77 4: ldmdb r1!, {r3, r4, r5, r6, r7, r8, ip, lr}
79 stmdb r0!, {r3, r4, r5, r6, r7, r8, ip, lr}
84 addne pc, pc, ip @ C is always clear here
106 7: ldmfd sp!, {r5 - r8}
108 8: movs r2, r2, lsl #31
109 ldrneb r3, [r1, #-1]!
110 ldrcsb r4, [r1, #-1]!
112 strneb r3, [r0, #-1]!
113 strcsb r4, [r0, #-1]!
118 ldrgtb r3, [r1, #-1]!
119 ldrgeb r4, [r1, #-1]!
121 strgtb r3, [r0, #-1]!
122 strgeb r4, [r0, #-1]!
136 .macro backward_copy_shift push pull
141 11: stmfd sp!, {r5 - r9}
144 13: ldmdb r1!, {r7, r8, r9, ip}
145 mov lr, r3, push #\push
147 ldmdb r1!, {r3, r4, r5, r6}
148 orr lr, lr, ip, pull #\pull
149 mov ip, ip, push #\push
150 orr ip, ip, r9, pull #\pull
151 mov r9, r9, push #\push
152 orr r9, r9, r8, pull #\pull
153 mov r8, r8, push #\push
154 orr r8, r8, r7, pull #\pull
155 mov r7, r7, push #\push
156 orr r7, r7, r6, pull #\pull
157 mov r6, r6, push #\push
158 orr r6, r6, r5, pull #\pull
159 mov r5, r5, push #\push
160 orr r5, r5, r4, pull #\pull
161 mov r4, r4, push #\push
162 orr r4, r4, r3, pull #\pull
163 stmdb r0!, {r4 - r9, ip, lr}
171 15: mov lr, r3, push #\push
174 orr lr, lr, r3, pull #\pull
178 16: add r1, r1, #(\pull / 8)
184 backward_copy_shift push=8 pull=24
186 17: backward_copy_shift push=16 pull=16
188 18: backward_copy_shift push=24 pull=8