标签:
A usual IA includes these parts:
asm [volatile] ( AssemblerTemplate
: OutputOperands
[ : InputOperands
[ : Clobbers ] ])
example:
#include <stdio.h> int main() { //changes a and b‘s value int a = 10, b = 0; asm(//note this program should be compile with gcc "xchg %1,%%eax;xchg %%eax,%0" :"=r"(b),"=m"(a) :"r"(a) :"%eax" //note register declare with one ‘%‘ ); return 0; }
note the register %eax is not initialized. a‘s value should be unknown. b‘s value should be 10.
the question is, in assembler, mov a,b means pass b‘s value into a, however, here is the opposite, to pass a‘s value into b..
标签:
原文地址:http://www.cnblogs.com/sansna/p/5687830.html