返回float st0或xmm0

问题描述

用于确定将哪个C ++代码中的汇编块中的浮点值返回到哪个寄存器(st(0)xmm0)的指令。

__declspec(naked) float __fastcall ln(float flt)
{
    float buf;

    _asm {
        mov buf,eax
        fld buf             // Return st(0)
    };
};

解决方法

对于32位x86代码,Visual Studio将always use the i387 stack,因为它是调用约定。
对于64位x64代码,使用XMM寄存器exclusively

恐怕您别无选择,只能为不同的体系结构编写单独的asm块。如果只有一种高级语言可以为每种体系结构生成特定的汇编代码,则它支持...;)

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...