1 ;------------------------------------------------------------------------------
3 ; CopyMem() worker for ARM
5 ; This file started out as C code that did 64 bit moves if the buffer was
6 ; 32-bit aligned, else it does a byte copy. It also does a byte copy for
7 ; any trailing bytes. It was updated to do 32-byte copies using stm/ldm.
9 ; Copyright (c) 2008 - 2010, Apple Inc. All rights reserved.<BR>
10 ; Copyright (c) 2016, Linaro Ltd. All rights reserved.<BR>
11 ; SPDX-License-Identifier: BSD-2-Clause-Patent
13 ;------------------------------------------------------------------------------
15 EXPORT InternalMemCopyMem
16 AREA SetMem, CODE, READONLY
20 stmfd sp!, {r4-r11, lr}
21 // Save the input parameters in extra registers (r11 = destination, r14 = source, r12 = length)
27 memcopy_check_overlapped
30 bcc memcopy_check_optim_default
32 // If (source + length < dest)
35 bcc memcopy_check_optim_default
36 b memcopy_check_optim_overlap
38 memcopy_check_optim_default
39 // Check if we can use an optimized path ((length >= 32) && destination word-aligned && source word-aligned) for the memcopy (optimized path if r0 == 1)
51 memcopy_check_optim_overlap
52 // r10 = dest_end, r14 = source_end
56 // Are we in the optimized case ((length >= 32) && dest_end word-aligned && source_end word-aligned)
66 memcopy_overlapped_non_optim
67 // We read 1 byte from the end of the source buffer
73 // We write 1 byte at the end of the dest buffer
77 bne memcopy_overlapped_non_optim
80 // r10 = dest_end, r14 = source_end
82 // Are we in the optimized case ?
84 beq memcopy_overlapped_non_optim
86 // Optimized Overlapped - Read 32 bytes
92 // If length is less than 32 then disable optim
97 // Optimized Overlapped - Write 32 bytes
101 // while (length != 0)
102 bne memcopy_overlapped
105 memcopy_default_non_optim
115 // r10 = dest, r14 = source
118 beq memcopy_default_non_optim
120 // Optimized memcopy - Read 32 Bytes
125 // If length is less than 32 then disable optim
130 // Optimized memcopy - Write 32 Bytes
133 // while (length != 0)
134 bne memcopy_default_loop
138 ldmfd sp!, {r4-r11, pc}