RISC/6000 assembler examples wanted

marc at arnor.uucp marc at arnor.uucp
Wed Nov 7 09:17:36 AEST 1990


madd at world.std.com (jim frost) writes:
 
>If you care about the calling conventions, beware that both the info
>and printed documentation are incorrect about shadowing floating point
>arguments and how to call varargs functions.  Floating point arguments
>should always be shadowed in GPR's (the documentation says otherwise)
>and there is no special calling convention for varargs functions.  If
>you are yourself a varargs function you can just write the GPR
>arguments onto the stack and access them that way.  Write some sample
>C programs and see how they do it, don't trust the documentation.
 
Be careful about reading the documentation or looking at what the
compiler does with reference to passing floating point value parameters.
There is a problem with the description in both the compiler manuals
and the compilers.  I don't know which manual you were referring to, but
I couldn't find it anywhere else.
 
The problem occurs when the callee expects more floating point value
parameters than were passed and generally only is manifest at low opt
levels as caller's automatics getting hosed.  The reason is that the
callee is storing what it thinks are its parameters in the stack.  It
shouldn't store past the first 32 bytes of parameter list for
unreferenced parameters.  The stores should happen on the calling side.
 
There may be a fix available to the compiler shortly (in the form of an
option that does the correct thing).  In the next release the correct
thing will be the default and there will be an option to do what release
1 does.
 
The correct thing:
- the first 8 words of arguments correspond to the 8 parameter registers
  r3-r10
- the non-float value words from the first 8 words of arguments are
  passed in the corresponding GPRs
- the first 13 floating point value parameters are passed in fp1-fp13
- if there is no function prototype for the called function, or the
  prototype contains an ellipsis then all floating point values
  are also passed in GPR/stack (GPRs for those occurring in the first
  8 words of the parameter list, stack otherwise)
- if there are more than 8 words of arguments, then the extra words
  are stored on the stack regardless of type
- the called function takes the parameters from fp1-fp13 for the first
  13 floating point value parameters, from r3-r10 for the first 8 words
  of non-floating point value parameters and from the stack otherwise.
  If it wants its parameters in contiguous storage (at low opt or if
  the address of a parameter is taken) then it stores only the first
  32 bytes from either FPRs or GPRs depending on the type.
 
Note that you can pass a floating point argument to an integer parameter
but not vice versa.
 
J.B. Minish



More information about the Comp.unix.aix mailing list