1*fdd8201dSApple OSS Distributions/* 2*fdd8201dSApple OSS Distributions * Copyright (c) 2007 Apple Inc. All rights reserved. 3*fdd8201dSApple OSS Distributions * 4*fdd8201dSApple OSS Distributions * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ 5*fdd8201dSApple OSS Distributions * 6*fdd8201dSApple OSS Distributions * This file contains Original Code and/or Modifications of Original Code 7*fdd8201dSApple OSS Distributions * as defined in and that are subject to the Apple Public Source License 8*fdd8201dSApple OSS Distributions * Version 2.0 (the 'License'). You may not use this file except in 9*fdd8201dSApple OSS Distributions * compliance with the License. The rights granted to you under the License 10*fdd8201dSApple OSS Distributions * may not be used to create, or enable the creation or redistribution of, 11*fdd8201dSApple OSS Distributions * unlawful or unlicensed copies of an Apple operating system, or to 12*fdd8201dSApple OSS Distributions * circumvent, violate, or enable the circumvention or violation of, any 13*fdd8201dSApple OSS Distributions * terms of an Apple operating system software license agreement. 14*fdd8201dSApple OSS Distributions * 15*fdd8201dSApple OSS Distributions * Please obtain a copy of the License at 16*fdd8201dSApple OSS Distributions * http://www.opensource.apple.com/apsl/ and read it before using this file. 17*fdd8201dSApple OSS Distributions * 18*fdd8201dSApple OSS Distributions * The Original Code and all software distributed under the License are 19*fdd8201dSApple OSS Distributions * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 20*fdd8201dSApple OSS Distributions * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 21*fdd8201dSApple OSS Distributions * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 22*fdd8201dSApple OSS Distributions * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 23*fdd8201dSApple OSS Distributions * Please see the License for the specific language governing rights and 24*fdd8201dSApple OSS Distributions * limitations under the License. 25*fdd8201dSApple OSS Distributions * 26*fdd8201dSApple OSS Distributions * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ 27*fdd8201dSApple OSS Distributions */ 28*fdd8201dSApple OSS Distributions 29*fdd8201dSApple OSS Distributions#include <arm/proc_reg.h> 30*fdd8201dSApple OSS Distributions 31*fdd8201dSApple OSS Distributions.syntax unified 32*fdd8201dSApple OSS Distributions.text 33*fdd8201dSApple OSS Distributions.align 2 34*fdd8201dSApple OSS Distributions 35*fdd8201dSApple OSS Distributions .globl _ovbcopy 36*fdd8201dSApple OSS Distributions .globl _memcpy 37*fdd8201dSApple OSS Distributions .globl _bcopy 38*fdd8201dSApple OSS Distributions .globl _memmove 39*fdd8201dSApple OSS Distributions 40*fdd8201dSApple OSS Distributions_bcopy: /* void bcopy(const void *src, void *dest, size_t len); */ 41*fdd8201dSApple OSS Distributions_ovbcopy: 42*fdd8201dSApple OSS Distributions mov r3, r0 43*fdd8201dSApple OSS Distributions mov r0, r1 44*fdd8201dSApple OSS Distributions mov r1, r3 45*fdd8201dSApple OSS Distributions 46*fdd8201dSApple OSS Distributions_memcpy: /* void *memcpy(void *dest, const void *src, size_t len); */ 47*fdd8201dSApple OSS Distributions_memmove: /* void *memmove(void *dest, const void *src, size_t len); */ 48*fdd8201dSApple OSS Distributions /* check for zero len or if the pointers are the same */ 49*fdd8201dSApple OSS Distributions cmp r2, #0 50*fdd8201dSApple OSS Distributions cmpne r0, r1 51*fdd8201dSApple OSS Distributions bxeq lr 52*fdd8201dSApple OSS Distributions 53*fdd8201dSApple OSS Distributions /* save r0 (return value), r4 (scratch), and r5 (scratch) */ 54*fdd8201dSApple OSS Distributions stmfd sp!, { r0, r4, r5, r7, lr } 55*fdd8201dSApple OSS Distributions add r7, sp, #12 56*fdd8201dSApple OSS Distributions 57*fdd8201dSApple OSS Distributions /* check for overlap. r3 <- distance between src & dest */ 58*fdd8201dSApple OSS Distributions subhs r3, r0, r1 59*fdd8201dSApple OSS Distributions sublo r3, r1, r0 60*fdd8201dSApple OSS Distributions cmp r3, r2 /* if distance(src, dest) < len, we have overlap */ 61*fdd8201dSApple OSS Distributions blo Loverlap 62*fdd8201dSApple OSS Distributions 63*fdd8201dSApple OSS DistributionsLnormalforwardcopy: 64*fdd8201dSApple OSS Distributions /* are src and dest dissimilarly word aligned? */ 65*fdd8201dSApple OSS Distributions mov r12, r0, lsl #30 66*fdd8201dSApple OSS Distributions cmp r12, r1, lsl #30 67*fdd8201dSApple OSS Distributions bne Lnonwordaligned_forward 68*fdd8201dSApple OSS Distributions 69*fdd8201dSApple OSS Distributions /* if len < 64, do a quick forward copy */ 70*fdd8201dSApple OSS Distributions cmp r2, #64 71*fdd8201dSApple OSS Distributions blt Lsmallforwardcopy 72*fdd8201dSApple OSS Distributions 73*fdd8201dSApple OSS Distributions /* check for 16 byte src/dest unalignment */ 74*fdd8201dSApple OSS Distributions tst r0, #0xf 75*fdd8201dSApple OSS Distributions bne Lsimilarlyunaligned 76*fdd8201dSApple OSS Distributions 77*fdd8201dSApple OSS Distributions /* check for 32 byte dest unalignment */ 78*fdd8201dSApple OSS Distributions tst r0, #(1<<4) 79*fdd8201dSApple OSS Distributions bne Lunaligned_32 80*fdd8201dSApple OSS Distributions 81*fdd8201dSApple OSS DistributionsLmorethan64_aligned: 82*fdd8201dSApple OSS Distributions /* save some more registers to use in the copy */ 83*fdd8201dSApple OSS Distributions stmfd sp!, { r6, r8, r10, r11 } 84*fdd8201dSApple OSS Distributions 85*fdd8201dSApple OSS Distributions /* pre-subtract 64 from the len counter to avoid an extra compare in the loop */ 86*fdd8201dSApple OSS Distributions sub r2, r2, #64 87*fdd8201dSApple OSS Distributions 88*fdd8201dSApple OSS DistributionsL64loop: 89*fdd8201dSApple OSS Distributions /* copy 64 bytes at a time */ 90*fdd8201dSApple OSS Distributions ldmia r1!, { r3, r4, r5, r6, r8, r10, r11, r12 } 91*fdd8201dSApple OSS Distributions pld [r1, #32] 92*fdd8201dSApple OSS Distributions stmia r0!, { r3, r4, r5, r6, r8, r10, r11, r12 } 93*fdd8201dSApple OSS Distributions ldmia r1!, { r3, r4, r5, r6, r8, r10, r11, r12 } 94*fdd8201dSApple OSS Distributions subs r2, r2, #64 95*fdd8201dSApple OSS Distributions pld [r1, #32] 96*fdd8201dSApple OSS Distributions stmia r0!, { r3, r4, r5, r6, r8, r10, r11, r12 } 97*fdd8201dSApple OSS Distributions bge L64loop 98*fdd8201dSApple OSS Distributions 99*fdd8201dSApple OSS Distributions /* restore the scratch registers we just saved */ 100*fdd8201dSApple OSS Distributions ldmfd sp!, { r6, r8, r10, r11 } 101*fdd8201dSApple OSS Distributions 102*fdd8201dSApple OSS Distributions /* fix up the len counter (previously subtracted an extra 64 from it) and test for completion */ 103*fdd8201dSApple OSS Distributions adds r2, r2, #64 104*fdd8201dSApple OSS Distributions beq Lexit 105*fdd8201dSApple OSS Distributions 106*fdd8201dSApple OSS DistributionsLlessthan64_aligned: 107*fdd8201dSApple OSS Distributions /* copy 16 bytes at a time until we have < 16 bytes */ 108*fdd8201dSApple OSS Distributions cmp r2, #16 109*fdd8201dSApple OSS Distributions ldmiage r1!, { r3, r4, r5, r12 } 110*fdd8201dSApple OSS Distributions stmiage r0!, { r3, r4, r5, r12 } 111*fdd8201dSApple OSS Distributions subsge r2, r2, #16 112*fdd8201dSApple OSS Distributions bgt Llessthan64_aligned 113*fdd8201dSApple OSS Distributions beq Lexit 114*fdd8201dSApple OSS Distributions 115*fdd8201dSApple OSS DistributionsLlessthan16_aligned: 116*fdd8201dSApple OSS Distributions mov r2, r2, lsl #28 117*fdd8201dSApple OSS Distributions msr cpsr_f, r2 118*fdd8201dSApple OSS Distributions 119*fdd8201dSApple OSS Distributions ldmiami r1!, { r2, r3 } 120*fdd8201dSApple OSS Distributions ldreq r4, [r1], #4 121*fdd8201dSApple OSS Distributions ldrhcs r5, [r1], #2 122*fdd8201dSApple OSS Distributions ldrbvs r12, [r1], #1 123*fdd8201dSApple OSS Distributions 124*fdd8201dSApple OSS Distributions stmiami r0!, { r2, r3 } 125*fdd8201dSApple OSS Distributions streq r4, [r0], #4 126*fdd8201dSApple OSS Distributions strhcs r5, [r0], #2 127*fdd8201dSApple OSS Distributions strbvs r12, [r0], #1 128*fdd8201dSApple OSS Distributions b Lexit 129*fdd8201dSApple OSS Distributions 130*fdd8201dSApple OSS DistributionsLsimilarlyunaligned: 131*fdd8201dSApple OSS Distributions /* both src and dest are unaligned in similar ways, align to dest on 32 byte boundary */ 132*fdd8201dSApple OSS Distributions mov r12, r0, lsl #28 133*fdd8201dSApple OSS Distributions rsb r12, r12, #0 134*fdd8201dSApple OSS Distributions msr cpsr_f, r12 135*fdd8201dSApple OSS Distributions 136*fdd8201dSApple OSS Distributions ldrbvs r3, [r1], #1 137*fdd8201dSApple OSS Distributions ldrhcs r4, [r1], #2 138*fdd8201dSApple OSS Distributions ldreq r5, [r1], #4 139*fdd8201dSApple OSS Distributions 140*fdd8201dSApple OSS Distributions strbvs r3, [r0], #1 141*fdd8201dSApple OSS Distributions strhcs r4, [r0], #2 142*fdd8201dSApple OSS Distributions streq r5, [r0], #4 143*fdd8201dSApple OSS Distributions 144*fdd8201dSApple OSS Distributions ldmiami r1!, { r3, r4 } 145*fdd8201dSApple OSS Distributions stmiami r0!, { r3, r4 } 146*fdd8201dSApple OSS Distributions 147*fdd8201dSApple OSS Distributions subs r2, r2, r12, lsr #28 148*fdd8201dSApple OSS Distributions beq Lexit 149*fdd8201dSApple OSS Distributions 150*fdd8201dSApple OSS DistributionsLunaligned_32: 151*fdd8201dSApple OSS Distributions /* bring up to dest 32 byte alignment */ 152*fdd8201dSApple OSS Distributions tst r0, #(1 << 4) 153*fdd8201dSApple OSS Distributions ldmiane r1!, { r3, r4, r5, r12 } 154*fdd8201dSApple OSS Distributions stmiane r0!, { r3, r4, r5, r12 } 155*fdd8201dSApple OSS Distributions subne r2, r2, #16 156*fdd8201dSApple OSS Distributions 157*fdd8201dSApple OSS Distributions /* we should now be aligned, see what copy method we should use */ 158*fdd8201dSApple OSS Distributions cmp r2, #64 159*fdd8201dSApple OSS Distributions bge Lmorethan64_aligned 160*fdd8201dSApple OSS Distributions b Llessthan64_aligned 161*fdd8201dSApple OSS Distributions 162*fdd8201dSApple OSS DistributionsLbytewise2: 163*fdd8201dSApple OSS Distributions /* copy 2 bytes at a time */ 164*fdd8201dSApple OSS Distributions subs r2, r2, #2 165*fdd8201dSApple OSS Distributions 166*fdd8201dSApple OSS Distributions ldrb r3, [r1], #1 167*fdd8201dSApple OSS Distributions ldrbpl r4, [r1], #1 168*fdd8201dSApple OSS Distributions 169*fdd8201dSApple OSS Distributions strb r3, [r0], #1 170*fdd8201dSApple OSS Distributions strbpl r4, [r0], #1 171*fdd8201dSApple OSS Distributions 172*fdd8201dSApple OSS Distributions bhi Lbytewise2 173*fdd8201dSApple OSS Distributions b Lexit 174*fdd8201dSApple OSS Distributions 175*fdd8201dSApple OSS DistributionsLbytewise: 176*fdd8201dSApple OSS Distributions /* simple bytewise forward copy */ 177*fdd8201dSApple OSS Distributions ldrb r3, [r1], #1 178*fdd8201dSApple OSS Distributions subs r2, r2, #1 179*fdd8201dSApple OSS Distributions strb r3, [r0], #1 180*fdd8201dSApple OSS Distributions bne Lbytewise 181*fdd8201dSApple OSS Distributions b Lexit 182*fdd8201dSApple OSS Distributions 183*fdd8201dSApple OSS DistributionsLsmallforwardcopy: 184*fdd8201dSApple OSS Distributions /* src and dest are word aligned similarly, less than 64 bytes to copy */ 185*fdd8201dSApple OSS Distributions cmp r2, #4 186*fdd8201dSApple OSS Distributions blt Lbytewise2 187*fdd8201dSApple OSS Distributions 188*fdd8201dSApple OSS Distributions /* bytewise copy until word aligned */ 189*fdd8201dSApple OSS Distributions tst r1, #3 190*fdd8201dSApple OSS DistributionsLwordalignloop: 191*fdd8201dSApple OSS Distributions ldrbne r3, [r1], #1 192*fdd8201dSApple OSS Distributions strbne r3, [r0], #1 193*fdd8201dSApple OSS Distributions subne r2, r2, #1 194*fdd8201dSApple OSS Distributions tstne r1, #3 195*fdd8201dSApple OSS Distributions bne Lwordalignloop 196*fdd8201dSApple OSS Distributions 197*fdd8201dSApple OSS Distributions cmp r2, #16 198*fdd8201dSApple OSS Distributions bge Llessthan64_aligned 199*fdd8201dSApple OSS Distributions blt Llessthan16_aligned 200*fdd8201dSApple OSS Distributions 201*fdd8201dSApple OSS DistributionsLoverlap: 202*fdd8201dSApple OSS Distributions /* src and dest overlap in some way, len > 0 */ 203*fdd8201dSApple OSS Distributions cmp r0, r1 /* if dest > src */ 204*fdd8201dSApple OSS Distributions bhi Loverlap_srclower 205*fdd8201dSApple OSS Distributions 206*fdd8201dSApple OSS DistributionsLoverlap_destlower: 207*fdd8201dSApple OSS Distributions /* dest < src, see if we can still do a fast forward copy or fallback to slow forward copy */ 208*fdd8201dSApple OSS Distributions cmp r3, #64 209*fdd8201dSApple OSS Distributions bge Lnormalforwardcopy /* overlap is greater than one stride of the copy, use normal copy */ 210*fdd8201dSApple OSS Distributions 211*fdd8201dSApple OSS Distributions cmp r3, #2 212*fdd8201dSApple OSS Distributions bge Lbytewise2 213*fdd8201dSApple OSS Distributions b Lbytewise 214*fdd8201dSApple OSS Distributions 215*fdd8201dSApple OSS Distributions /* the following routines deal with having to copy in the reverse direction */ 216*fdd8201dSApple OSS DistributionsLoverlap_srclower: 217*fdd8201dSApple OSS Distributions /* src < dest, with overlap */ 218*fdd8201dSApple OSS Distributions 219*fdd8201dSApple OSS Distributions /* src += len; dest += len; */ 220*fdd8201dSApple OSS Distributions add r0, r0, r2 221*fdd8201dSApple OSS Distributions add r1, r1, r2 222*fdd8201dSApple OSS Distributions 223*fdd8201dSApple OSS Distributions /* we have to copy in reverse no matter what, test if we can we use a large block reverse copy */ 224*fdd8201dSApple OSS Distributions cmp r2, #64 /* less than 64 bytes to copy? */ 225*fdd8201dSApple OSS Distributions cmpgt r3, #64 /* less than 64 bytes of nonoverlap? */ 226*fdd8201dSApple OSS Distributions blt Lbytewise_reverse 227*fdd8201dSApple OSS Distributions 228*fdd8201dSApple OSS Distributions /* test of src and dest are nonword aligned differently */ 229*fdd8201dSApple OSS Distributions mov r3, r0, lsl #30 230*fdd8201dSApple OSS Distributions cmp r3, r1, lsl #30 231*fdd8201dSApple OSS Distributions bne Lbytewise_reverse 232*fdd8201dSApple OSS Distributions 233*fdd8201dSApple OSS Distributions /* test if src and dest are non word aligned or dest is non 16 byte aligned */ 234*fdd8201dSApple OSS Distributions tst r0, #0xf 235*fdd8201dSApple OSS Distributions bne Lunaligned_reverse_similarly 236*fdd8201dSApple OSS Distributions 237*fdd8201dSApple OSS Distributions /* test for dest 32 byte alignment */ 238*fdd8201dSApple OSS Distributions tst r0, #(1<<4) 239*fdd8201dSApple OSS Distributions bne Lunaligned_32_reverse_similarly 240*fdd8201dSApple OSS Distributions 241*fdd8201dSApple OSS Distributions /* 64 byte reverse block copy, src and dest aligned */ 242*fdd8201dSApple OSS DistributionsLmorethan64_aligned_reverse: 243*fdd8201dSApple OSS Distributions /* save some more registers to use in the copy */ 244*fdd8201dSApple OSS Distributions stmfd sp!, { r6, r8, r10, r11 } 245*fdd8201dSApple OSS Distributions 246*fdd8201dSApple OSS Distributions /* pre-subtract 64 from the len counter to avoid an extra compare in the loop */ 247*fdd8201dSApple OSS Distributions sub r2, r2, #64 248*fdd8201dSApple OSS Distributions 249*fdd8201dSApple OSS DistributionsL64loop_reverse: 250*fdd8201dSApple OSS Distributions /* copy 64 bytes at a time */ 251*fdd8201dSApple OSS Distributions ldmdb r1!, { r3, r4, r5, r6, r8, r10, r11, r12 } 252*fdd8201dSApple OSS Distributions#if ARCH_ARMv5 || ARCH_ARMv5e || ARCH_ARMv6 253*fdd8201dSApple OSS Distributions pld [r1, #-32] 254*fdd8201dSApple OSS Distributions#endif 255*fdd8201dSApple OSS Distributions stmdb r0!, { r3, r4, r5, r6, r8, r10, r11, r12 } 256*fdd8201dSApple OSS Distributions ldmdb r1!, { r3, r4, r5, r6, r8, r10, r11, r12 } 257*fdd8201dSApple OSS Distributions subs r2, r2, #64 258*fdd8201dSApple OSS Distributions pld [r1, #-32] 259*fdd8201dSApple OSS Distributions stmdb r0!, { r3, r4, r5, r6, r8, r10, r11, r12 } 260*fdd8201dSApple OSS Distributions bge L64loop_reverse 261*fdd8201dSApple OSS Distributions 262*fdd8201dSApple OSS Distributions /* restore the scratch registers we just saved */ 263*fdd8201dSApple OSS Distributions ldmfd sp!, { r6, r8, r10, r11 } 264*fdd8201dSApple OSS Distributions 265*fdd8201dSApple OSS Distributions /* fix up the len counter (previously subtracted an extra 64 from it) and test for completion */ 266*fdd8201dSApple OSS Distributions adds r2, r2, #64 267*fdd8201dSApple OSS Distributions beq Lexit 268*fdd8201dSApple OSS Distributions 269*fdd8201dSApple OSS DistributionsLbytewise_reverse: 270*fdd8201dSApple OSS Distributions ldrb r3, [r1, #-1]! 271*fdd8201dSApple OSS Distributions strb r3, [r0, #-1]! 272*fdd8201dSApple OSS Distributions subs r2, r2, #1 273*fdd8201dSApple OSS Distributions bne Lbytewise_reverse 274*fdd8201dSApple OSS Distributions b Lexit 275*fdd8201dSApple OSS Distributions 276*fdd8201dSApple OSS DistributionsLunaligned_reverse_similarly: 277*fdd8201dSApple OSS Distributions /* both src and dest are unaligned in similar ways, align to dest on 32 byte boundary */ 278*fdd8201dSApple OSS Distributions mov r12, r0, lsl #28 279*fdd8201dSApple OSS Distributions msr cpsr_f, r12 280*fdd8201dSApple OSS Distributions 281*fdd8201dSApple OSS Distributions ldrbvs r3, [r1, #-1]! 282*fdd8201dSApple OSS Distributions ldrhcs r4, [r1, #-2]! 283*fdd8201dSApple OSS Distributions ldreq r5, [r1, #-4]! 284*fdd8201dSApple OSS Distributions 285*fdd8201dSApple OSS Distributions strbvs r3, [r0, #-1]! 286*fdd8201dSApple OSS Distributions strhcs r4, [r0, #-2]! 287*fdd8201dSApple OSS Distributions streq r5, [r0, #-4]! 288*fdd8201dSApple OSS Distributions 289*fdd8201dSApple OSS Distributions ldmdbmi r1!, { r3, r4 } 290*fdd8201dSApple OSS Distributions stmdbmi r0!, { r3, r4 } 291*fdd8201dSApple OSS Distributions 292*fdd8201dSApple OSS Distributions subs r2, r2, r12, lsr #28 293*fdd8201dSApple OSS Distributions beq Lexit 294*fdd8201dSApple OSS Distributions 295*fdd8201dSApple OSS DistributionsLunaligned_32_reverse_similarly: 296*fdd8201dSApple OSS Distributions /* bring up to dest 32 byte alignment */ 297*fdd8201dSApple OSS Distributions tst r0, #(1 << 4) 298*fdd8201dSApple OSS Distributions ldmdbne r1!, { r3, r4, r5, r12 } 299*fdd8201dSApple OSS Distributions stmdbne r0!, { r3, r4, r5, r12 } 300*fdd8201dSApple OSS Distributions subne r2, r2, #16 301*fdd8201dSApple OSS Distributions 302*fdd8201dSApple OSS Distributions /* we should now be aligned, see what copy method we should use */ 303*fdd8201dSApple OSS Distributions cmp r2, #64 304*fdd8201dSApple OSS Distributions bge Lmorethan64_aligned_reverse 305*fdd8201dSApple OSS Distributions b Lbytewise_reverse 306*fdd8201dSApple OSS Distributions 307*fdd8201dSApple OSS Distributions /* the following routines deal with non word aligned copies */ 308*fdd8201dSApple OSS DistributionsLnonwordaligned_forward: 309*fdd8201dSApple OSS Distributions cmp r2, #8 310*fdd8201dSApple OSS Distributions blt Lbytewise2 /* not worth the effort with less than 24 bytes total */ 311*fdd8201dSApple OSS Distributions 312*fdd8201dSApple OSS Distributions /* bytewise copy until src word aligned */ 313*fdd8201dSApple OSS Distributions tst r1, #3 314*fdd8201dSApple OSS DistributionsLwordalignloop2: 315*fdd8201dSApple OSS Distributions ldrbne r3, [r1], #1 316*fdd8201dSApple OSS Distributions strbne r3, [r0], #1 317*fdd8201dSApple OSS Distributions subne r2, r2, #1 318*fdd8201dSApple OSS Distributions tstne r1, #3 319*fdd8201dSApple OSS Distributions bne Lwordalignloop2 320*fdd8201dSApple OSS Distributions 321*fdd8201dSApple OSS Distributions /* figure out how the src and dest are unaligned */ 322*fdd8201dSApple OSS Distributions and r3, r0, #3 323*fdd8201dSApple OSS Distributions cmp r3, #2 324*fdd8201dSApple OSS Distributions blt Lalign1_forward 325*fdd8201dSApple OSS Distributions beq Lalign2_forward 326*fdd8201dSApple OSS Distributions bgt Lalign3_forward 327*fdd8201dSApple OSS Distributions 328*fdd8201dSApple OSS DistributionsLalign1_forward: 329*fdd8201dSApple OSS Distributions /* the dest pointer is 1 byte off from src */ 330*fdd8201dSApple OSS Distributions mov r12, r2, lsr #2 /* number of words we should copy */ 331*fdd8201dSApple OSS Distributions sub r0, r0, #1 332*fdd8201dSApple OSS Distributions 333*fdd8201dSApple OSS Distributions /* prime the copy */ 334*fdd8201dSApple OSS Distributions ldrb r4, [r0] /* load D[7:0] */ 335*fdd8201dSApple OSS Distributions 336*fdd8201dSApple OSS DistributionsLalign1_forward_loop: 337*fdd8201dSApple OSS Distributions ldr r3, [r1], #4 /* load S */ 338*fdd8201dSApple OSS Distributions orr r4, r4, r3, lsl #8 /* D[31:8] = S[24:0] */ 339*fdd8201dSApple OSS Distributions str r4, [r0], #4 /* save D */ 340*fdd8201dSApple OSS Distributions mov r4, r3, lsr #24 /* D[7:0] = S[31:25] */ 341*fdd8201dSApple OSS Distributions subs r12, r12, #1 342*fdd8201dSApple OSS Distributions bne Lalign1_forward_loop 343*fdd8201dSApple OSS Distributions 344*fdd8201dSApple OSS Distributions /* finish the copy off */ 345*fdd8201dSApple OSS Distributions strb r4, [r0], #1 /* save D[7:0] */ 346*fdd8201dSApple OSS Distributions 347*fdd8201dSApple OSS Distributions ands r2, r2, #3 348*fdd8201dSApple OSS Distributions beq Lexit 349*fdd8201dSApple OSS Distributions b Lbytewise2 350*fdd8201dSApple OSS Distributions 351*fdd8201dSApple OSS DistributionsLalign2_forward: 352*fdd8201dSApple OSS Distributions /* the dest pointer is 2 bytes off from src */ 353*fdd8201dSApple OSS Distributions mov r12, r2, lsr #2 /* number of words we should copy */ 354*fdd8201dSApple OSS Distributions sub r0, r0, #2 355*fdd8201dSApple OSS Distributions 356*fdd8201dSApple OSS Distributions /* prime the copy */ 357*fdd8201dSApple OSS Distributions ldrh r4, [r0] /* load D[15:0] */ 358*fdd8201dSApple OSS Distributions 359*fdd8201dSApple OSS DistributionsLalign2_forward_loop: 360*fdd8201dSApple OSS Distributions ldr r3, [r1], #4 /* load S */ 361*fdd8201dSApple OSS Distributions orr r4, r4, r3, lsl #16 /* D[31:16] = S[15:0] */ 362*fdd8201dSApple OSS Distributions str r4, [r0], #4 /* save D */ 363*fdd8201dSApple OSS Distributions mov r4, r3, lsr #16 /* D[15:0] = S[31:15] */ 364*fdd8201dSApple OSS Distributions subs r12, r12, #1 365*fdd8201dSApple OSS Distributions bne Lalign2_forward_loop 366*fdd8201dSApple OSS Distributions 367*fdd8201dSApple OSS Distributions /* finish the copy off */ 368*fdd8201dSApple OSS Distributions strh r4, [r0], #2 /* save D[15:0] */ 369*fdd8201dSApple OSS Distributions 370*fdd8201dSApple OSS Distributions ands r2, r2, #3 371*fdd8201dSApple OSS Distributions beq Lexit 372*fdd8201dSApple OSS Distributions b Lbytewise2 373*fdd8201dSApple OSS Distributions 374*fdd8201dSApple OSS DistributionsLalign3_forward: 375*fdd8201dSApple OSS Distributions /* the dest pointer is 3 bytes off from src */ 376*fdd8201dSApple OSS Distributions mov r12, r2, lsr #2 /* number of words we should copy */ 377*fdd8201dSApple OSS Distributions sub r0, r0, #3 378*fdd8201dSApple OSS Distributions 379*fdd8201dSApple OSS Distributions /* prime the copy */ 380*fdd8201dSApple OSS Distributions ldr r4, [r0] 381*fdd8201dSApple OSS Distributions and r4, r4, #0x00ffffff /* load D[24:0] */ 382*fdd8201dSApple OSS Distributions 383*fdd8201dSApple OSS DistributionsLalign3_forward_loop: 384*fdd8201dSApple OSS Distributions ldr r3, [r1], #4 /* load S */ 385*fdd8201dSApple OSS Distributions orr r4, r4, r3, lsl #24 /* D[31:25] = S[7:0] */ 386*fdd8201dSApple OSS Distributions str r4, [r0], #4 /* save D */ 387*fdd8201dSApple OSS Distributions mov r4, r3, lsr #8 /* D[24:0] = S[31:8] */ 388*fdd8201dSApple OSS Distributions subs r12, r12, #1 389*fdd8201dSApple OSS Distributions bne Lalign3_forward_loop 390*fdd8201dSApple OSS Distributions 391*fdd8201dSApple OSS Distributions /* finish the copy off */ 392*fdd8201dSApple OSS Distributions strh r4, [r0], #2 /* save D[15:0] */ 393*fdd8201dSApple OSS Distributions mov r4, r4, lsr #16 394*fdd8201dSApple OSS Distributions strb r4, [r0], #1 /* save D[23:16] */ 395*fdd8201dSApple OSS Distributions 396*fdd8201dSApple OSS Distributions ands r2, r2, #3 397*fdd8201dSApple OSS Distributions beq Lexit 398*fdd8201dSApple OSS Distributions b Lbytewise2 399*fdd8201dSApple OSS Distributions 400*fdd8201dSApple OSS DistributionsLexit: 401*fdd8201dSApple OSS Distributions ldmfd sp!, { r0, r4, r5, r7, pc } 402*fdd8201dSApple OSS Distributions 403