[<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
UNION Define a Union TASM Directive
name UNION TASM Ideal Mode: UNION name
[name] ENDS ENDS [name]
A UNION may be thought of as a STRUC, except that all of its members
start at the beginning of the union and overlap. You can refer to
the set of fields that result with one name. (The length of the
union is the length of its largest member.)
UNIONs are useful to get around strong typing requirements, because
you can address the data in a union as though it were any of the
contained data types.
The fields indicated above are defined with the normal data
allocation directives like DB or DD. For example, to define a union
named MY_UNION, you can use this definition:
MEM_BYTE DB ?
MEM_WORD DW ?
MEM_DWORD DD ?
Every field (MEM_BYTE, MEM_WORD, MEM_DWORD) in MY_UNION begins at
the same place, at offset 0 from the beginning of the union. You can
refer to the memory area defined by MY_UNION with any of the above
Online resources provided by: http://www.ousob.com --- NG 2 HTML conversion by Dave Pearson