I just comment it like mad, then still get it wrong some of the
time.  I do use the "psuedo codes" like clrc, skpc, skpnc, nvc, nz, bnz,
movfw, tst f, etc.  I've also defined macros called bank0, bank1, etc.
These are listed below.

DisableIRQ macro
        local DIRQloop          ; Declare local symbol in macro
DIRQloop
        bcf     intcon,gie      ; disable global interrupts
        btfsc   intcon,gie      ; make sure it's clear
        goto    dirqLoop        ; if not, go clear again
        endm
EnableIRQ macro
        bsf     intcon,gie      ; set global interrupt enable
        endm

  cblock                        ; reserve ram for save and restore
context
        isrW            ; Hold registers during ISR
        isrStatus
        isrFSR
  endc
SaveContext macro
; Save register context for isr.  Swaps swap high and low halves of f
with the result going either
; back to f or to w.  Swap is used here because they affect no status
bits.
        movwf   isrW            ; Save W
        swapf   status,w        ; get status in W (including bank
select bits) swapping hi/lo halves
        bcf     status,rp0      ; force to bank 0
        movwf   isrStatus       ; and save swapped status
        movf    fsr,0           ; Get fsr in w
        movwf   isrFSR          ; and save it
        endm
RestoreContext macro
        movf    isrFSR,0        ; get old fsr
        movwf   fsr             ; and restore it
        swapf   isrStatus,w     ; get old status (including bsr
bits) in w, swapping back to normal
        movwf   status          ; restore it
        swapf   isrw,1          ; swap halves in isrw making
them backwards
        swapf   isrw,0          ; swap back to forward and in
W without affecting status
        endm
Bank1   macro
        bsf     status,rp0      ; Set bank select bit
        endm
Bank0   macro
        bcf     status,rp0      ; Clear bank select bit
        endm


Harold



Harold Hallikainen
harold@hallikainen.com
Hallikainen & Friends, Inc.
See the FCC Rules at http://hallikainen.com/FccRules and comments filed
in LPFM proceeding at http://hallikainen.com/lpfm


_____________________________________________________________________
You don't need to buy Internet access to use free Internet e-mail.
Get completely free e-mail from Juno at http://www.juno.com
Or call Juno at (800) 654-JUNO [654-5866]