__asm__
is a gcc extension of permitting assembly language statements to be entered nested within your C codeIf our assembly statement must execute where we put it, (i.e. must not be moved out of a loop as an optimization), put the keyword
volatile
after asm and before the ()’s. So to keep it from moving,
deleting and all, we declare it as
asm volatile ( ... : ... : ... : ...);
Use
__volatile__
when we have to be verymuch careful.
If our assembly is just for doing some calculations and doesn’t have any side effects, it’s better not to use the keyword
volatile
. Avoiding it
helps gcc in optimizing the code and making it more beautiful.
No comments:
Post a Comment