scr*_*101 6 c x86 assembly x87
我试图尝试内联汇编,我试图在内联汇编中添加十进制数字(不,不是整数).问题是,当我调用以下函数时:
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
你可能想要的指令是ADDSD,但我不确定.
这是英特尔指令集手册的链接. http://www.intel.com/content/www/us/en/processors/architectures-software-developer-manuals.html/
他们过去常常免费邮寄你的硬拷贝,但看起来已经不再适用了.