summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRafaël Carré <rafael.carre@gmail.com>2010-05-14 16:47:58 +0000
committerRafaël Carré <rafael.carre@gmail.com>2010-05-14 16:47:58 +0000
commit685209d9070d6a9d1b7e2292fe64079d05c722b3 (patch)
tree456bf8a0a4b0e73992ec20a075ede9815c833c7b
parentea6eb920d0bc257e0407afd746649a5e1930c5b2 (diff)
downloadrockbox-685209d9070d6a9d1b7e2292fe64079d05c722b3.zip
rockbox-685209d9070d6a9d1b7e2292fe64079d05c722b3.tar.gz
rockbox-685209d9070d6a9d1b7e2292fe64079d05c722b3.tar.bz2
rockbox-685209d9070d6a9d1b7e2292fe64079d05c722b3.tar.xz
as3525: add some comments in the microphone channel copy loop
Indent the asm constraints at the same level than instructions Also add a trick to reduce the number of instructions outputted by gcc in the commented C version of the loop The difference between C and asm is now 1 instruction git-svn-id: svn://svn.rockbox.org/rockbox/trunk@26027 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--firmware/target/arm/as3525/pcm-as3525.c28
1 files changed, 16 insertions, 12 deletions
diff --git a/firmware/target/arm/as3525/pcm-as3525.c b/firmware/target/arm/as3525/pcm-as3525.c
index 10877ec..4033a9b 100644
--- a/firmware/target/arm/as3525/pcm-as3525.c
+++ b/firmware/target/arm/as3525/pcm-as3525.c
@@ -237,22 +237,26 @@ static inline void mono2stereo(int16_t *end)
if(audio_channels != 1) /* only for microphone */
return;
#if 0
+ /* load pointer in a register and avoid updating it in each loop */
+ register int16_t *samples = mono_samples;
+
do {
- int16_t left = *mono_samples++;
- *mono_samples++ = left;
- } while(mono_samples != end);
+ int16_t left = *samples++; // load 1 sample of the left-channel
+ *samples++ = left; // copy it in the right-channel
+ } while(samples != end);
+
+ mono_samples = samples; /* update pointer */
#else
- /* gcc doesn't use pre indexing and load/store mono_samples at each loop
- * let's save some cycles with a smaller loop */
- int16_t tmp;
+ /* gcc doesn't use pre indexing : let's save 1 cycle */
+ int16_t left;
asm (
- "1: ldrh %0, [%1], #2 \n"
- " strh %0, [%1], #2 \n"
- " cmp %1, %2 \n"
+ "1: ldrh %0, [%1], #2 \n" // load 1 sample of the left-channel
+ " strh %0, [%1], #2 \n" // copy it in the right-channel
+ " cmp %1, %2 \n" // are we finished?
" bne 1b \n"
- : "=r"(tmp), "+r"(mono_samples)
- : "r"(end)
- : "memory"
+ : "=r"(left), "+r"(mono_samples)
+ : "r"(end)
+ : "memory"
);
#endif /* C / ASM */
#else