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