当前位置:技 术首页 >> 编程相关 >> 在汇编中使用浮点运算的 DEMO
在汇编中使用浮点运算的 DEMO
2008-02-10 13:09:15  作者:  来源:互联网  浏览次数:1  文字大小:【】【】【
  •   /* 通过FPU运算完成 64 位整数加法运算 */ #include struct dlong { unsigned long low; unsigned long hi;}; struct dlong * fputest (struct dlong * a, long b){ struct dlong _a = *a; asm { FI ...
/* 通过FPU运算完成 64 位整数加法运算 */

#include

struct dlong {
 unsigned long low;
 unsigned long hi;
};

struct dlong * fputest (struct dlong * a, long b)
{
 struct dlong _a = *a;

 asm {
   FINIT     /* 初始化 FPU */
   FILD  _a  /* 装入长整数 */
   FIADD b   /* 进行整数加法运算 */
   FISTP _a  /* 计算结果出栈 */
 }

 *a = _a;
 return (a);
}

int main (void)
{
 struct dlong dla;

 printf ("Hello\n");

 dla.hi  = 1;
 dla.low = 2;
 printf ("%08lx %08lx\n", dla.hi, dla.low);
 fputest (&dla, -8);
 printf ("%08lx %08lx\n", dla.hi, dla.low);

 getchar ();
 return (0);
}

运行结果:
Hello
00000001 00000002
00000000 fffffffa


0

顶一下

0

踩一下
相关文章
    {tag_首页栏目_经典案例}
    {tag_首页栏目_技术文章}