	LIST	P=16F84A,				; usar PIC 16F84A
	#include <p16f84A.inc>

	__CONFIG _CP_OFF&_PWRTE_ON&_WDT_OFF&_XT_OSC
	
	CBLOCK	0X0C
	horas
	deceminutos
	uniminutos
	decesegundos
	unisegundos
	R_ContA
	R_ContB
	R_ContC
	ENDC
	
	ORG	0
;
inicio
	bsf	STATUS,RP0
	movlw	b'00010000'
	movwf	TRISA
	movlw	b'11000000'
	movwf	TRISB
	bcf	STATUS,RP0
	clrf	PORTB
	clrf	PORTA
	clrf	unisegundos
	clrf	decesegundos
	clrf	uniminutos
	clrf	deceminutos
	clrf	horas
	bsf	PORTB,5

configuracion
	btfss	PORTB,6
	goto	configuracion
	call	retardo_20ms
	btfsc	PORTB,6
	goto	configuracion

dejahora
	btfss	PORTB,6
	goto	dejahora
horadisplay
	btfsc	PORTB,6
	goto	incremhora
	btfsc	PORTB,7
	goto	decemindisplay
	movf	horas,0
	movwf	PORTA
	movlw	b'11111110'
	movwf	PORTB	
	call	retardo_5ms
	btfsc	PORTB,6
	goto	incremhora
	btfsc	PORTB,7
	goto	decemindisplay
	movf	deceminutos,0
	movwf	PORTA
	movlw	b'11111101'
	movwf	PORTB	
	call	retardo_5ms
	btfsc	PORTB,6
	goto	incremhora
	btfsc	PORTB,7
	goto	decemindisplay
	movf	uniminutos,0
	movwf	PORTA
	movlw	b'11111011'
	movwf	PORTB	
	call	retardo_5ms
	btfsc	PORTB,6
	goto	incremhora
	btfsc	PORTB,7
	goto	decemindisplay
	movf	decesegundos,0
	movwf	PORTA
	movlw	b'11110111'
	movwf	PORTB	
	call	retardo_5ms
	btfsc	PORTB,6
	goto	incremhora
	btfsc	PORTB,7
	goto	decemindisplay
	movf	unisegundos,0
	movwf	PORTA
	movlw	b'11101111'
	movwf	PORTB
	call	retardo_5ms
	btfsc	PORTB,6
	goto	incremhora
	btfsc	PORTB,7
	goto	decemindisplay
	movf	deceminutos,0
	movwf	PORTA
	movlw	b'11111101'
	movwf	PORTB	
	call	retardo_5ms
	btfsc	PORTB,6
	goto	incremhora
	btfsc	PORTB,7
	goto	decemindisplay
	movf	uniminutos,0
	movwf	PORTA
	movlw	b'11111011'
	movwf	PORTB	
	call	retardo_5ms
	btfsc	PORTB,6
	goto	incremhora
	btfsc	PORTB,7
	goto	decemindisplay
	movf	decesegundos,0
	movwf	PORTA
	movlw	b'11110111'
	movwf	PORTB	
	call	retardo_5ms
	btfsc	PORTB,6
	goto	incremhora
	btfsc	PORTB,7
	goto	decemindisplay
	movf	unisegundos,0
	movwf	PORTA
	movlw	b'11101111'
	movwf	PORTB
	call	retardo_5ms
	btfsc	PORTB,6
	goto	incremhora
	btfsc	PORTB,7
	goto	decemindisplay
	btfsc	PORTB,6
	goto	incremhora
	btfsc	PORTB,7
	goto	decemindisplay
	movf	deceminutos,0
	movwf	PORTA
	movlw	b'11111101'
	movwf	PORTB	
	call	retardo_5ms
	btfsc	PORTB,6
	goto	incremhora
	btfsc	PORTB,7
	goto	decemindisplay
	movf	uniminutos,0
	movwf	PORTA
	movlw	b'11111011'
	movwf	PORTB	
	call	retardo_5ms
	btfsc	PORTB,6
	goto	incremhora
	btfsc	PORTB,7
	goto	decemindisplay
	movf	decesegundos,0
	movwf	PORTA
	movlw	b'11110111'
	movwf	PORTB	
	call	retardo_5ms
	btfsc	PORTB,6
	goto	incremhora
	btfsc	PORTB,7
	goto	decemindisplay
	movf	unisegundos,0
	movwf	PORTA
	movlw	b'11101111'
	movwf	PORTB
	call	retardo_5ms
	btfsc	PORTB,6
	goto	incremhora
	btfsc	PORTB,7
	goto	decemindisplay
	
	goto	horadisplay

incremhora
	call	retardo_20ms
	btfsc	PORTB,6
	goto	horadisplay
