summaryrefslogtreecommitdiff
path: root/firmware/asm/sh/memcpy.S
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/memcpy.S
parent7d1a47cf13726c95ac46027156cc12dd9da5b855 (diff)
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/memcpy.S')
-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 @@
.align 2
.global _memcpy
+ .global _mempcpy
.global ___memcpy_fwd_entry
.type _memcpy,@function
+ .type _mempcpy,@function
/* Copies <length> bytes of data in memory from <source> to <dest>
* This version is optimized for speed
@@ -51,6 +53,10 @@
* The instruction order is devised in a way to utilize the pipelining
* of the SH1 to the max. The routine also tries to utilize fast page mode.
*/
+_mempcpy:
+ mov r4,r7 /* store dest + length for returning */
+ bra ___memcpy_fwd_entry
+ add r6,r7
_memcpy:
mov r4,r7 /* store dest for returning */
@@ -217,3 +223,5 @@ ___memcpy_fwd_entry:
mov r7,r0 /* return dest start address */
.end:
.size _memcpy,.end-_memcpy
+ .size _mempcpy,.end-_mempcpy
+