Declares a structure
having the specified
fielddeclarations.
Each field must
be a valid data definition.
Each fielddeclaration of the structure MUST be declared with a name that is unique
within the structure. The allowed data types are FCB, FDB, FQB, ZMB, ZMD, ZMQ,
UNION, or another data structure. If an expression is supplied the resulting
value will determine the number of elements of the specified type to use.
color struct
red rmb 1
green rmb 1
blue rmb 1
ends
Members of the structure are accessed as "structurename"."membername". An
example of accessing member structures:
lda $1000+color.red
lda color.blue,x
Alternatively a structure can be used in a similar manner as built in data
types such as FCB and FDB. An example of accessing a structure when used like a
built in data type:
data color
lda data.blue
lda data.green
lda data.red
Structures can also be declared and accessed as arrays in
the following form:
palette struct
colors color 16
ends
lda colors[2].red
suba colors[3].blue
sta colors[4].green
A special operator has also been provided for use in expressions when dealing
with structures. The sizeof operator can be used to determine
the size of a structure or of data declared with a structure.
palette struct
colors color 16
ends
ldb #sizeof(palette)/sizeof(color)
ldx #palette
clear clr color.red,x
clr color.green,x
clr color.blue,x
leax sizeof(color),x
decb
bne clear