dejahorina
	btfss	PORTB,6
	goto	dejahorina
	incf	horas,F
	movlw	d'10'
	subwf	horas,W
	btfsc	STATUS,C
	clrf	horas
	goto	horadisplay
;
decemindisplay
	btfsc	PORTB,6
	goto	incremdecemin
	btfsc	PORTB,7
	goto	unimindisplay
	movf	horas,0
	movwf	PORTA
	movlw	b'11111110'
	movwf	PORTB	
	call	retardo_5ms
	btfsc	PORTB,6
	goto	incremdecemin
	btfsc	PORTB,7
	goto	unimindisplay
	movf	deceminutos,0
	movwf	PORTA
	movlw	b'11111101'
	movwf	PORTB	
	call	retardo_5ms
	btfsc	PORTB,6
	goto	incremdecemin
	btfsc	PORTB,7
	goto	unimindisplay
	movf	uniminutos,0
	movwf	PORTA
	movlw	b'11111011'
	movwf	PORTB	
	call	retardo_5ms
	btfsc	PORTB,6
	goto	incremdecemin
	btfsc	PORTB,7
	goto	unimindisplay
	movf	decesegundos,0
	movwf	PORTA
	movlw	b'11110111'
	movwf	PORTB	
	call	retardo_5ms
	btfsc	PORTB,6
	goto	incremdecemin
	btfsc	PORTB,7
	goto	unimindisplay
	movf	unisegundos,0
	movwf	PORTA
	movlw	b'11101111'
	movwf	PORTB	
	call	retardo_5ms
	btfsc	PORTB,6
	goto	incremdecemin
	btfsc	PORTB,7
	goto	unimindisplay
	movf	horas,0
	movwf	PORTA
	movlw	b'11111110'
	movwf	PORTB	
	call	retardo_5ms
	btfsc	PORTB,6
	goto	incremdecemin
	btfsc	PORTB,7
	goto	unimindisplay
	movf	uniminutos,0
	movwf	PORTA
	movlw	b'11111011'
	movwf	PORTB	
	call	retardo_5ms
	btfsc	PORTB,6
	goto	incremdecemin
	btfsc	PORTB,7
	goto	unimindisplay
	movf	decesegundos,0
	movwf	PORTA
	movlw	b'11110111'
	movwf	PORTB	
	call	retardo_5ms
	btfsc	PORTB,6
	goto	incremdecemin
	btfsc	PORTB,7
	goto	unimindisplay
	movf	unisegundos,0
	movwf	PORTA
	movlw	b'11101111'
	movwf	PORTB	
	call	retardo_5ms
	btfsc	PORTB,6
	goto	incremdecemin
	btfsc	PORTB,7
	goto	unimindisplay
	movf	horas,0
	movwf	PORTA
	movlw	b'11111110'
	movwf	PORTB	
	call	retardo_5ms
	btfsc	PORTB,6
	goto	incremdecemin
	btfsc	PORTB,7
	goto	unimindisplay
	movf	uniminutos,0
	movwf	PORTA
	movlw	b'11111011'
	movwf	PORTB	
	call	retardo_5ms
	btfsc	PORTB,6
	goto	incremdecemin
	btfsc	PORTB,7
	goto	unimindisplay
	movf	decesegundos,0
	movwf	PORTA
	movlw	b'11110111'
	movwf	PORTB	
	call	retardo_5ms
	btfsc	PORTB,6
	goto	incremdecemin
	btfsc	PORTB,7
	goto	unimindisplay
	movf	unisegundos,0
	movwf	PORTA
	movlw	b'11101111'
	movwf	PORTB	
	call	retardo_5ms
	btfsc	PORTB,6
	goto	incremdecemin
	btfsc	PORTB,7
	goto	unimindisplay
	movf	horas,0
	movwf	PORTA
	movlw	b'11111110'
	movwf	PORTB	
	call	retardo_5ms
	btfsc	PORTB,6
	goto	incremdecemin
	btfsc	PORTB,7
	goto	unimindisplay
	movf	uniminutos,0
	movwf	PORTA
	movlw	b'11111011'
	movwf	PORTB	
	call	retardo_5ms
	btfsc	PORTB,6
	goto	incremdecemin
	btfsc	PORTB,7
	goto	unimindisplay
	movf	decesegundos,0
	movwf	PORTA
	movlw	b'11110111'
	movwf	PORTB	
	call	retardo_5ms
	btfsc	PORTB,6
	goto	incremdecemin
	btfsc	PORTB,7
	goto	unimindisplay
	movf	unisegundos,0
	movwf	PORTA
	movlw	b'11101111'
	movwf	PORTB	
	call	retardo_5ms
	btfsc	PORTB,6
	goto	incremdecemin
	btfsc	PORTB,7
	goto	unimindisplay
	goto	decemindisplay

