


		LIST		P=PIC16F84
		#INCLUDE	<P16F84.INC>
;-------------------------------------
		KOD1	EQU	H'15'
		KOD2	EQU	H'16'
		KOD3	EQU	H'17'
		KOD4	EQU	H'18'
;-------------------------------------
		PUK1	EQU	H'19'
		PUK2	EQU	H'1A'
		PUK3	EQU	H'1B'
		PUK4	EQU	H'1C'
		PUK5	EQU	H'1D'
		PUK6	EQU	H'1E'
;-------------------------------------
		SAYI1	EQU	H'10'
		SAYI2	EQU	H'11'
		SAYI3	EQU	H'12'
		SAYI4	EQU	H'13'
		DURUM	EQU	H'14'
;-------------------------------------
		CLRF	SAYI1		;SAYILARI SIFIRLA
		CLRF	SAYI2
		CLRF	SAYI3
		CLRF	SAYI4
		CLRF	DURUM
		CLRF	PORTA
		CLRF	PORTB
		CLRF	EEADR
		CLRF	EEDATA
;-------------------------------------
		BSF	STATUS,RP0	;GIRIS-CIKIS TANIMLA
		MOVLW	B'00001111'
		MOVWF	TRISA
		MOVLW	B'00100000'
		MOVWF	TRISB
		BCF	STATUS,RP0
;--------------------------------------
		BSF	PORTB,7		;HATTI KULLANIMA GETIR
		NOP
		NOP
		BCF	PORTB,7
;--------------------------------------
SIF_KON		CALL	SIF_YUK		;KULLANICI GUVENLIK
		CALL	BAK		;SIFRESINI KONNTROL ET
		MOVF	PORTA,W
		SUBWF	KOD1,W
		BTFSS	STATUS,Z
		GOTO	SIF_KON
		CALL	DON
;--------------------------------------
		CALL	BAK
		MOVF	PORTA,W
		SUBWF	KOD2,W
		BTFSS	STATUS,Z
		GOTO	SIF_KON
		CALL	DON
;--------------------------------------
		CALL	BAK
		MOVF	PORTA,W
		SUBWF	KOD3,W
		BTFSS	STATUS,Z
		GOTO	SIF_KON
		CALL	DON
;--------------------------------------
		CALL	BAK
		MOVF	PORTA,W
		SUBWF	KOD4,W
		BTFSS	STATUS,Z
		GOTO	SIF_KON
		CALL	DON
;--------------------------------------
START		BTFSS	PORTB,5		;TUSA BASILMASINI BEKLE
		GOTO	START
;--------------------------------------
		MOVLW	H'01'		;HANGI TUSA BASILMIS?
		SUBWF	PORTA,0
		BTFSC	STATUS,Z
		GOTO	SAY1
;--------------------------------------
		MOVLW	H'02'
		SUBWF	PORTA,0
		BTFSC	STATUS,Z
		GOTO	SAY2
;--------------------------------------
		MOVLW	H'03'
		SUBWF	PORTA,0
		BTFSC	STATUS,Z
		GOTO	SAY3
;--------------------------------------
		MOVLW	H'04'
		SUBWF	PORTA,0
		BTFSC	STATUS,Z
		GOTO	SAY4
;--------------------------------------
		MOVLW	H'05'
		SUBWF	PORTA,0
		BTFSC	STATUS,Z
		GOTO	SAY5
;--------------------------------------
		MOVLW	H'06'
		SUBWF	PORTA,0
		BTFSC	STATUS,Z
		GOTO	SAY6
;--------------------------------------
		MOVLW	H'07'
		SUBWF	PORTA,0
		BTFSC	STATUS,Z
		GOTO	SAY7
;--------------------------------------
		MOVLW	H'08'
		SUBWF	PORTA,0
		BTFSC	STATUS,Z
		GOTO	SAY8
;--------------------------------------
		MOVLW	H'09'
		SUBWF	PORTA,0
		BTFSC	STATUS,Z
		GOTO	SAY9
;--------------------------------------
		MOVLW	H'0A'
		SUBWF	PORTA,0
		BTFSC	STATUS,Z
		GOTO	SAY10
		CALL	DON
