Re: hii
Ganga wrote:
> Please, will anyone explain me difference between 'register' and
Register keyword for a variable will force the compiler backend to give
register.
so by this compiler can acess the variable without store
instruction(i.e it can use mov instruction).
> 'volatile' variables
Volatile Keyword for a variable will prevent variable from
optimization.
i.e
main()
{
int i=2,j=3,a,b;
a=i+j;
b=i+j;
return a+b;
}
For above code the compiler try to optimize the code.
i.e
main()
{
int i=2,j=3,a,b
t=i+j; //where t is the temproray variable which is interal generated
by compiler.
a=t;//a & b are automatic variable.
b=t;
// by this we can save one addition.
return a+b;
}
main()
{
volatile int i=2,j=3,a,b;
a=i+j;
b=i+j;
return a+b;
}
but in the case volatile.it prevents variables(i,j) from optimization.
so above code remain same.
.
Relevant Pages
- Re: [PATCH 0/24] make atomic_read() behave consistently across all architectures
... It doesn't mean that (volatile int*) cast is bad, ... I would agree that fixing the compiler in this case would be a good thing, ... bad register allocation. ... still quite possible to find cases where it did some optimization (in this ... (Linux-Kernel) - Re: Volatile for shared data protected by critical section
... I don't think that it optimizes register variable use across function calls. ... seeing 'volatile' used much with globals in the CE code base. ... Does the current compiler implementation not attempt to optimize variables ... You are right that the global data will be shared by multiple threads ... (microsoft.public.windowsce.embedded) - Re: Volatile for shared data protected by critical section
... used for hard spin loops and register accesses, ... 'volatile' used much with globals in the CE code base. ... Does the current compiler implementation not attempt to optimize variables ... You are right that the global data will be shared by multiple threads ... (microsoft.public.windowsce.embedded) - Re: switch statement, was compiler, status...
... Primary Register, Secondary Register, ... Stack, and abit of storage does it. ... This version of Small-C is copyrighted as a revision to Ron Cain's ... Croatia) is "Calculator Compiler" by Senko Rasik. ... (alt.lang.asm) - Volatile + multithreading
... Is volatile really of any use with the current compilers VS 2003? ... field or global seems to have no impact because it seems the compiler will ... //What if compiler put m_bDone in register AX here ... rule that only parameter variables and stack variables (method variables) ... (microsoft.public.vc.language) |
|