incremdecemin
	call	retardo_20ms
	btfsc	PORTB,6
	goto	decemindisplay
dejardecemin
	btfss	PORTB,6	
	goto	dejardecemin
	incf	deceminutos,F
	movlw	d'7'
	subwf	horas,W
	btfsc	STATUS,C
	clrf	deceminutos
	goto	decemindisplay

unimindisplay
	btfsc	PORTB,6
	goto	increunimin
	btfsc	PORTB,7
	goto	decesegdisplay
	movf	horas,0
	movwf	PORTA
	movlw	b'11111110'
	movwf	PORTB	
	call	retardo_5ms
	btfsc	PORTB,6
	goto	increunimin
	btfsc	PORTB,7
	goto	decesegdisplay
	movf	deceminutos,0
	movwf	PORTA
	movlw	b'11111101'
	movwf	PORTB	
	call	retardo_5ms
	btfsc	PORTB,6
	goto	increunimin
	btfsc	PORTB,7
	goto	decesegdisplay
	movf	uniminutos,0
	movwf	PORTA
	movlw	b'11111011'
	movwf	PORTB	
	call	retardo_5ms
	btfsc	PORTB,6
	goto	increunimin
	btfsc	PORTB,7
	goto	decesegdisplay
	movf	decesegundos,0
	movwf	PORTA
	movlw	b'11110111'
	movwf	PORTB	
	call	retardo_5ms
	btfsc	PORTB,6
	goto	increunimin
	btfsc	PORTB,7
	goto	decesegdisplay
	movf	unisegundos,0
	movwf	PORTA
	movlw	b'11101111'
	movwf	PORTB	
	call	retardo_5ms
	btfsc	PORTB,6
	goto	increunimin
	btfsc	PORTB,7
	goto	decesegdisplay
	movf	horas,0
	movwf	PORTA
	movlw	b'11111110'
	movwf	PORTB	
	call	retardo_5ms
	btfsc	PORTB,6
	goto	increunimin
	btfsc	PORTB,7
	goto	decesegdisplay
	movf	deceminutos,0
	movwf	PORTA
	movlw	b'11111101'
	movwf	PORTB	
	call	retardo_5ms
	btfsc	PORTB,6
	goto	increunimin
	btfsc	PORTB,7
	goto	decesegdisplay
	movf	decesegundos,0
	movwf	PORTA
	movlw	b'11110111'
	movwf	PORTB	
	call	retardo_5ms
	btfsc	PORTB,6
	goto	increunimin
	btfsc	PORTB,7
	goto	decesegdisplay
	movf	unisegundos,0
	movwf	PORTA
	movlw	b'11101111'
	movwf	PORTB	
	call	retardo_5ms
	btfsc	PORTB,6
	goto	increunimin
	btfsc	PORTB,7
	goto	decesegdisplay
	movf	horas,0
	movwf	PORTA
	movlw	b'11111110'
	movwf	PORTB	
	call	retardo_5ms
	btfsc	PORTB,6
	goto	increunimin
	btfsc	PORTB,7
	goto	decesegdisplay
	movf	deceminutos,0
	movwf	PORTA
	movlw	b'11111101'
	movwf	PORTB	
	call	retardo_5ms
	btfsc	PORTB,6
	goto	increunimin
	btfsc	PORTB,7
	goto	decesegdisplay
	movf	decesegundos,0
	movwf	PORTA
	movlw	b'11110111'
	movwf	PORTB	
	call	retardo_5ms
	btfsc	PORTB,6
	goto	increunimin
	btfsc	PORTB,7
	goto	decesegdisplay
	movf	unisegundos,0
	movwf	PORTA
	movlw	b'11101111'
	movwf	PORTB	
	call	retardo_5ms
	btfsc	PORTB,6
	goto	increunimin
	btfsc	PORTB,7
	goto	decesegdisplay
	movf	horas,0
	movwf	PORTA
	movlw	b'11111110'
	movwf	PORTB	
	call	retardo_5ms
	btfsc	PORTB,6
	goto	increunimin
	btfsc	PORTB,7
	goto	decesegdisplay
	movf	deceminutos,0
	movwf	PORTA
	movlw	b'11111101'
	movwf	PORTB	
	call	retardo_5ms
	btfsc	PORTB,6
	goto	increunimin
	btfsc	PORTB,7
	goto	decesegdisplay
	movf	decesegundos,0
	movwf	PORTA
	movlw	b'11110111'
	movwf	PORTB	
	call	retardo_5ms
	btfsc	PORTB,6
	goto	increunimin
	btfsc	PORTB,7
	goto	decesegdisplay
	movf	unisegundos,0
	movwf	PORTA
	movlw	b'11101111'
	movwf	PORTB	
	call	retardo_5ms
	btfsc	PORTB,6
	goto	increunimin
	btfsc	PORTB,7
	goto	decesegdisplay
	movf	horas,0
	movwf	PORTA
	movlw	b'11111110'
	movwf	PORTB	
	call	retardo_5ms
	btfsc	PORTB,6
	goto	increunimin
	btfsc	PORTB,7
	goto	decesegdisplay
	movf	deceminutos,0
	movwf	PORTA
	movlw	b'11111101'
	movwf	PORTB	
	call	retardo_5ms
	btfsc	PORTB,6
	goto	increunimin
	btfsc	PORTB,7
	goto	decesegdisplay
	movf	decesegundos,0
	movwf	PORTA
	movlw	b'11110111'
	movwf	PORTB	
	call	retardo_5ms
	btfsc	PORTB,6
	goto	increunimin
	btfsc	PORTB,7
	goto	decesegdisplay
	movf	unisegundos,0
	movwf	PORTA
	movlw	b'11101111'
	movwf	PORTB	
	call	retardo_5ms
	btfsc	PORTB,6
	goto	increunimin
	btfsc	PORTB,7
	goto	decesegdisplay
	goto	unimindisplay

