Significant changes have been made for procedure and jump handling in MASM 6.0. The new functionality closely resembles high-level-language implementations of the procedure calls. MASM now generates the code to correctly handle argument passing, to check type compatibility between parameters and arguments, and to process a variable number of arguments. MASM 6.0 can also handle jumps intelligently and optimize the coding according to the distance from the target.
The PROTO directive prototypes a function, which enables type-checking and type conversion of arguments if the function is called with INVOKE. For more information, see Section 7.3.6, “Declaring Procedure Prototypes.”
The new INVOKE directive calls a procedure and correctly passes the arguments according to the prototype. For more information, see Section 7.3.7, “Calling Procedures with INVOKE.”
You can also use the new VARARG keyword to pass a variable number of arguments to a procedure with INVOKE. See Section 7.3.3, “Declaring Parameters with the PROC Directive.”
The ADDR keyword is also new. When used with INVOKE, it changes an expression to an address expression (for passing by reference instead of by value). See Section 7.3.7, “Calling Procedures with INVOKE.”
High-Level Flow-Control Constructions
MASM 6.0 contains several new directives that generate code for loops and decisions depending on the status of a conditional statement. The conditions are tested at run time rather than at assembly time.
The new directives are .IF, .ELSE, .ELSEIF, .REPEAT, .UNTIL, .UNTILCXZ, .WHILE, and .ENDW. MASM 6.0 also implements the associated .BREAK and .CONTINUE directives to use in loops and if statements and the binary operators used in the C language to form binary expressions.
For more information, see Section 7.2, “Loops,” and Section 7.1.2.6, “Decision Directives.”
Automatic Optimization for Unconditional Jumps
MASM 6.0 automatically determines the smallest encoding for direct unconditional jumps. See Section 7.1.1, “Unconditional Jumps.”
Automatic Lengthening for Conditional Jumps
If a conditional jump requires a distance other than SHORT, MASM automatically generates the necessary comparison and unconditional jump to the destination. See Section 7.1.2, “Conditional Jumps.”
User-Defined Stack Frame Setup and Cleanup
The code generated following a PROC statement—a prologue—sets up the stack for parameters and local variables. The epilogue code handles stack cleanup. MASM 6.0 allows the implementation of user-defined prologues and epilogues with macros and the OPTION directive. See Section 7.3.8, “Generating Prologue and Epilogue Code.”