Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- TASM 2.x / MASM 6.x Assembly Language - <b>union define a union tasm directive</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
UNION            Define a Union                                TASM Directive

   name UNION     TASM Ideal Mode:   UNION name
   fields                            fields
   [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:

                        MY_UNION UNION
                        MEM_BYTE    DB ?
                        MEM_WORD    DW ?
                        MEM_DWORD   DD ?
                        MY_UNION ENDS

     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
     field names.

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson