GNU Info

Info Node: (nasm.info)Section 4.8.6

(nasm.info)Section 4.8.6


Next: Section 4.8.7 Prev: Section 4.8.5 Up: Section 4.8
Enter node , (file) or (file)node

4.8.6. `ISTRUC', `AT' and `IEND': Declaring Instances of Structures
-------------------------------------------------------------------

   Having defined a structure type, the next thing you typically want
to do is to declare instances of that structure in your data segment.
NASM provides an easy way to do this in the `ISTRUC' mechanism. To
declare a structure of type `mytype' in a program, you code something
like this:

     mystruc:
         istruc mytype
     
             at mt_long, dd      123456
             at mt_word, dw      1024
             at mt_byte, db      'x'
             at mt_str,  db      'hello, world', 13, 10, 0
     
         iend

   The function of the `AT' macro is to make use of the `TIMES' prefix
to advance the assembly position to the correct point for the specified
structure field, and then to declare the specified data.  Therefore the
structure fields must be declared in the same order as they were
specified in the structure definition.

   If the data to go in a structure field requires more than one source
line to specify, the remaining source lines can easily come after the
`AT' line. For example:

             at mt_str,  db      123,134,145,156,167,178,189
                         db      190,100,0

   Depending on personal taste, you can also omit the code part of the
`AT' line completely, and start the structure field on the next line:

             at mt_str
                     db      'hello, world'
                     db      13,10,0


automatically generated by info2www version 1.2.2.9