increunimin
	call	retardo_20ms
	btfsc	PORTB,6
	goto	unimindisplay
dejadecemin	
	btfss	PORTB,6
	goto	dejadecemin
	incf	uniminutos,F
	movlw	d'10'
	subwf	uniminutos,W
	btfsc	STATUS,C
	clrf	deceminutos
	goto	unimindisplay
;
decesegdisplay
	btfsc	PORTB,6
	goto	incresegdisplay
	btfsc	PORTB,7
	goto	unisegdisplay
	movf	horas,0
	movwf	PORTA
	movlw	b'11111110'
	movwf	PORTB	
	call	retardo_5ms
	btfsc	PORTB,6
	goto	incresegdisplay
	btfsc	PORTB,7
	goto	unisegdisplay
	movf	deceminutos,0
	movwf	PORTA
	movlw	b'11111101'
	movwf	PORTB	
	call	retardo_5ms
	btfsc	PORTB,6
	goto	incresegdisplay
	btfsc	PORTB,7
	goto	unisegdisplay
	movf	uniminutos,0
	movwf	PORTA
	movlw	b'11111011'
	movwf	PORTB	
	call	retardo_5ms
	btfsc	PORTB,6
	goto	incresegdisplay
	btfsc	PORTB,7
	goto	unisegdisplay
	movf	decesegundos,0
	movwf	PORTA
	movlw	b'11110111'
	movwf	PORTB	
	call	retardo_5ms
	btfsc	PORTB,6
	goto	incresegdisplay
	btfsc	PORTB,7
	goto	unisegdisplay
	movf	unisegundos,0
	movwf	PORTA
	movlw	b'11101111'
	movwf	PORTB	
	call	retardo_5ms
	btfsc	PORTB,6
	goto	incresegdisplay
	btfsc	PORTB,7
	goto	unisegdisplay
	movf	horas,0
	movwf	PORTA
	movlw	b'11111110'
	movwf	PORTB	
	call	retardo_5ms
	btfsc	PORTB,6
	goto	incresegdisplay
	btfsc	PORTB,7
	goto	unisegdisplay
	movf	deceminutos,0
	movwf	PORTA
	movlw	b'11111101'
	movwf	PORTB	
	call	retardo_5ms
	btfsc	PORTB,6
	goto	incresegdisplay
	btfsc	PORTB,7
	goto	unisegdisplay
	movf	uniminutos,0
	movwf	PORTA
	movlw	b'11111011'
	movwf	PORTB	
	call	retardo_5ms
	btfsc	PORTB,6
	goto	incresegdisplay
	btfsc	PORTB,7
	goto	unisegdisplay
	movf	unisegundos,0
	movwf	PORTA
	movlw	b'11101111'
	movwf	PORTB	
	call	retardo_5ms
	btfsc	PORTB,6
	goto	incresegdisplay
	btfsc	PORTB,7
	goto	unisegdisplay
	movf	horas,0
	movwf	PORTA
	movlw	b'11111110'
	movwf	PORTB	
	call	retardo_5ms
	btfsc	PORTB,6
	goto	incresegdisplay
	btfsc	PORTB,7
	goto	unisegdisplay
	movf	deceminutos,0
	movwf	PORTA
	movlw	b'11111101'
	movwf	PORTB	
	call	retardo_5ms
	btfsc	PORTB,6
	goto	incresegdisplay
	btfsc	PORTB,7
	goto	unisegdisplay
	movf	uniminutos,0
	movwf	PORTA
	movlw	b'11111011'
	movwf	PORTB	
	call	retardo_5ms
	btfsc	PORTB,6
	goto	incresegdisplay
	btfsc	PORTB,7
	goto	unisegdisplay
	movf	unisegundos,0
	movwf	PORTA
	movlw	b'11101111'
	movwf	PORTB	
	call	retardo_5ms
	btfsc	PORTB,6
	goto	incresegdisplay
	btfsc	PORTB,7
	goto	unisegdisplay
	movf	horas,0
	movwf	PORTA
	movlw	b'11111110'
	movwf	PORTB	
	call	retardo_5ms
	btfsc	PORTB,6
	goto	incresegdisplay
	btfsc	PORTB,7
	goto	unisegdisplay
	movf	deceminutos,0
	movwf	PORTA
	movlw	b'11111101'
	movwf	PORTB	
	call	retardo_5ms
	btfsc	PORTB,6
	goto	incresegdisplay
	btfsc	PORTB,7
	goto	unisegdisplay
	movf	uniminutos,0
	movwf	PORTA
	movlw	b'11111011'
	movwf	PORTB	
	call	retardo_5ms
	btfsc	PORTB,6
	goto	incresegdisplay
	btfsc	PORTB,7
	goto	unisegdisplay
	movf	unisegundos,0
	movwf	PORTA
	movlw	b'11101111'
	movwf	PORTB	
	call	retardo_5ms
	btfsc	PORTB,6
	goto	incresegdisplay
	btfsc	PORTB,7
	goto	unisegdisplay
	movf	horas,0
	movwf	PORTA
	movlw	b'11111110'
	movwf	PORTB	
	call	retardo_5ms
	btfsc	PORTB,6
	goto	incresegdisplay
	btfsc	PORTB,7
	goto	unisegdisplay
	movf	deceminutos,0
	movwf	PORTA
	movlw	b'11111101'
	movwf	PORTB	
	call	retardo_5ms
	btfsc	PORTB,6
	goto	incresegdisplay
	btfsc	PORTB,7
	goto	unisegdisplay
	movf	uniminutos,0
	movwf	PORTA
	movlw	b'11111011'
	movwf	PORTB	
	call	retardo_5ms
	btfsc	PORTB,6
	goto	incresegdisplay
	btfsc	PORTB,7
	goto	unisegdisplay
	movf	unisegundos,0
	movwf	PORTA
	movlw	b'11101111'
	movwf	PORTB	
	call	retardo_5ms
