This is very compiler specific. However, for a realistic example, take gcc on x86. Format:
asm ( assembler template : output operands (optional) : input operands (optional) : list of clobbered registers (optional) );
Where is the "written-off register list" you say that the compiler that registers your code uses.
Here is a simple memory copy code:
asm ("movl $count, %%ecx; up: lodsl; stosl; loop up;" : :"S"(src), "D"(dst) :"%ecx", "%eax" );
Given these guidelines, gcc will not use eax and ecx for other things in the block.
More details here .
Eli bendersky
source share