STRUCT/STRUC (Define a Structure Type Name)
Defines a Structure-TypeName
that represents an aggregate
data type containing one or more fields.
Structure-Name STRUCT
FieldDeclaration
.
.
.
Structure-Name ENDS
Where FieldDeclaration has the following form:
[FieldName] Allocation-TypeName InitialValue [, InitialValue ...]
Remarks
The obsolete spelling for the STRUCT directive is STRUC.
The syntax for the FieldDeclaration is that of a normal data allocation
statement. See the section on Data
Allocation for a full description of this syntax.
The various parts of the FieldDeclaration are described as follows:
FieldName
Each FieldName entry
is converted to Structure-FieldName
when processing of the structure definition is complete. If this
field is omitted and the Allocation-TypeName resolves to a
Structure-TypeName or
Union-TypeName, then all
of the fields defined within the imbedded structure or union are promoted
to be visible at the same level as other FieldName entries
in the current structure given by the Structure-Name.
Allocation-TypeName
The allowable values for this field are
described in detail in the Data Allocation
section. In modes other than M510,
the assembler accepts imbedded occurrences of other structures or unions
by specifying an identifier that resolves to a Structure-TypeName
or Union-TypeName in
this field.
InitialValue
The
InitialValue field must be an Expression
that resolves to an ExpressionType
appropriate for the Allocation-TypeName
utilized in the FieldDeclaration. The InitialValue expressions
become part of the structure type definition. These values are used as
default initializers when an instance of the structure is allocated and
no explict override values are specified for a particular field.
Example
Numbers STRUCT
One DB 0
Two WORD 0
BYTE 3
Four DWORD ?
Numbers ENDS
Allocate a structure variable called Values using the Numbers
Structure-TypeName,
overriding the One, Two, and Four Structure-FieldName
entries with explicit values, and the third (unnamed) entry is initialized
with the default InitialValue inherited from the FieldDeclaration:
Values Numbers <1, 2, , 4>
[Back: RECORD (Define a Record Type Name)]
[Next: TYPEDEF (Create a User-Defined Type Name)]