;--------------------------------------
		MOVLW	H'0B'
		SUBWF	PORTA,0
		BTFSC	STATUS,Z
		GOTO	SAY11
;--------------------------------------
		MOVLW	H'0C'
		SUBWF	PORTA,0
		BTFSC	STATUS,Z
		GOTO	SAY12
;--------------------------------------
		MOVLW	H'0D'
		SUBWF	PORTA,0
		BTFSC	STATUS,Z
		GOTO	SAY13
;--------------------------------------
		MOVLW	H'0E'
		SUBWF	PORTA,0
		BTFSC	STATUS,Z
		GOTO	SAY14
;--------------------------------------
		MOVLW	H'0F'
		SUBWF	PORTA,0
		BTFSC	STATUS,Z
		GOTO	SAY15
;--------------------------------------
SAY1		BTFSC	DURUM,1		;SAYI1 ILE ILGILI ISLEMI YAP
		GOTO	S1BILGI
		BTFSC	DURUM,2
		GOTO	KAPAT1
		BSF	PORTB,0
		GOTO	START
KAPAT1		BCF	PORTB,0
		BCF	DURUM,2
		CALL	DON
		CALL	BEKLE
		GOTO	START
S1BILGI		BTFSC	PORTB,0
		GOTO	AKTIF1
		CALL	T_SIN
		BCF	DURUM,1
		GOTO	START
AKTIF1		CALL	C_SIN
		BCF	DURUM,1
		GOTO	START
;-------------------------------------
SAY2		BTFSC	DURUM,1		;SAYI2 ILE ILGILI ISLEMI YAP
		GOTO	S2BILGI
		BTFSC	DURUM,2
		GOTO	KAPAT2
		BSF	PORTB,1
		GOTO	START
KAPAT2		BCF	PORTB,1
		BCF	DURUM,2
		CALL	DON
		CALL	BEKLE
		GOTO	START
S2BILGI		BTFSC	PORTB,1
		GOTO	AKTIF2
		CALL	T_SIN
		BCF	DURUM,1
		GOTO	START
AKTIF2		CALL	C_SIN
		BCF	DURUM,1
		GOTO	START
;-------------------------------------
SAY3		BTFSC	DURUM,1		;SAYI3 ILE ILGILI ISLEMI YAP
		GOTO	S3BILGI
		BTFSC	DURUM,2
		GOTO	KAPAT3
		BSF	PORTB,2
		GOTO	START
KAPAT3		BCF	PORTB,2
		BCF	DURUM,2
		CALL	DON
		CALL	BEKLE
		GOTO	START
S3BILGI		BTFSC	PORTB,2
		GOTO	AKTIF3
		CALL	T_SIN
		BCF	DURUM,1
		GOTO	START
AKTIF3		CALL	C_SIN
		BCF	DURUM,1
		GOTO	START
;-------------------------------------
SAY4		BTFSC	DURUM,1		;SAYI4 ILE ILGILI ISLEMI YAP
		GOTO	S4BILGI
		BTFSC	DURUM,2
		GOTO	KAPAT4
		BSF	PORTB,3
		GOTO	START
KAPAT4		BCF	PORTB,3
		BCF	DURUM,2
		CALL	DON
		CALL	BEKLE
		GOTO	START
S4BILGI		BTFSC	PORTB,3
		GOTO	AKTIF4
		CALL	T_SIN
		BCF	DURUM,1
		GOTO	START
AKTIF4		CALL	C_SIN
		BCF	DURUM,1
		GOTO	START
;-------------------------------------
SAY5		CALL	U_SIN
		GOTO	START
;-------------------------------------
SAY6		CALL	U_SIN
		GOTO	START
;-------------------------------------
SAY7		CALL	U_SIN
		GOTO	START
;-------------------------------------
SAY8		CALL	U_SIN
		GOTO	START
;-------------------------------------
SAY9		CALL	U_SIN
		GOTO	START
;-------------------------------------
SAY10		CALL	T_SIN		;PUK KODUNU GIR
		CALL	BAK		;TUSA BASILMASINI BEKLE
		MOVF	PORTA,W
		SUBWF	PUK1,W
		BTFSS	STATUS,Z
		GOTO	HATA
		CALL	DON
