        CSEG
Keypad	EQU	80H

        Org     $
Ambil_Keypad:
	Mov	Keypad,#0FFH
	Push	TH0
	Push	TL0
	Push	TMOD

Tunggu_Ditekan:
	Mov	A,Keypad
	Cjne	A,#0FFH,Ambil_Lagi
	Ajmp	Tunggu_Ditekan

Ambil_Lagi:
	Jb	P,Tunggu_Ditekan
	Lcall	Delay_Bouncing
        Push    ACC

TungguDilepas:
	Mov	A,Keypad
	Cjne	A,#0FFH,TungguDilepas
	Lcall	Delay_Bouncing
        Pop     ACC
	Mov	DPL,A
	Mov	A,#00H
	Movc	A,@A+DPTR
	Pop	TMOD
	Pop	TL0
	Pop	TH0
	Ret


Delay_Bouncing:
	Push	TCON
	Push	B
	Mov	B,#1H
LoopDelayBounce:
	Mov	TH0,#0EEH
	Mov	TL0,#00H
	Setb	TR0
        Jnb     TF0,$
	Clr	TF0
	Djnz	B,LoopDelayBounce
	Pop	B
	Pop	TCON
	Ret

