The usual way to return a value is by passing it in EAX
. I know also that a 64 Bit value would be returned in EAX:EDX
. However I have now a function that calcluates the localtime to miliseconds into a 64Bit double value, and the function returns it in the FPU stack, so the caller, upon return, pops it off from there.
IDA identified this function as void
and when I try to declare it as double
it says that it is a "bad declaraton". Even if IDA would accept it, this would mean that the value would have been passed back using EAX:EDX
right?
According to Wikipedia calling conventions, float/doubles are returned using the x87 registers as a standard. So how do I tell IDA this, resp. why doesn't it accept double as the return value?
Update
I found another function which returns a double, and this one is correctly using the double
as the return value, when I press Y
to change the function. So whats wrong with this one?
void __userpurge GetTimeInMilliseconds(unsigned __int16 nHour<ax>, unsigned __int16 nMinute<dx>, unsigned __int16 nSeconds<cx>, unsigned __int32 nMilliseconds)
When I try to change the void
to double
, then it failes. I assume that I may have to specify the returnvalue manually, but how do I do this for a FPU register?
Something like this, also doesn't work, so probalby there is some different name for the FPU?
void __userpurge GetTimeInMilliseconds<st>(unsigned __int16 nHour<ax>, unsigned __int16 nMinute<dx>, unsigned __int16 nSeconds<cx>, unsigned __int32 nMilliseconds)
fstp
instruction. Apparently this is the way how i.e. gcc returns a double. – Devolus Nov 11 '13 at 7:48st
is not a register, butst0
throughst7
are, and these FPU registers do work with IDA's type declaration overrides. – Jason Geffner Nov 11 '13 at 14:28