Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

shmaLbus

inline assembler

This topic is 6538 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

how the fugg do i convert between floating point and integer types in visual c++''s inline assembler? i know it''s ''ftol'' and that family. i even disassembled a simple program just converting numbers (it is __ftol) and copied exactly what it had and that didn''t even work! any help would be nice

Share this post


Link to post
Share on other sites
Advertisement
hah, yes i am a genious.. thank you (well ok not really, but let me think that). i disassembled it again and just called the address of __ftol and that worked. if anyone really cares here's what it looks like.

        
int i=10;
float f=20.1;
DWORD __ftol_ptr=0x0040ea88;

_asm {
fld f
call [__ftol_ptr]
mov i, eax
}


Edited by - shmaLbus on July 24, 2000 10:33:10 AM

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
The reason you are using __ftol in the first place is to get the result truncated instead of rounded. Try this instead:

-----------------
float f=20.1;
int i;

_asm fld f
_asm fistp i

-----------------

I have not tried this on VC++ but it works beautifully in Watcom C++. When I started using this in a lighting computation, the speed of my entire program increased by 10% because it didn''t have to call a slow function anymore.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!