Rev 2465 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2465 | Rev 3022 | ||
---|---|---|---|
1 | # |
1 | # |
2 | # Copyright (c) 2007 Michal Kebrt |
2 | # Copyright (c) 2007 Michal Kebrt |
3 | # All rights reserved. |
3 | # All rights reserved. |
4 | # |
4 | # |
5 | # Redistribution and use in source and binary forms, with or without |
5 | # Redistribution and use in source and binary forms, with or without |
6 | # modification, are permitted provided that the following conditions |
6 | # modification, are permitted provided that the following conditions |
7 | # are met: |
7 | # are met: |
8 | # |
8 | # |
9 | # - Redistributions of source code must retain the above copyright |
9 | # - Redistributions of source code must retain the above copyright |
10 | # notice, this list of conditions and the following disclaimer. |
10 | # notice, this list of conditions and the following disclaimer. |
11 | # - Redistributions in binary form must reproduce the above copyright |
11 | # - Redistributions in binary form must reproduce the above copyright |
12 | # notice, this list of conditions and the following disclaimer in the |
12 | # notice, this list of conditions and the following disclaimer in the |
13 | # documentation and/or other materials provided with the distribution. |
13 | # documentation and/or other materials provided with the distribution. |
14 | # - The name of the author may not be used to endorse or promote products |
14 | # - The name of the author may not be used to endorse or promote products |
15 | # derived from this software without specific prior written permission. |
15 | # derived from this software without specific prior written permission. |
16 | # |
16 | # |
17 | # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
17 | # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
18 | # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
18 | # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
19 | # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
19 | # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
20 | # IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
20 | # IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
21 | # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
21 | # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
22 | # NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
22 | # NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
23 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
23 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
24 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
25 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
25 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
26 | # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
27 | # |
27 | # |
28 | 28 | ||
29 | 29 | ||
30 | .text |
30 | .text |
31 | 31 | ||
32 | .global memcpy |
32 | .global memcpy |
33 | 33 | ||
34 | memcpy: |
34 | memcpy: |
35 | add r3, r1, #3 |
35 | add r3, r1, #3 |
36 | bic r3, r3, #3 |
36 | bic r3, r3, #3 |
37 | cmp r1, r3 |
37 | cmp r1, r3 |
38 | stmdb sp!, {r4, lr} |
38 | stmdb sp!, {r4, lr} |
39 | beq 4f |
39 | beq 4f |
40 | 1: |
40 | 1: |
41 | cmp r2, #0 |
41 | cmp r2, #0 |
42 | movne ip, #0 |
42 | movne ip, #0 |
43 | beq 3f |
43 | beq 3f |
44 | 2: |
44 | 2: |
45 | ldrb r3, [ip, r1] |
45 | ldrb r3, [ip, r1] |
46 | strb r3, [ip, r0] |
46 | strb r3, [ip, r0] |
47 | add ip, ip, #1 |
47 | add ip, ip, #1 |
48 | cmp ip, r2 |
48 | cmp ip, r2 |
49 | bne 2b |
49 | bne 2b |
50 | 3: |
50 | 3: |
51 | mov r0, r1 |
51 | mov r0, r1 |
52 | ldmia sp!, {r4, pc} |
52 | ldmia sp!, {r4, pc} |
53 | 4: |
53 | 4: |
54 | add r3, r0, #3 |
54 | add r3, r0, #3 |
55 | bic r3, r3, #3 |
55 | bic r3, r3, #3 |
56 | cmp r0, r3 |
56 | cmp r0, r3 |
57 | bne 1b |
57 | bne 1b |
58 | movs r4, r2, lsr #2 |
58 | movs r4, r2, lsr #2 |
59 | moveq lr, r4 |
59 | moveq lr, r4 |
60 | beq 6f |
60 | beq 6f |
61 | mov lr, #0 |
61 | mov lr, #0 |
62 | mov ip, lr |
62 | mov ip, lr |
63 | 5: |
63 | 5: |
64 | ldr r3, [ip, r1] |
64 | ldr r3, [ip, r1] |
65 | add lr, lr, #1 |
65 | add lr, lr, #1 |
66 | cmp lr, r4 |
66 | cmp lr, r4 |
67 | str r3, [ip, r0] |
67 | str r3, [ip, r0] |
68 | add ip, ip, #4 |
68 | add ip, ip, #4 |
69 | bne 5b |
69 | bne 5b |
70 | 6: |
70 | 6: |
71 | ands r4, r2, #3 |
71 | ands r4, r2, #3 |
72 | beq 3b |
72 | beq 3b |
73 | mov r3, lr, lsl #2 |
73 | mov r3, lr, lsl #2 |
74 | add r0, r3, r0 |
74 | add r0, r3, r0 |
75 | add ip, r3, r1 |
75 | add ip, r3, r1 |
76 | mov r2, #0 |
76 | mov r2, #0 |
77 | 7: |
77 | 7: |
78 | ldrb r3, [r2, ip] |
78 | ldrb r3, [r2, ip] |
79 | strb r3, [r2, r0] |
79 | strb r3, [r2, r0] |
80 | add r2, r2, #1 |
80 | add r2, r2, #1 |
81 | cmp r2, r4 |
81 | cmp r2, r4 |
82 | bne 7b |
82 | bne 7b |
83 | b 3b |
83 | b 3b |
84 | 84 | ||
85 | 85 | ||
86 | 86 |