4.39. 4.39 Union Constants

Like records, HLA allows you to create union constants within your HLA source files. However, because all the fields of a union occupy the same storage at runtime, union constants only let you specify a single value. The question is, "which value?" Well, when you create a union constant, you have to explicitly specify the field whose value you want provide. You do this using the following syntax:

typename.fieldname:[ field_value ]

The typename item must be a union type you've previously defined in a type section. The fieldname item must be a valid field from that union type. The field_value item must be an appropriate constant whose type matches the typename.fieldname field. Here is a quick example:

type utype: union b:byte; ...

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

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.