【问题标题】:Nasm: how to load a long double into the FPU from memoryNasm:如何从内存中将 long double 加载到 FPU
【发布时间】:2016-11-09 21:21:44
【问题描述】:

我正在用 nasm 编写一个将从 32 位 ansi C 调用的函数。

C 中的函数原型如下所示: long double scalar(int n, long double *x) 其中 x 是指向 long doubles 数组的指针。

当我尝试将单个 long double 加载到 FPU 时出现问题:

    mov ecx, [esp+8] ; n
    mov eax, [esp+12] ; *x
    fld [eax] ; ERROR: operation size not specified

我应该如何指定尺寸?我的 C 编译器使用 12 个字节作为 long double,如何将其放入 80 位?

【问题讨论】:

    标签: c nasm fpu long-double


    【解决方案1】:

    要明确指定大小,请在 NASM 中使用以下形式:

    fld TWORD [eax] ; load 10 bytes from [eax]
    

    正如您所指出的,FPU 堆栈寄存器为 80 位宽。 C 编译器选择 12 字节,因为堆栈帧的数据对齐要求。

    【讨论】:

    • 在 nasm 中,关键字是 tword
    • @JanOsch:是的,我不确定这两者之间的关系。谢谢,
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2010-10-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-11-23
    相关资源
    最近更新 更多