I am writing a function in nasm that will be called from 32bit ansi C.
The function prototype in C looks like this:
long double scalar(int n, long double *x)
Where x is a pointer to an array of long doubles
.
The problem occurs when I try to load a single long double
to the FPU:
mov ecx, [esp+8] ; n
mov eax, [esp+12] ; *x
fld [eax] ; ERROR: operation size not specified
How should I specify the size? My C compiler uses 12 bytes for a long double, how to fit it into the 80 bits?
To specify the size explicitely use the following form in NASM:
fld TWORD [eax] ; load 10 bytes from [eax]
As you pointed out, FPU stack registers are 80 bits wide. The C compiler chooses 12 bytes, because of the data alignment requirements of the stack frame.