Embed assembly code in C

#include <stdio.h>

int main(void)
{
	int x = 10, y = 1;
	
	asm ("movl %1, %%eax;"
	     "movl %%eax, %0;"
		:"=&r"(y)	/* y is output operand, note the	
				   & constraint modifier. */
		:"r"(x)		/* x is input operand */
		:"%eax");	/* %eax is clobbered register */
    printf("y: %d\n", y);
}
 Refer to  http://www.ibm.com/developerworks/library/l-ia.html.

 

你可能感兴趣的:(html,C++,c,C#,IBM)