IFDEF and IFNDEF Directives 

The syntax of IFDEF and IFNDEF directives is

     IFDEF  symbol
     IFNDEF symbol

If symbol is defined (IFDEF) or not defined (IFNDEF), the conditional block of statements is assembled. A common use of these directives is to customize code for a particular processor.

Example: Write a macro to save all registers on the stack.
  PUSHALL  MACRO  
             IFNDEF PROC_TYPE
                PROC_TYPE EQU 8086
             ENDIF
             IF PROC_TYPE EQ 8086 
                PUSH AX
                PUSH BX
                PUSH CX
                PUSH DX
                PUSH SI
                PUSH DI
                PUSH BP
                PUSH SP
             ELSE
                PUSHA
             ENDIF
           ENDM
 

In the above example, the assembly time variable PROC_TYPE is used to identify the processor type. The /D option (e.g. /D PROC_TYPE=486) can be used to generate code targeted for a particular processor. If the processor type is not specified on the assembly command line (i.e., the /D option is not specified), the default 8086 version is generated.

For 80186 or later processors, the PUSHA instruction pushes all registers (AX, BX, CX, DX, SI, DI, BP, and SP) onto the stack. However, there is no such instruction for the 8086 processor, and we have to push each register individually.