Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
awilliam
GitHub Repository: awilliam/linux-vfio
Path: blob/master/arch/avr32/lib/memcpy.S
10817 views
1
/*
2
* Copyright (C) 2004-2006 Atmel Corporation
3
*
4
* This program is free software; you can redistribute it and/or modify
5
* it under the terms of the GNU General Public License version 2 as
6
* published by the Free Software Foundation.
7
*/
8
9
/*
10
* void *memcpy(void *to, const void *from, unsigned long n)
11
*
12
* This implementation does word-aligned loads in the main loop,
13
* possibly sacrificing alignment of stores.
14
*
15
* Hopefully, in most cases, both "to" and "from" will be
16
* word-aligned to begin with.
17
*/
18
.text
19
.global memcpy
20
.type memcpy, @function
21
memcpy:
22
mov r9, r11
23
andl r9, 3, COH
24
brne 1f
25
26
/* At this point, "from" is word-aligned */
27
2: mov r9, r12
28
5: sub r10, 4
29
brlt 4f
30
31
3: ld.w r8, r11++
32
sub r10, 4
33
st.w r12++, r8
34
brge 3b
35
36
4: neg r10
37
reteq r9
38
39
/* Handle unaligned count */
40
lsl r10, 2
41
add pc, pc, r10
42
ld.ub r8, r11++
43
st.b r12++, r8
44
ld.ub r8, r11++
45
st.b r12++, r8
46
ld.ub r8, r11++
47
st.b r12++, r8
48
retal r9
49
50
/* Handle unaligned "from" pointer */
51
1: sub r10, 4
52
movlt r9, r12
53
brlt 4b
54
add r10, r9
55
lsl r9, 2
56
add pc, pc, r9
57
ld.ub r8, r11++
58
st.b r12++, r8
59
ld.ub r8, r11++
60
st.b r12++, r8
61
ld.ub r8, r11++
62
st.b r12++, r8
63
mov r8, r12
64
add pc, pc, r9
65
sub r8, 1
66
nop
67
sub r8, 1
68
nop
69
sub r8, 1
70
nop
71
mov r9, r8
72
rjmp 5b
73
74