LIST P=18F4680, F=INHX32 ;directive to define processor
#include <P18F4680.INC> ;processor specific variable definitions
org 0x800 ;reset vector
goto Main
org 0x808
goto ISR
Main:
bsf RCON,7 ;Enable priority interrupts
bcf INTCON,RBIF ;RBIF limpiar bandera
bsf INTCON,RBIE ;RBIE enables PORTB interrupt
bsf INTCON,7 ;Activador General de Interrupciones
inicio
bsf PORTA,0
btfsc PORTB,3
goto inicio
setf PORTA
goto supci
supci
movf 0x40,W ;0x40=1
decfsz 0x50,F
goto cicloA
bcf INTCON,0 ;apago bandera de interrupcion
goto fin
cicloA
btg PORTA,0
movlw 0x0B
movwf TMR0H
movlw 0xDC
movwf TMR0L
cicloB
btfss INTCON,2
goto cicloB
bcf INTCON,2
goto supci
ISR
btfsc INTCON,0
retfie
bcf PORTA, 1
clrf WREG
movf 0x40,W ;W=1
addwf 0x43,F ;0x43=1+0x43
movf 0x43,W ;W=valor en 0x43
cpfseq 0x49 ;lo comparas con un 2, si no, se regresa a cicloPrin
retfie
movlw 0x01 ;W=1
addwf 0x45,F ;0x45=1+0x45
movf 0x41,W
addwf 0x49,F
retfie
END