Chinaunix首页 | 论坛 | 博客
  • 博客访问: 117161
  • 博文数量: 24
  • 博客积分: 1411
  • 博客等级: 上尉
  • 技术积分: 261
  • 用 户 组: 普通用户
  • 注册时间: 2009-08-07 17:49
文章分类

全部博文(24)

文章存档

2009年(24)

我的朋友

分类:

2009-08-13 09:53:53

// ASM实现全32位无符号乘法

Use the asm statement to implement a function with the following prototype:

void full_umul(unsigned x, unsigned y, unsigned dest[]);

This function should compute the full 64-bit product of its arguments and store the results in the destination array, with dest[0] having the low-order 4 bytes and dest[1] having the high-order 4 bytes

..................................................

void full_umul(unsigned x, unsigned y, unsigned dest[])
{
  /*
    movl x %eax
    mull y
    movl %eax dest[0]
    movl %edx dest[1]
   */

  asm("movl %2,%%eax; mull %3; movl %%eax,%0; movl %%edx,%1"
      :"=r" (dest[0]), "=r" (dest[1])
      :"r" (x), "r" (y)
      :"%eax", "%edx"
      );
}


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