http://en.wikibooks.org/wiki/X86_Disass ... ack_Frames
Everything seems to be well until there. It seems that a cdecl function could be coded like this:
Code: Select all
some_function:
push ebp ;save EBP
mov ebp,esp ;point EBP to current stack position
add ebp,8 ;discard, in EBP, the saved EBP size to point directly to parameters
;and also the return addres that was pushed by near CALL instruction
push ebx
push esi
push edi
pop edi
pop esi
pop ebx
pop ebp
ret
Now, what seems strange are the floating point values and how to handle them, which are said to be returned as a single return value in FP0 register of the FPU. First of all there doesn't seem to be a convention to save anything from the FPU state. Is this supposition correct?
The other problem is, how can a program using floating point values run in a machine without FPU, like a 386DX. How can a "float" type routine return value and "float" arguments in stack be handled at compile time?