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?


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)
  • Already answered at reverseengineering.stackexchange.com/a/2968/1562 Nov 10, 2013 at 17:30
  • @JasonGeffner, Unfortunately this is not covered, because the answers only deal with regular registers and not with FPU registers. I haven't found a way yet, how to represent a returnvalue which is passed in the FPU and then retrieved by the caller with the fstp instruction. Apparently this is the way how i.e. gcc returns a double.
    – Devolus
    Nov 11, 2013 at 7:48
  • st is not a register, but st0 through st7 are, and these FPU registers do work with IDA's type declaration overrides. Nov 11, 2013 at 14:28


Browse other questions tagged or ask your own question.