Mixing High Level Inline (HLI) Assembly with a High Level Language (HLL, for example C or C++) requires special attention. The Compiler does care about used or modified registers in HLI Assembly, thus you do not have save/restore registers which are used in HLI. It is recommended to place complex HLI Assembly code, or HLI Assembly code modifying any registers, into separate functions.
Example:
void foo(void) {
/* some C statements */
p->v = 1;
__asm {
/* some HLI statements destroying registers */
}
/* some C statements */
p->v = 2;
}
In the above sequence, the Compiler holds the value of p in a register. The compiler will correctly reload p if necessary.