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 - for functions whose code is generated by watcom c/c++ and whose argument http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
For functions whose code is generated by Watcom C/C++ and whose argument
list is described by an auxiliary pragma, Watcom C/C++ has some freedom in
choosing how arguments are assigned to registers.  Since the code for
in-line functions is specified by the programmer, the description of the
argument list must be very explicit.  To achieve this, Watcom C/C++ assumes
that each register set corresponds to an argument.  Consider the following
DOS example of an in-line function called scrollactivepgup.


     void scrollactivepgup(char,char,char,char,char,char);
     #pragma aux scrollactivepgup = \
         "mov AH,6"   \
         "int 10h"    \
         parm [ch] [cl] [dh] [dl] [al] [bh] \
         modify [ah];

The BIOS video call to scroll the active page up requires the following
arguments.

 1. The row and column of the upper left corner of the scroll window is
    passed in registers CH and CL respectively.

 2. The row and column of the lower right corner of the scroll window is
    passed in registers DH and DL respectively.

 3. The number of lines blanked at the bottom of the window is passed in
    register AL.

 4. The attribute to be used on the blank lines is passed in register BH.

When passing arguments, Watcom C/C++ will convert the argument so that it
fits in the register(s) specified in the register set for that argument.
 For example, in the above example, if the first argument to
scrollactivepgup was called with an argument whose type was int, it would
first be converted to char before assigning it to register CH.  Similarly,
if an in-line function required its argument in register pair DX:AX and the
argument was of type short int, the argument would be converted to long int
before assigning it to register pair DX:AX.

In general, Watcom C/C++ assigns the following types to register sets.

 1. A register set consisting of a single 8-bit register (1 byte) is
    assigned a type of unsigned char.

 2. A register set consisting of a single 16-bit register (2 bytes) is
    assigned a type of unsigned short int.

 3. A register set consisting of two 16-bit registers (4 bytes) is assigned
    a type of unsigned long int.

 4. A register set consisting of four 16-bit registers (8 bytes) is assigned
    a type of double.

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