c – 在汇编中添加浮点/双精度数

我试图尝试内联汇编,我试图在内联汇编中添加十进制数字(不,不是整数).问题是,当我调用以下函数时:
inline double ADD(double num1,double num2) {
  double res;
_asm{

    push eax; push the former state of eax onto stack
    mov eax,num1;
    add eax,num2;
    mov res,eax;
    pop eax; restore the former state of eax Now that we are done   
     }  return res;}

编译器抱怨内联汇编中的操作数大小不合适(除了push和pop指令行之外的所有汇编行).所以我必须更改为整数类型,例如unsigned long,然后它可以工作,但当然只支持整数类型;小数结果四舍五入.

有没有办法添加允许像8.4这样的十进制结果的汇编?

解决方法

我在十年内没有完成x87组装,但它应该是这样的:
fld num1   ; load num1 and push it onto the fpu stack
fld num2   ; load num2 and push it onto the fpu stack
faddp      ; pop two numbers,add them,push sum on the stack
fstp res   ; pop sum from the stack and store it in res

相关文章

本程序的编译和运行环境如下(如果有运行方面的问题欢迎在评...
水了一学期的院选修,万万没想到期末考试还有比较硬核的编程...
补充一下,先前文章末尾给出的下载链接的完整代码含有部分C&...
思路如标题所说采用模N取余法,难点是这个除法过程如何实现。...
本篇博客有更新!!!更新后效果图如下: 文章末尾的完整代码...
刚开始学习模块化程序设计时,估计大家都被形参和实参搞迷糊...