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