incresegdisplay
	call	retardo_20ms
	btfsc	PORTB,6
	goto	decesegdisplay
dejadeceseg
	btfss	PORTB,6
	goto	dejadeceseg
	incf	decesegundos
	movlw	d'7'
	subwf	uniminutos,W
	btfsc	STATUS,C
	clrf	deceminutos
	goto	decesegdisplay
;
unisegdisplay
	btfsc	PORTB,6
	goto	increuniseg
	btfsc	PORTB,7
	goto	starting
	movf	horas,0
	movwf	PORTA
	movlw	b'11111110'
	movwf	PORTB	
	call	retardo_5ms
	btfsc	PORTB,6
	goto	increuniseg
	btfsc	PORTB,7
	goto	starting
	movf	deceminutos,0
	movwf	PORTA
	movlw	b'11111101'
	movwf	PORTB	
	call	retardo_5ms
	btfsc	PORTB,6
	goto	increuniseg
	btfsc	PORTB,7
	goto	starting
	movf	uniminutos,0
	movwf	PORTA
	movlw	b'11111011'
	movwf	PORTB	
	call	retardo_5ms
	btfsc	PORTB,6
	goto	increuniseg
	btfsc	PORTB,7
	goto	starting
	movf	decesegundos,0
	movwf	PORTA
	movlw	b'11110111'
	movwf	PORTB	
	call	retardo_5ms
	btfsc	PORTB,6
	goto	increuniseg
	btfsc	PORTB,7
	goto	starting
	movf	unisegundos,0
	movwf	PORTA
	movlw	b'11101111'
	movwf	PORTB	
	call	retardo_5ms
	btfsc	PORTB,6
	goto	increuniseg
	btfsc	PORTB,7
	goto	starting
	movf	horas,0
	movwf	PORTA
	movlw	b'11111110'
	movwf	PORTB	
	call	retardo_5ms
	btfsc	PORTB,6
	goto	increuniseg
	btfsc	PORTB,7
	goto	starting
	movf	deceminutos,0
	movwf	PORTA
	movlw	b'11111101'
	movwf	PORTB	
	call	retardo_5ms
	btfsc	PORTB,6
	goto	increuniseg
	btfsc	PORTB,7
	goto	starting
	movf	uniminutos,0
	movwf	PORTA
	movlw	b'11111011'
	movwf	PORTB	
	call	retardo_5ms
	btfsc	PORTB,6
	goto	increuniseg
	btfsc	PORTB,7
	goto	starting
	movf	decesegundos,0
	movwf	PORTA
	movlw	b'11110111'
	movwf	PORTB	
	call	retardo_5ms
	btfsc	PORTB,6
	goto	increuniseg
	btfsc	PORTB,7
	goto	starting
	movf	horas,0
	movwf	PORTA
	movlw	b'11111110'
	movwf	PORTB	
	call	retardo_5ms
	btfsc	PORTB,6
	goto	increuniseg
	btfsc	PORTB,7
	goto	starting
	movf	deceminutos,0
	movwf	PORTA
	movlw	b'11111101'
	movwf	PORTB	
	call	retardo_5ms
	btfsc	PORTB,6
	goto	increuniseg
	btfsc	PORTB,7
	goto	starting
	movf	uniminutos,0
	movwf	PORTA
	movlw	b'11111011'
	movwf	PORTB	
	call	retardo_5ms
	btfsc	PORTB,6
	goto	increuniseg
	btfsc	PORTB,7
	goto	starting
	movf	decesegundos,0
	movwf	PORTA
	movlw	b'11110111'
	movwf	PORTB	
	call	retardo_5ms
	btfsc	PORTB,6
	goto	increuniseg
	btfsc	PORTB,7
	goto	starting
	movf	horas,0
	movwf	PORTA
	movlw	b'11111110'
	movwf	PORTB	
	call	retardo_5ms
	btfsc	PORTB,6
	goto	increuniseg
	btfsc	PORTB,7
	goto	starting
	movf	deceminutos,0
	movwf	PORTA
	movlw	b'11111101'
	movwf	PORTB	
	call	retardo_5ms
	btfsc	PORTB,6
	goto	increuniseg
	btfsc	PORTB,7
	goto	starting
	movf	uniminutos,0
	movwf	PORTA
	movlw	b'11111011'
	movwf	PORTB	
	call	retardo_5ms
	btfsc	PORTB,6
	goto	increuniseg
	btfsc	PORTB,7
	goto	starting
	movf	decesegundos,0
	movwf	PORTA
	movlw	b'11110111'
	movwf	PORTB	
	call	retardo_5ms
	btfsc	PORTB,6
	goto	increuniseg
	btfsc	PORTB,7
	goto	starting
	movf	horas,0
	movwf	PORTA
	movlw	b'11111110'
	movwf	PORTB	
	call	retardo_5ms
	btfsc	PORTB,6
	goto	increuniseg
	btfsc	PORTB,7
	goto	starting
	movf	deceminutos,0
	movwf	PORTA
	movlw	b'11111101'
	movwf	PORTB	
	call	retardo_5ms
	btfsc	PORTB,6
	goto	increuniseg
	btfsc	PORTB,7
	goto	starting
	movf	uniminutos,0
	movwf	PORTA
	movlw	b'11111011'
	movwf	PORTB	
	call	retardo_5ms
	btfsc	PORTB,6
	goto	increuniseg
	btfsc	PORTB,7
	goto	starting
	movf	decesegundos,0
	movwf	PORTA
	movlw	b'11110111'
	movwf	PORTB	
	call	retardo_5ms
	goto	unisegdisplay
