Rev 3274 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
2145 | kebrt | 1 | # |
2153 | kebrt | 2 | # Copyright (c) 2007 Michal Kebrt |
2145 | kebrt | 3 | # All rights reserved. |
4 | # |
||
5 | # Redistribution and use in source and binary forms, with or without |
||
6 | # modification, are permitted provided that the following conditions |
||
7 | # are met: |
||
8 | # |
||
9 | # - Redistributions of source code must retain the above copyright |
||
10 | # notice, this list of conditions and the following disclaimer. |
||
11 | # - Redistributions in binary form must reproduce the above copyright |
||
12 | # notice, this list of conditions and the following disclaimer in the |
||
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 |
||
15 | # derived from this software without specific prior written permission. |
||
16 | # |
||
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 |
||
19 | # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
||
20 | # IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
||
21 | # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
||
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 |
||
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 |
||
26 | # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||
27 | # |
||
28 | |||
29 | |||
30 | .text |
||
31 | |||
2153 | kebrt | 32 | .global memcpy |
2145 | kebrt | 33 | |
34 | memcpy: |
||
2165 | kebrt | 35 | add r3, r1, #3 |
36 | bic r3, r3, #3 |
||
37 | cmp r1, r3 |
||
3274 | jermar | 38 | stmdb sp!, {r4, r5, lr} |
39 | mov r5, r0 |
||
2323 | kebrt | 40 | beq 4f |
41 | 1: |
||
2165 | kebrt | 42 | cmp r2, #0 |
43 | movne ip, #0 |
||
2323 | kebrt | 44 | beq 3f |
45 | 2: |
||
2165 | kebrt | 46 | ldrb r3, [ip, r1] |
47 | strb r3, [ip, r0] |
||
48 | add ip, ip, #1 |
||
49 | cmp ip, r2 |
||
2323 | kebrt | 50 | bne 2b |
51 | 3: |
||
3274 | jermar | 52 | mov r0, r5 |
53 | ldmia sp!, {r4, r5, pc} |
||
2323 | kebrt | 54 | 4: |
2165 | kebrt | 55 | add r3, r0, #3 |
56 | bic r3, r3, #3 |
||
57 | cmp r0, r3 |
||
2323 | kebrt | 58 | bne 1b |
2165 | kebrt | 59 | movs r4, r2, lsr #2 |
60 | moveq lr, r4 |
||
2323 | kebrt | 61 | beq 6f |
2165 | kebrt | 62 | mov lr, #0 |
63 | mov ip, lr |
||
2323 | kebrt | 64 | 5: |
2165 | kebrt | 65 | ldr r3, [ip, r1] |
66 | add lr, lr, #1 |
||
67 | cmp lr, r4 |
||
68 | str r3, [ip, r0] |
||
69 | add ip, ip, #4 |
||
2323 | kebrt | 70 | bne 5b |
71 | 6: |
||
2165 | kebrt | 72 | ands r4, r2, #3 |
2323 | kebrt | 73 | beq 3b |
2165 | kebrt | 74 | mov r3, lr, lsl #2 |
75 | add r0, r3, r0 |
||
76 | add ip, r3, r1 |
||
77 | mov r2, #0 |
||
2323 | kebrt | 78 | 7: |
2165 | kebrt | 79 | ldrb r3, [r2, ip] |
80 | strb r3, [r2, r0] |
||
81 | add r2, r2, #1 |
||
82 | cmp r2, r4 |
||
2323 | kebrt | 83 | bne 7b |
84 | b 3b |
||
2145 | kebrt | 85 | |
86 |