1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
diff --git a/apps/dsp_arm.S b/apps/dsp_arm.S
index 7e36074..ea19c60 100644
--- a/apps/dsp_arm.S
+++ b/apps/dsp_arm.S
@@ -88,8 +88,6 @@ channels_process_sound_chan_custom:
     ldmia   r1, { r5, r6 }             @ r5 = Li0, r6 = Li1
     ldmia   r2, { r7, r8 }             @ r7 = Ri0, r8 = Ri1

-    subs    r0, r0, #2
-
     smull   r9, r10, r5, r3            @ Lc0 = Li0*gain
     smull   r12, r14, r7, r3           @ Rc0 = Ri0*gain
     smlal   r9, r10, r7, r4            @ Lc0 += Ri0*cross
@@ -109,10 +107,14 @@ channels_process_sound_chan_custom:
     mov     r12, r12, lsr #31
     orr     r6, r9, r10, asl #1
     orr     r8, r12, r14, asl #1
-    
-    stmia   r1!, { r5, r6 }            @ Store Lc0, Lc1
-    stmia   r2!, { r7, r8 }            @ Store Rc0, Rc1

+    cmp     rX, 0
+    stmiaeq   r1!, { r5, r6 }            @ Store Lc0, Lc1
+    stmiaeq   r2!, { r7, r8 }            @ Store Rc0, Rc1
+    stmiane   r1!, { r6, r5 }            @ Store Lc0, Lc1
+    stmiane   r2!, { r8, r7 }            @ Store Rc0, Rc1
+
+    subs    r0, r0, #2
     bgt     .custom_loop

     ldmpc   cond=lt, regs=r4-r10       @ < 0? even count