;
increuniseg
	call	retardo_20ms
	btfsc	PORTB,6
	goto	unisegdisplay
dejauniseg
	btfss	PORTB,6
	goto	dejauniseg
	incf	unisegundos,F
	movlw	d'10'
	subwf	unisegundos,W
	btfsc	STATUS,C
	clrf	unisegundos
	goto	unisegdisplay
;
starting			((modificar esto lea por el 6 y el k calke mande un impulso=)))
	btfsc	PORTB,6
	goto	horadisplay
	btfsc	PORTB,7	
	goto	lect
	movf	horas,0
	movwf	PORTA
	movlw	b'11111110'
	movwf	PORTB	
	call	retardo_5ms
	btfsc	PORTB,6
	goto	horadisplay
	btfsc	PORTB,7	
	goto	lect
	movf	deceminutos,0
	movwf	PORTA
	movlw	b'11111101'
	movwf	PORTB	
	call	retardo_5ms
	btfsc	PORTB,6
	goto	horadisplay
	btfsc	PORTB,7	
	goto	lect
	movf	uniminutos,0
	movwf	PORTA
	movlw	b'11111011'
	movwf	PORTB	
	call	retardo_5ms
	btfsc	PORTB,6
	goto	horadisplay
	btfsc	PORTB,7	
	goto	lect
	movf	decesegundos,0
	movwf	PORTA
	movlw	b'11110111'
	movwf	PORTB	
	call	retardo_5ms
	btfsc	PORTB,6
	goto	horadisplay
	btfsc	PORTB,7	
	goto	lect
	movf	unisegundos,0
	movwf	PORTA
	movlw	b'11101111'
	movwf	PORTB	
	call	retardo_5ms
	btfsc	PORTB,6
	goto	horadisplay
	btfsc	PORTB,7	
	goto	lect
	goto	starting
