This documentation is archived and is not being maintained.

Type and Variable Sizes in Inline Assembly

Microsoft Specific

The LENGTH, SIZE, and TYPE operators have a limited meaning in inline assembly. They cannot be used at all with the DUP operator (because you cannot define data with MASM directives or operators). But you can use them to find the size of C or C++ variables or types:

  • The LENGTH operator can return the number of elements in an array. It returns the value 1 for non-array variables.

  • The SIZE operator can return the size of a C or C++ variable. A variable's size is the product of its LENGTH and TYPE.

  • The TYPE operator can return the size of a C or C++ type or variable. If the variable is an array, TYPE returns the size of a single element of the array.

For example, if your program has an 8-element int array,

int arr[8];

the following C and assembly expressions yield the size of arr and its elements.

__asm C Size




SIZE arr



TYPE arr



END Microsoft Specific