;-------------------------------------
		CALL	BAK
		MOVF	PORTA,W
		SUBWF	PUK2,W
		BTFSS	STATUS,Z
		GOTO	HATA
		CALL	DON
;--------------------------------------
		CALL	BAK
		MOVF	PORTA,W
		SUBWF	PUK3,W
		BTFSS	STATUS,Z
		GOTO	HATA
		CALL	DON
;--------------------------------------
		CALL	BAK
		MOVF	PORTA,W
		SUBWF	PUK4,W
		BTFSS	STATUS,Z
		GOTO	HATA
		CALL	DON
;--------------------------------------
		CALL	BAK
		MOVF	PORTA,W
		SUBWF	PUK5,W
		BTFSS	STATUS,Z
		GOTO	HATA
		CALL	DON
;--------------------------------------
		CALL	BAK
		MOVF	PORTA,W
		SUBWF	PUK6,W
		BTFSS	STATUS,Z
		GOTO	HATA
		CALL	DON
		CALL	T_SIN		;PUK KODU DOGRU
;--------------------------------------
GIR		CALL	BAK		;YENI SIFREYI GIR
		MOVF	PORTA,W
		MOVWF	KOD1
		CALL	DON
;--------------------------------------
		CALL	BAK
		MOVF	PORTA,W
		MOVWF	KOD2
		CALL	DON
;--------------------------------------
		CALL	BAK
		MOVF	PORTA,W
		MOVWF	KOD3
		CALL	DON
;--------------------------------------
		CALL	BAK
		MOVF	PORTA,W
		MOVWF	KOD4
		CALL	DON
;--------------------------------------
		CALL	U_SIN		;YENI SIFREYI TEKRAR GIR
;--------------------------------------
T_GIR		CALL	BAK
		MOVF	PORTA,W
		SUBWF	KOD1,W
		BTFSS	STATUS,Z
		GOTO	HATA
		CALL	DON
;---------------------------------------
		CALL	BAK
		MOVF	PORTA,W
		SUBWF	KOD2,W
		BTFSS	STATUS,Z
		GOTO	HATA
		CALL	DON
;---------------------------------------
		CALL	BAK
		MOVF	PORTA,W
		SUBWF	KOD3,W
		BTFSS	STATUS,Z
		GOTO	HATA
		CALL	DON
;----------------------------------------
		CALL	BAK
		MOVF	PORTA,W
		SUBWF	KOD4,W
		BTFSS	STATUS,Z
		GOTO	HATA
		CALL	DON
;----------------------------------------
OK_YAZ		MOVF	KOD1,W		;YENI BILGILERI YAZ
		MOVWF	EEDATA
		MOVLW	H'00'
		MOVWF	EEADR
		CALL	YAZ
		CALL	BEKLE
;-----------------------------------------
		MOVF	KOD2,W
		MOVWF	EEDATA
		MOVLW	H'01'
		MOVWF	EEADR
		CALL	YAZ
		CALL	BEKLE
;-----------------------------------------
		MOVF	KOD3,W
		MOVWF	EEDATA
		MOVLW	H'02'
		MOVWF	EEADR
		CALL	YAZ
		CALL	BEKLE
;-----------------------------------------
		MOVF	KOD4,W
		MOVWF	EEDATA
		MOVLW	H'03'
		MOVWF	EEADR
		CALL	YAZ
		CALL	BEKLE
;-----------------------------------------
		CALL	SIF_YUK
		CALL	C_SIN
		CALL	BEKLE
		CALL	C_SIN
		GOTO	START
;------------------------------------------
HATA		CALL	U_SIN		;HATALI KODLAMA
		CALL	BEKLE
		CALL	U_SIN
		GOTO	START
;------------------------------------------
SAY11		BSF	DURUM,2
		GOTO	START
;------------------------------------------
SAY12		BSF	DURUM,1
		GOTO	START
;------------------------------------------
SAY13		CALL	U_SIN
		GOTO	START
;------------------------------------------
SAY14		CALL	U_SIN
		GOTO	START
;------------------------------------------
SAY15		CALL	U_SIN
		GOTO	START
;------------------------------------------
SIF_YUK		MOVLW	H'00'		;SIFRELERI YUKLEME RUTINI
		MOVWF	EEADR
		CALL	OKU
		MOVF	EEDATA,0
		MOVWF	KOD1