lect	
	bsf	STATUS,RP0
	movlw	b'11000000'
	movwf	TRISB
	bcd	STATUS,RP0
	btfsc	PORTB,7
	goto 	comenzar
	btfss	PORTB.6
	goto	comenzar
	movf	horas,0
	movwf	PORTA
	movlw	b'11111110'
	movwf	PORTB	
	call	retardo_5ms
	btfsc	PORTB,7
	goto 	comenzar
	btfss	PORTB.6
	goto	comenzar
	movf	deceminutos,0
	movwf	PORTA
	movlw	b'11111101'
	movwf	PORTB	
	call	retardo_5ms
	btfsc	PORTB,7
	goto 	comenzar
	btfss	PORTB.6
	goto	comenzar
	movf	uniminutos,0
	movwf	PORTA
	movlw	b'11111011'
	movwf	PORTB	
	call	retardo_5ms
	btfsc	PORTB,7
	goto 	comenzar
	btfss	PORTB.6
	goto	comenzar
	movf	decesegundos,0
	movwf	PORTA
	movlw	b'11110111'
	movwf	PORTB	
	call	retardo_5ms
	btfsc	PORTB,7
	goto 	comenzar
	btfss	PORTB.6
	goto	comenzar
	movf	unisegundos,0
	movwf	PORTA
	movlw	b'11101111'
	movwf	PORTB	
	call	retardo_5ms
	btfsc	PORTB,7
	goto 	comenzar
	btfss	PORTB.6
	goto	comenzar
	goto	lect
	
	

decrementarunisegundos
	decf	unisegundos,F
	goto	visualizar

decrementardecesegundos
	decf	decesegundos,F
	movlw	d'9'
	movwf	unisegundos
	goto	visualizar

decrementaruniminutos
	decf	uniminutos,F
	movlw	d'5'
	movwf	decesegundos
	movlw	d'9'
	movwf	unisegundos
	goto	visualizar
	
decrementardeceminutos
	decf	deceminutos,F
	movlw	d'9'
	movwf	uniminutos
	movlw	d'5'
	movwf	decesegundos
	movlw	d'9'
	movwf	unisegundos
	goto	visualizar
decrementarhoras
	decf	horas,F
	movlw	d'5'
	movwf	deceminutos
	movlw	d'9'
	movwf	uniminutos
	movlw	d'5'
	movwf	decesegundos
	movlw	d'9'
	movwf	unisegundos
	goto	visualizar

visualizar
	call	lectura
	movf	horas,0
	movwf	PORTA
	movlw	b'11111110'
	movwf	PORTB	
	call	retardo_5ms
	call	lectura
	movf	deceminutos,0
	movwf	PORTA
	movlw	b'11111101'
	movwf	PORTB	
	call	retardo_5ms
	call	lectura
	movf	uniminutos,0
	movwf	PORTA
	movlw	b'11111011'
	movwf	PORTB	
	call	retardo_5ms
	call	lectura
	movf	decesegundos,0
	movwf	PORTA
	movlw	b'11110111'
	movwf	PORTB	
	call	retardo_5ms
	call	lectura
	movf	unisegundos,0
	movwf	PORTA
	movlw	b'11101111'
	movwf	PORTB	
	call	retardo_5ms
	call	lectura
	
	goto	comenzar
;
lectura
	btfsc	PORTB,6
	call	stopandgo
	btfsc	PORTB,7
	call	stop
	return

;

stopandgo
	call	retardo_20ms
	btfsc	PORTB,6
	return
dejarpulsarstandgo
	btfss	PORTB,6
	goto	dejarpulsarstandgo
