PRB: SIZE Operator ValueLast reviewed: January 9, 1995Article ID: Q11910 |
The information in this article applies to:
SYMPTOMSWhen trying to get the length of a text string, using the SIZE operator can produce undesired results. In the example below, MSG_LEN is set to a value of 1, but it seems it should be set to a value of 11:
MSG DB 'Darth Vader' MSG_LEN EQU SIZE MSG CAUSEThe value of MSG_LEN should be 1. The SIZE operator is defined to be the LENGTH * TYPE as stated in the documentation. The expression, LENGTH MSG, will be equal to 1 (when applied to a data label, the LENGTH operator returns the number of elements created by the DUP operator; otherwise it returns 1) and the expression, TYPE MSG, will be equal to 1. Therefore, the variable MSG_LEN will be equal to 1.
RESOLUTIONIn Macro Assembler version 6.0, the SIZEOF operator can be used to calulate the total number of bytes allocated to a data item. In versions prior to 6.0, a simple way to calculate the value you want is as follows:
MSG DB 'Darth Vader' MSG_LEN EQU $-MSG |
Additional reference words: 4.00 5.00 5.10 6.00
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |