Warning: Attempt to read property "date" on null in /usr/local/www/websvn.planix.org/blame.php on line 247

Warning: Attempt to read property "msg" on null in /usr/local/www/websvn.planix.org/blame.php on line 247
WebSVN – planix.SVN – Blame – /os/branches/feature_fixcpp/sys/src/ape/lib/ap/sparc/memmove.s – Rev 2

Subversion Repositories planix.SVN

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 - 1
	TEXT	memmove(SB), $0
2
	JMP	move
3
 
4
	TEXT	memcpy(SB), $0
5
move:
6
 
7
/*
8
 * performance:
9
 * (tba)
10
 */
11
 
12
	MOVW	R7, s1+0(FP)
13
	MOVW	n+8(FP), R9		/* R9 is count */
14
	MOVW	R7, R10			/* R10 is to-pointer */
15
	SUBCC	R0,R9, R0
16
	BGE	ok
17
	MOVW	0(R0), R0
18
 
19
ok:
20
	MOVW	s2+4(FP), R11		/* R11 is from-pointer */
21
	ADD	R9,R11, R13		/* R13 is end from-pointer */
22
	ADD	R9,R10, R12		/* R12 is end to-pointer */
23
 
24
/*
25
 * easiest test is copy backwards if
26
 * destination string has higher mem address
27
 */
28
	SUBCC	R11,R10, R0
29
	BGU	back
30
 
31
/*
32
 * if not at least 4 chars,
33
 * dont even mess around.
34
 * 3 chars to guarantee any
35
 * rounding up to a word
36
 * boundary and 4 characters
37
 * to get at least maybe one
38
 * full word store.
39
 */
40
	SUBCC	$4,R9, R0
41
	BL	fout
42
 
43
/*
44
 * test if both pointers
45
 * are similarly word aligned
46
 */
47
	XOR	R10,R11, R7
48
	ANDCC	$3,R7, R0
49
	BNE	fout
50
 
51
/*
52
 * byte at a time to word align
53
 */
54
f1:
55
	ANDCC	$3,R10, R0
56
	BE	f2
57
	MOVB	0(R11), R16
58
	ADD	$1, R11
59
	MOVB	R16, 0(R10)
60
	ADD	$1, R10
61
	JMP	f1
62
 
63
/*
64
 * turn R9 into to-end pointer-15
65
 * copy 16 at a time while theres room.
66
 * R12 is smaller than R13 --
67
 * there are problems if R13 is 0.
68
 */
69
f2:
70
	SUB	$15,R12, R9
71
f3:
72
	SUBCC	R10,R9, R0
73
	BLEU	f4
74
	MOVW	0(R11), R16
75
	MOVW	4(R11), R17
76
	MOVW	R16, 0(R10)
77
	MOVW	8(R11), R16
78
	MOVW	R17, 4(R10)
79
	MOVW	12(R11), R17
80
	ADD	$16, R11
81
	MOVW	R16, 8(R10)
82
	MOVW	R17, 12(R10)
83
	ADD	$16, R10
84
	JMP	f3
85
 
86
/*
87
 * turn R9 into to-end pointer-3
88
 * copy 4 at a time while theres room
89
 */
90
f4:
91
	SUB	$3,R12, R9
92
f5:
93
	SUBCC	R10,R9, R0
94
	BLEU	fout
95
	MOVW	0(R11), R16
96
	ADD	$4, R11
97
	MOVW	R16, 0(R10)
98
	ADD	$4, R10
99
	JMP	f5
100
 
101
/*
102
 * last loop, copy byte at a time
103
 */
104
fout:
105
	SUBCC	R11,R13, R0
106
	BLEU	ret
107
	MOVB	0(R11), R16
108
	ADD	$1, R11
109
	MOVB	R16, 0(R10)
110
	ADD	$1, R10
111
	JMP	fout
112
 
113
/*
114
 * whole thing repeated for backwards
115
 */
116
back:
117
	SUBCC	$4,R9, R0 
118
	BL	bout
119
 
120
	XOR	R12,R13, R7
121
	ANDCC	$3,R7, R0
122
	BNE	bout
123
b1:
124
	ANDCC	$3,R13, R0
125
	BE	b2
126
	MOVB	-1(R13), R16
127
	SUB	$1, R13
128
	MOVB	R16, -1(R12)
129
	SUB	$1, R12
130
	JMP	b1
131
b2:
132
	ADD	$15,R11, R9
133
b3:
134
	SUBCC	R9,R13, R0
135
	BLEU	b4
136
	MOVW	-4(R13), R16
137
	MOVW	-8(R13), R17
138
	MOVW	R16, -4(R12)
139
	MOVW	-12(R13), R16
140
	MOVW	R17, -8(R12)
141
	MOVW	-16(R13), R17
142
	SUB	$16, R13
143
	MOVW	R16, -12(R12)
144
	MOVW	R17, -16(R12)
145
	SUB	$16, R12
146
	JMP	b3
147
b4:
148
	ADD	$3,R11, R9
149
b5:
150
	SUBCC	R9,R13, R0
151
	BLEU	bout
152
	MOVW	-4(R13), R16
153
	SUB	$4, R13
154
	MOVW	R16, -4(R12)
155
	SUB	$4, R12
156
	JMP	b5
157
 
158
bout:
159
	SUBCC	R11,R13, R0
160
	BLEU	ret
161
	MOVB	-1(R13), R16
162
	SUB	$1, R13
163
	MOVB	R16, -1(R12)
164
	SUB	$1, R12
165
	JMP	bout
166
 
167
ret:
168
	MOVW	s1+0(FP), R7
169
	RETURN