Assembly Language Help (alang.hlp) (Table of Contents; Topic list)
Important Notice
The pages on this site contain documentation for very old MS-DOS software, purely for historical purposes. If you're looking for up-to-date documentation, particularly for programming, you should not rely on the information found here, as it will be woefully out of date.
Start a Far Data Segment
                                             Up Contents Index Back
────────────────────────────────────────────────────────────────────────────
 
  Syntax:   .FARDATA [name]
 
            .FARDATA? [name]
 
  See also: .DATA, .MODEL, .CODE, .CONST, .STACK, SEG, @data, @fardata,
            @DataSize, Table of Memory Models, MASM 5.1 Compatibility
 
  Description:
 
     The .FARDATA directive starts a far data segment for initialized
     data (segment name FAR_DATA or <name>, if given), ending any
     previous segment. The .FARDATA? directive starts a far data
     segment for uninitialized data (segment name FAR_BSS or
     <segmentname>, if given), ending any previous segment.
 
     Data in segments defined with .FARDATA and .FARDATA? are not
     placed in a group or combined with far data segments for other
     source modules. Using <name> allows you to create multiple far
     data segments in one source module. The .MODEL directive must
     precede these directives.
 
     Putting uninitialized arrays and buffers into a segment created
     by .FARDATA? rather than .FARDATA can decrease the size of object
     files and libraries.
 
     Normally, you cannot access far data segments by name, because
     there may be multiple PRIVATE segments with the same name. Use
     SEG expressions instead.
 
  Example:
 
   ┌─MODULE1.ASM───────────────────────────────────────────────────────────┐
   │                                                                       │
   │         .FARDATA?                                                     │
   │ array   WORD      1000 DUP ?                                          │
   └───────────────────────────────────────────────────────────────────────┘
 
   ┌─MODULE2.ASM───────────────────────────────────────────────────────────┐
   │                                                                       │
   │         mov       ax, SEG array   ;Right                              │
   │         mov       ax, @fardata    ;Wrong, as different modules        │
   │                                   ;create different far data segments │
   │         mov       ds, ax                                              │
   └───────────────────────────────────────────────────────────────────────┘
                                    -♦-