-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcompiler.s
More file actions
134 lines (105 loc) · 2.1 KB
/
compiler.s
File metadata and controls
134 lines (105 loc) · 2.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
;
; compiler.s
;
; Copyright 2014 Fernando Rodriguez (support@fernansoft.com).
; All rights reserved
;
.global _memcpy_fast
_memcpy_fast:
cp0 w2
bra z, _memcpy_return
_memcpy_fast2:
btst w0, #0
bra nz, _memcpy_dst_unaligned
btst w1, #0
bra nz, _memcpy_unaligned
goto _memcpy_aligned
_memcpy_dst_unaligned:
btst w1, #0
bra z, _memcpy_unaligned
mov.b [w1++], w3
mov.b w3, [w0++]
dec w2, w2
cp0 w2
bra z, _memcpy_return
_memcpy_aligned:
cp w2, #1
bra gtu, _memcpy_aligned2
mov.b [w1++], w3
mov.b w3, [w0++]
return
_memcpy_aligned2:
mov #~1, w3
and w2, w3, w3
lsr w3, #1, w3
dec w3, w3
do w3, _memcpy_fast_loop
;nop ;<-- this is needed if the source is in auto_psv
mov [w1++], w3
_memcpy_fast_loop:
mov w3, [w0++]
btss w2, #0
return
mov.b [w1], w3
mov.b w3, [w0]
_memcpy_return:
return
_memcpy_unaligned:
dec w2, w3
do w3, _memcpy_fast_loop_u
;nop ;<-- this is needed if the source is in auto_psv
mov.b [w1++], w3
_memcpy_fast_loop_u:
mov.b w3, [w0++]
return
.global _memmove_fast
_memmove_fast:
cp0 w2
bra z, _memmove_return
cp w0, w1
bra ltu, _memcpy_fast2
add w0, w2, w0
add w1, w2, w1
btst w0, #0
bra nz, _memmove_dst_unaligned
btst w1, #0
bra nz, _memmove_unaligned
goto _memmove_aligned
_memmove_dst_unaligned:
btst w1, #0
bra z, _memmove_unaligned
mov.b [--w1], w3
mov.b w3, [--w0]
dec w2, w2
cp0 w2
bra z, _memmove_return
_memmove_aligned:
cp w2, #1
bra gtu, _memmove_aligned2
mov.b [--w1], w3
mov.b w3, [--w0]
return
_memmove_aligned2:
mov #~1, w3
and w2, w3, w3
lsr w3, #1, w3
dec w3, w3
do w3, _memmove_fast_loop
;nop ;<-- this is needed if the source is in auto_psv
mov [--w1], w3
_memmove_fast_loop:
mov w3, [--w0]
btss w2, #0
return
mov.b [w1 + 1], w3
mov.b w3, [w0 + 1]
_memmove_return:
return
_memmove_unaligned:
dec w2, w3
do w3, _memmove_fast_loop_u
;nop ;<-- this is needed if the source is in auto_psv
mov.b [--w1], w3
_memmove_fast_loop_u:
mov.b w3, [--w0]
return