This is my personal blog about programming. In my 20+ odd years I found that programming is mainly problem solving. In my earlier days I was handed out the Pure Mathematics book by Hardy and found that what gem it is. Clarity, chronology, and preciseness has been achieved at the highest level in my opinion. So that inspires me a lot... And I try to follow it in my professional career. And that is the only reason I gave this blogs objective - Pure programming!

-- If we use registers, we should make GCC aware about them, so it preserves the values before using them.

Compiler toolchains are smart these days, so depending on the analysis, GCC could delete the whole code section or a part or it can move code around for optimization. There may be situation where we want the compiler to stop doing those optimization, and place the code as is ( i.e. in place ). For that in systems code we almost always uses __volatile__ keyword, like the following example.

From <asm-i386/atomic.h> of Linux source -

statoc __inline__ void atomic_inc(atomic_t *v)

{

__asm__ __volatile__ (

LOCK "incl %0"

:"=m" (v->counter)

: "m" (v->counter)

);

}

For the detail syntax, and semantics, please use the GNU compiler connection manual. It is available on line.