The information in this article applies to:
SUMMARY
With the Microsoft Macro Assembler (MASM) version 6.0, the coding for
a procedure call may be simplified by the use of the PROTO and INVOKE
directives. These directives handle many of the details, such as
pushing the parameters on the stack in the correct order, generating
the correct external references, coercing arguments to the correct
size, and cleaning up the stack (if required) after the function
terminates.
MORE INFORMATIONPROTO defines a prototype for a procedure much the way a function prototype works in C. This is the syntax for PROTO:
The PROTO statement is used by the assembler to check parameter types
and quantity along with indicating the naming convention for the
function. Arguments for the function are indicated by listing the
type, and optionally, a parameter name. For example,
This indicates that the function myfunc takes two arguments. The first
is a signed word, the second is a signed byte. If you need a variable
argument list, you use the type VARARG.
INVOKE actually generates the code to call the function. You must have defined the function previously with either a PROC, an EXTERNDEF, a TYPEDEF, or a PROTO statement. This is the syntax for INVOKE:
Because the assembler knows what the function is expecting in the way
of arguments and calling convention, it can take the arguments passed
in the INVOKE statement and push them on the stack in the correct
order, call the function using the required function name, and clean
up the stack afterwards (if required by the calling convention used).
If an argument passed by INVOKE is smaller than the type specified in the PROTO statement, MASM does a type conversion. It widens the argument in the PROTO statement to match that in the INVOKE statement (for example, SBYTE to SWORD). These types of conversions use the AX and DX registers on the 8086 and 8088 and the EAX and EDX registers on the 80386/80486. Because these registers are effectively overwritten, you should take care to avoid using these registers to pass arguments. The language type for the function determines the naming and calling conventions. In addition to the language type in the PROTO statement, the language type can be set by the .MODEL directive, the OPTION LANGTYPE:, or by the command line switches /Gc (for Pascal) and /Gd (for C). There is a table of the various language conventions provided in Help. Sample Code 1
Sample Code 2
Additional query words: kbinf 6.00 6.00a 6.00b s_c
Keywords : |
Last Reviewed: January 4, 2000 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |