]> git.proxmox.com Git - mirror_edk2.git/blob - ArmPkg/Library/CompilerIntrinsicsLib/Arm/memmove.S
79f95b007d80a4355c211d62f0b1cd710a79a2bb
[mirror_edk2.git] / ArmPkg / Library / CompilerIntrinsicsLib / Arm / memmove.S
1 #------------------------------------------------------------------------------
2 #
3 # Copyright (c) 2011-2014, ARM Limited. All rights reserved.
4 #
5 # This program and the accompanying materials
6 # are licensed and made available under the terms and conditions of the BSD License
7 # which accompanies this distribution. The full text of the license may be found at
8 # http://opensource.org/licenses/bsd-license.php
9 #
10 # THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
12 #
13 #------------------------------------------------------------------------------
14
15 .text
16 .align 2
17 GCC_ASM_EXPORT (memmove)
18
19 # VOID
20 # EFIAPI
21 # memmove (
22 # IN VOID *Destination,
23 # IN CONST VOID *Source,
24 # IN UINT32 Size
25 # );
26 ASM_PFX(memmove):
27 CMP r2, #0
28 BXEQ lr
29 CMP r0, r1
30 BXEQ lr
31 BHI memmove_backward
32
33 memmove_forward:
34 LDRB r3, [r1], #1
35 STRB r3, [r0], #1
36 SUBS r2, r2, #1
37 BXEQ lr
38 B memmove_forward
39
40 memmove_backward:
41 add r0, r2
42 add r1, r2
43 memmove_backward_loop:
44 LDRB r3, [r1, #-1]!
45 STRB r3, [r0, #-1]!
46 SUBS r2, r2, #1
47 BXEQ lr
48 B memmove_backward_loop