;******************************************************** ;Int_context ;This program demonstrates need for context saving. ;Intended for simulation. ;TJW 15.4.05 Tested 17.4.09 ;******************************************************** ; ;Port A not used. Port B bit 0 used for ext.interrupt ip. #include p16f84A.inc ; rhi equ 10 rlo equ 11 phi equ 12 plo equ 13 qhi equ 14 qlo equ 15 org 00 goto start org 04 ;here if interrupt occurs goto Int_Routine ; start org 0010 bsf intcon,inte ;enable external interrupt bsf intcon,gie ;enable global int loop movlw 99 movwf phi movwf plo movwf qhi movwf qlo call Double_add movlw 00 movwf rhi movwf rlo goto loop ;This subroutine adds two 16-bit numbers, stored in phi-plo, and qhi-qlo, ;and stores result in rhi-rlo. 16-bit overflow in Carry flag at end. Double_add movf plo,0 ;move plo to the W reg addwf qlo,0 ;add lower bytes movwf rlo btfsc status,0 incf phi,1 ;add in Carry movf phi,0 addwf qhi,0 ;add upper bytes movwf rhi return Int_Routine bcf status,0 ;clear the Carry flag movlw 0ff ;change W reg value bcf intcon,intf retfie end