Home | History | Annotate | Line # | Download | only in string
memmove.S revision 1.5
      1  1.5      matt /*	$NetBSD: memmove.S,v 1.5 2013/08/11 04:56:32 matt Exp $	*/
      2  1.1  christos 
      3  1.1  christos /*-
      4  1.1  christos  * Copyright (c) 1997 The NetBSD Foundation, Inc.
      5  1.1  christos  * All rights reserved.
      6  1.1  christos  *
      7  1.1  christos  * This code is derived from software contributed to The NetBSD Foundation
      8  1.1  christos  * by Neil A. Carson and Mark Brinicombe
      9  1.1  christos  *
     10  1.1  christos  * Redistribution and use in source and binary forms, with or without
     11  1.1  christos  * modification, are permitted provided that the following conditions
     12  1.1  christos  * are met:
     13  1.1  christos  * 1. Redistributions of source code must retain the above copyright
     14  1.1  christos  *    notice, this list of conditions and the following disclaimer.
     15  1.1  christos  * 2. Redistributions in binary form must reproduce the above copyright
     16  1.1  christos  *    notice, this list of conditions and the following disclaimer in the
     17  1.1  christos  *    documentation and/or other materials provided with the distribution.
     18  1.1  christos  *
     19  1.1  christos  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     20  1.1  christos  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     21  1.1  christos  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     22  1.1  christos  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     23  1.1  christos  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     24  1.1  christos  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     25  1.1  christos  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     26  1.1  christos  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     27  1.1  christos  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     28  1.1  christos  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     29  1.1  christos  * POSSIBILITY OF SUCH DAMAGE.
     30  1.1  christos  */
     31  1.1  christos 
     32  1.1  christos #include <machine/asm.h>
     33  1.1  christos 
     34  1.4      matt #if defined(__ARM_EABI__) && !defined(BCOPY)
     35  1.4      matt STRONG_ALIAS(__aeabi_memmove, memmove)
     36  1.4      matt #endif
     37  1.4      matt 
     38  1.1  christos #ifndef _BCOPY
     39  1.1  christos /* LINTSTUB: Func: void *memmove(void *, const void *, size_t) */
     40  1.1  christos ENTRY(memmove)
     41  1.1  christos #else
     42  1.1  christos /* bcopy = memcpy/memmove with arguments reversed. */
     43  1.1  christos /* LINTSTUB: Func: void bcopy(void *, void *, size_t) */
     44  1.1  christos ENTRY(bcopy)
     45  1.1  christos 	/* switch the source and destination registers */
     46  1.1  christos 	eor     r0, r1, r0
     47  1.1  christos 	eor     r1, r0, r1
     48  1.1  christos 	eor     r0, r1, r0
     49  1.1  christos #endif
     50  1.1  christos 	/* Do the buffers overlap? */
     51  1.1  christos 	cmp	r0, r1
     52  1.1  christos 	RETc(eq)		/* Bail now if src/dst are the same */
     53  1.2       scw 	subhs	r3, r0, r1	/* if (dst > src) r3 = dst - src */
     54  1.2       scw 	sublo	r3, r1, r0	/* if (src > dst) r3 = src - dst */
     55  1.2       scw 	cmp	r3, r2		/* if (r3 >= len) we have an overlap */
     56  1.2       scw 	bhs	PIC_SYM(_C_LABEL(memcpy), PLT)
     57  1.1  christos 
     58  1.1  christos 	/* Determine copy direction */
     59  1.1  christos 	cmp	r1, r0
     60  1.1  christos 	bcc	.Lmemmove_backwards
     61  1.1  christos 
     62  1.1  christos 	moveq	r0, #0			/* Quick abort for len=0 */
     63  1.1  christos 	RETc(eq)
     64  1.1  christos 
     65  1.5      matt 	push	{r0, lr}		/* memmove() returns dest addr */
     66  1.1  christos 	subs	r2, r2, #4
     67  1.1  christos 	blt	.Lmemmove_fl4		/* less than 4 bytes */
     68  1.1  christos 	ands	r12, r0, #3
     69  1.1  christos 	bne	.Lmemmove_fdestul	/* oh unaligned destination addr */
     70  1.1  christos 	ands	r12, r1, #3
     71  1.1  christos 	bne	.Lmemmove_fsrcul		/* oh unaligned source addr */
     72  1.1  christos 
     73  1.1  christos .Lmemmove_ft8:
     74  1.1  christos 	/* We have aligned source and destination */
     75  1.1  christos 	subs	r2, r2, #8
     76  1.1  christos 	blt	.Lmemmove_fl12		/* less than 12 bytes (4 from above) */
     77  1.1  christos 	subs	r2, r2, #0x14
     78  1.1  christos 	blt	.Lmemmove_fl32		/* less than 32 bytes (12 from above) */
     79  1.5      matt 	push	{r4}		/* borrow r4 */
     80  1.1  christos 
     81  1.1  christos 	/* blat 32 bytes at a time */
     82  1.1  christos 	/* XXX for really big copies perhaps we should use more registers */
     83  1.1  christos .Lmemmove_floop32:
     84  1.1  christos 	ldmia	r1!, {r3, r4, r12, lr}
     85  1.1  christos 	stmia	r0!, {r3, r4, r12, lr}
     86  1.1  christos 	ldmia	r1!, {r3, r4, r12, lr}
     87  1.1  christos 	stmia	r0!, {r3, r4, r12, lr}
     88  1.1  christos 	subs	r2, r2, #0x20
     89  1.1  christos 	bge	.Lmemmove_floop32
     90  1.1  christos 
     91  1.1  christos 	cmn	r2, #0x10
     92  1.5      matt 	ldmiage	r1!, {r3, r4, r12, lr}	/* blat a remaining 16 bytes */
     93  1.5      matt 	stmiage	r0!, {r3, r4, r12, lr}
     94  1.1  christos 	subge	r2, r2, #0x10
     95  1.5      matt 	pop	{r4}		/* return r4 */
     96  1.1  christos 
     97  1.1  christos .Lmemmove_fl32:
     98  1.1  christos 	adds	r2, r2, #0x14
     99  1.1  christos 
    100  1.1  christos 	/* blat 12 bytes at a time */
    101  1.1  christos .Lmemmove_floop12:
    102  1.5      matt 	ldmiage	r1!, {r3, r12, lr}
    103  1.5      matt 	stmiage	r0!, {r3, r12, lr}
    104  1.5      matt 	subsge	r2, r2, #0x0c
    105  1.1  christos 	bge	.Lmemmove_floop12
    106  1.1  christos 
    107  1.1  christos .Lmemmove_fl12:
    108  1.1  christos 	adds	r2, r2, #8
    109  1.1  christos 	blt	.Lmemmove_fl4
    110  1.1  christos 
    111  1.1  christos 	subs	r2, r2, #4
    112  1.1  christos 	ldrlt	r3, [r1], #4
    113  1.1  christos 	strlt	r3, [r0], #4
    114  1.5      matt 	ldmiage	r1!, {r3, r12}
    115  1.5      matt 	stmiage	r0!, {r3, r12}
    116  1.1  christos 	subge	r2, r2, #4
    117  1.1  christos 
    118  1.1  christos .Lmemmove_fl4:
    119  1.1  christos 	/* less than 4 bytes to go */
    120  1.1  christos 	adds	r2, r2, #4
    121  1.5      matt 	popeq	{r0, pc}		/* done */
    122  1.1  christos 
    123  1.1  christos 	/* copy the crud byte at a time */
    124  1.1  christos 	cmp	r2, #2
    125  1.1  christos 	ldrb	r3, [r1], #1
    126  1.1  christos 	strb	r3, [r0], #1
    127  1.5      matt 	ldrbge	r3, [r1], #1
    128  1.5      matt 	strbge	r3, [r0], #1
    129  1.5      matt 	ldrbgt	r3, [r1], #1
    130  1.5      matt 	strbgt	r3, [r0], #1
    131  1.5      matt 	pop	{r0, pc}
    132  1.1  christos 
    133  1.1  christos 	/* erg - unaligned destination */
    134  1.1  christos .Lmemmove_fdestul:
    135  1.1  christos 	rsb	r12, r12, #4
    136  1.1  christos 	cmp	r12, #2
    137  1.1  christos 
    138  1.1  christos 	/* align destination with byte copies */
    139  1.1  christos 	ldrb	r3, [r1], #1
    140  1.1  christos 	strb	r3, [r0], #1
    141  1.5      matt 	ldrbge	r3, [r1], #1
    142  1.5      matt 	strbge	r3, [r0], #1
    143  1.5      matt 	ldrbgt	r3, [r1], #1
    144  1.5      matt 	strbgt	r3, [r0], #1
    145  1.1  christos 	subs	r2, r2, r12
    146  1.1  christos 	blt	.Lmemmove_fl4		/* less the 4 bytes */
    147  1.1  christos 
    148  1.1  christos 	ands	r12, r1, #3
    149  1.1  christos 	beq	.Lmemmove_ft8		/* we have an aligned source */
    150  1.1  christos 
    151  1.1  christos 	/* erg - unaligned source */
    152  1.1  christos 	/* This is where it gets nasty ... */
    153  1.1  christos .Lmemmove_fsrcul:
    154  1.1  christos 	bic	r1, r1, #3
    155  1.1  christos 	ldr	lr, [r1], #4
    156  1.1  christos 	cmp	r12, #2
    157  1.1  christos 	bgt	.Lmemmove_fsrcul3
    158  1.1  christos 	beq	.Lmemmove_fsrcul2
    159  1.1  christos 	cmp	r2, #0x0c
    160  1.1  christos 	blt	.Lmemmove_fsrcul1loop4
    161  1.1  christos 	sub	r2, r2, #0x0c
    162  1.5      matt 	push	{r4, r5}
    163  1.1  christos 
    164  1.1  christos .Lmemmove_fsrcul1loop16:
    165  1.1  christos #ifdef __ARMEB__
    166  1.1  christos 	mov	r3, lr, lsl #8
    167  1.1  christos #else
    168  1.1  christos 	mov	r3, lr, lsr #8
    169  1.1  christos #endif
    170  1.1  christos 	ldmia	r1!, {r4, r5, r12, lr}
    171  1.1  christos #ifdef __ARMEB__
    172  1.1  christos 	orr	r3, r3, r4, lsr #24
    173  1.1  christos 	mov	r4, r4, lsl #8
    174  1.1  christos 	orr	r4, r4, r5, lsr #24
    175  1.1  christos 	mov	r5, r5, lsl #8
    176  1.1  christos 	orr	r5, r5, r12, lsr #24
    177  1.1  christos 	mov	r12, r12, lsl #8
    178  1.1  christos 	orr	r12, r12, lr, lsr #24
    179  1.1  christos #else
    180  1.1  christos 	orr	r3, r3, r4, lsl #24
    181  1.1  christos 	mov	r4, r4, lsr #8
    182  1.1  christos 	orr	r4, r4, r5, lsl #24
    183  1.1  christos 	mov	r5, r5, lsr #8
    184  1.1  christos 	orr	r5, r5, r12, lsl #24
    185  1.1  christos 	mov	r12, r12, lsr #8
    186  1.1  christos 	orr	r12, r12, lr, lsl #24
    187  1.1  christos #endif
    188  1.1  christos 	stmia	r0!, {r3-r5, r12}
    189  1.1  christos 	subs	r2, r2, #0x10
    190  1.1  christos 	bge	.Lmemmove_fsrcul1loop16
    191  1.5      matt 	pop	{r4, r5}
    192  1.1  christos 	adds	r2, r2, #0x0c
    193  1.1  christos 	blt	.Lmemmove_fsrcul1l4
    194  1.1  christos 
    195  1.1  christos .Lmemmove_fsrcul1loop4:
    196  1.1  christos #ifdef __ARMEB__
    197  1.1  christos 	mov	r12, lr, lsl #8
    198  1.1  christos #else
    199  1.1  christos 	mov	r12, lr, lsr #8
    200  1.1  christos #endif
    201  1.1  christos 	ldr	lr, [r1], #4
    202  1.1  christos #ifdef __ARMEB__
    203  1.1  christos 	orr	r12, r12, lr, lsr #24
    204  1.1  christos #else
    205  1.1  christos 	orr	r12, r12, lr, lsl #24
    206  1.1  christos #endif
    207  1.1  christos 	str	r12, [r0], #4
    208  1.1  christos 	subs	r2, r2, #4
    209  1.1  christos 	bge	.Lmemmove_fsrcul1loop4
    210  1.1  christos 
    211  1.1  christos .Lmemmove_fsrcul1l4:
    212  1.1  christos 	sub	r1, r1, #3
    213  1.1  christos 	b	.Lmemmove_fl4
    214  1.1  christos 
    215  1.1  christos .Lmemmove_fsrcul2:
    216  1.1  christos 	cmp	r2, #0x0c
    217  1.1  christos 	blt	.Lmemmove_fsrcul2loop4
    218  1.1  christos 	sub	r2, r2, #0x0c
    219  1.5      matt 	push	{r4, r5}
    220  1.1  christos 
    221  1.1  christos .Lmemmove_fsrcul2loop16:
    222  1.1  christos #ifdef __ARMEB__
    223  1.1  christos 	mov	r3, lr, lsl #16
    224  1.1  christos #else
    225  1.1  christos 	mov	r3, lr, lsr #16
    226  1.1  christos #endif
    227  1.1  christos 	ldmia	r1!, {r4, r5, r12, lr}
    228  1.1  christos #ifdef __ARMEB__
    229  1.1  christos 	orr	r3, r3, r4, lsr #16
    230  1.1  christos 	mov	r4, r4, lsl #16
    231  1.1  christos 	orr	r4, r4, r5, lsr #16
    232  1.1  christos 	mov	r5, r5, lsl #16
    233  1.1  christos 	orr	r5, r5, r12, lsr #16
    234  1.1  christos 	mov	r12, r12, lsl #16
    235  1.1  christos 	orr	r12, r12, lr, lsr #16
    236  1.1  christos #else
    237  1.1  christos 	orr	r3, r3, r4, lsl #16
    238  1.1  christos 	mov	r4, r4, lsr #16
    239  1.1  christos 	orr	r4, r4, r5, lsl #16
    240  1.1  christos 	mov	r5, r5, lsr #16
    241  1.1  christos 	orr	r5, r5, r12, lsl #16
    242  1.1  christos 	mov	r12, r12, lsr #16
    243  1.1  christos 	orr	r12, r12, lr, lsl #16
    244  1.1  christos #endif
    245  1.1  christos 	stmia	r0!, {r3-r5, r12}
    246  1.1  christos 	subs	r2, r2, #0x10
    247  1.1  christos 	bge	.Lmemmove_fsrcul2loop16
    248  1.5      matt 	pop	{r4, r5}
    249  1.1  christos 	adds	r2, r2, #0x0c
    250  1.1  christos 	blt	.Lmemmove_fsrcul2l4
    251  1.1  christos 
    252  1.1  christos .Lmemmove_fsrcul2loop4:
    253  1.1  christos #ifdef __ARMEB__
    254  1.1  christos 	mov	r12, lr, lsl #16
    255  1.1  christos #else
    256  1.1  christos 	mov	r12, lr, lsr #16
    257  1.1  christos #endif
    258  1.1  christos 	ldr	lr, [r1], #4
    259  1.1  christos #ifdef __ARMEB__
    260  1.1  christos 	orr	r12, r12, lr, lsr #16
    261  1.1  christos #else
    262  1.1  christos 	orr	r12, r12, lr, lsl #16
    263  1.1  christos #endif
    264  1.1  christos 	str	r12, [r0], #4
    265  1.1  christos 	subs	r2, r2, #4
    266  1.1  christos 	bge	.Lmemmove_fsrcul2loop4
    267  1.1  christos 
    268  1.1  christos .Lmemmove_fsrcul2l4:
    269  1.1  christos 	sub	r1, r1, #2
    270  1.1  christos 	b	.Lmemmove_fl4
    271  1.1  christos 
    272  1.1  christos .Lmemmove_fsrcul3:
    273  1.1  christos 	cmp	r2, #0x0c
    274  1.1  christos 	blt	.Lmemmove_fsrcul3loop4
    275  1.1  christos 	sub	r2, r2, #0x0c
    276  1.5      matt 	push	{r4, r5}
    277  1.1  christos 
    278  1.1  christos .Lmemmove_fsrcul3loop16:
    279  1.1  christos #ifdef __ARMEB__
    280  1.1  christos 	mov	r3, lr, lsl #24
    281  1.1  christos #else
    282  1.1  christos 	mov	r3, lr, lsr #24
    283  1.1  christos #endif
    284  1.1  christos 	ldmia	r1!, {r4, r5, r12, lr}
    285  1.1  christos #ifdef __ARMEB__
    286  1.1  christos 	orr	r3, r3, r4, lsr #8
    287  1.1  christos 	mov	r4, r4, lsl #24
    288  1.1  christos 	orr	r4, r4, r5, lsr #8
    289  1.1  christos 	mov	r5, r5, lsl #24
    290  1.1  christos 	orr	r5, r5, r12, lsr #8
    291  1.1  christos 	mov	r12, r12, lsl #24
    292  1.1  christos 	orr	r12, r12, lr, lsr #8
    293  1.1  christos #else
    294  1.1  christos 	orr	r3, r3, r4, lsl #8
    295  1.1  christos 	mov	r4, r4, lsr #24
    296  1.1  christos 	orr	r4, r4, r5, lsl #8
    297  1.1  christos 	mov	r5, r5, lsr #24
    298  1.1  christos 	orr	r5, r5, r12, lsl #8
    299  1.1  christos 	mov	r12, r12, lsr #24
    300  1.1  christos 	orr	r12, r12, lr, lsl #8
    301  1.1  christos #endif
    302  1.1  christos 	stmia	r0!, {r3-r5, r12}
    303  1.1  christos 	subs	r2, r2, #0x10
    304  1.1  christos 	bge	.Lmemmove_fsrcul3loop16
    305  1.5      matt 	pop	{r4, r5}
    306  1.1  christos 	adds	r2, r2, #0x0c
    307  1.1  christos 	blt	.Lmemmove_fsrcul3l4
    308  1.1  christos 
    309  1.1  christos .Lmemmove_fsrcul3loop4:
    310  1.1  christos #ifdef __ARMEB__
    311  1.1  christos 	mov	r12, lr, lsl #24
    312  1.1  christos #else
    313  1.1  christos 	mov	r12, lr, lsr #24
    314  1.1  christos #endif
    315  1.1  christos 	ldr	lr, [r1], #4
    316  1.1  christos #ifdef __ARMEB__
    317  1.1  christos 	orr	r12, r12, lr, lsr #8
    318  1.1  christos #else
    319  1.1  christos 	orr	r12, r12, lr, lsl #8
    320  1.1  christos #endif
    321  1.1  christos 	str	r12, [r0], #4
    322  1.1  christos 	subs	r2, r2, #4
    323  1.1  christos 	bge	.Lmemmove_fsrcul3loop4
    324  1.1  christos 
    325  1.1  christos .Lmemmove_fsrcul3l4:
    326  1.1  christos 	sub	r1, r1, #1
    327  1.1  christos 	b	.Lmemmove_fl4
    328  1.1  christos 
    329  1.1  christos .Lmemmove_backwards:
    330  1.1  christos 	add	r1, r1, r2
    331  1.1  christos 	add	r0, r0, r2
    332  1.1  christos 	subs	r2, r2, #4
    333  1.1  christos 	blt	.Lmemmove_bl4		/* less than 4 bytes */
    334  1.1  christos 	ands	r12, r0, #3
    335  1.1  christos 	bne	.Lmemmove_bdestul	/* oh unaligned destination addr */
    336  1.1  christos 	ands	r12, r1, #3
    337  1.1  christos 	bne	.Lmemmove_bsrcul		/* oh unaligned source addr */
    338  1.1  christos 
    339  1.1  christos .Lmemmove_bt8:
    340  1.1  christos 	/* We have aligned source and destination */
    341  1.1  christos 	subs	r2, r2, #8
    342  1.1  christos 	blt	.Lmemmove_bl12		/* less than 12 bytes (4 from above) */
    343  1.5      matt 	push	{r4, lr}
    344  1.1  christos 	subs	r2, r2, #0x14		/* less than 32 bytes (12 from above) */
    345  1.1  christos 	blt	.Lmemmove_bl32
    346  1.1  christos 
    347  1.1  christos 	/* blat 32 bytes at a time */
    348  1.1  christos 	/* XXX for really big copies perhaps we should use more registers */
    349  1.1  christos .Lmemmove_bloop32:
    350  1.1  christos 	ldmdb	r1!, {r3, r4, r12, lr}
    351  1.1  christos 	stmdb	r0!, {r3, r4, r12, lr}
    352  1.1  christos 	ldmdb	r1!, {r3, r4, r12, lr}
    353  1.1  christos 	stmdb	r0!, {r3, r4, r12, lr}
    354  1.1  christos 	subs	r2, r2, #0x20
    355  1.1  christos 	bge	.Lmemmove_bloop32
    356  1.1  christos 
    357  1.1  christos .Lmemmove_bl32:
    358  1.1  christos 	cmn	r2, #0x10
    359  1.5      matt 	ldmdbge	r1!, {r3, r4, r12, lr}	/* blat a remaining 16 bytes */
    360  1.5      matt 	stmdbge	r0!, {r3, r4, r12, lr}
    361  1.1  christos 	subge	r2, r2, #0x10
    362  1.1  christos 	adds	r2, r2, #0x14
    363  1.5      matt 	ldmdbge	r1!, {r3, r12, lr}	/* blat a remaining 12 bytes */
    364  1.5      matt 	stmdbge	r0!, {r3, r12, lr}
    365  1.1  christos 	subge	r2, r2, #0x0c
    366  1.5      matt 	pop	{r4, lr}
    367  1.1  christos 
    368  1.1  christos .Lmemmove_bl12:
    369  1.1  christos 	adds	r2, r2, #8
    370  1.1  christos 	blt	.Lmemmove_bl4
    371  1.1  christos 	subs	r2, r2, #4
    372  1.1  christos 	ldrlt	r3, [r1, #-4]!
    373  1.1  christos 	strlt	r3, [r0, #-4]!
    374  1.5      matt 	ldmdbge	r1!, {r3, r12}
    375  1.5      matt 	stmdbge	r0!, {r3, r12}
    376  1.1  christos 	subge	r2, r2, #4
    377  1.1  christos 
    378  1.1  christos .Lmemmove_bl4:
    379  1.1  christos 	/* less than 4 bytes to go */
    380  1.1  christos 	adds	r2, r2, #4
    381  1.1  christos 	RETc(eq)
    382  1.1  christos 
    383  1.1  christos 	/* copy the crud byte at a time */
    384  1.1  christos 	cmp	r2, #2
    385  1.1  christos 	ldrb	r3, [r1, #-1]!
    386  1.1  christos 	strb	r3, [r0, #-1]!
    387  1.5      matt 	ldrbge	r3, [r1, #-1]!
    388  1.5      matt 	strbge	r3, [r0, #-1]!
    389  1.5      matt 	ldrbgt	r3, [r1, #-1]!
    390  1.5      matt 	strbgt	r3, [r0, #-1]!
    391  1.1  christos 	RET
    392  1.1  christos 
    393  1.1  christos 	/* erg - unaligned destination */
    394  1.1  christos .Lmemmove_bdestul:
    395  1.1  christos 	cmp	r12, #2
    396  1.1  christos 
    397  1.1  christos 	/* align destination with byte copies */
    398  1.1  christos 	ldrb	r3, [r1, #-1]!
    399  1.1  christos 	strb	r3, [r0, #-1]!
    400  1.5      matt 	ldrbge	r3, [r1, #-1]!
    401  1.5      matt 	strbge	r3, [r0, #-1]!
    402  1.5      matt 	ldrbgt	r3, [r1, #-1]!
    403  1.5      matt 	strbgt	r3, [r0, #-1]!
    404  1.1  christos 	subs	r2, r2, r12
    405  1.1  christos 	blt	.Lmemmove_bl4		/* less than 4 bytes to go */
    406  1.1  christos 	ands	r12, r1, #3
    407  1.1  christos 	beq	.Lmemmove_bt8		/* we have an aligned source */
    408  1.1  christos 
    409  1.1  christos 	/* erg - unaligned source */
    410  1.1  christos 	/* This is where it gets nasty ... */
    411  1.1  christos .Lmemmove_bsrcul:
    412  1.1  christos 	bic	r1, r1, #3
    413  1.1  christos 	ldr	r3, [r1, #0]
    414  1.1  christos 	cmp	r12, #2
    415  1.1  christos 	blt	.Lmemmove_bsrcul1
    416  1.1  christos 	beq	.Lmemmove_bsrcul2
    417  1.1  christos 	cmp	r2, #0x0c
    418  1.1  christos 	blt	.Lmemmove_bsrcul3loop4
    419  1.1  christos 	sub	r2, r2, #0x0c
    420  1.5      matt 	push	{r4, r5, lr}
    421  1.1  christos 
    422  1.1  christos .Lmemmove_bsrcul3loop16:
    423  1.1  christos #ifdef __ARMEB__
    424  1.1  christos 	mov	lr, r3, lsr #8
    425  1.1  christos #else
    426  1.1  christos 	mov	lr, r3, lsl #8
    427  1.1  christos #endif
    428  1.1  christos 	ldmdb	r1!, {r3-r5, r12}
    429  1.1  christos #ifdef __ARMEB__
    430  1.1  christos 	orr	lr, lr, r12, lsl #24
    431  1.1  christos 	mov	r12, r12, lsr #8
    432  1.1  christos 	orr	r12, r12, r5, lsl #24
    433  1.1  christos 	mov	r5, r5, lsr #8
    434  1.1  christos 	orr	r5, r5, r4, lsl #24
    435  1.1  christos 	mov	r4, r4, lsr #8
    436  1.1  christos 	orr	r4, r4, r3, lsl #24
    437  1.1  christos #else
    438  1.1  christos 	orr	lr, lr, r12, lsr #24
    439  1.1  christos 	mov	r12, r12, lsl #8
    440  1.1  christos 	orr	r12, r12, r5, lsr #24
    441  1.1  christos 	mov	r5, r5, lsl #8
    442  1.1  christos 	orr	r5, r5, r4, lsr #24
    443  1.1  christos 	mov	r4, r4, lsl #8
    444  1.1  christos 	orr	r4, r4, r3, lsr #24
    445  1.1  christos #endif
    446  1.1  christos 	stmdb	r0!, {r4, r5, r12, lr}
    447  1.1  christos 	subs	r2, r2, #0x10
    448  1.1  christos 	bge	.Lmemmove_bsrcul3loop16
    449  1.5      matt 	pop	{r4, r5, lr}
    450  1.1  christos 	adds	r2, r2, #0x0c
    451  1.1  christos 	blt	.Lmemmove_bsrcul3l4
    452  1.1  christos 
    453  1.1  christos .Lmemmove_bsrcul3loop4:
    454  1.1  christos #ifdef __ARMEB__
    455  1.1  christos 	mov	r12, r3, lsr #8
    456  1.1  christos #else
    457  1.1  christos 	mov	r12, r3, lsl #8
    458  1.1  christos #endif
    459  1.1  christos 	ldr	r3, [r1, #-4]!
    460  1.1  christos #ifdef __ARMEB__
    461  1.1  christos 	orr	r12, r12, r3, lsl #24
    462  1.1  christos #else
    463  1.1  christos 	orr	r12, r12, r3, lsr #24
    464  1.1  christos #endif
    465  1.1  christos 	str	r12, [r0, #-4]!
    466  1.1  christos 	subs	r2, r2, #4
    467  1.1  christos 	bge	.Lmemmove_bsrcul3loop4
    468  1.1  christos 
    469  1.1  christos .Lmemmove_bsrcul3l4:
    470  1.1  christos 	add	r1, r1, #3
    471  1.1  christos 	b	.Lmemmove_bl4
    472  1.1  christos 
    473  1.1  christos .Lmemmove_bsrcul2:
    474  1.1  christos 	cmp	r2, #0x0c
    475  1.1  christos 	blt	.Lmemmove_bsrcul2loop4
    476  1.1  christos 	sub	r2, r2, #0x0c
    477  1.5      matt 	push	{r4, r5, lr}
    478  1.1  christos 
    479  1.1  christos .Lmemmove_bsrcul2loop16:
    480  1.1  christos #ifdef __ARMEB__
    481  1.1  christos 	mov	lr, r3, lsr #16
    482  1.1  christos #else
    483  1.1  christos 	mov	lr, r3, lsl #16
    484  1.1  christos #endif
    485  1.1  christos 	ldmdb	r1!, {r3-r5, r12}
    486  1.1  christos #ifdef __ARMEB__
    487  1.1  christos 	orr	lr, lr, r12, lsl #16
    488  1.1  christos 	mov	r12, r12, lsr #16
    489  1.1  christos 	orr	r12, r12, r5, lsl #16
    490  1.1  christos 	mov	r5, r5, lsr #16
    491  1.1  christos 	orr	r5, r5, r4, lsl #16
    492  1.1  christos 	mov	r4, r4, lsr #16
    493  1.1  christos 	orr	r4, r4, r3, lsl #16
    494  1.1  christos #else
    495  1.1  christos 	orr	lr, lr, r12, lsr #16
    496  1.1  christos 	mov	r12, r12, lsl #16
    497  1.1  christos 	orr	r12, r12, r5, lsr #16
    498  1.1  christos 	mov	r5, r5, lsl #16
    499  1.1  christos 	orr	r5, r5, r4, lsr #16
    500  1.1  christos 	mov	r4, r4, lsl #16
    501  1.1  christos 	orr	r4, r4, r3, lsr #16
    502  1.1  christos #endif
    503  1.1  christos 	stmdb	r0!, {r4, r5, r12, lr}
    504  1.1  christos 	subs	r2, r2, #0x10
    505  1.1  christos 	bge	.Lmemmove_bsrcul2loop16
    506  1.5      matt 	pop	{r4, r5, lr}
    507  1.1  christos 	adds	r2, r2, #0x0c
    508  1.1  christos 	blt	.Lmemmove_bsrcul2l4
    509  1.1  christos 
    510  1.1  christos .Lmemmove_bsrcul2loop4:
    511  1.1  christos #ifdef __ARMEB__
    512  1.1  christos 	mov	r12, r3, lsr #16
    513  1.1  christos #else
    514  1.1  christos 	mov	r12, r3, lsl #16
    515  1.1  christos #endif
    516  1.1  christos 	ldr	r3, [r1, #-4]!
    517  1.1  christos #ifdef __ARMEB__
    518  1.1  christos 	orr	r12, r12, r3, lsl #16
    519  1.1  christos #else
    520  1.1  christos 	orr	r12, r12, r3, lsr #16
    521  1.1  christos #endif
    522  1.1  christos 	str	r12, [r0, #-4]!
    523  1.1  christos 	subs	r2, r2, #4
    524  1.1  christos 	bge	.Lmemmove_bsrcul2loop4
    525  1.1  christos 
    526  1.1  christos .Lmemmove_bsrcul2l4:
    527  1.1  christos 	add	r1, r1, #2
    528  1.1  christos 	b	.Lmemmove_bl4
    529  1.1  christos 
    530  1.1  christos .Lmemmove_bsrcul1:
    531  1.1  christos 	cmp	r2, #0x0c
    532  1.1  christos 	blt	.Lmemmove_bsrcul1loop4
    533  1.1  christos 	sub	r2, r2, #0x0c
    534  1.5      matt 	push	{r4, r5, lr}
    535  1.1  christos 
    536  1.1  christos .Lmemmove_bsrcul1loop32:
    537  1.1  christos #ifdef __ARMEB__
    538  1.1  christos 	mov	lr, r3, lsr #24
    539  1.1  christos #else
    540  1.1  christos 	mov	lr, r3, lsl #24
    541  1.1  christos #endif
    542  1.1  christos 	ldmdb	r1!, {r3-r5, r12}
    543  1.1  christos #ifdef __ARMEB__
    544  1.1  christos 	orr	lr, lr, r12, lsl #8
    545  1.1  christos 	mov	r12, r12, lsr #24
    546  1.1  christos 	orr	r12, r12, r5, lsl #8
    547  1.1  christos 	mov	r5, r5, lsr #24
    548  1.1  christos 	orr	r5, r5, r4, lsl #8
    549  1.1  christos 	mov	r4, r4, lsr #24
    550  1.1  christos 	orr	r4, r4, r3, lsl #8
    551  1.1  christos #else
    552  1.1  christos 	orr	lr, lr, r12, lsr #8
    553  1.1  christos 	mov	r12, r12, lsl #24
    554  1.1  christos 	orr	r12, r12, r5, lsr #8
    555  1.1  christos 	mov	r5, r5, lsl #24
    556  1.1  christos 	orr	r5, r5, r4, lsr #8
    557  1.1  christos 	mov	r4, r4, lsl #24
    558  1.1  christos 	orr	r4, r4, r3, lsr #8
    559  1.1  christos #endif
    560  1.1  christos 	stmdb	r0!, {r4, r5, r12, lr}
    561  1.1  christos 	subs	r2, r2, #0x10
    562  1.1  christos 	bge	.Lmemmove_bsrcul1loop32
    563  1.5      matt 	pop	{r4, r5, lr}
    564  1.1  christos 	adds	r2, r2, #0x0c
    565  1.1  christos 	blt	.Lmemmove_bsrcul1l4
    566  1.1  christos 
    567  1.1  christos .Lmemmove_bsrcul1loop4:
    568  1.1  christos #ifdef __ARMEB__
    569  1.1  christos 	mov	r12, r3, lsr #24
    570  1.1  christos #else
    571  1.1  christos 	mov	r12, r3, lsl #24
    572  1.1  christos #endif
    573  1.1  christos 	ldr	r3, [r1, #-4]!
    574  1.1  christos #ifdef __ARMEB__
    575  1.1  christos 	orr	r12, r12, r3, lsl #8
    576  1.1  christos #else
    577  1.1  christos 	orr	r12, r12, r3, lsr #8
    578  1.1  christos #endif
    579  1.1  christos 	str	r12, [r0, #-4]!
    580  1.1  christos 	subs	r2, r2, #4
    581  1.1  christos 	bge	.Lmemmove_bsrcul1loop4
    582  1.1  christos 
    583  1.1  christos .Lmemmove_bsrcul1l4:
    584  1.1  christos 	add	r1, r1, #1
    585  1.1  christos 	b	.Lmemmove_bl4
    586