/*
============================================================================
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內聯彙編小例子
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.