From: funman Date: Fri, 14 May 2010 16:47:58 +0000 (+0000) Subject: as3525: add some comments in the microphone channel copy loop X-Git-Url: https://repo.or.cz/w/kugel-rb.git/commitdiff_plain/fa6def5a9fbb5f3d9323379193f334b520b18fc3 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 --- diff --git a/firmware/target/arm/as3525/pcm-as3525.c b/firmware/target/arm/as3525/pcm-as3525.c index 10877ecf4..4033a9b88 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