Example of Passing and Returning Aggregates by Value to an Unprototyped Routine

This example differs from the example of Passing and Returning Aggregates by Value to a Prototyped Routine by the presence of an eyecatcher after the call to bar in the caller's code and the code necessary to perform the default widening rules required by ANSI.

   struct s_tag {
             long  a;
             float b;
             long  c;
             } x, y;
   long  z;
   double q;

   /* Actual Call */
   y = bar(z, x, q);
    ...

   /* callee */
   struct s_tag bar(long lvar, struct s_tag aggr, float fvar)
   {
      struct s_tag temp;

      temp.a = lvar + aggr.a + 23;
      temp.b = fvar - aggr.b;
      temp.c = aggr.c;

      return temp;
   }


Caller's code up until call:

   FLD     QWORD_PTR q          ; Load lexically first floating-point
                                ;  parameter to be converted
   SUB     ESP, 8               ; Allocate space for the floating-point
                                ;  register parameter
   PUSH    x.c                  ; Push nonconforming parameters on
   PUSH    x.b                  ;  stack
   PUSH    x.a                  ;
   MOV     EAX, z               ; Load lexically first
                                ;  conforming parameter
                                ;  into EAX
   SUB     ESP, 4               ; Allocate stack space for the first
                                ;  general-purpose register parameter.
   PUSH    addr y               ; Push hidden first parameter (address of
                                ;  return space)
   CALL    BAR
   TEST    EAX, 00408000h       ; Eyecatcher
   ADD     ESP, 28              ; Clean up parameters

 



Calling Conventions
Eyecatchers


Examples of Passing Parameters Using _Optlink