;-------------------------------------------
		MOVLW	H'01'
		MOWVF	EEADR
		CALL	OKU
		MOVF	EEDATA,0
		MOVWF	KOD2
;-------------------------------------------
		MOVLW	H'02'
		MOWVF	EEADR
		CALL	OKU
		MOVF	EEDATA,0
		MOVWF	KOD3
;-------------------------------------------
		MOVLW	H'03'
		MOWVF	EEADR
		CALL	OKU
		MOVF	EEDATA,0
		MOVWF	KOD4
;-------------------------------------------
		MOVLW	H'04'
		MOWVF	EEADR
		CALL	OKU
		MOVF	EEDATA,0
		MOVWF	PUK1
;-------------------------------------------
		MOVLW	H'05'
		MOWVF	EEADR
		CALL	OKU
		MOVF	EEDATA,0
		MOVWF	PUK2
;-------------------------------------------
		MOVLW	H'06'
		MOWVF	EEADR
		CALL	OKU
		MOVF	EEDATA,0
		MOVWF	PUK3
;-------------------------------------------
		MOVLW	H'07'
		MOWVF	EEADR
		CALL	OKU
		MOVF	EEDATA,0
		MOVWF	PUK4
;-------------------------------------------
		MOVLW	H'08'
		MOWVF	EEADR
		CALL	OKU
		MOVF	EEDATA,0
		MOVWF	PUK5
;-------------------------------------------
		MOVLW	H'09'
		MOWVF	EEADR
		CALL	OKU
		MOVF	EEDATA,0
		MOVWF	PUK6
		RETURN
;-------------------------------------------
T_SIN		CALL	BEKLE		;KISA SURELI TEK SINYAL
		BSF	PORTB,6
		CALL	BEKLE
		CALL	BEKLE
		BCF	PORTB,6
		RETURN
;-------------------------------------------
C_SIN		CALL	BEKLE		;KISA SURELI IKI SINYAL
		BSF	PORTB,6
		CALL	BEKLE
		CALL	BEKLE
		BCF	PORTB,6
		CALL	BEKLE
		BSF	PORTB,6
		CALL	BEKLE
		CALL	BEKLE
		BCF	PORTB,6
		RETURN
;-------------------------------------------
U_SIN		CALL	BEKLE		;YANLIS ISLEM SINYALI
		BSF	PORTB,6
		CALL	BEKLE
		CALL	BEKLE
		CALL	BEKLE
		CALL	BEKLE
		CALL	BEKLE
		CALL	BEKLE
		BCF	PORTB,6
		RETURN
;--------------------------------------------
BEKLE		DECFSZ	SAYI1,1		;IKI DONGU KADAR BEKLE
		GOTO	BEKLE
		DECFSZ	SAYI2,1
		GOTO	BEKLE
		RETURN
;--------------------------------------------
DON		CALL	BEKLE		;BIRAKILANA KADAR BEKLE
		BTFSC	PORTB,5
		GOTO	DON
		RETURN
;--------------------------------------------
BAK		BTFSS	PORTB,5		;TUSA BASILMIS MI BAK?
		GOTO	BAK
		RETURN
;--------------------------------------------
H_KAPA		BSF	PORTB,7		;HATTI KAPATMA RUTINI
		CALL	BEKLE
		BCF	PORTB,7
		CALL	BEKLE
		BSF	PORTB,7
		CALL	BEKLE
		BCF	PORTB,7
		BCF	DURUM,2
		BCF	DURUM,1
		RETURN
;--------------------------------------------
YAZ		BSF	STATUS,RP0	;BILGI YAZMA RUTINI
		BCF	INTCON,GIE
		BSF	EECON1,WREN
		MOVLW	H'55'
		MOVWF	EECON2
		MOVLW	H'AA'
		MOVWF	EECON2
		BSF	EECON1,WR
		BSF	INTCON,GIE
		BCF	STATUS,RP0
		RETURN
;--------------------------------------------
OKU		BSF	STATUS,RP0	;BILGI OKUMA RUTINI
		BSF	EECON1,RD
		BCF	STATUS,RP0
		RETURN
;--------------------------------------------
		END