Skip to main content
GameDev.net gamedev.net
🔒 Locked

initialize 8087 x86 asm

Started by JoeZ Oct 4, 2002 at 9:22 PM 2 replies 550+ views
Original Post
JoeZ
JoeZ
Hi: a newbie question I am trying to write a round integer function in assembly and c++ my function is int Round(float x){ int num; _asm{ finit; //init 8087 fld x; //load float number frndint; //round it fist num; //store number } return num; } I want to know that will that be slow because each time the function is called the finit is call to init 8087?
Jan Wassenberg
Jan Wassenberg
Yep.
All you need is
fld [ x ]
fistp [ num ]

BTW: VC++ does float->int with ftol(), which is sloow. The compiler switch QIfist has it use the current FPU rounding mode instead (your code will no longer be portable, because ANSI specifies truncation).
E8 17 00 42 CE DC D2 DC E4 EA C4 40 CA DA C2 D8 CC 40 CA D0 E8 40E0 CA CA 96 5B B0 16 50 D7 D4 02 B2 02 86 E2 CD 21 58 48 79 F2 C3
Schwammerl-Bob
Schwammerl-Bob
QIfist ??
never heard of that. it does not seem to exist in M$ VC++ anyway.

[edited by - Schwammerl-Bob on October 5, 2002 12:13:19 PM]
Jan Wassenberg
Jan Wassenberg
> it does not seem to exist in M$ VC++ anyway.

Just add /QIfist to your project options - works fine with VC++ 6.

> QIfist ?? never heard of that.

That''s what MSDN is for
E8 17 00 42 CE DC D2 DC E4 EA C4 40 CA DA C2 D8 CC 40 CA D0 E8 40E0 CA CA 96 5B B0 16 50 D7 D4 02 B2 02 86 E2 CD 21 58 48 79 F2 C3

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.