drc: dumb detection of writes to current block
[picodrive.git] / pico / cd / misc_arm.s
CommitLineData
cff531af 1@*
2@* Memory converters for different modes
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@*
6cadc2da 8
9
10@ r10 is tmp, io1 is lsb halfword, io2 is msb
11@ | 0 1 | 2 3 | -> | 0 2 | 1 3 | (little endian)
12.macro _conv_reg io1 io2
13 mov r10, \io2, lsl #16
14 and \io2, \io2, r11, lsl #16
15 orr \io2, \io2, \io1, lsr #16
16 and \io1, \io1, r11
17 orr \io1, \io1, r10
18/*
19 mov \io2, \io2, ror #16
20 mov r10, \io1, lsl #16
21 orr r10, r10, \io2, lsr #16
22 mov \io1, \io1, lsr #16
23 orr \io1, \io1, \io2, lsl #16
24 mov \io2, r10, ror #16
25*/
26.endm
27
28
29.global wram_2M_to_1M
30wram_2M_to_1M:
31 stmfd sp!,{r4-r11,lr}
32 add r1, r0, #0x60000 @ m1M_b1
33 add r0, r0, #0x40000 @ m1M_b0
34 mov r2, r0 @ m2M
35
36 mov r11, #0xff
37 orr r11, r11, r11, lsl #8
38 mov r12, #(0x40000/8/4)
39
40_2Mto1M_loop:
41 ldmdb r2!,{r3-r9,lr}
42 _conv_reg r3,r4
43 _conv_reg r5,r6
44 _conv_reg r7,r8
45 _conv_reg r9,lr
46 subs r12, r12, #1
47 stmdb r0!,{r3,r5,r7,r9}
48 stmdb r1!,{r4,r6,r8,lr}
49 bne _2Mto1M_loop
50
51 ldmfd sp!,{r4-r11,pc}
52
53
54
55.global wram_1M_to_2M
56wram_1M_to_2M:
57 stmfd sp!,{r4-r11,lr}
58 mov r2, r0 @ m2M
59 add r1, r0, #0x40000 @ m1M_b1
60 add r0, r0, #0x20000 @ m1M_b0
61
62 mov r11, #0xff
63 orr r11, r11, r11, lsl #8
64 mov r12, #(0x40000/8/4)
65
66_1Mto2M_loop:
67 ldmia r0!,{r3,r5,r7,r9}
68 ldmia r1!,{r4,r6,r8,lr}
69 _conv_reg r3,r4
70 _conv_reg r5,r6
71 _conv_reg r7,r8
72 _conv_reg r9,lr
73 subs r12, r12, #1
74 stmia r2!,{r3-r9,lr}
75 bne _1Mto2M_loop
76
77 ldmfd sp!,{r4-r11,pc}
78
cff531af 79@ vim:filetype=armasm