UNDEFINE/DEFINE Example

MPASM Assembler

UNDEFINE/DEFINE Example

Directives highlighted in this example are:

  • #undefine
  • #define
  • Program Functional Description

    This example shows the the usage of #UNDEFINE directive. A symbol name previously defined with the #DEFINE directive, is removed from the symbol table if #UNDEFINE directive is used. The same symbol may be redefined again.

    Commented Code Listing

    list p=16f877 ;Select the device.

    #include <p16f877.inc> ;Include standard header file

    ;for the selected device.

    area set 0 ;The label 'area' is assigned

    ;the value 0.

    #define lngth 50H ;Label 'lngth' is assigned

    ;the value 50H.

    #define wdth 25H ;Label 'wdth' is assigned

    ;the value 25H

    area set lngth*wdth ;Reassignment of label 'area'.

    ;So 'area' will be reassigned a

    ;value equal to 50H*25H.

    #undefine lngth ;Undefine label 'lngth'.

    #undefine wdth ;Undefine label 'wdth'

    #define lngth 0 ;Define label 'lngth' to '0'.

    end


    Microchip Technology Inc.
    Microchip's Web Site
    Voice: (480) 792-7200
    Fax: (480) 899-9210
    Microchip's E-mail Address
    PreviousNext