From 685209d9070d6a9d1b7e2292fe64079d05c722b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C3=ABl=20Carr=C3=A9?= Date: Fri, 14 May 2010 16:47:58 +0000 Subject: 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 --- firmware/target/arm/as3525/pcm-as3525.c | 28 ++++++++++++++++------------ 1 file 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 -- cgit v1.1