local volatiles live on stack (I believe this is in docs). but where is volatile declaration in your code?
As I can see from your example there is simple 'constant propagation' technique being used. ~d On Wednesday 23 June 2004 21:05, Matthias Weingart wrote: > Hi, > > again a problem with volatile - or too much optimizing of the compiler. > With "volatile uint n;" my code will work as expected, but it uses space on > the stack and it wastes cycles. I want registers for my purpose. > > This is the code (Stripped down to something useless :-) > > #define VALUE 8 > > void foo(void) > { > { > uint n; > n=VALUE; > __asm__ __volatile__("dec %0\n jnz $-2\n" :: "r" (n)); > } > //do someth. > { > uint n; > n=VALUE; > __asm__ __volatile__("dec %0\n jnz $-2\n" :: "r" (n)); > } > //do someth. > } > > The compiler is setting N=2*VALUE before the first loop: > > mov #16, r15 > dec r15 > jnz $-2 > > ... ;do smth. > > dec r15 > jnz $-2 > > ... ;do smth. > ret > > but I want it to look like this: > mov #8, r15 > dec r15 > jnz $-2 > > ... ;do smth. > > mov #8, r15 > dec r15 > jnz $-2 > > ... ;do smth. > ret > > any ideas? > > thx > > M. > > > ------------------------------------------------------- > This SF.Net email sponsored by Black Hat Briefings & Training. > Attend Black Hat Briefings & Training, Las Vegas July 24-29 - > digital self defense, top technical experts, no vendor pitches, > unmatched networking opportunities. Visit www.blackhat.com > _______________________________________________ > Mspgcc-users mailing list > Mspgcc-users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/mspgcc-users