I'm writing a short routine to copy a 32-bit mixing buffer to the sound output, and noticed the assembler isn't too great:
As far as I can see the two lines I marked with stars are unneeded. Has anyone got any tricks to tell the compiler not to do this?
- Code:
// Copy to output and clip
pm=SndMix; pd=WaveDest; pe=pd+(WaveLen<<1);
do
{
int m=*pm;
// Clip to -0x8000,0x7fff
if (m<-0x8000) m=-0x8000;
if (m> 0x7fff) m= 0x7fff;
*pd=(short)m;
pm++; pd++;
}
while (pd<pe);
; 55 : // Clip to -0x8000,0x7fff
; 56 : if (m<-0x8000) m=-0x8000;
; 57 : if (m> 0x7fff) m= 0x7fff;
; 58 : *pd=(short)m;
; 59 :
; 60 : pm++; pd++;
add r2, r2, #4
cmp r1, r3
movlt r1, r3
cmp r1, r4
movgt r1, r4
mov r1, r1, lsl #16 *****
mov r1, r1, asr #16 *****
strh r1, [r0]
add r0, r0, #2
As far as I can see the two lines I marked with stars are unneeded. Has anyone got any tricks to tell the compiler not to do this?