PIC JAL Code Flow Routine

Interrupts

by Vasile Surducan

   When I tested this it was good some help.... 
 sometimes is enough to save W register. 

-- interrupt settings
var byte w_temp
var byte status_temp

procedure push is
 assembler
           movwf  w_temp
           swapf  status, w
           movwf  status_temp
  end assembler 
end procedure

procedure pop is
assembler
          swapf status_temp, w
          movwf status
          swapf w_temp, f
          swapf w_temp, w
 end assembler 
end procedure


procedure interrupt is
  pragma interrupt
-- disable all interrupts
  intcon_gie = low 
-- save w register and status
  push
-- check sources of interrupt port_b on change
  if intcon_rbif then

-- do your job    

-- restore status and w
     pop
--   asm retfie
    
-- prepare for next interrupt port_b on change
  intcon_rbif = low
 
end procedure

See: