summaryrefslogtreecommitdiff
path: root/firmware/asm/sh
diff options
context:
space:
mode:
authorMichael Sevakis <jethead71@rockbox.org>2014-08-06 04:26:52 -0400
committerMichael Sevakis <jethead71@rockbox.org>2014-08-29 22:06:57 -0400
commit77b3625763ae4d5aa6aaa9d44fbc1bfec6b29335 (patch)
tree74b12e2669da8653932f48f1ca3816eef4bf6324 /firmware/asm/sh
parent7d1a47cf13726c95ac46027156cc12dd9da5b855 (diff)
downloadrockbox-77b3625763ae4d5aa6aaa9d44fbc1bfec6b29335.tar.gz
rockbox-77b3625763ae4d5aa6aaa9d44fbc1bfec6b29335.zip
Add mempcpy implementation
A GNU extension that returns dst + size instead of dst. It's a nice shortcut when copying strings with a known size or back-to-back blocks and you have to do it often. May of course be called directly or alternately through __builtin_mempcpy in some compiler versions. For ASM on native targets, it is implemented as an alternate entrypoint to memcpy which adds minimal code and overhead. Change-Id: I4cbb3483f6df3c1007247fe0a95fd7078737462b
Diffstat (limited to 'firmware/asm/sh')
-rw-r--r--firmware/asm/sh/memcpy.S8
1 files changed, 8 insertions, 0 deletions
diff --git a/firmware/asm/sh/memcpy.S b/firmware/asm/sh/memcpy.S
index 59c5801ac0..3d623c48cd 100644
--- a/firmware/asm/sh/memcpy.S
+++ b/firmware/asm/sh/memcpy.S
@@ -24,8 +24,10 @@
24 24
25 .align 2 25 .align 2
26 .global _memcpy 26 .global _memcpy
27 .global _mempcpy
27 .global ___memcpy_fwd_entry 28 .global ___memcpy_fwd_entry
28 .type _memcpy,@function 29 .type _memcpy,@function
30 .type _mempcpy,@function
29 31
30/* Copies <length> bytes of data in memory from <source> to <dest> 32/* Copies <length> bytes of data in memory from <source> to <dest>
31 * This version is optimized for speed 33 * This version is optimized for speed
@@ -51,6 +53,10 @@
51 * The instruction order is devised in a way to utilize the pipelining 53 * The instruction order is devised in a way to utilize the pipelining
52 * of the SH1 to the max. The routine also tries to utilize fast page mode. 54 * of the SH1 to the max. The routine also tries to utilize fast page mode.
53 */ 55 */
56_mempcpy:
57 mov r4,r7 /* store dest + length for returning */
58 bra ___memcpy_fwd_entry
59 add r6,r7
54 60
55_memcpy: 61_memcpy:
56 mov r4,r7 /* store dest for returning */ 62 mov r4,r7 /* store dest for returning */
@@ -217,3 +223,5 @@ ___memcpy_fwd_entry:
217 mov r7,r0 /* return dest start address */ 223 mov r7,r0 /* return dest start address */
218.end: 224.end:
219 .size _memcpy,.end-_memcpy 225 .size _memcpy,.end-_memcpy
226 .size _mempcpy,.end-_mempcpy
227