#### Archived

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

# inline assembler

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

## 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 on other sites
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 on other sites
If you want the slowest possible conversion - why the ''fugg'' are you using assembler???

bored

##### Share on other sites
eh, what''s a quick way then?

##### Share on other sites
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.