Example of external .asm file

Language reference ›› Procedures and functions ›› External procedures and functions ››
Parent Previous Next

Example for the 'External.asm' file, assuming that it contains all the called routines above:

       list        p=PIC16F690                ; Target processor device

       list        r=dec                        ; Use decimal radix

       include        "PROCESSOR.ASM"        ; Device specifics include file

       errorlevel -302

; procedure ExternalProc1A(N: byte); external 'Externals';

__EXTERNALS_0        code        


       global        Externals.ExternalProc1A

       extern        Externals.ExternalProc1A.N

       banksel        Externals.ExternalProc1A.N ; current bank is unknown

       movf        Externals.ExternalProc1A.N, W


       banksel        PORTA

       movwf        PORTA

       banksel        0 ; restore bank


; function ExternalFunc1B: BYTE; external 'Externals';

__EXTERNALS_1        code        


       global        Externals.ExternalFunc1B

       extern        Externals.ExternalFunc1B.Result

       banksel        PORTA ; current bank is unknown

       movf        PORTA, W

       banksel        Externals.ExternalFunc1B.Result

       movwf        Externals.ExternalFunc1B.Result ; result in internal AND in W


       banksel        0 ; restore bank


; procedure ExternalProc2; external;

__EXTERNALS_2        code        


       global        ExternalProc2

       banksel        PORTA ; current bank is unknown

       clrf        PORTA

       banksel        0 ; restore bank