4.32. 4.32 Arrays/Records as Record Fields

Records may contain other records or arrays as fields. Consider the following definition:

type
     Pixel:
          record
               Pt:        point;
               color:     dword;
          endrecord;

The definition above defines a single point with a 32-bit color component. When initializing an object of type Pixel, the first initializer corresponds to the Pt field, not the x-coordinate field. The following definition is incorrect:

static
     ThisPt: Pixel := Pixel:[ 5, 10 ];   // Syntactically incorrect!

The value of the first field ("5") is not an object of type point. Therefore, the assembler generates an error when encountering this statement. HLA will allow you to initialize the fields of Pixel using declarations like the following:

static ThisPt: Pixel := Pixel:[ ...

Get Art of Assembly Language, 1st Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.