2

我正在用 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 字节的长双精度,如何将其放入 80 位?

4

1 回答 1

3

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

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

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

于 2016-11-09T21:28:45.830 回答