A vector data item is a linear collection of one or more sub-items of identical type that are allocated, initialized, and treated as a single unit. A vector (more commonly referred to as an array) is defined to have a specific number of items n, which are numbered from 0 to n - 1 and occupy a contiguous area of allocated storage. The items in the vector may be of any type, possibly even other vectors (commonly known as a multi-dimensional array). The assembler provides the ability to define vector types through the use of the standard Type-Declaration syntax.
The syntax required to initialize a vector is similar to that used for an aggegrate data type, and is as follows:
Array-Initializer:
The syntax requires that an Array-Initializer be enclosed in an outer set of braces or angle brackets, but the Initializer-List or individual comma-separated Initializer-Items may be left unspecified, in which case a default initializer value is used. Commas are used to denote the position of each sub-item within the entire array, and nested initializers are allowed to accomodate imbedded occurrences of other arrays (or aggregate types, which share the same initializer syntax).
Examples
Here are some examples of vector initialization:
; Data structures to define a "computer" data type TRUE equ 1 FALSE equ 0 MB equ 1024 ; Megabytes BOOL_T typedef BYTE ; true or false value INCHES_T typedef BYTE ; number of inches MONITOR_T typedef INCHES_T ; size of monitor in inches KEYBOARD_T typedef BOOL_T ; is a keyboard installed? MOUSE_T typedef BOOL_T ; is a mouse installed? KBYTES_T typedef WORD ; number of kilobytes MBYTES_T typedef WORD ; number of megabytes FPRESENT_T typedef BOOL_T[2] ; up to two floppies installed FSIZE_T typedef KBYTES_T[2] ; how big they are DPRESENT_T typedef BOOL_T[4] ; up to four hardfiles installed DSIZE_T typedef MBYTES_T[4] ; how big they are RAM_T typedef DWORD ; how much memory we have NAME_T typedef BYTE[64] ; what we call the system FLOPPIES_T struct DriveCount FPRESENT_T { TRUE, FALSE } ; assume one floppy installed DriveSize FSIZE_T { 360, 0 } ; assume 360KB in size :-) FLOPPIES_T ends DRIVES_T struct DriveCount DPRESENT_T { TRUE, FALSE, FALSE, FALSE } ; one drive installed DriveSize DSIZE_T { 20, 0, 0, 0 } ; 20MB in size (!) DRIVES_T ends COMPUTER_T struct Monitor MONITOR_T 14 ; Assume a 14 inch monitor Keyboard BOOL_T TRUE ; We have a keyboard Mouse BOOL_T FALSE ; but no mouse Memory RAM_T 640 ; Assume 640KB Floppies FLOPPIES_T {} ; Go with the defaults HardFiles DRIVES_T {} ; Go with the defaults ModelName NAME_T {} ; No default name COMPUTER_T ends DATA segment Circa1997 COMPUTER_T \ ; initializer begins on next line { 17, ; of course, we have a 17" monitor TRUE, TRUE, ; a keyboard and a mouse 32 * MB, ; 32 Megabytes of ram { { }, ; still one floppy { 1440 } }, ; but it has a 1.2 MB capacity { { , TRUE, TRUE }, ; also have second and third hardfiles { 512, 1024, 4096 } }, ; 512MB, 1 GIG, and 4 GIG { "Spiffatron 9000", 10, 13, ; with a fancy system name "Acme Computers", 10, 13, 0 } } DATA ends end