Array Declaration 

Arrays and Strings:

An array is a sequential collection of variables, all of the same size and type, called "array elements". A string is an array of characters. For example, in the string “ABC,” each letter is an element. You can access the elements in an array or string relative to the first element.

Declaring and Referencing Arrays:

Array elements occupy contiguous memory locations. The program references each element relative to the start of the array. An array is declared by giving it a name, a type, and a series of initializing values or placeholders (?).

The following example shows how to declare an array of bytes (b_array) and an array of words (w_array):

Array declaration
b_array BYTE  1, 2, 3, 4
w_array WORD 0FFFFh, 789Ah, 0BCDEh

Initializer lists of array declarations can span multiple lines. The first initializer must appear on the same line as the data type, all entries must be initialized, and, if the array is to continue to the new line, the line must end with a comma.

The following example shows legal multiple-line array declaration:

Multiple Line Byte Declaration
big	BYTE	21, 22, 23, 24, 25,26, 27, 28,
            	10, 20, 30

An array may span more than one logical line, such as the array var1 in the example below, although a separate type declaration is needed in each logical line:

Multiple line array declaration
var1 	BYTE 10, 20, 30
	BYTE 40, 50, 60
	BYTE 70, 80, 90

The DUP Operator:

The DUP operator is very often used in the declaration of arrays This operator works with any of the data allocation directives.

In the syntax:
	count DUP (initialvalue [[, initialvalue]]...)

the count value sets the number of times to repeat all values within the parentheses. The initial value can be an integer, character constant, or another DUP operator, and must always appear within parentheses.

For example, the statement allocates the integer value 1 five times for a total of 5 bytes.:
The DUP Operator
barray	BYTE	5	DUP	(1)

The following examples show various ways for allocating data elements with the DUP operator:

Different uses of the DUP Operator
array	 DWORD	10  DUP (1)				;10 doublewords initialized to 1
buffer	 BYTE	256 DUP (?)				;256-byte buffer
masks	 BYTE	20  DUP (040h, 020h, 04h, 02h)	;80-byte buffer with bit masks
threed	 DWORD	5   DUP (5 DUP (5 DUP (0)))		;125 doublewords initialized to 0