Disabling auto-refresh of game list by default, as it is causing bugs sometimes
[open-ps2-loader.git] / modules / iopcore / cdvdman / smsutils.s
blob11eb997c8055132821b521afc789844c8b064bf0
1 /*
2 # ___ _ _ ___
3 # | | | | |
4 # ___| | | ___| PS2DEV Open Source Project.
5 #----------------------------------------------------------
6 # Highly optimized versions of memcpy/memset.
7 # Pulled out 'sde' library from MIPS.
8 # by Eugene Plotnikov
9 */
10 .set noreorder
11 .set noat
12 .set nomacro
14 .globl mips_memcpy
15 .globl mips_memset
17 .text
18 mips_memcpy:
19 move $v0, $a0
20 beqz $a2, 1f
21 sltiu $t2, $a2, 12
22 bnez $t2, 2f
23 xor $v1, $a1, $a0
24 andi $v1, $v1, 3
25 negu $a3, $a0
26 beqz $v1, 3f
27 andi $a3, $a3, 3
28 beqz $a3, 4f
29 subu $a2, $a2, $a3
30 lwr $v1, 0($a1)
31 lwl $v1, 3($a1)
32 addu $a1, $a1, $a3
33 swr $v1, 0($a0)
34 addu $a0, $a0, $a3
36 andi $v1, $a2, 15
37 subu $a3, $a2, $v1
38 beqz $a3, 5f
39 move $a2, $v1
40 addu $a3, $a3, $a1
42 lwr $v1, 0($a1)
43 lwl $v1, 3($a1)
44 lwr $t0, 4($a1)
45 lwl $t0, 7($a1)
46 lwr $t1, 8($a1)
47 lwl $t1, 11($a1)
48 lwr $t2, 12($a1)
49 lwl $t2, 15($a1)
50 sw $v1, 0($a0)
51 sw $t0, 4($a0)
52 sw $t1, 8($a0)
53 addiu $a1, $a1, 16
54 addiu $a0, $a0, 16
55 bne $a1, $a3, 6b
56 sw $t2, -4($a0)
58 andi $v1, $a2, 3
59 subu $a3, $a2, $v1
60 beqz $a3, 2f
61 move $a2, $v1
62 addu $a3, $a3, $a1
64 lwr $v1, 0($a1)
65 lwl $v1, 3($a1)
66 addiu $a1, $a1, 4
67 addiu $a0, $a0, 4
68 bne $a1, $a3, 7b
69 sw $v1, -4($a0)
70 b 2f
71 nop
73 beqz $a3, 8f
74 subu $a2, $a2, $a3
75 lwr $v1, 0($a1)
76 addu $a1, $a1, $a3
77 swr $v1, 0($a0)
78 addu $a0, $a0, $a3
80 andi $v1, $a2, 15
81 subu $a3, $a2, $v1
82 beqz $a3, 9f
83 move $a2, $v1
84 addu $a3, $a3, $a1
85 10:
86 lw $v1, 0($a1)
87 lw $t0, 4($a1)
88 lw $t1, 8($a1)
89 lw $t2, 12($a1)
90 sw $v1, 0($a0)
91 sw $t0, 4($a0)
92 sw $t1, 8($a0)
93 addiu $a1, $a1, 16
94 addiu $a0, $a0, 16
95 bne $a1, $a3, 10b
96 sw $t2, -4($a0)
98 andi $v1, $a2, 3
99 subu $a3, $a2, $v1
100 beqz $a3, 2f
101 move $a2, $v1
102 addu $a3, $a3, $a1
104 lw $v1, 0($a1)
105 addiu $a1, $a1, 4
106 addiu $a0, $a0, 4
107 bne $a1, $a3, 11b
108 sw $v1, -4($a0)
110 beqz $a2, 1f
111 addu $a3, $a2, $a1
113 lbu $v1, 0($a1)
114 addiu $a1, $a1, 1
115 addiu $a0, $a0, 1
116 bne $a1, $a3, 12b
117 sb $v1, -1($a0)
119 jr $ra
121 mips_memset:
122 move $v0, $a0
123 beqz $a2, 1f
124 sltiu $t2, $a2, 16
125 bnez $t2, 2f
126 andi $a1, $a1, 255
127 sll $t2, $a1, 8
128 or $a1, $a1, $t2
129 sll $t2, $a1, 16
130 or $a1, $a1, $t2
131 andi $v1, $a0, 3
132 beqz $v1, 3f
133 li $a3, 4
134 subu $a3, $a3, $v1
135 subu $a2, $a2, $a3
136 swr $a1, 0($a0)
137 addu $a0, $a0, $a3
139 andi $v1, $a2, 15
140 subu $a3, $a2, $v1
141 beqz $a3, 4f
142 move $a2, $v1
143 addu $a3, $a3, $a0
145 sw $a1, 0($a0)
146 sw $a1, 4($a0)
147 sw $a1, 8($a0)
148 addiu $a0, $a0, 16
149 bne $a0, $a3, 5b
150 sw $a1, -4($a0)
152 andi $v1, $a2, 3
153 subu $a3, $a2, $v1
154 beqz $a3, 2f
155 move $a2, $v1
156 addu $a3, $a3, $a0
158 addiu $a0, $a0, 4
159 bne $a0, $a3, 6b
160 sw $a1, -4($a0)
162 beqz $a2, 1f
163 addu $a3, $a2, $a0
165 addiu $a0, $a0, 1
166 bne $a0, $a3, 7b
167 sb $a1, -1($a0)
169 _dummy:
170 jr $ra