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 can-not define data with MASM directives or operators). But you can use them to find the size of C variables or types:
The LENGTH operator can return the number of elements in an array. It returns the value 1 for nonarray variables.
The SIZE operator can return the size of a C variable. A variable's size is the product of its LENGTH and TYPE.
The TYPE operator can return the size of a C type or variable. If the variable is an array, TYPE returns the size of a single element of the array.
For instance, if your program has an eight-element int array,
int arr[8];
the following C and assembly expressions yield the size of arr and its
elements:
__asm | C | Size |
LENGTH arr | sizeof(arr)/sizeof(arr[0]) | 8 |
SIZE arr | sizeof(arr) | 16 |
TYPE arr | sizeof(arr[0]) | 2 |
Instructions in an __asm block can use assembly-language comments:
__asm mov ax, offset buff ; Load address of buff
Because C macros expand into a single logical line, avoid using assembly-language comments in macros (see the section “Defining __asm Blocks as
C Macros,” below). An __asm block can also contain C-style comments, as
noted below.
Programs containing inline assembly code can be debugged with the CodeView debugger, assuming you compile with the /Zi option.
Note that putting multiple assembly instructions or C statements on one line can hamper debugging with CodeView. In source mode, the CodeView debugger lets you set breakpoints on a single line but not on individual statements on the same line. The same principle applies to an __asm block defined as a C macro, which expands to a single logical line.