C語言代碼內嵌彙編的方法:app
1 #include<stdio.h> 2 #include <unistd.h> 3 int main() 4 { 5 int a,b; 6 pid_t t,asm_t; 7 t =getpid(); 8 a = t; 9 printf("pid = %d\n",a); 10 asm volatile( 11 "mov $0x14,%%eax\n\t" 12 "int $0x80\n\t" 13 "mov %%eax,%0\n\t" 14 :"=m"(asm_t) 15 ); 16 b = asm_t; 17 printf("asm_t = %d\n",b); 18 return 0; 19 }
by 崑崙雪狐函數
原創做品轉載請註明出處優化
《Linux內核分析》spa
MOOC課程http://mooc.study.163.com/course/USTC-1000029000code