Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Watcom C/C++ User's Guide - function prototypes define the types of the formal parameters of a function. http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
Function prototypes define the types of the formal parameters of a function.
 Their appearance affects the way in which arguments are passed.  An
argument will be converted to the type of the corresponding formal parameter
in the function prototype.  Consider the following example.


     void prototype( float x, int i );

     void main()
     {
       float x;
       int   i;

       x = 3.14;
       i = 314;
       prototype( x, i );
       rtn( x, i );
     }

The function prototype for prototype specifies that the first argument is to
be passed as a "float" and the second argument is to be passed as an "int".
This results in the first argument being passed in registers DX and AX and
the second argument being passed in register BX.

If no function prototype is given, as is the case for the function rtn, the
first argument will be passed as a "double" and the second argument would be
passed as an "int".  This results in the first argument being passed in
registers AX, BX, CX and DX and the second argument being passed on the
stack.

Note that even though both prototype and rtn were called with identical
argument lists, the way in which the arguments were passed was completely
different simply because a function prototype for prototype was specified.
 Function prototyping is an excellent way to guarantee that arguments will
be passed as expected to your assembly language function.

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson