kernel mailz <kernelmailz@xxxxxxxxxxxxxx> writes: > I've been fiddling my luck with gcc 4.3.2 inline assembly on powerpc > There are a few queries > > 1. asm volatile or simply asm produce the same assembly code. > Tried with a few examples but didnt find any difference by adding > volatile with asm > > 2. Use of "memory" and clobbered registers. > > "memory" - > a. announce to the compiler that the memory has been modified > b. this instruction writes to some memory (other than a listed output) > and GCC shouldn’t cache memory values in registers across this asm. > > I tried with stw and stwcx instruction, adding "memory" has no effect. > > Is there any example scenerio where gcc would generate different > assembly by adding / removing "memory" ? Please never send a message to both gcc@xxxxxxxxxxx and gcc-help@xxxxxxxxxxxx This message is appropriate for gcc-help@xxxxxxxxxxx, not for gcc@xxxxxxxxxxxx Thanks. An asm with no outputs is always considered to be volatile. To see the affect of volatile, just try something like asm ("# modify %0" : "=r" (i) : /* no inputs */ : /* no clobbers */); Try it with and without optimization. As the documentation says, the effect of adding a "memory" clobber is that gcc does not cache values in registers across the asm. So the effect will be shown in something like int i = *p; asm volatile ("# read %0" : : "r" (i)); return *p; The memory clobber will only make a different when optimizing. Ian