/*
============================================================================
Name : GCC.c
Author : Gentoo
Version :
Copyright : Your copyright notice
Description : Hello World in C, Ansi-style
============================================================================
*/
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
int x = 2;
int y = 3;
int result = 0;
asm(
"xor %%eax, %%eax\n\t"
"movl %1, %%eax\n\t"
"add %2, %%eax\n\t"
"mov %%eax, %0"
:"=r"(result) /*output*/
:"r"(x), "r"(y) /*input*/
:"%eax"
);
printf("%d + %d = %d\n", x, y, result);
return EXIT_SUCCESS;
}
Linux下C内联汇编小例子
最新推荐文章于 2024-05-06 13:27:33 发布