Re: result double



> How can I read a double returning from a basm function ?
> Example:
>
> function display(x:double):double;
> begin
> asm
> ?????????????
> end;
> end;
>
> Form1.Button1Click(Sender:TObject);
> begin
> Label1.Caption:=FloatToStr(display(2.54));
> end;

First: don't add "begin" and "end" to your BASM function.

You read double parameters using their name, since they will always be
stored on the stack. You return a floating point value by leaving it on
the stack.

For example the function below doubles it's argument and returns that:

function TwoTimes(X: Double): Double;
asm
fld X
fadd st(0), st(0)
end;

--
The Fastcode Project: http://www.fastcodeproject.org/
.


Quantcast