Conditionally Assembling the END Directive

Last reviewed: January 23, 1995
Article ID: Q84744
The information in this article applies to:
  • Microsoft Macro Assembler for MS-DOS, versions 5.x, 6.0, 6.0a, and 6.0b
  • Microsoft Macro Assembler for OS/2, versions 5.x, 6.0, 6.0a, and 6.0b

Sometimes it is helpful to conditionally have a starting label specified with the END directive; for example, to use preprocessor directives to specify various END directives:

IFDEF xyz

  END start_label
ELSE
  END
ENDIF

Note, however, that this approach will not work. As soon as MASM encounters the first END directive it will stop assembling. The assembler stops regardless of whether or not the END directive is inside a preprocessor block. This is the expected behavior for the assembler.

A method that can be used to accomplish this task involves using a conditionally defined text equate with the END directive. The following sample code demonstrates this method:

Sample Code

; Assemble options needed: /Dxyz

.MODEL small

.STACK 4096

.CODE start_label:

  mov ax, 4C00h
  int 21h

IFDEF xyz
  end_label EQU <start_label>
ELSE
  end_label EQU <>
ENDIF

END end_label


Additional reference words: kbinf 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 23, 1995
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.