| View previous topic :: View next topic |
| Author |
Message |
Marcello Lenci Guest
|
Posted: Sat Oct 29, 2005 4:19 pm Post subject: 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;
Thank you
Marcello Lenci
|
|
| Back to top |
|
 |
Dennis Guest
|
Posted: Sat Oct 29, 2005 4:24 pm Post subject: Re: result double |
|
|
Hi
As you would do from a Pascal function.
The function calling convention ensures that.
Best regards
Dennis Kjaer Christensen
New Fastcode site
http://www.fastcodeproject.org/
|
|
| Back to top |
|
 |
Avatar Zondertau Guest
|
Posted: Sat Oct 29, 2005 6:14 pm Post subject: Re: result double |
|
|
| Quote: | 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/
|
|
| Back to top |
|
 |
|