Referrence:
1. GCC DOC:
C Extensions::Extended Asm::2. HOWTO:
Base Inline: asm("assembly code");
Extended Asm:
asm ( assembler template
: output operands /* optional */
: input operands /* optional */
: list of clobbered registers /* optional */
);
Operands = "ConstraintModifiers-Constraint"(Operand-Expr), Another, ...
Clobbered register:
registers that may be modified in this inline asm instructions, or "memory" indicates that our instruction modifies memory in a unpredictable fashion, and will cause GCC to not keep memory values cached in registers across the assembler instruction.
Constraint Modifiers:
= + &
Constraint:
m r g 0-9 and so on. Constrains tells where the operands come from, and where to put the operands.
__asm__ equals to asm key word.
__volatile__ equals to volatile key word.
When it decorates variables, it means that the var can be modified by some external program routine.And when it decorates routines just like here, following the asm key word, it tells gcc to not do any optimization on these instuctions. I think it's the difference with "memory" clobber string.
阅读(940) | 评论(0) | 转发(0) |