Chinaunix首页 | 论坛 | 博客
  • 博客访问: 44579
  • 博文数量: 10
  • 博客积分: 877
  • 博客等级: 准尉
  • 技术积分: 227
  • 用 户 组: 普通用户
  • 注册时间: 2006-04-04 15:45
文章分类
文章存档

2011年(5)

2010年(3)

2009年(2)

我的朋友

分类:

2011-07-08 10:26:16

#include //这个是需要的,否则提示eax找不到
#include

static long asm_bsr( const long x);

int main(void){

 int i = 0;
 printf("%d\n",asm_bsr(8));
 return 0;
}

long asm_bsr( const long x){
 long y = x;
 _asm {
  mov eax,y; //居然能敢这么干,让我感觉很惊奇
  //mov ebx,[eax];
  bsr eax,eax;
  mov y,eax;
 };
 return y;
}


linux版本:

 #include
 
  static long asm_bsr( const long x);
  
  int main(void){
  printf("%d\n",asm_bsr( 8));
  return 0 ;
 }  
 
  long asm_bsr( const long x){
  long y = x;
  __asm__(
  "bsr %0,%0\r\n"
  : "=r" (y)
  : "0" (y)
  ); 
  return y;
 }  

阅读(498) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~