Kernel/armv7 - Improved memcpy
[tpg/acess2.git] / Kernel / arch / armv7 / lib.S
1 /*
2  * Acess2 ARM
3  * - By John Hodge (thePowersGang)
4  *
5  * arch/arm7/lib.S
6  * - Assembly editions of library functions
7  */
8 #include "include/assembly.h"
9
10 .globl __memcpy_byte
11 __memcpy_byte:
12 1:
13         tst r2, r2      @ Check counter
14         moveq pc, lr    @ Return if zero
15         ldrb r3, [r1],#1        @ Read
16         strb r3, [r0],#1        @ Write
17         sub r2, #1
18         b 1b
19
20
21 @ Pre-aligned memcpy (32-bit blocks)
22
23 .globl __memcpy_align4
24 __memcpy_align4:
25         push {r4}
26         mvn r3, #3      @ Mask for checking length
27         
28         @ 4 byte chunk copies
29 1:      tst r2, r3
30         ldrne r4, [r1],#4
31         strne r4, [r0],#4
32         subne r2, #4
33         bne 1b
34
35         @ single byte copies to finish off
36 2:      tst r2, #3
37         beq 3f
38         ldrb r4, [r1],#1
39         strb r4, [r0],#1
40         sub r2, #1
41         b 2b
42
43 3:      pop {r4}
44         mov pc, lr

UCC git Repository :: git.ucc.asn.au