Previous: The Clobber Parameter, Up: Other Asm Functionality [Contents][Index]
Volatile
ParameterCompiler optimizations in the presence of Inline Assembler may sometimes have
unwanted effects. For example, when an Asm
invocation with an input
variable is inside a loop, the compiler might move the loading of the input
variable outside the loop, regarding it as a one-time initialization.
If this effect is not desired, you can disable such optimizations by setting
the Volatile
parameter to True
; for example:
Asm ("movl %0, %%ebx" & LF & HT & "movl %%ebx, %1", Outputs => Unsigned_32'Asm_Output ("=g", Var_Out), Inputs => Unsigned_32'Asm_Input ("g", Var_In), Clobber => "ebx", Volatile => True);
By default, Volatile
is set to False
unless there is no
Outputs
parameter.
Although setting Volatile
to True
prevents unwanted
optimizations, it will also disable other optimizations that might be
important for efficiency. In general, you should set Volatile
to True
only if the compiler’s optimizations have created
problems.