inline assembler
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
-werdup-
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.
Edited by - shmaLbus on July 24, 2000 10:33:10 AM
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
-werdup-
If you want the slowest possible conversion - why the ''fugg'' are you using assembler???
July 24, 2000 01:11 PM
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.
-----------------
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.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement