// 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) |