Mail Archives: djgpp/1998/05/16/13:53:22
At 01:48 5/16/1998 GMT, Paul Derbyshire wrote:
>It's documented everywhere and generally frequently mentioned that "DJGPP C
>functions return their values in eax"..... this makes sense for many cases.
>
>
>class huge {
>public:
> int f[900];
> bool b[20];
> char g[1048576];
> int foo (void);
>}
>
>huge voodoo (bool b) {
> //...
> return my_huge;
>}
>
>... so how the hell does THAT fit in eax?? :-)
>
>I suppose objects bigger than 32 bits are implicitly passed by reference using
>a pointer in eax, and the temporary is deleted only after receipt of the value
>in the caller?
No. The way it works is that the caller passes an invisible first argument
which is the address where the returned aggregate should be stored. This is
useful, because in the case:
struct huge { ... };
struct huge f();
void y()
{
struct huge h;
h = f();
}
you end up with only one copy of huge, since the compiler will pass &h as
the address.
That's how it works in C, anyway. I don't use C++, but I imagine it is
similar except for the complications from other invisible arguments.
Btw, looking at the output of `gcc -S' helps in understanding this as well.
Nate Eldredge
nate AT cartsys DOT com
- Raw text -