get rid of custom memcpy funcs
[picodrive.git] / pico / misc_amips.s
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
17 memset32:
18 ms32_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
29 ms32_bloop_prep:
30     srl     $t0, $a2, 4    # we will do 64 bytes per iteration (cache line)
31     beqz    $t0, ms32_bloop_end
32
33 ms32_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
55 ms32_bloop_end:
56     andi    $a2, $a2, 0x0f
57     beqz    $a2, ms32_return
58
59 ms32_cloop:
60     addiu   $a2, -1
61     sw      $a1, 0($a0)
62     bnez    $a2, ms32_cloop
63     addiu   $a0, 4
64
65 ms32_return:
66     jr      $ra
67     nop
68
69
70 .globl memset32_uncached # int *dest, int c, int count
71
72 memset32_uncached:
73     srl     $t0, $a2, 3    # we will do 32 bytes per iteration
74     beqz    $t0, ms32u_bloop_end
75
76 ms32u_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
89 ms32u_bloop_end:
90     andi    $a2, $a2, 0x0f
91     beqz    $a2, ms32u_return
92
93 ms32u_cloop:
94     addiu   $a2, -1
95     sw      $a1, 0($a0)
96     bnez    $a2, ms32u_cloop
97     addiu   $a0, 4
98
99 ms32u_return:
100     jr      $ra
101     nop
102
103
104 # vim:filetype=mips