BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

result double

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Language BASM
View previous topic :: View next topic  
Author Message
Marcello Lenci
Guest





PostPosted: Sat Oct 29, 2005 4:19 pm    Post subject: result double Reply with 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;

Thank you
Marcello Lenci


Back to top
Dennis
Guest





PostPosted: Sat Oct 29, 2005 4:24 pm    Post subject: Re: result double Reply with quote



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





PostPosted: Sat Oct 29, 2005 6:14 pm    Post subject: Re: result double Reply with quote



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
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Language BASM All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.