- Fixed memmove when going backward: the copy started one byte
after the end of the region to copy
- memset: - removed unused register
- fixed arguments size and character arguments were
actually reversed
- Added memmove() to ARM32 GCC
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Olivier Martin <olivier.martin@arm.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@16328
6f19259b-4bc3-4df7-8a09-
765794883524
--- /dev/null
+#------------------------------------------------------------------------------\r
+#\r
+# Copyright (c) 2011-2014, ARM Limited. All rights reserved.\r
+#\r
+# This program and the accompanying materials\r
+# are licensed and made available under the terms and conditions of the BSD License\r
+# which accompanies this distribution. The full text of the license may be found at\r
+# http://opensource.org/licenses/bsd-license.php\r
+#\r
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+#\r
+#------------------------------------------------------------------------------\r
+\r
+ .text\r
+ .align 2\r
+ GCC_ASM_EXPORT (memmove)\r
+\r
+# VOID\r
+# EFIAPI\r
+# memmove (\r
+# IN VOID *Destination,\r
+# IN CONST VOID *Source,\r
+# IN UINT32 Size\r
+# );\r
+ASM_PFX(memmove):\r
+ CMP r2, #0\r
+ BXEQ lr\r
+ CMP r0, r1\r
+ BXEQ lr\r
+ BHI memmove_backward\r
+\r
+memmove_forward:\r
+ LDRB r3, [r1], #1\r
+ STRB r3, [r0], #1\r
+ SUBS r2, r2, #1\r
+ BXEQ lr\r
+ B memmove_forward\r
+\r
+memmove_backward:\r
+ add r0, r2\r
+ add r1, r2\r
+memmove_backward_loop:\r
+ LDRB r3, [r1, #-1]!\r
+ STRB r3, [r0, #-1]!\r
+ SUBS r2, r2, #1\r
+ BXEQ lr\r
+ B memmove_backward_loop\r
//------------------------------------------------------------------------------\r
//\r
-// Copyright (c) 2011, ARM Limited. All rights reserved.\r
+// Copyright (c) 2011-2014, ARM Limited. All rights reserved.\r
//\r
// This program and the accompanying materials\r
// are licensed and made available under the terms and conditions of the BSD License\r
;\r
__aeabi_memmove\r
CMP r2, #0\r
- BXEQ r14\r
+ BXEQ lr\r
CMP r0, r1\r
- BXEQ r14\r
+ BXEQ lr\r
BHI memmove_backward\r
- BLS memmove_forward\r
\r
memmove_forward\r
LDRB r3, [r1], #1\r
STRB r3, [r0], #1\r
SUBS r2, r2, #1\r
- BXEQ r14\r
- B memmove_forward\r
+ BNE memmove_forward\r
+ BX lr\r
\r
memmove_backward\r
add r0, r2\r
add r1, r2\r
memmove_backward_loop\r
- LDRB r3, [r1], #-1\r
- STRB r3, [r0], #-1\r
- SUBS r2, r2, #-1\r
- BXEQ r14\r
- B memmove_backward_loop\r
+ LDRB r3, [r1, #-1]!\r
+ STRB r3, [r0, #-1]!\r
+ SUBS r2, r2, #1\r
+ BNE memmove_backward_loop\r
+ BX lr\r
\r
END\r
#------------------------------------------------------------------------------\r
#\r
# Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>\r
+# Copyright (c) 2014, ARM Ltd. All rights reserved.<BR>\r
#\r
# This program and the accompanying materials\r
# are licensed and made available under the terms and conditions of the BSD License\r
.align 2\r
GCC_ASM_EXPORT (memset)\r
\r
-\r
+# VOID\r
+# EFIAPI\r
+# memset (\r
+# IN VOID *Destination,\r
+# IN UINT32 Character,\r
+# IN UINT32 Size\r
+# );\r
ASM_PFX(memset):\r
-\r
+ cmp r2, #0\r
+ bxeq lr\r
@ args = 0, pretend = 0, frame = 0\r
@ frame_needed = 1, uses_anonymous_args = 0\r
- stmfd sp!, {r7, lr}\r
- mov ip, #0\r
- add r7, sp, #0\r
- mov lr, r0\r
- b L9\r
L10:\r
- and r3, r1, #255\r
- add ip, ip, #1\r
- strb r3, [lr], #1\r
-L9:\r
- cmp ip, r2\r
+ strb r1, [r0], #1\r
+ subs r2, r2, #1\r
+ @ While size is not 0\r
bne L10\r
- ldmfd sp!, {r7, pc}\r
-\r
+ bx lr\r
//------------------------------------------------------------------------------\r
//\r
// Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>\r
+// Copyright (c) 2014, ARM Ltd. All rights reserved.<BR>\r
//\r
// This program and the accompanying materials\r
// are licensed and made available under the terms and conditions of the BSD License\r
\r
AREA Memset, CODE, READONLY\r
\r
+; void __aeabi_memclr4(void *dest, size_t n);\r
+; void __aeabi_memclr(void *dest, size_t n);\r
+__aeabi_memclr\r
+__aeabi_memclr4\r
+ mov r2, #0\r
+\r
;\r
;VOID\r
;EFIAPI\r
;__aeabi_memset (\r
; IN VOID *Destination,\r
-; IN UINT32 Character,\r
-; IN UINT32 Size\r
+; IN UINT32 Size,\r
+; IN UINT32 Character\r
; );\r
;\r
__aeabi_memset\r
-\r
+ cmp r1, #0\r
+ bxeq lr\r
; args = 0, pretend = 0, frame = 0\r
; frame_needed = 1, uses_anonymous_args = 0\r
- stmfd sp!, {r7, lr}\r
- mov ip, #0\r
- add r7, sp, #0\r
- mov lr, r0\r
- b L9\r
L10\r
- and r3, r1, #255\r
- add ip, ip, #1\r
- strb r3, [lr], #1\r
-L9\r
- cmp ip, r2\r
+ strb r2, [r0], #1\r
+ subs r1, r1, #1\r
+ ; While size is not 0\r
bne L10\r
- ldmfd sp!, {r7, pc}\r
-\r
-__aeabi_memclr\r
- mov r2, r1\r
- mov r1, #0\r
- b __aeabi_memset\r
-\r
-__aeabi_memclr4\r
- mov r2, r1\r
- mov r1, #0\r
- b __aeabi_memset\r
+ bx lr\r
\r
END\r
\r
Arm/memcpy.S | GCC\r
Arm/memset.S | GCC\r
+ Arm/memmove.S | GCC\r
\r
# Arm/modsi3.c | GCC\r
# Arm/moddi3.c | GCC\r