    ifndef _tools_h
        #define _tools_h



;**************************************************
;
; (C) Copyright notice
;
; Written by Richard Prinz.
; Copyright 2003 by Richard Prinz.
; OE1RIB Richard.Prinz@MIN.at
;
; Permission to use, copy, and modify this program
; without restriction is hereby granted, as long as
;
; 1) this copyright notice appears in each copy of
;    the program source code and
;
; 2) the source code is not used for commercial
;    purposes.
;
; This program is freely distributable without
; licensing fees and is provided without guarantee
; or warrantee expressed or implied.
;
; This program is -not- in the public domain.
;
;**************************************************



;**************************************************
;
;   TOOL Definitions
;
;**************************************************

PCLBit macro label,bit,check
        local mask
mask set (1 << bit)
        if (check == 1)
            if (high($)) == (high(label))
                messg "Source and destination "label" on same Page!"
            endif
        endif
        if ((high($) & mask) == (high(label) & mask))
            bcf     PCLATH,bit
        else
            bsf     PCLATH,bit
        endif       
    endm
    
gotoEX macro label
        local gotoEXLabel
        PCLBit label,0,1
        PCLBit label,1,1
            goto        label
gotoEXLabel:            
        PCLBit gotoEXLabel,0,0
        PCLBit gotoEXLabel,1,0
    endm

callEX macro label
        local callEXLabel
        PCLBit label,0,1
        PCLBit label,1,1
            call        label
callEXLabel:            
        PCLBit callEXLabel,0,0
        PCLBit callEXLabel,1,0
    endm

DelaySet macro HighWait,LowWait
        movlw   HighWait
        movwf   DELAY_H
        movlw   LowWait
        movwf   DELAY_L
    endm

DelayCPU macro HighWait,LowWait
        DelaySet HighWait,LowWait
        callEX  Delay
    endm



;**************************************************
;
;   TOOL Variables
;
;**************************************************

    cblock
DELAY_W
DELAY_T
DELAY_H
DELAY_L
    endc

    endif


