summaryrefslogtreecommitdiff
path: root/firmware/asm/m68k/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/m68k/memcpy.S
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/m68k/memcpy.S')
-rw-r--r--firmware/asm/m68k/memcpy.S10
1 files changed, 10 insertions, 0 deletions
diff --git a/firmware/asm/m68k/memcpy.S b/firmware/asm/m68k/memcpy.S
index 9762e31e02..a88ac3d091 100644
--- a/firmware/asm/m68k/memcpy.S
+++ b/firmware/asm/m68k/memcpy.S
@@ -27,6 +27,8 @@
27 .global memcpy 27 .global memcpy
28 .global __memcpy_fwd_entry 28 .global __memcpy_fwd_entry
29 .type memcpy,@function 29 .type memcpy,@function
30 .global mempcpy
31 .type mempcpy,@function
30 32
31/* Copies <length> bytes of data in memory from <source> to <dest> 33/* Copies <length> bytes of data in memory from <source> to <dest>
32 * This version is optimized for speed 34 * This version is optimized for speed
@@ -53,6 +55,14 @@
53 * long+3) it writes longwords only. Same goes for word aligned destinations 55 * long+3) it writes longwords only. Same goes for word aligned destinations
54 * if FULLSPEED is undefined. 56 * if FULLSPEED is undefined.
55 */ 57 */
58mempcpy:
59 move.l (4,%sp),%a1 /* Destination */
60 move.l (8,%sp),%a0 /* Source */
61 move.l (12,%sp),%d1 /* Length */
62
63 add.l %d1,(4,%sp) /* retval=Destination + Length */
64 bra.b __memcpy_fwd_entry
65
56memcpy: 66memcpy:
57 move.l (4,%sp),%a1 /* Destination */ 67 move.l (4,%sp),%a1 /* Destination */
58 move.l (8,%sp),%a0 /* Source */ 68 move.l (8,%sp),%a0 /* Source */