4.1.2 Data Initialization

You can initialize variables when you declare them by giving initial values—that is, constants or expressions that evaluate to integer constants. The assembler generates an error if you specify an initial value too large for the specified variable type. Variables can also be initialized with ? if there are no initial values.

You can declare and initialize variables in one step with the data directives, as these examples show.

integer BYTE 16 ; Initialize byte to 16

negint SBYTE -16 ; Initialize signed byte to -16

expression WORD 4*3 ; Initialize word to 12

signedexp SWORD 4*3 ; Initialize signed word to 12

empty QWORD ? ; Allocate uninitialized long

; integer

BYTE 1,2,3,4,5,6 ; Initialize six unnamed bytes

long DWORD 4294967295 ; Initialize doubleword to

; 4,294,967,295

longnum SDWORD -2147433648 ; Initialize signed doubleword

; to -2,147,433,648

tb TBYTE 2345t ; Initialize 10-byte binary

; number

See Section 5.1, “Arrays and Strings,” for information on arrays and on using the DUP operator to allocate initializer lists.

Once you have declared integer variables in your program, you can use them in integer operations such as adding, moving, loading, and exchanging. The next section describes these operations.