32x: adjust sh2 cycles again
[picodrive.git] / pico / misc_amips.s
... / ...
CommitLineData
1#*
2#* Some misc routines for Allegrex MIPS
3#* (C) notaz, 2007-2008
4#*
5#* This work is licensed under the terms of MAME license.
6#* See COPYING file in the top-level directory.
7#*
8
9.set noreorder
10.set noat
11
12.text
13.align 4
14
15.globl memset32 # int *dest, int c, int count
16
17memset32:
18ms32_aloop:
19 andi $t0, $a0, 0x3f
20 beqz $t0, ms32_bloop_prep
21 nop
22 sw $a1, 0($a0)
23 addiu $a2, -1
24 beqz $a2, ms32_return
25 addiu $a0, 4
26 j ms32_aloop
27 nop
28
29ms32_bloop_prep:
30 srl $t0, $a2, 4 # we will do 64 bytes per iteration (cache line)
31 beqz $t0, ms32_bloop_end
32
33ms32_bloop:
34 addiu $t0, -1
35 cache 0x18, ($a0) # create dirty exclusive
36 sw $a1, 0x00($a0)
37 sw $a1, 0x04($a0)
38 sw $a1, 0x08($a0)
39 sw $a1, 0x0c($a0)
40 sw $a1, 0x10($a0)
41 sw $a1, 0x14($a0)
42 sw $a1, 0x18($a0)
43 sw $a1, 0x1c($a0)
44 sw $a1, 0x20($a0)
45 sw $a1, 0x24($a0)
46 sw $a1, 0x28($a0)
47 sw $a1, 0x2c($a0)
48 sw $a1, 0x30($a0)
49 sw $a1, 0x34($a0)
50 sw $a1, 0x38($a0)
51 sw $a1, 0x3c($a0)
52 bnez $t0, ms32_bloop
53 addiu $a0, 0x40
54
55ms32_bloop_end:
56 andi $a2, $a2, 0x0f
57 beqz $a2, ms32_return
58
59ms32_cloop:
60 addiu $a2, -1
61 sw $a1, 0($a0)
62 bnez $a2, ms32_cloop
63 addiu $a0, 4
64
65ms32_return:
66 jr $ra
67 nop
68
69
70.globl memset32_uncached # int *dest, int c, int count
71
72memset32_uncached:
73 srl $t0, $a2, 3 # we will do 32 bytes per iteration
74 beqz $t0, ms32u_bloop_end
75
76ms32u_bloop:
77 addiu $t0, -1
78 sw $a1, 0x00($a0)
79 sw $a1, 0x04($a0)
80 sw $a1, 0x08($a0)
81 sw $a1, 0x0c($a0)
82 sw $a1, 0x10($a0)
83 sw $a1, 0x14($a0)
84 sw $a1, 0x18($a0)
85 sw $a1, 0x1c($a0)
86 bnez $t0, ms32u_bloop
87 addiu $a0, 0x20
88
89ms32u_bloop_end:
90 andi $a2, $a2, 0x0f
91 beqz $a2, ms32u_return
92
93ms32u_cloop:
94 addiu $a2, -1
95 sw $a1, 0($a0)
96 bnez $a2, ms32u_cloop
97 addiu $a0, 4
98
99ms32u_return:
100 jr $ra
101 nop
102
103
104.globl memcpy32 # int *dest, int *src, int count
105
106memcpy32:
107mc32_aloop:
108 andi $t0, $a0, 0x3f
109 beqz $t0, mc32_bloop_prep
110 nop
111 lw $t1, 0($a1)
112 addiu $a2, -1
113 sw $t1, 0($a0)
114 beqz $a2, mc32_return
115 addiu $a0, 4
116 j mc32_aloop
117 addiu $a1, 4
118
119mc32_bloop_prep:
120 srl $t0, $a2, 4 # we will do 64 bytes per iteration (cache line)
121 beqz $t0, mc32_bloop_end
122
123mc32_bloop:
124 addiu $t0, -1
125 cache 0x18, ($a0) # create dirty exclusive
126 lw $t2, 0x00($a1)
127 lw $t3, 0x04($a1)
128 lw $t4, 0x08($a1)
129 lw $t5, 0x0c($a1)
130 lw $t6, 0x10($a1)
131 lw $t7, 0x14($a1)
132 lw $t8, 0x18($a1)
133 lw $t9, 0x1c($a1)
134 sw $t2, 0x00($a0)
135 sw $t3, 0x04($a0)
136 sw $t4, 0x08($a0)
137 sw $t5, 0x0c($a0)
138 sw $t6, 0x10($a0)
139 sw $t7, 0x14($a0)
140 sw $t8, 0x18($a0)
141 sw $t9, 0x1c($a0)
142 lw $t2, 0x20($a1)
143 lw $t3, 0x24($a1)
144 lw $t4, 0x28($a1)
145 lw $t5, 0x2c($a1)
146 lw $t6, 0x30($a1)
147 lw $t7, 0x34($a1)
148 lw $t8, 0x38($a1)
149 lw $t9, 0x3c($a1)
150 sw $t2, 0x20($a0)
151 sw $t3, 0x24($a0)
152 sw $t4, 0x28($a0)
153 sw $t5, 0x2c($a0)
154 sw $t6, 0x30($a0)
155 sw $t7, 0x34($a0)
156 sw $t8, 0x38($a0)
157 sw $t9, 0x3c($a0)
158 addiu $a0, 0x40
159 bnez $t0, mc32_bloop
160 addiu $a1, 0x40
161
162mc32_bloop_end:
163 andi $a2, $a2, 0x0f
164 beqz $a2, mc32_return
165
166mc32_cloop:
167 lw $t1, 0($a1)
168 addiu $a2, -1
169 addiu $a1, 4
170 sw $t1, 0($a0)
171 bnez $a2, mc32_cloop
172 addiu $a0, 4
173
174mc32_return:
175 jr $ra
176 nop
177
178# vim:filetype=mips