





					       Conditional Assembly



		 7.1  Introduction

		 The  Conditional   Assembly   directives   provide
		 conditional   assembly	 of  blocks  of	 statements
		 within	a source file.	 There	are  the  following
		 conditional directives:

		      IF       IFE	 IF1	   IF2	      IFDEF
		      IFNDEF	     IFB	 IFNB	      IFIDN
		      IFDIF	 ELSE	    ENDIF

		 The  IF  directives  and  the	 ENDIF	 and   ELSE
		 directives  can  be used to enclose the statements
		 to be considered for  conditional  assembly.	The
		 conditional block takes the form:

		      IF		  statements	       ELSE
			      statements      ENDIF

		 where the statements can be any valid	statements,
		 including  other  conditional	blocks.	  The  ELSE
		 directive is optional.

		 MASM assembles	the statements in  the	conditional
		 block	only  if  the  condition that satisfies	the
		 corresponding	IF  directive  is  met.	   If	the
		 conditional  block  contains  an  ELSE	 directive,
		 however, MASM will assemble only the statements up
		 to  the  ELSE directive.  The statements following
		 the ELSE directive are	assembled only	if  the	 IF
		 condition  is	not  met.   An ENDIF directive must
		 mark the end of the conditional  block.   No  more
		 than one ELSE for each	IF directive is	allowed.









								7-1



















	      XENIX Macro Assembler Reference Manual



	      IF directives can	be nested up to	255 levels.   To
	      avoid  ambiguity,	 a  nested ELSE	directive always
	      belongs to the nearest, preceding	IF directive.


	      7.2  IF and IFE Directives

	      Syntax

		   IF expression      IFE expression

	      The IF and IFE directives	test  the  value  of  an
	      expression.   The	 IF directive grants assembly if
	      expression is non-zero (true).  The IFE  directive
	      grants  assembly	if  expression is 0 (false). The
	      expression must resolve to an absolute  value  and
	      must not contain forward references.

	      Example

		   if  DEBUG			  extrn	dump:far
			   extrn trace:far
			   extrn breakpoint:far	     endif



	      7.3  IF1 and IF2 Directives

	      Syntax

		   IF1		IF2

	      The  IF1	and  IF2  directives  test  the	 current
	      assembly	pass.  The IF1 directive grants	assembly
	      on pass 1	only. IF2 grants  assembly  on	pass  2.
	      The directives take no arguments.






	      7-2



















					       Conditional Assembly



		 Example

		      if1		       %out Pass 1 Starting
		      endif



		 7.4  IFDEF and	IFNDEF Directives

		 Syntax

		      IFDEF   name	IFNDEF	 name

		 The IFDEF and IFNDEF directives  test	whether	 or
		 not  the  given  name has been	defined.  The IFDEF
		 directive grants assembly  if	name  is  a  label,
		 variable,  or symbol.	The IFNDEF directive grants
		 assembly if name has not yet been defined.

		 The name can be any valid name.  Note that if name
		 is a forward reference, it is considered undefined
		 on pass 1, but	defined	 on  pass  2.	This  is  a
		 frequent cause	of phase errors.

		 Example

		      ifndef  BUFFER	  BUFFER  db	  10 dup(?)
		      endif



		 7.5  IFB and IFNB Directives

		 Syntax

		      IFB <arg>	     IFNB <arg>

		 The IFB and IFNB directives test  the	given  arg.
		 The IFB directive grants assembly if arg is blank.
		 The IFNB directive grants assembly if arg  is	not



								7-3


















	      XENIX Macro Assembler Reference Manual



	      blank.  The  arg	can  be	 any  name,  number,  or
	      expression.   The	 angle	brackets   (<	>)   are
	      required.

	      The IFB and IFNB directives  are	intended  to  be
	      used  in	macro  definitions.  They can be used to
	      control conditional assembly of statements in  the
	      macro  based on the parameters passed in the macro
	      call.  In	such cases, arg	should	be  one	 of  the
	      dummy parameters listed by the MACRO directive.

	      Examples

		   IFB <X>

	      This example tests the argument ``<X>.''	If  this
	      is  in  a	 macro	definition  and	no parameter was
	      passed for X, the	directive would	grant assembly.

		   IFNB	<&EXIT>

	      This example tests the argument ``<&EXIT>.''  This
	      is  assumed  to  be  in a	macro definition.  If no
	      parameter	is passed for EXIT, the	 directive  does
	      not grant	assembly.


	      7.6  IFIDN and IFDIF Directives

	      Syntax

		   IFIDN <arg1>, <arg2>
		   IFDIF <arg1>, <arg2>

	      The IFIDN	and IFDIF directives test arg1 and arg2.
	      The   IFIDN   directive  grants  assembly	 if  the
	      arguments	 are  identical.   The	IFDIF  directive
	      grants  assembly	if  the	arguments are different.
	      The  arguments  can  be  any  names,  numbers,  or
	      expressions.   To	 be identical, each character in



	      7-4


















					       Conditional Assembly



		 arg1 must match  the  corresponding  character	 in
		 arg2.	The angle brackets (< >) are required.

		 The IFIDN and IFDIF directives	are intended to	 be
		 used  in  macro  definitions.	They can be used to
		 control conditional assembly of statements in	the
		 macro	based on the parameters	passed in the macro
		 call.	In such	 cases,	 the  arguments	 should	 be
		 dummy parameters listed by the	MACRO directive.

		 Examples

		      IFIDN <X>, <Y>

		 This  example	tests  the  arguments  ``<X>''	and
		 ``<Y>.''  If this is in a macro definition and	the
		 parameters passed for X and Y are  identical,	the
		 directive grants assembly.

		      IFDIF <&EXIT>, <CASE>

		 This example tests the	arguments  ``<&EXIT>''	and
		 ``<CASE>.''  This  is	assumed	 to  be	 in a macro
		 definition.  If the parameters	passed for EXIT	and
		 CASE  are  identical, the directive does not grant
		 assembly.
















								7-5























	      Chapter 7


	      Conditional Assembly
	      __________________________________________________



	      7.1  Introduction	 7-1

	      7.2  IF and IFE Directives  7-2

	      7.3  IF1 and IF2 Directives  7-2

	      7.4  IFDEF and IFNDEF Directives	7-3

	      7.5  IFB and IFNB	Directives  7-3

	      7.6  IFIDN and IFDIF Directives  7-4





































