.MODEL Directive Forces DOSSEG Segment Ordering in MASM

Last reviewed: January 6, 1995
Article ID: Q68562
The information in this article applies to:
  • Microsoft Macro Assembler for MS-DOS, version 5.0, 5.1, 5.1a, 6.0, 6.0a, 6.0b, and 6.11
  • Microsoft Macro Assembler for OS/2, versions 5.1, 5.1a, 6.0, 6.0a, and 6.0b

SUMMARY

The .MODEL assembler directive forces the segments in the resulting executable program to be ordered as if the DOSSEG directive had been used. This will override any other directives used to organize segments in an executable program. The code below demonstrates this behavior.

Because of this, the options below will be ignored:

   /A and /S command line switches
   .ALPHA and .SEQ assembler directives

This behavior is not documented and no warnings or errors are generated.

This behavior is also true with QuickAssembler versions 2.01 and 2.51. The .MODEL assembler directive was designed for use in mixed-language programming. Because of this, it will automatically order the segments in a way compatible with the way higher-level language compilers order them. This will happen even if the <,language> option on the .MODEL directive is not used.

MORE INFORMATION

The map file created from the linker is included below.

Map file:

Start  Stop   Length Name                        Class
00000H 00000H 00000H _TEXT                       CODE
00000H 00002H 00003H B                           CODE
00004H 00004H 00000H _DATA                       DATA
00004H 00005H 00002H A                           DATA
00010H 0010FH 00100H STACK                       STACK

Origin   Group
0000:0   DGROUP

When the .MODEL and .STACK directives are removed (.STACK must be removed because it requires .MODEL), the following map file results. Note that the segments appear in the proper order in this case.

Start  Stop   Length Name                        Class
00000H 00001H 00002H A                           DATA
00002H 00004H 00003H B                           CODE

Sample Code

; Assemble options needed: none

.MODEL medium .286 .SEQ .STACK 100h

A SEGMENT WORD PUBLIC 'DATA' test_data DW 10 A ENDS

B SEGMENT WORD PUBLIC 'CODE'

    mov ax, 1
B ENDS

END


Additional reference words: 5.10 5.10a 6.00 6.00a 6.00b
KBCategory: kbprg
KBSubCategory: MASMLngIss


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: January 6, 1995
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.