Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

What/Where is ftol?

432 views
Skip to first unread message

David Foringer

unread,
Aug 25, 1998, 3:00:00 AM8/25/98
to
Hi all.
Ok.. it does not exist?
When I try to link my objects (using the Pharlap linker)
and I include no libraries.. I get __ftol is undefined.

Possibly is VC++ making a call to ftol
when I use a statement like...

float float_var = 5;
long deci = (long)float_var;

Either way.. I need to find a function ... or get VC++
not to call it.. any ideas? I could use the source too...

Thanks in advance.
david.f...@cas.honeywell.com


Gregory Malocha

unread,
Aug 26, 1998, 3:00:00 AM8/26/98
to
The statement:
long deci = (long)float_var;
implicitly generates a call to _ftol ( float to long ).

Normally this is implemented in a math library.

Gregory Malocha,
Sezam Technologies

David Foringer wrote in message <35e33660...@msnews.microsoft.com>...

David Foringer

unread,
Aug 26, 1998, 3:00:00 AM8/26/98
to
hi..
The source is not on the CD. I need to compile it and include it with my
project because i cannot link with any libs. So.. all library function I
would be needing I must create and compile as part of the project.
Unfortunately, _ftol seems to be some kind of intrinsic function....
microsoft gives no source but the compiler automatically generates a call
to it when needed.

So I've created the following... and it seems to work ok.. not all that
happy with it though.. perhaps better assembly programmers can help out.

long _cdecl _ftol(float f)
{
__asm
{
// Remove what the compiler put on the stack for the c function
call.
pop edi
pop esi
pop ebx

// Below is the disassembly generated by the debugger for the
microsoft
// version of _ftol.
// add esp, 0F4h
wait
fnstcw word ptr [ebp-2]
wait
mov ax, word ptr [ebp-2]
or ah, 0Ch
mov word ptr [ebp-4], ax
fldcw word ptr [ebp-4]
fistp qword ptr [ebp-0Ch]
fldcw word ptr [ebp-2]
mov eax, dword ptr [ebp-0Ch]
mov edx, dword ptr [ebp-8]
// End microsoft version.

// Push what the compiler expects back onto the stack for the c
function.
push ebx
push esi
push edi
}
}


David Foringer


Gregory Malocha <_nospam_...@worldnet.att.net_nospam_> wrote in
article <#YgTRER0...@uppssnewspub04.moswest.msn.net>...

0 new messages