volver
	btfsc	PORTB,6
	return
	movf	horas,0
	movwf	PORTA
	movlw	b'11111110'
	movwf	PORTB	
	call	retardo_5ms
	btfsc	PORTB,6
	return
	movf	deceminutos,0
	movwf	PORTA
	movlw	b'11111101'
	movwf	PORTB	
	call	retardo_5ms
	btfsc	PORTB,6
	return
	movf	uniminutos,0
	movwf	PORTA
	movlw	b'11111011'
	movwf	PORTB	
	call	retardo_5ms
	btfsc	PORTB,6
	return
	movf	decesegundos,0
	movwf	PORTA
	movlw	b'11110111'
	movwf	PORTB	
	call	retardo_5ms
	btfsc	PORTB,6
	return
	movf	unisegundos,0
	movwf	PORTA
	movlw	b'11101111'
	movwf	PORTB	
	call	retardo_5ms
	btfsc	PORTB,6
	return
	goto	volver
;

stop
	call	retardo_20ms
	btfsc	PORTB,7
	return
dejarstop
	btfss	PORTB,6
	goto	dejarstop
	btfsc	PORTA,4
	call	incretrenta
	bsf	STATUS,RP0
	movlw	b'00000011'
	bcf	STATUS,RP0
	bsf	PORTB,5
	call	retardo_20ms			
	bcf	PORTB,5
	bsf	STATUS,RP0
	movlw	B'00000111'
	bcf	STATUS,RP0
recibir
	btfsc	PORTB,5
	return
	movf	horas,0
	movwf	PORTA
	movlw	b'11111110'
	movwf	PORTB	
	call	retardo_5ms
	btfsc	PORTB,5
	return
	movf	deceminutos,0
	movwf	PORTA
	movlw	b'11111101'
	movwf	PORTB	
	call	retardo_5ms
	btfsc	PORTB,5
	return
	movf	uniminutos,0
	movwf	PORTA
	movlw	b'11111011'
	movwf	PORTB	
	call	retardo_5ms
	btfsc	PORTB,5
	return
	movf	decesegundos,0
	movwf	PORTA
	movlw	b'11110111'
	movwf	PORTB	
	call	retardo_5ms
	btfsc	PORTB,5
	return
	movf	segundos,0
	movwf	PORTA
	movlw	b'11101111'
	movwf	PORTB	
	call	retardo_5ms
	btfsc	PORTB,5
	return

	goto	recibir
		

;
incretrenta	
	movlw	d'3'
	subwf	decesegundos,W
	btfsc	STATUS,C
	goto	mirarunimin

	return		
mirarunimin
	movlw	d'9'
	subwf	uniminutos,W
	btfsc	STATUS,C
	goto	mirardecemin
	incf	uniminutos,F
	movlw	d'3'
	subwf	decesegundos,F
	return
mirardecemin
	movlw	d'5'
	subwf	deceminutos,W
	btfsc	STATUS,C
	goto	mirarhoras
	incf	deceminutos,F
	movlw	d'3'
	subwf	decesegundos,F
	clrf	uniminutos
	return
mirarhoras
	movlw	d'9'	
	subwf	horas,W
	btfsc	STATUS,C
	goto	maximo
	incf	horas,F
	clrf	deceminutos
	clrf	uniminutos
	movlw	d'3'
	subwf	decesegundos,F
	return
maximo
	movlw	d'9'
	movwf	horas
	movlw	d'6'
	movwf	deceminutos
	clrf	uniminutos
	movlw	d'6'
	movwf	decesegundos
	clrf	unisegundos
	return

;
led
	bsf	STATUS,RP0
	clrf	TRISB
	bcf	STATUS,RP0
parpadeo
	clrf	PORTA
	movlw	b'00000011'
	movwf	PORTB
	call	retardo_500ms
	movlw	b'00000000'
	movwf	PORTB
	goto 	parpadeo
;	
retardo_20ms
	movlw	d'20'
	goto	retardo_ms
retardo_10ms
	movlw	d'10'
	goto	retardo_ms
retardo_5ms
	movlw	d'5'
	goto	retardo_ms
retardo_2ms
	movlw	d'2'
	goto	retardo_ms
retardo_1ms	
	movlw	d'1'
	goto	retardo_ms
retardo_ms
	movwf	R_ContB
bucleexterno
	movlw	d'249'
	movwf	R_ContA
bucleinterno
	nop
	decfsz	R_ContA,F
	goto	bucleinterno
	decfsz	R_ContB,F
	goto	Bucleexterno
	return

comenzar
	movf	unisegundos,F
	btfss	STATUS,Z
	goto	decrementarunisegundos
	movf	decesegundos,F
	btfss	STATUS,Z
	goto	decrementardecesegundos	
	movf	uniminutos,F
	btfss	STATUS,Z
	goto	decrementaruniminutos
	movf	deceminutos,F
	btfss	STATUS,Z
	goto	decrementardeceminutos
	movf	horas,F
	btfss	STATUS,Z
	goto	decrementarhoras
	goto 	led

	END

