libretro: pass required arg to VirtualProtect
[picodrive.git] / pico / m68kif_cyclone.s
CommitLineData
cff531af 1/*
2 * PicoDrive
3 * (C) notaz, 2009
4 *
5 * This work is licensed under the terms of MAME license.
6 * See COPYING file in the top-level directory.
7 */
5e89f0f5 8
9.equ M68K_MEM_SHIFT, 16
10
11.global cyclone_checkpc
12.global cyclone_fetch8
13.global cyclone_fetch16
14.global cyclone_fetch32
15.global cyclone_read8
16.global cyclone_read16
17.global cyclone_read32
18.global cyclone_write8
19.global cyclone_write16
20.global cyclone_write32
21
22@ Warning: here we abuse the fact that we are only called
23@ from Cyclone, and assume that r7 contains context pointer.
24cyclone_checkpc:
25 ldr r1, [r7, #0x60] @ membase
26 sub r0, r0, r1
12da51c2 27 and r3, r0, #0xff000000
28 bic r0, r0, #1
29 bics r2, r0, #0xff000000
5e89f0f5 30 beq crashed
31
32 ldr r1, [r7, #0x6c] @ read16 map
12da51c2 33 mov r2, r2, lsr #M68K_MEM_SHIFT
5e89f0f5 34 ldr r1, [r1, r2, lsl #2]
35 movs r1, r1, lsl #1
36 bcs crashed
37
12da51c2 38 sub r1, r1, r3
5e89f0f5 39 str r1, [r7, #0x60] @ membase
40 add r0, r0, r1
41 bx lr
42
43crashed:
44 stmfd sp!,{lr}
45 mov r1, r7
46 bl cyclone_crashed
47 ldr r0, [r7, #0x40] @ reload PC + membase
48 ldmfd sp!,{pc}
49
50
51cyclone_read8: @ u32 a
52cyclone_fetch8:
53 bic r0, r0, #0xff000000
54 ldr r1, [r7, #0x68] @ read8 map
55 mov r2, r0, lsr #M68K_MEM_SHIFT
56 ldr r1, [r1, r2, lsl #2]
57 eor r2, r0, #1
58 movs r1, r1, lsl #1
59 ldrccb r0, [r1, r2]
60 bxcc lr
61 bx r1
62
63
64cyclone_read16: @ u32 a
65cyclone_fetch16:
66 bic r0, r0, #0xff000000
67 ldr r1, [r7, #0x6c] @ read16 map
68 mov r2, r0, lsr #M68K_MEM_SHIFT
69 ldr r1, [r1, r2, lsl #2]
70 bic r0, r0, #1
71 movs r1, r1, lsl #1
72 ldrcch r0, [r1, r0]
73 bxcc lr
74 bx r1
75
76
77cyclone_read32: @ u32 a
78cyclone_fetch32:
79 bic r0, r0, #0xff000000
80 ldr r1, [r7, #0x6c] @ read16 map
81 mov r2, r0, lsr #M68K_MEM_SHIFT
82 ldr r1, [r1, r2, lsl #2]
83 bic r0, r0, #1
84 movs r1, r1, lsl #1
85 ldrcch r0, [r1, r0]!
86 ldrcch r1, [r1, #2]
87 orrcc r0, r1, r0, lsl #16
88 bxcc lr
89
90 stmfd sp!,{r0,r1,lr}
91 mov lr, pc
92 bx r1
93 mov r2, r0, lsl #16
94 ldmia sp, {r0,r1}
95 str r2, [sp]
96 add r0, r0, #2
97 mov lr, pc
98 bx r1
99 ldr r1, [sp]
100 mov r0, r0, lsl #16
101 orr r0, r1, r0, lsr #16
102 ldmfd sp!,{r1,r2,pc}
103
104
105cyclone_write8: @ u32 a, u8 d
106 bic r0, r0, #0xff000000
107 ldr r2, [r7, #0x74] @ write8 map
108 mov r3, r0, lsr #M68K_MEM_SHIFT
109 ldr r2, [r2, r3, lsl #2]
110 eor r3, r0, #1
111 movs r2, r2, lsl #1
112 strccb r1, [r2, r3]
113 bxcc lr
114 bx r2
115
116
117cyclone_write16: @ u32 a, u16 d
118 bic r0, r0, #0xff000000
119 ldr r2, [r7, #0x78] @ write16 map
120 mov r3, r0, lsr #M68K_MEM_SHIFT
121 ldr r2, [r2, r3, lsl #2]
122 bic r0, r0, #1
123 movs r2, r2, lsl #1
124 strcch r1, [r2, r0]
125 bxcc lr
126 bx r2
127
128
129cyclone_write32: @ u32 a, u32 d
130 bic r0, r0, #0xff000000
131 ldr r2, [r7, #0x78] @ write16 map
132 mov r3, r0, lsr #M68K_MEM_SHIFT
133 ldr r2, [r2, r3, lsl #2]
134 bic r0, r0, #1
135 movs r2, r2, lsl #1
136 movcc r3, r1, lsr #16
137 strcch r3, [r2, r0]!
138 strcch r1, [r2, #2]
139 bxcc lr
140
141 stmfd sp!,{r0-r2,lr}
142 mov r1, r1, lsr #16
143 mov lr, pc
144 bx r2
145 ldmfd sp!,{r0-r2,lr}
146 add r0, r0, #2
147 bx r2
148
cff531af 149@ vim:filetype=armasm