B
BartC
glen herrmannsfeldt said:(snip on calling functions with an unknown, at compile time, number
of arguments, possibly of unknown type.)
Even worse, if that register is on the x87 stack. You can't just ignore
it, as sometime later, likely at an unexpected time and place, a
floating point stack overflow will be detected.
Fortunately, I will know, at the time of the call, what the result type is.
So a float value can be 'popped' from the FPU stack, even if the function is
being called (from the target language) as a procedure with the return value
unused. (Although of course the language could get the return type wrong,
but that will be a user bug, and could happen also when declared in C.)
Slightly more tricky, are pointers to such functions, which may need the
return type and call-type contained within them to avoid problems (since
there is no static typing).
I do remember random number generators for OS/360 Fortran that would
return either a floating point value between 0 and 1, or a 32 bit
integer, depending on declaring the function INTEGER or REAL.
The (assembler) function returned values in both general and floaing
point registers, and the compiler used the appropriate one.
Many 32 bit compilers will pass an additional argument to store the
result in if the result type is more than 32 bits. (Such as a struct.)
That might not be true for 64 bit compilers.
That sounds unlikely for values such 64-bit versions of int types. It will
probably just use adjacent registers. Not sure about 64-bit structs though..