Slide 8.3: PTR operator Slide 8.5: SIZEOF operator and LABEL directive Home |
TYPE
and LENGTHOF
Operators
TYPE Operator
The TYPE operator returns the size, in bytes, of a single element of a variable.
|
|
LENGTHOF
Operator
LENGTHOF
operator counts the number of elements in an array, defined by the values appearing on the same line as its label.
LENGTHOF
regards the data from these two lines as part of the array.
TYPE DWORD |
TYPE DWORD 12 DUP(?) |
LENGTHOF DWORD 12 DUP(?) |
.data var DWORD ? .code mov eax, TYPE var call WriteInt |
.data arr DWORD 12 DUP(?) .code mov eax, TYPE arr call WriteInt |
.data arr DWORD 12 DUP(?) .code mov eax, LENGTHOF arr call WriteInt |
Output | Output | Output |
LENGTHOF BYTE \ |
WORD 100h, 200h |
WORD 100h, 200h, |
.data s BYTE "12345", 0 .code mov eax, LENGTHOF s call WriteInt |
.data arr WORD 100h, 200h WORD 300h, 400h .code mov eax, LENGTHOF arr call WriteInt |
.data arr WORD 100h, 200h, 300h, 400h .code mov eax, LENGTHOF arr call WriteInt |
Output | Output | Output |