USING PROCEDURES, FUNCTIONS AND MACROS

 1  Stack Procedures

Stack procedures use the pascal calling style for parameters.  Stack
procedures must therefore be called with the same number of parameters as
declared for the procedure.  Stack procedure names must contain at least
one lower case letter to signify that it is a stack procedure, not a REG
procedure.

The programmer must specify what the type is for each parameter.  If the
programmer does not specify a type, 'word' will be assumed.

    stack_procedure(x,y);

is the same as:

    stack_procedure(word x,word y);

C-- does not remember what the type is for each parameter of a procedure,
care must be used by the programmer to ensure that the types are the same.
For example, if a procedure has three parameters, and the first parameter is
a 'long' and last two are 'int', the programmer must call it in the following
format:

    stack_procedure(long x,int x,int x);

If the programmer left out the 'long', only 6 bytes will be pushed onto the
stack, not 8.  Unexpected things would then start to happen, so watch out.


2  REG Procedures

For REG procedures, the parameters are passed via registers.  The 16 bit
register used for each position is as follows:

    REG_PROCEDURE(AX,BX,CX,DX,DI,SI);

If byte or char is used in a position, the 8 bit register that is used for
the position is as follows (note that byte or char values cannot be used in
the DI and SI positions):

    REG_PROCEDURE(byte AL,byte BL,byte CL,byte DL);

If dword or long is used in a positions, the 32 bit register that will be
used for the position is as follows:

    REG_PROCEDURE(long EAX,long EBX,long ECX,long EDX,long EDI,long ESI);


3  Macros

Macros are simply REG procedures whose code is inserted rather than called.
An '@' symbol is placed before the REG procedure name to specify the code to
be inserted rather than called.  In order for a REG procedure to be used as
a macro, the REG procedure must be declared as a dynamic procedure or found
in the internal library.

All other characteristics of macros are identical to REG procedures.

Post a Comment

0 Comments