ArgVar


include vmm.inc

ArgVar varname, size, used

Declares a stack argument for a procedure.

varname

Specifies the name of the variable.

size

A numeric expression specifying the size of the variable in bytes. The words BYTE, WORD, and DWORD, are acceptable as synonyms for 1, 2, and 4, respectively. If the value is not a multiple of four, the variable is padded to the nearest multiple of four.

used

An optional parameter, normally omitted. If present and identical to the word NOTUSED, indicates that this parameter is not used. In such case, the ArgVar macro will point the name at an intentionally undefined symbol.

This macro is used in writing assembly-language procedures which use the C, Pascal, or StdCall calling convention.

If the variable is a WORD, then two additional symbols are defined: varnameL refers to the low byte and varnameH refers to the high byte. If the variable is a DWORD, then six additional symbols are defined: varnameL refers to the low word, varnameLL to the low byte of the low word, varnameLH to the high byte of the low word, varnameH to the high word, varnameHL to the low byte of hte high word, and varnameHH to the high byte of the high word.

When the EndProc is reached, the names of all ArgVar variables are set to an intentionally undefined symbol so that they cannot be used by accident later. (This behavior can be overridden by using the KEEPFRAMEVARS attribute on EndProc.) Here is an example procedure that uses these macros. The example procedure doesn't do anything interesting, but it illustrates the proper use of the macros.


BeginProc MyProc, CCALL

ArgVar Param1, DWORD
ArgVar Param2, WORD
ArgVar Param3, 12    ; third parameter is a 12-byte structure, 
                     ;   passed by value

LocalVar Local1, DWORD
LocalVar Local2, <size FOO>

EnterProc
SaveReg <ebx, esi>
lea  eax, Local2    ; eax now points to a FOO structure on the stack
mov  cx, Param2     ; cx contains the value of Param2
mov  Local1LL, ch   ; Store ch into the the low byte of the low 
                    ;   word of Local1
lea  edx, Param3    ; edx points to the 128-byte structure on the stack
RestoreReg <esi, ebx>
LeaveProc
Return
EndProc MyProc

The above example illustrates several important points.

See also Debug_Test_Valid_Handle