LocalVar


include vmm.inc

LocalVar varname, size
LocalVar varname, size, PACK

Declares a stack local variable 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 next multiple of four.

PACK

An optional parameter, normally omitted. If present and identical to the word PACK, indicates that the traditional padding to the next multiple of four is suppressed. Packing local variables should be done with care, lest you end up with a total size of local variables not a multiple of four.

This macro is used in writing assembly-language procedures which use the C, Pascal, or StdCall calling convention. See the description of the ArgVar macro for additional information.

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 the high word, and varnameHH to the high byte of the high word.

When the EndProc is reached, the names of all LocalVar 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 of the PACK attribute:


LocalVar MyLocal, DWORD
LocalVar First, BYTE, PACK
LocalVar Second, BYTE, PACK
LocalVar Third, BYTE, PACK
LocalVar Fourth, BYTE, PACK

This example declares eight bytes of local variables. The first four bytes are a DWORD, named MyLocal. The fifth byte is a BYTE variable named First, the sixth a BYTE variable named Second, the seventh a BYTE variable named Third, and the eighth a BYTE variable named Fourth. If the PACK attributes were omitted, this sequence of declarations would have created twenty bytes of local variables, with three bytes of padding inserted after each BYTE variable. Note carefully that the BYTE variables come in groups of four so as to maintain stack dword alignment.

See also Debug_Test_Valid_Handle